refactor(Core/Combat): Cleanup DoZoneInCombat function. (#8789)

* Core/Combat: Cleanup DoZoneInCombat function.

Updates #7960

* Restore distance parameter.

* You don't belong here.

* Update
This commit is contained in:
UltraNix
2021-11-09 00:54:44 +01:00
committed by GitHub
parent 5d1a7a4dc9
commit affa6f9084
3 changed files with 55 additions and 67 deletions

View File

@@ -2549,40 +2549,8 @@ void Creature::SendZoneUnderAttackMessage(Player* attacker)
void Creature::SetInCombatWithZone()
{
if (!CanHaveThreatList())
{
LOG_ERROR("entities.unit", "Creature entry %u call SetInCombatWithZone but creature cannot have threat list.", GetEntry());
return;
}
Map* map = GetMap();
if (!map->IsDungeon())
{
LOG_ERROR("entities.unit", "Creature entry %u call SetInCombatWithZone for map (id: %u) that isn't an instance.", GetEntry(), map->GetId());
return;
}
Map::PlayerList const& PlList = map->GetPlayers();
if (PlList.isEmpty())
return;
for (Map::PlayerList::const_iterator i = PlList.begin(); i != PlList.end(); ++i)
{
if (Player* player = i->GetSource())
{
if (player->IsGameMaster())
continue;
if (player->IsAlive())
{
this->SetInCombatWith(player);
player->SetInCombatWith(this);
AddThreat(player, 0.0f);
}
}
}
if (IsAIEnabled)
AI()->DoZoneInCombat();
}
void Creature::ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs)