aboutsummaryrefslogtreecommitdiff
path: root/src/game/Creature.cpp
diff options
context:
space:
mode:
authormegamage <none@none>2009-06-27 15:37:33 -0500
committermegamage <none@none>2009-06-27 15:37:33 -0500
commitfe89fbfbdb00ab6e71a9a0ba00b4cc7d803dda0e (patch)
treebac9bd2c19018c4c5bc8be9cf13504aa79a5c7ca /src/game/Creature.cpp
parentd401ede8f24fe8f733357c742e861b453c1794f8 (diff)
[8057] Move code from Event AI to class Creature function for reuse in other scripting cases. Author: NoFantasy
--HG-- branch : trunk
Diffstat (limited to 'src/game/Creature.cpp')
-rw-r--r--src/game/Creature.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp
index 50fa95337f6..c8dcd0d2414 100644
--- a/src/game/Creature.cpp
+++ b/src/game/Creature.cpp
@@ -2262,6 +2262,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;