Merge branch 'develop' of https://github.com/DFHack/dfhack into develop

develop
Japa 2016-04-25 22:39:18 +05:30
commit b8f5496b24
7 changed files with 937 additions and 803 deletions

@ -106,8 +106,8 @@ endif()
# set up versioning.
set(DF_VERSION "0.42.06")
SET(DFHACK_RELEASE "beta1")
SET(DFHACK_PRERELEASE TRUE)
SET(DFHACK_RELEASE "r1")
SET(DFHACK_PRERELEASE FALSE)
set(DFHACK_VERSION "${DF_VERSION}-${DFHACK_RELEASE}")

@ -33,6 +33,9 @@ Changelog
DFHack future
=============
DFHack 0.42.06-r1
=================
Internals
---------
- Commands to run on startup can be specified on the command line with ``+``
@ -62,6 +65,7 @@ New Scripts
New Features
------------
- `buildingplan`: Support for floodgates, grates, and bars
- `colonies`: new ``place`` subcommand and supports any vermin (default honey bees)
- `confirm`: Added a confirmation for retiring locations
- `exportlegends`: Exports more information (poetic/musical/dance forms, written/artifact content, landmasses, extra histfig information, and more)
- `search-plugin`: Support for new screens:
@ -76,7 +80,10 @@ New Features
- ``tweak hide-priority``: Adds an option to hide designation priority indicators
- ``tweak title-start-rename``: Adds a safe rename option to the title screen "Start Playing" menu
- `colonies`: new ``place`` subcommand and supports any vermin (default honey bees)
- `zone`:
- Added ``unassign`` subcommand
- Added ``only`` option to ``assign`` subcommand
Fixes
-----
@ -117,6 +124,7 @@ Misc Improvements
- `remotefortressreader`: Can now trigger keyboard events
- `stockflow`: Now offers better control over individual craft jobs
- `weather`: now implemented by a script
- `zone`: colored output
Removed
-------

@ -1557,6 +1557,13 @@ static const LuaWrapper::FunctionReg dfhack_units_module[] = {
WRAPM(Units, isMerchant),
WRAPM(Units, isForest),
WRAPM(Units, isMarkedForSlaughter),
WRAPM(Units, isTame),
WRAPM(Units, isTrained),
WRAPM(Units, isGay),
WRAPM(Units, isNaked),
WRAPM(Units, isUndead),
WRAPM(Units, isGelded),
WRAPM(Units, isDomesticated),
{ NULL, NULL }
};

@ -266,6 +266,13 @@ DFHACK_EXPORT bool isFemale(df::unit* unit);
DFHACK_EXPORT bool isMerchant(df::unit* unit);
DFHACK_EXPORT bool isForest(df::unit* unit);
DFHACK_EXPORT bool isMarkedForSlaughter(df::unit* unit);
DFHACK_EXPORT bool isTame(df::unit* unit);
DFHACK_EXPORT bool isTrained(df::unit* unit);
DFHACK_EXPORT bool isGay(df::unit* unit);
DFHACK_EXPORT bool isNaked(df::unit* unit);
DFHACK_EXPORT bool isUndead(df::unit* unit);
DFHACK_EXPORT bool isGelded(df::unit* unit);
DFHACK_EXPORT bool isDomesticated(df::unit* unit);
DFHACK_EXPORT double getAge(df::unit *unit, bool true_age = false);
DFHACK_EXPORT int getKillCount(df::unit *unit);

@ -72,6 +72,7 @@ using namespace std;
#include "df/unit_misc_trait.h"
#include "df/unit_skill.h"
#include "df/unit_soul.h"
#include "df/unit_wound.h"
#include "df/world.h"
using namespace DFHack;
@ -1846,3 +1847,120 @@ bool Units::isMarkedForSlaughter(df::unit* unit)
CHECK_NULL_POINTER(unit);
return unit->flags2.bits.slaughter == 1;
}
bool Units::isTame(df::unit* unit)
{
CHECK_NULL_POINTER(unit);
bool tame = false;
if(unit->flags1.bits.tame)
{
switch (unit->training_level)
{
case df::animal_training_level::SemiWild: //??
case df::animal_training_level::Trained:
case df::animal_training_level::WellTrained:
case df::animal_training_level::SkilfullyTrained:
case df::animal_training_level::ExpertlyTrained:
case df::animal_training_level::ExceptionallyTrained:
case df::animal_training_level::MasterfullyTrained:
case df::animal_training_level::Domesticated:
tame=true;
break;
case df::animal_training_level::Unk8: //??
case df::animal_training_level::WildUntamed:
default:
tame=false;
break;
}
}
return tame;
}
bool Units::isTrained(df::unit* unit)
{
CHECK_NULL_POINTER(unit);
// case a: trained for war/hunting (those don't have a training level, strangely)
if(Units::isWar(unit) || Units::isHunter(unit))
return true;
// case b: tamed and trained wild creature, gets a training level
bool trained = false;
switch (unit->training_level)
{
case df::animal_training_level::Trained:
case df::animal_training_level::WellTrained:
case df::animal_training_level::SkilfullyTrained:
case df::animal_training_level::ExpertlyTrained:
case df::animal_training_level::ExceptionallyTrained:
case df::animal_training_level::MasterfullyTrained:
//case df::animal_training_level::Domesticated:
trained = true;
break;
default:
break;
}
return trained;
}
bool Units::isGay(df::unit* unit)
{
CHECK_NULL_POINTER(unit);
if (!unit->status.current_soul)
return false;
df::orientation_flags orientation = unit->status.current_soul->orientation_flags;
return (Units::isFemale(unit) && ! (orientation.whole & (orientation.mask_marry_male | orientation.mask_romance_male)))
|| (!Units::isFemale(unit) && ! (orientation.whole & (orientation.mask_marry_female | orientation.mask_romance_female)));
}
bool Units::isNaked(df::unit* unit)
{
CHECK_NULL_POINTER(unit);
// TODO(kazimuth): is this correct?
return (unit->inventory.empty());
}
bool Units::isUndead(df::unit* unit)
{
CHECK_NULL_POINTER(unit);
// ignore vampires, they should be treated like normal dwarves
return (unit->flags3.bits.ghostly ||
( (unit->curse.add_tags1.bits.OPPOSED_TO_LIFE || unit->curse.add_tags1.bits.NOT_LIVING)
&& !unit->curse.add_tags1.bits.BLOODSUCKER ));
}
bool Units::isGelded(df::unit* unit)
{
CHECK_NULL_POINTER(unit);
auto wounds = unit->body.wounds;
for(auto wound = wounds.begin(); wound != wounds.end(); ++wound)
{
auto parts = (*wound)->parts;
for (auto part = parts.begin(); part != parts.end(); ++part)
{
if ((*part)->flags2.bits.gelded)
return true;
}
}
return false;
}
// check if creature is domesticated
// seems to be the only way to really tell if it's completely safe to autonestbox it (training can revert)
bool Units::isDomesticated(df::unit* unit)
{
CHECK_NULL_POINTER(unit);
bool tame = false;
if(unit->flags1.bits.tame)
{
switch (unit->training_level)
{
case df::animal_training_level::Domesticated:
tame=true;
break;
default:
tame=false;
break;
}
}
return tame;
}

@ -1 +1 @@
Subproject commit 58806dc7e4bfcc1bb5f33b15395bdc9fd5a1ea28
Subproject commit 98cc1e01886aaea161d651cf97229ad08e9782b0

File diff suppressed because it is too large Load Diff