Flee action, factory setting

This commit is contained in:
Yunfan Li
2023-05-29 11:45:18 +08:00
parent dc21fa9d41
commit 2ad567a1a8
22 changed files with 236 additions and 163 deletions

View File

@@ -145,7 +145,23 @@ bool MyAttackerCountTrigger::IsActive()
bool AoeTrigger::IsActive()
{
return AI_VALUE2(bool, "combat", "self target") && AI_VALUE(uint8, "aoe count") >= amount && AI_VALUE(uint8, "attacker count") >= amount;
Unit* current_target = AI_VALUE(Unit*, "current target");
if (!current_target) {
return false;
}
GuidVector attackers = context->GetValue<GuidVector>("attackers")->Get();
int attackers_count = 0;
for (ObjectGuid const guid : attackers)
{
Unit* unit = botAI->GetUnit(guid);
if (!unit || !unit->IsAlive())
continue;
if (unit->GetExactDist2d(current_target) <= range) {
attackers_count++;
}
}
return attackers_count >= amount;
}
bool NoFoodTrigger::IsActive()