From 807894ac6cbb477e7bf133c1da1992c7881e7113 Mon Sep 17 00:00:00 2001 From: Josh Cooper Date: Tue, 29 Nov 2022 13:19:19 -0800 Subject: [PATCH] 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 --- library/modules/Units.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/library/modules/Units.cpp b/library/modules/Units.cpp index 0395044ce..777c3239b 100644 --- a/library/modules/Units.cpp +++ b/library/modules/Units.cpp @@ -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)