Merge pull request #2429 from cppcooper/patch-3

Updates Units::isAnimal
develop
Myk 2022-11-29 18:43:04 -08:00 committed by GitHub
commit 018bf712d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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)