1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Add isMeleeAttacker to Unit

This commit is contained in:
Andrej Dudenhefner
2025-11-07 11:44:56 +01:00
parent 7161ce858e
commit 3b72a74161
4 changed files with 26 additions and 6 deletions

View File

@@ -545,6 +545,22 @@ bool CUnitState::isShooter() const
return shots.total() > 0;
}
bool CUnitState::isMeleeAttacker() const
{
//exclude non melee attackers
static const std::set<CreatureID> nonMeleeAttackers{
CreatureID::FIRST_AID_TENT,
CreatureID::CATAPULT,
CreatureID::BALLISTA,
CreatureID::AMMO_CART,
CreatureID::ARROW_TOWERS
};
if (vstd::contains(nonMeleeAttackers, creatureId()))
return false;
return true;
}
int32_t CUnitState::getKilled() const
{
int32_t res = unitBaseAmount() - health.getCount() + health.getResurrected();