From 9c48e32bb7009b04fcc45bd85cb8a3985e40c886 Mon Sep 17 00:00:00 2001 From: NoFantasy Date: Thu, 7 Jan 2010 20:18:22 +0100 Subject: [PATCH] [9120] Implement option to use delay in ForcedDespawn for creature Signed-off-by: NoFantasy --- src/game/Creature.cpp | 20 ++++++++++++++++++-- src/game/Creature.h | 12 +++++++++++- src/shared/revision_nr.h | 2 +- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 66b9b3133..a1cde1be3 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -105,6 +105,12 @@ bool AssistDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) return true; } +bool ForcedDespawnDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) +{ + m_owner.ForcedDespawn(); + return true; +} + Creature::Creature() : Unit(), i_AI(NULL), lootForPickPocketed(false), lootForBody(false), m_groupLootTimer(0), lootingGroupLeaderGUID(0), @@ -1294,9 +1300,19 @@ void Creature::Respawn() } } -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 9cabccd59..65e0beb35 100644 --- a/src/game/Creature.h +++ b/src/game/Creature.h @@ -538,7 +538,7 @@ class MANGOS_DLL_SPEC Creature : public Unit 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; @@ -660,4 +660,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/shared/revision_nr.h b/src/shared/revision_nr.h index 54f39c0d7..12362f898 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "9119" + #define REVISION_NR "9120" #endif // __REVISION_NR_H__