mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[8057] Move code from Event AI to class Creature function for reuse in other scripting cases.
Also some outdated and wrong checks remove. Signed-off-by: VladimirMangos <vladimir@getmangos.com>
This commit is contained in:
parent
9b9fe55981
commit
400c110e1f
5 changed files with 43 additions and 37 deletions
|
|
@ -1978,6 +1978,43 @@ void Creature::SendZoneUnderAttackMessage(Player* attacker)
|
|||
sWorld.SendGlobalMessage(&data,NULL,(enemy_team==ALLIANCE ? HORDE : ALLIANCE));
|
||||
}
|
||||
|
||||
void Creature::SetInCombatWithZone()
|
||||
{
|
||||
if (!CanHaveThreatList())
|
||||
{
|
||||
error_log("Creature entry %u call SetInCombatWithZone but creature cannot have threat list.", GetEntry());
|
||||
return;
|
||||
}
|
||||
|
||||
Map* pMap = GetMap();
|
||||
|
||||
if (!pMap->IsDungeon())
|
||||
{
|
||||
error_log("Creature entry %u call SetInCombatWithZone for map (id: %u) that isn't an instance.", GetEntry(), pMap->GetId());
|
||||
return;
|
||||
}
|
||||
|
||||
Map::PlayerList const &PlList = pMap->GetPlayers();
|
||||
|
||||
if (PlList.isEmpty())
|
||||
return;
|
||||
|
||||
for(Map::PlayerList::const_iterator i = PlList.begin(); i != PlList.end(); ++i)
|
||||
{
|
||||
if (Player* pPlayer = i->getSource())
|
||||
{
|
||||
if (pPlayer->isGameMaster())
|
||||
continue;
|
||||
|
||||
if (pPlayer->isAlive())
|
||||
{
|
||||
pPlayer->SetInCombatWith(this);
|
||||
AddThreat(pPlayer, 0.0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Creature::_AddCreatureSpellCooldown(uint32 spell_id, time_t end_time)
|
||||
{
|
||||
m_CreatureSpellCooldowns[spell_id] = end_time;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue