Updates Units::isAnimal

Now checks that the unit cannot learn or speak, and has either a wilderness population source, a pet/pet_exotic token, or is trainable for war/hunting
develop
Josh Cooper 2022-11-29 13:19:19 -08:00
parent 344ed4312b
commit 807894ac6c
1 changed files with 10 additions and 3 deletions

@ -623,10 +623,17 @@ bool Units::isDwarf(df::unit *unit)
unit->enemy.normal_race == ui->race_id;
}
bool Units::isAnimal(df::unit* unit)
{
bool Units::isAnimal(df::unit* unit) {
CHECK_NULL_POINTER(unit)
return unit->enemy.caste_flags.is_set(df::enums::caste_raw_flags::NATURAL_ANIMAL);
using namespace df::enums::caste_raw_flags;
const auto &cf = unit->enemy.caste_flags;
// we're (somewhat) matching Dwarf Therapist's animal check. We care about wild animals too however.
return !cf.is_set(CAN_LEARN) && !cf.is_set(CAN_SPEAK) &&
(unit->flags2.bits.roaming_wilderness_population_source ||
cf.is_set(PET) ||
cf.is_set(PET_EXOTIC) ||
cf.is_set(TRAINABLE_WAR) || //These last two may be redundant
cf.is_set(TRAINABLE_HUNTING));
}
bool Units::isMerchant(df::unit* unit)