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 | |
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
-rw-r--r-- | src/game/Creature.cpp | 20 | ||||
-rw-r--r-- | src/game/Creature.h | 13 | ||||
-rw-r--r-- | src/game/CreatureEventAI.cpp | 2 | ||||
-rw-r--r-- | src/game/CreatureEventAI.h | 7 |
4 files changed, 37 insertions, 5 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 } diff --git a/src/game/Creature.h b/src/game/Creature.h index cd9f30f703a..efc09deb49f 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -589,7 +589,7 @@ class TRINITY_DLL_SPEC Creature : public Unit, public GridObject<Creature> void RemoveCorpse(); bool isDeadByDefault() const { return m_isDeadByDefault; }; - void ForcedDespawn(); + void ForcedDespawn(uint32 timeMSToDespawn = 0); time_t const& GetRespawnTime() const { return m_respawnTime; } time_t GetRespawnTimeEx() const; @@ -710,6 +710,7 @@ class TRINITY_DLL_SPEC Creature : public Unit, public GridObject<Creature> CreatureData const* m_creatureData; uint16 m_LootMode; // bitmask, default DEFAULT_LOOT_MODE, determines what loot will be lootable + private: //WaypointMovementGenerator vars uint32 m_waypointID; @@ -734,4 +735,14 @@ class AssistDelayEvent : public BasicEvent Unit& m_owner; }; +class ForcedDespawnDelayEvent : public BasicEvent +{ + public: + ForcedDespawnDelayEvent(Creature& owner) : BasicEvent(), m_owner(owner) { } + bool Execute(uint64 e_time, uint32 p_time); + + private: + Creature& m_owner; +}; + #endif diff --git a/src/game/CreatureEventAI.cpp b/src/game/CreatureEventAI.cpp index e3fc574d697..a2c522fc609 100644 --- a/src/game/CreatureEventAI.cpp +++ b/src/game/CreatureEventAI.cpp @@ -801,7 +801,7 @@ void CreatureEventAI::ProcessAction(CreatureEventAI_Action const& action, uint32 } case ACTION_T_FORCE_DESPAWN: { - m_creature->ForcedDespawn(); + m_creature->ForcedDespawn(action.forced_despawn.msDelay); break; } case ACTION_T_SET_INVINCIBILITY_HP_LEVEL: diff --git a/src/game/CreatureEventAI.h b/src/game/CreatureEventAI.h index e3bab96d133..ede597e8710 100644 --- a/src/game/CreatureEventAI.h +++ b/src/game/CreatureEventAI.h @@ -387,7 +387,12 @@ struct CreatureEventAI_Action { uint32 sheath; } set_sheath; - // ACTION_T_SET_INVINCIBILITY_HP_LEVEL = 42 + // ACTION_T_FORCE_DESPAWN = 41 + struct + { + uint32 msDelay; + } forced_despawn; + // ACTION_T_SET_INVINCIBILITY_HP_LEVEL = 42 struct { uint32 hp_level; |