diff options
author | Machiavelli <machiavelli.trinity@gmail.com> | 2011-03-06 15:12:34 +0100 |
---|---|---|
committer | Machiavelli <machiavelli.trinity@gmail.com> | 2011-03-06 15:12:34 +0100 |
commit | d5be3353f3cdea77a0ef302135d33a4f49729a4c (patch) | |
tree | cb1918548b5fd783b1575324a48318aa3cc2c1b0 /src | |
parent | 5be032fe7964675f36e9b819aad98730989c9ffd (diff) |
Core/TempSummon: Implement ForcedUnsummonDelayEvent. Similar to ForcedDespawnEvent for Creatures, this will unsummon TempSummon objects with specified delay.
Core/Vehicles: Implement ForcedUnsummonDelayEvent for creatures exiting vehicles. Fixes visual bug that showed creatures mounted on vehicle after being ejected.
Diffstat (limited to 'src')
-rwxr-xr-x | src/server/game/Entities/Creature/TemporarySummon.cpp | 16 | ||||
-rwxr-xr-x | src/server/game/Entities/Creature/TemporarySummon.h | 11 | ||||
-rwxr-xr-x | src/server/game/Entities/Unit/Unit.cpp | 2 |
3 files changed, 26 insertions, 3 deletions
diff --git a/src/server/game/Entities/Creature/TemporarySummon.cpp b/src/server/game/Entities/Creature/TemporarySummon.cpp index 1204a104d9c..62174fe8c9c 100755 --- a/src/server/game/Entities/Creature/TemporarySummon.cpp +++ b/src/server/game/Entities/Creature/TemporarySummon.cpp @@ -224,8 +224,16 @@ void TempSummon::SetTempSummonType(TempSummonType type) m_type = type; } -void TempSummon::UnSummon() +void TempSummon::UnSummon(uint32 msTime) { + if (msTime) + { + ForcedUnsummonDelayEvent *pEvent = new ForcedUnsummonDelayEvent(*this); + + m_Events.AddEvent(pEvent, m_Events.CalculateTime(msTime)); + return; + } + //ASSERT(!isPet()); if (isPet()) { @@ -241,6 +249,12 @@ void TempSummon::UnSummon() AddObjectToRemoveList(); } +bool ForcedUnsummonDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) +{ + m_owner.UnSummon(); + return true; +} + void TempSummon::RemoveFromWorld() { if (!IsInWorld()) diff --git a/src/server/game/Entities/Creature/TemporarySummon.h b/src/server/game/Entities/Creature/TemporarySummon.h index c4fe70a0983..82f63d887ab 100755 --- a/src/server/game/Entities/Creature/TemporarySummon.h +++ b/src/server/game/Entities/Creature/TemporarySummon.h @@ -29,7 +29,7 @@ class TempSummon : public Creature void Update(uint32 time); virtual void InitStats(uint32 lifetime); virtual void InitSummon(); - void UnSummon(); + void UnSummon(uint32 msTime = 0); void RemoveFromWorld(); void SetTempSummonType(TempSummonType type); void SaveToDB(uint32 /*mapid*/, uint8 /*spawnMask*/, uint32 /*phaseMask*/) {} @@ -97,5 +97,14 @@ class Puppet : public Minion Player *m_owner; }; +class ForcedUnsummonDelayEvent : public BasicEvent +{ +public: + ForcedUnsummonDelayEvent(TempSummon& owner) : BasicEvent(), m_owner(owner) { } + bool Execute(uint64 e_time, uint32 p_time); + +private: + TempSummon& m_owner; +}; #endif diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 4b480199792..437778a957c 100755 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -16711,7 +16711,7 @@ void Unit::_ExitVehicle(Position const* exitPosition) setDeathState(JUST_DIED); // If for other reason we as minion are exiting the vehicle (ejected, master unmounted) - unsummon else - ToTempSummon()->UnSummon(); + ToTempSummon()->UnSummon(2000); // Approximation } } |