diff options
author | n0n4m3 <none@none> | 2010-01-16 19:51:59 +0300 |
---|---|---|
committer | n0n4m3 <none@none> | 2010-01-16 19:51:59 +0300 |
commit | 720318e85601321d633103ab61b6efdadbdf5965 (patch) | |
tree | 5b5bf43aa6356a01fde66835dc38e3fae56dd288 /src/game/Creature.cpp | |
parent | a29727e4238d0a02dab80fb7489af59848c21a03 (diff) |
Implement option to use delay in ForcedDespawn for creature, allow use delayed forced despawn also in EAI, by NoFantasy.
--HG--
branch : trunk
Diffstat (limited to 'src/game/Creature.cpp')
-rw-r--r-- | src/game/Creature.cpp | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 8868b24c768..69334a31562 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -137,6 +137,12 @@ CreatureBaseStats const* CreatureBaseStats::GetBaseStats(uint32 level, uint8 uni return objmgr.GetCreatureBaseStats(level, unitClass); } +bool ForcedDespawnDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) +{ + m_owner.ForcedDespawn(); + return true; +} + Creature::Creature() : Unit(), lootForPickPocketed(false), lootForBody(false), m_groupLootTimer(0), lootingGroupLeaderGUID(0), @@ -1586,9 +1592,19 @@ void Creature::Respawn(bool force) SetToNotify(); } -void Creature::ForcedDespawn() +void Creature::ForcedDespawn(uint32 timeMSToDespawn) { - setDeathState(JUST_DIED); + if (timeMSToDespawn) + { + ForcedDespawnDelayEvent *pEvent = new ForcedDespawnDelayEvent(*this); + + m_Events.AddEvent(pEvent, m_Events.CalculateTime(timeMSToDespawn)); + return; + } + + if (isAlive()) + setDeathState(JUST_DIED); + RemoveCorpse(); SetHealth(0); // just for nice GM-mode view } |