dead & killed flag separation

squashed 4 commits from #1297
develop
PatrikLundell 2018-06-07 19:10:14 +02:00 committed by lethosor
parent 02b7f2145f
commit f329774059
3 changed files with 29 additions and 2 deletions

@ -1633,6 +1633,9 @@ static const LuaWrapper::FunctionReg dfhack_units_module[] = {
WRAPM(Units, isGay), WRAPM(Units, isGay),
WRAPM(Units, isNaked), WRAPM(Units, isNaked),
WRAPM(Units, isUndead), WRAPM(Units, isUndead),
WRAPM(Units, isGhost),
WRAPM(Units, isActive),
WRAPM(Units, isKilled),
WRAPM(Units, isGelded), WRAPM(Units, isGelded),
WRAPM(Units, isDomesticated), WRAPM(Units, isDomesticated),
WRAPM(Units, getMainSocialActivity), WRAPM(Units, getMainSocialActivity),

@ -146,6 +146,9 @@ DFHACK_EXPORT bool isTrained(df::unit* unit);
DFHACK_EXPORT bool isGay(df::unit* unit); DFHACK_EXPORT bool isGay(df::unit* unit);
DFHACK_EXPORT bool isNaked(df::unit* unit); DFHACK_EXPORT bool isNaked(df::unit* unit);
DFHACK_EXPORT bool isUndead(df::unit* unit); DFHACK_EXPORT bool isUndead(df::unit* unit);
DFHACK_EXPORT bool isGhost(df::unit *unit);
DFHACK_EXPORT bool isActive(df::unit *unit);
DFHACK_EXPORT bool isKilled(df::unit *unit);
DFHACK_EXPORT bool isGelded(df::unit* unit); DFHACK_EXPORT bool isGelded(df::unit* unit);
DFHACK_EXPORT bool isDomesticated(df::unit* unit); DFHACK_EXPORT bool isDomesticated(df::unit* unit);

@ -388,7 +388,7 @@ bool Units::isDead(df::unit *unit)
{ {
CHECK_NULL_POINTER(unit); CHECK_NULL_POINTER(unit);
return unit->flags1.bits.dead || return unit->flags2.bits.killed ||
unit->flags3.bits.ghostly; unit->flags3.bits.ghostly;
} }
@ -396,7 +396,7 @@ bool Units::isAlive(df::unit *unit)
{ {
CHECK_NULL_POINTER(unit); CHECK_NULL_POINTER(unit);
return !unit->flags1.bits.dead && return !unit->flags2.bits.killed &&
!unit->flags3.bits.ghostly && !unit->flags3.bits.ghostly &&
!unit->curse.add_tags1.bits.NOT_LIVING; !unit->curse.add_tags1.bits.NOT_LIVING;
} }
@ -1568,6 +1568,27 @@ bool Units::isUndead(df::unit* unit)
&& !unit->curse.add_tags1.bits.BLOODSUCKER )); && !unit->curse.add_tags1.bits.BLOODSUCKER ));
} }
bool Units::isGhost(df::unit *unit)
{
CHECK_NULL_POINTER(unit);
return !unit->flags3.bits.ghostly;
}
bool Units::isActive(df::unit *unit)
{
CHECK_NULL_POINTER(unit);
return !unit->flags1.bits.dead;
}
bool Units::isKilled(df::unit *unit)
{
CHECK_NULL_POINTER(unit);
return unit->flags2.bits.killed;
}
bool Units::isGelded(df::unit* unit) bool Units::isGelded(df::unit* unit)
{ {
CHECK_NULL_POINTER(unit); CHECK_NULL_POINTER(unit);