diff --git a/src/common/Utilities/EventProcessor.cpp b/src/common/Utilities/EventProcessor.cpp index 2659491de..96da65158 100644 --- a/src/common/Utilities/EventProcessor.cpp +++ b/src/common/Utilities/EventProcessor.cpp @@ -5,11 +5,20 @@ */ #include "EventProcessor.h" +#include "Errors.h" -EventProcessor::EventProcessor() +void BasicEvent::ScheduleAbort() { - m_time = 0; - m_aborting = false; + ASSERT(IsRunning() + && "Tried to scheduled the abortion of an event twice!"); + m_abortState = AbortState::STATE_ABORT_SCHEDULED; +} + +void BasicEvent::SetAborted() +{ + ASSERT(!IsAborted() + && "Tried to abort an already aborted event!"); + m_abortState = AbortState::STATE_ABORTED; } EventProcessor::~EventProcessor() @@ -27,63 +36,92 @@ void EventProcessor::Update(uint32 p_time) while (((i = m_events.begin()) != m_events.end()) && i->first <= m_time) { // get and remove event from queue - BasicEvent* Event = i->second; + BasicEvent* event = i->second; m_events.erase(i); - if (!Event->to_Abort) + if (event->IsRunning()) { - if (Event->Execute(m_time, p_time)) + if (event->Execute(m_time, p_time)) { // completely destroy event if it is not re-added - delete Event; + delete event; } + continue; } - else + + if (event->IsAbortScheduled()) { - Event->Abort(m_time); - delete Event; + event->Abort(m_time); + // Mark the event as aborted + event->SetAborted(); } + + if (event->IsDeletable()) + { + delete event; + continue; + } + + // Reschedule non deletable events to be checked at + // the next update tick + AddEvent(event, CalculateTime(1), false); } } void EventProcessor::KillAllEvents(bool force) { - // prevent event insertions - m_aborting = true; - // first, abort all existing events - for (EventList::iterator i = m_events.begin(); i != m_events.end();) + for (auto itr = m_events.begin(); itr != m_events.end();) { - EventList::iterator i_old = i; - ++i; - - i_old->second->to_Abort = true; - i_old->second->Abort(m_time); - if (force || i_old->second->IsDeletable()) + // Abort events which weren't aborted already + if (!itr->second->IsAborted()) { - delete i_old->second; - - if (!force) // need per-element cleanup - { - m_events.erase (i_old); - } + itr->second->SetAborted(); + itr->second->Abort(m_time); } + + // Skip non-deletable events when we are + // not forcing the event cancellation. + if (!force && !itr->second->IsDeletable()) + { + ++itr; + continue; + } + + delete itr->second; + + if (force) + ++itr; // Clear the whole container when forcing + else + itr = m_events.erase(itr); } - // fast clear event list (in force case) if (force) - { m_events.clear(); - } } void EventProcessor::AddEvent(BasicEvent* Event, uint64 e_time, bool set_addtime) { - if (set_addtime) { Event->m_addTime = m_time; } + if (set_addtime) + Event->m_addTime = m_time; Event->m_execTime = e_time; m_events.insert(std::pair(e_time, Event)); } +void EventProcessor::ModifyEventTime(BasicEvent* event, Milliseconds newTime) +{ + for (auto itr = m_events.begin(); itr != m_events.end(); ++itr) + { + if (itr->second != event) + continue; + + event->m_execTime = newTime.count(); + m_events.erase(itr); + m_events.insert(std::pair(newTime.count(), event)); + break; + } +} + uint64 EventProcessor::CalculateTime(uint64 t_offset) const { return (m_time + t_offset); diff --git a/src/common/Utilities/EventProcessor.h b/src/common/Utilities/EventProcessor.h index 530479394..393a46b4e 100644 --- a/src/common/Utilities/EventProcessor.h +++ b/src/common/Utilities/EventProcessor.h @@ -8,58 +8,77 @@ #define __EVENTPROCESSOR_H #include "Define.h" +#include "Duration.h" #include -// Note. All times are in milliseconds here. +class EventProcessor; +// Note. All times are in milliseconds here. class BasicEvent { -public: - BasicEvent() + + friend class EventProcessor; + + enum class AbortState : uint8 { - to_Abort = false; - m_addTime = 0; - m_execTime = 0; - } - virtual ~BasicEvent() = default; // override destructor to perform some actions on event removal + STATE_RUNNING, + STATE_ABORT_SCHEDULED, + STATE_ABORTED + }; - // this method executes when the event is triggered - // return false if event does not want to be deleted - // e_time is execution time, p_time is update interval - virtual bool Execute(uint64 /*e_time*/, uint32 /*p_time*/) { return true; } + public: + BasicEvent() + : m_abortState(AbortState::STATE_RUNNING), m_addTime(0), m_execTime(0) { } - [[nodiscard]] virtual bool IsDeletable() const { return true; } // this event can be safely deleted + virtual ~BasicEvent() { } // override destructor to perform some actions on event removal - virtual void Abort(uint64 /*e_time*/) { } // this method executes when the event is aborted + // this method executes when the event is triggered + // return false if event does not want to be deleted + // e_time is execution time, p_time is update interval + [[nodiscard]] virtual bool Execute(uint64 /*e_time*/, uint32 /*p_time*/) { return true; } - bool to_Abort; // set by externals when the event is aborted, aborted events don't execute - // and get Abort call when deleted + [[nodiscard]] virtual bool IsDeletable() const { return true; } // this event can be safely deleted - // these can be used for time offset control - uint64 m_addTime; // time when the event was added to queue, filled by event handler - uint64 m_execTime; // planned time of next execution, filled by event handler + virtual void Abort(uint64 /*e_time*/) { } // this method executes when the event is aborted + + // Aborts the event at the next update tick + void ScheduleAbort(); + + private: + void SetAborted(); + bool IsRunning() const { return (m_abortState == AbortState::STATE_RUNNING); } + bool IsAbortScheduled() const { return (m_abortState == AbortState::STATE_ABORT_SCHEDULED); } + bool IsAborted() const { return (m_abortState == AbortState::STATE_ABORTED); } + + AbortState m_abortState; // set by externals when the event is aborted, aborted events don't execute + + // these can be used for time offset control + uint64 m_addTime; // time when the event was added to queue, filled by event handler + uint64 m_execTime; // planned time of next execution, filled by event handler }; typedef std::multimap EventList; class EventProcessor { -public: - EventProcessor(); - ~EventProcessor(); + public: + EventProcessor() : m_time(0) { } + ~EventProcessor(); - void Update(uint32 p_time); - void KillAllEvents(bool force); - void AddEvent(BasicEvent* Event, uint64 e_time, bool set_addtime = true); - [[nodiscard]] uint64 CalculateTime(uint64 t_offset) const; + void Update(uint32 p_time); + void KillAllEvents(bool force); + void AddEvent(BasicEvent* Event, uint64 e_time, bool set_addtime = true); + void ModifyEventTime(BasicEvent* event, Milliseconds newTime); + [[nodiscard]] uint64 CalculateTime(uint64 t_offset) const; - // Xinef: calculates next queue tick time - [[nodiscard]] uint64 CalculateQueueTime(uint64 delay) const; + //calculates next queue tick time + [[nodiscard]] uint64 CalculateQueueTime(uint64 delay) const; -protected: - uint64 m_time; - EventList m_events; - bool m_aborting; + protected: + uint64 m_time; + EventList m_events; + bool m_aborting; }; + #endif diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp index 2957153df..91afb98e3 100644 --- a/src/server/game/AI/CreatureAI.cpp +++ b/src/server/game/AI/CreatureAI.cpp @@ -51,7 +51,7 @@ void CreatureAI::DoZoneInCombat(Creature* creature /*= nullptr*/, float maxRange creature->AI()->AttackStart(nearTarget); else if (creature->IsSummon()) { - if (Unit* summoner = creature->ToTempSummon()->GetSummoner()) + if (Unit* summoner = creature->ToTempSummon()->GetSummonerUnit()) { Unit* target = summoner->getAttackerForHelper(); if (!target && summoner->CanHaveThreatList() && !summoner->getThreatManager().isThreatListEmpty()) diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index 7a90c4348..e2f049f84 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -3638,8 +3638,8 @@ ObjectList* SmartScript::GetTargets(SmartScriptHolder const& e, Unit* invoker /* if (Unit* owner = ObjectAccessor::GetUnit(*me, me->GetCharmerOrOwnerGUID())) l->push_back(owner); // Xinef: dont add same unit twice - else if (me->IsSummon() && me->ToTempSummon()->GetSummoner()) - l->push_back(me->ToTempSummon()->GetSummoner()); + else if (me->IsSummon() && me->ToTempSummon()->GetSummonerUnit()) + l->push_back(me->ToTempSummon()->GetSummonerUnit()); } else if (go) { diff --git a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp index 4a96e72f4..843d23f91 100644 --- a/src/server/game/Battlefield/Zones/BattlefieldWG.cpp +++ b/src/server/game/Battlefield/Zones/BattlefieldWG.cpp @@ -598,7 +598,7 @@ void BattlefieldWG::OnCreatureCreate(Creature* creature) if (!creature->IsSummon() || !creature->ToTempSummon()->GetSummonerGUID()) return; - if (Unit* owner = creature->ToTempSummon()->GetSummoner()) + if (Unit* owner = creature->ToTempSummon()->GetSummonerUnit()) creature->setFaction(owner->getFaction()); break; } diff --git a/src/server/game/Entities/Creature/TemporarySummon.cpp b/src/server/game/Entities/Creature/TemporarySummon.cpp index 73c031724..7f03c0ade 100644 --- a/src/server/game/Entities/Creature/TemporarySummon.cpp +++ b/src/server/game/Entities/Creature/TemporarySummon.cpp @@ -16,13 +16,39 @@ TempSummon::TempSummon(SummonPropertiesEntry const* properties, ObjectGuid owner Creature(isWorldObject), m_Properties(properties), m_type(TEMPSUMMON_MANUAL_DESPAWN), m_timer(0), m_lifetime(0) { - m_summonerGUID = owner; + if (owner) + { + m_summonerGUID = owner; + } + m_unitTypeMask |= UNIT_MASK_SUMMON; } -Unit* TempSummon::GetSummoner() const +WorldObject* TempSummon::GetSummoner() const { - return m_summonerGUID ? ObjectAccessor::GetUnit(*this, m_summonerGUID) : nullptr; + return m_summonerGUID ? ObjectAccessor::GetWorldObject(*this, m_summonerGUID) : nullptr; +} + +Unit* TempSummon::GetSummonerUnit() const +{ + if (WorldObject* summoner = GetSummoner()) + { + return summoner->ToUnit(); + } + + return nullptr; +} + +Creature* TempSummon::GetSummonerCreatureBase() const +{ + return m_summonerGUID ? ObjectAccessor::GetCreature(*this, m_summonerGUID) : nullptr; +} + +GameObject* TempSummon::GetSummonerGameObject() const +{ + if (WorldObject* summoner = GetSummoner()) + return summoner->ToGameObject(); + return nullptr; } void TempSummon::Update(uint32 diff) @@ -147,7 +173,7 @@ void TempSummon::InitStats(uint32 duration) { ASSERT(!IsPet()); - Unit* owner = GetSummoner(); + Unit* owner = GetSummonerUnit(); if (owner) if (Player* player = owner->ToPlayer()) sScriptMgr->OnBeforeTempSummonInitStats(player, this, duration); @@ -197,7 +223,7 @@ void TempSummon::InitStats(uint32 duration) void TempSummon::InitSummon() { - Unit* owner = GetSummoner(); + Unit* owner = GetSummonerUnit(); if (owner) { if (owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsAIEnabled) @@ -237,7 +263,7 @@ void TempSummon::UnSummon(uint32 msTime) return; } - Unit* owner = GetSummoner(); + Unit* owner = GetSummonerUnit(); if (owner && owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsAIEnabled) owner->ToCreature()->AI()->SummonedCreatureDespawn(this); @@ -257,7 +283,7 @@ void TempSummon::RemoveFromWorld() if (m_Properties) if (uint32 slot = m_Properties->Slot) - if (Unit* owner = GetSummoner()) + if (Unit* owner = GetSummonerUnit()) if (owner->m_SummonSlot[slot] == GetGUID()) owner->m_SummonSlot[slot].Clear(); diff --git a/src/server/game/Entities/Creature/TemporarySummon.h b/src/server/game/Entities/Creature/TemporarySummon.h index cde06a077..547e44692 100644 --- a/src/server/game/Entities/Creature/TemporarySummon.h +++ b/src/server/game/Entities/Creature/TemporarySummon.h @@ -37,7 +37,10 @@ public: void RemoveFromWorld() override; void SetTempSummonType(TempSummonType type); void SaveToDB(uint32 /*mapid*/, uint8 /*spawnMask*/, uint32 /*phaseMask*/) override {} - [[nodiscard]] Unit* GetSummoner() const; + [[nodiscard]] WorldObject* GetSummoner() const; + [[nodiscard]] Unit* GetSummonerUnit() const; + [[nodiscard]] Creature* GetSummonerCreatureBase() const; + [[nodiscard]] GameObject* GetSummonerGameObject() const; ObjectGuid GetSummonerGUID() { return m_summonerGUID; } TempSummonType const& GetSummonType() { return m_type; } uint32 GetTimer() { return m_timer; } diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index 01b8a1955..be6f31d7c 100644 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -465,48 +465,33 @@ struct Position [[nodiscard]] bool IsPositionValid() const; - [[nodiscard]] float GetExactDist2dSq(float x, float y) const + [[nodiscard]] float GetExactDist2dSq(const float x, const float y) const { - float dx = m_positionX - x; - float dy = m_positionY - y; - return dx * dx + dy * dy; - } - [[nodiscard]] float GetExactDist2d(const float x, const float y) const - { - return sqrt(GetExactDist2dSq(x, y)); - } - float GetExactDist2dSq(const Position* pos) const - { - float dx = m_positionX - pos->m_positionX; - float dy = m_positionY - pos->m_positionY; - return dx * dx + dy * dy; - } - float GetExactDist2d(const Position* pos) const - { - return sqrt(GetExactDist2dSq(pos)); - } - [[nodiscard]] float GetExactDistSq(float x, float y, float z) const - { - float dz = m_positionZ - z; - return GetExactDist2dSq(x, y) + dz * dz; - } - [[nodiscard]] float GetExactDist(float x, float y, float z) const - { - return sqrt(GetExactDistSq(x, y, z)); - } - float GetExactDistSq(const Position* pos) const - { - float dx = m_positionX - pos->m_positionX; - float dy = m_positionY - pos->m_positionY; - float dz = m_positionZ - pos->m_positionZ; - return dx * dx + dy * dy + dz * dz; - } - float GetExactDist(const Position* pos) const - { - return sqrt(GetExactDistSq(pos)); + float dx = x - m_positionX; + float dy = y - m_positionY; + return dx*dx + dy*dy; } + float GetExactDist2dSq(Position const& pos) const { return GetExactDist2dSq(pos.m_positionX, pos.m_positionY); } + float GetExactDist2dSq(Position const* pos) const { return GetExactDist2dSq(*pos); } + float GetExactDist2d(const float x, const float y) const { return std::sqrt(GetExactDist2dSq(x, y)); } + float GetExactDist2d(Position const& pos) const { return GetExactDist2d(pos.m_positionX, pos.m_positionY); } + float GetExactDist2d(Position const* pos) const { return GetExactDist2d(*pos); } + + float GetExactDistSq(float x, float y, float z) const + { + float dz = z - m_positionZ; + return GetExactDist2dSq(x, y) + dz*dz; + } + + float GetExactDistSq(Position const& pos) const { return GetExactDistSq(pos.m_positionX, pos.m_positionY, pos.m_positionZ); } + float GetExactDistSq(Position const* pos) const { return GetExactDistSq(*pos); } + float GetExactDist(float x, float y, float z) const { return std::sqrt(GetExactDistSq(x, y, z)); } + float GetExactDist(Position const& pos) const { return GetExactDist(pos.m_positionX, pos.m_positionY, pos.m_positionZ); } + float GetExactDist(Position const* pos) const { return GetExactDist(*pos); } + void GetPositionOffsetTo(const Position& endPos, Position& retOffset) const; + Position GetPositionWithOffset(Position const& offset) const; float GetAngle(const Position* pos) const; [[nodiscard]] float GetAngle(float x, float y) const; @@ -566,6 +551,81 @@ struct Position return fmod(o, 2.0f * static_cast(M_PI)); } }; + +#define MAPID_INVALID 0xFFFFFFFF + +class WorldLocation : public Position +{ +public: + explicit WorldLocation(uint32 _mapId = MAPID_INVALID, float x = 0.f, float y = 0.f, float z = 0.f, float o = 0.f) + : Position(x, y, z, o), m_mapId(_mapId) { } + + WorldLocation(uint32 mapId, Position const& position) + : Position(position), m_mapId(mapId) { } + + void WorldRelocate(const WorldLocation& loc) + { + m_mapId = loc.GetMapId(); + Relocate(loc); + } + + void WorldRelocate(uint32 mapId = MAPID_INVALID, float x = 0.f, float y = 0.f, float z = 0.f, float o = 0.f) + { + m_mapId = mapId; + Relocate(x, y, z, o); + } + + void SetMapId(uint32 mapId) + { + m_mapId = mapId; + } + + [[nodiscard]] uint32 GetMapId() const + { + return m_mapId; + } + + void GetWorldLocation(uint32& mapId, float& x, float& y) const + { + mapId = m_mapId; + x = m_positionX; + y = m_positionY; + } + + void GetWorldLocation(uint32& mapId, float& x, float& y, float& z) const + { + mapId = m_mapId; + x = m_positionX; + y = m_positionY; + z = m_positionZ; + } + + void GetWorldLocation(uint32& mapId, float& x, float& y, float& z, float& o) const + { + mapId = m_mapId; + x = m_positionX; + y = m_positionY; + z = m_positionZ; + o = m_orientation; + } + + void GetWorldLocation(WorldLocation* location) const + { + if (location) + { + location->Relocate(m_positionX, m_positionY, m_positionZ, m_orientation); + location->SetMapId(m_mapId); + } + } + + [[nodiscard]] WorldLocation GetWorldLocation() const + { + return *this; + } + + uint32 m_mapId; +}; + ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYStreamer const& streamer); ByteBuffer& operator >> (ByteBuffer& buf, Position::PositionXYStreamer const& streamer); ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYZStreamer const& streamer); @@ -643,80 +703,6 @@ struct MovementInfo void OutDebug(); }; -#define MAPID_INVALID 0xFFFFFFFF - -class WorldLocation : public Position -{ -public: - explicit WorldLocation(uint32 _mapId = MAPID_INVALID, float x = 0.f, float y = 0.f, float z = 0.f, float o = 0.f) - : Position(x, y, z, o), m_mapId(_mapId) { } - - WorldLocation(uint32 mapId, Position const& position) - : Position(position), m_mapId(mapId) { } - - void WorldRelocate(const WorldLocation& loc) - { - m_mapId = loc.GetMapId(); - Relocate(loc); - } - - void WorldRelocate(uint32 mapId = MAPID_INVALID, float x = 0.f, float y = 0.f, float z = 0.f, float o = 0.f) - { - m_mapId = mapId; - Relocate(x, y, z, o); - } - - void SetMapId(uint32 mapId) - { - m_mapId = mapId; - } - - [[nodiscard]] uint32 GetMapId() const - { - return m_mapId; - } - - void GetWorldLocation(uint32& mapId, float& x, float& y) const - { - mapId = m_mapId; - x = m_positionX; - y = m_positionY; - } - - void GetWorldLocation(uint32& mapId, float& x, float& y, float& z) const - { - mapId = m_mapId; - x = m_positionX; - y = m_positionY; - z = m_positionZ; - } - - void GetWorldLocation(uint32& mapId, float& x, float& y, float& z, float& o) const - { - mapId = m_mapId; - x = m_positionX; - y = m_positionY; - z = m_positionZ; - o = m_orientation; - } - - void GetWorldLocation(WorldLocation* location) const - { - if (location) - { - location->Relocate(m_positionX, m_positionY, m_positionZ, m_orientation); - location->SetMapId(m_mapId); - } - } - - [[nodiscard]] WorldLocation GetWorldLocation() const - { - return *this; - } - - uint32 m_mapId; -}; - template class GridObject { diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 1b7a661b7..6dd48cb29 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -16960,7 +16960,7 @@ void Unit::Kill(Unit* killer, Unit* victim, bool durabilityLoss, WeaponAttackTyp creature->AI()->JustDied(killer ? killer : victim); if (TempSummon* summon = creature->ToTempSummon()) - if (Unit* summoner = summon->GetSummoner()) + if (Unit* summoner = summon->GetSummonerUnit()) if (summoner->ToCreature() && summoner->IsAIEnabled) summoner->ToCreature()->AI()->SummonedCreatureDies(creature, killer); diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index 0a30ab72c..a76772beb 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -250,7 +250,7 @@ bool SpellClickInfo::IsFitToRequirements(Unit const* clicker, Unit const* clicke Unit const* summoner = nullptr; // Check summoners for party if (clickee->IsSummon()) - summoner = clickee->ToTempSummon()->GetSummoner(); + summoner = clickee->ToTempSummon()->GetSummonerUnit(); if (!summoner) summoner = clickee; diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 3e8709b25..0be7cbe4d 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -453,12 +453,12 @@ int32 AuraEffect::CalculateAmount(Unit* caster) ItemRandomSuffixEntry const* item_rand_suffix = sItemRandomSuffixStore.LookupEntry(abs(castItem->GetItemRandomPropertyId())); if (item_rand_suffix) { - for (int k = 0; k < MAX_ITEM_ENCHANTMENT_EFFECTS; k++) + for (uint8 k = 0; k < MAX_ITEM_ENCHANTMENT_EFFECTS; k++) { SpellItemEnchantmentEntry const* pEnchant = sSpellItemEnchantmentStore.LookupEntry(item_rand_suffix->enchant_id[k]); if (pEnchant) { - for (int t = 0; t < MAX_SPELL_ITEM_ENCHANTMENT_EFFECTS; t++) + for (uint8 t = 0; t < MAX_SPELL_ITEM_ENCHANTMENT_EFFECTS; t++) if (pEnchant->spellid[t] == m_spellInfo->Id) { amount = uint32((item_rand_suffix->prefix[k] * castItem->GetItemSuffixFactor()) / 10000); diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.h b/src/server/game/Spells/Auras/SpellAuraEffects.h index 11e504bd1..be2cfe863 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.h +++ b/src/server/game/Spells/Auras/SpellAuraEffects.h @@ -68,6 +68,7 @@ public: uint32 GetTickNumber() const { return m_tickNumber; } int32 GetTotalTicks() const { return m_amplitude ? (GetBase()->GetMaxDuration() / m_amplitude) : 1;} void ResetPeriodic(bool resetPeriodicTimer = false) { if (resetPeriodicTimer) m_periodicTimer = m_amplitude; m_tickNumber = 0;} + void ResetTicks() { m_tickNumber = 0; } bool IsPeriodic() const { return m_isPeriodic; } void SetPeriodic(bool isPeriodic) { m_isPeriodic = isPeriodic; } diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index 679a0dcbf..193112465 100644 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -847,12 +847,33 @@ void Aura::SetDuration(int32 duration, bool withMods) SetNeedClientUpdateForTargets(); } -void Aura::RefreshDuration() +void Aura::RefreshDuration(bool withMods) { - SetDuration(GetMaxDuration()); + Unit* caster = GetCaster(); + + if (!caster) + return; + + if (withMods && caster) + { + int32 duration = m_spellInfo->GetMaxDuration(); + // Calculate duration of periodics affected by haste. + if (caster->HasAuraTypeWithAffectMask(SPELL_AURA_PERIODIC_HASTE, m_spellInfo) || m_spellInfo->HasAttribute(SPELL_ATTR5_SPELL_HASTE_AFFECTS_PERIODIC)) + duration = int32(duration * caster->GetFloatValue(UNIT_MOD_CAST_SPEED)); + SetMaxDuration(duration); + + SetDuration(duration); + } + else + SetDuration(GetMaxDuration()); if ((m_spellInfo->ManaPerSecond || m_spellInfo->ManaPerSecondPerLevel) && !m_spellInfo->HasAttribute(SPELL_ATTR2_NO_TARGET_PER_SECOND_COST)) m_timeCla = 1 * IN_MILLISECONDS; + + // also reset periodic counters + for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) + if (AuraEffect* aurEff = m_effects[i]) + aurEff->ResetTicks(); } void Aura::RefreshTimers(bool periodicReset /*= false*/) @@ -860,27 +881,13 @@ void Aura::RefreshTimers(bool periodicReset /*= false*/) m_maxDuration = CalcMaxDuration(); RefreshDuration(); Unit* caster = GetCaster(); - for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) - if (HasEffect(i)) - { - GetEffect(i)->CalculatePeriodic(caster, periodicReset, false); - GetEffect(i)->CalculatePeriodicData(); - } -} -// xinef: dot's rolling function -void Aura::RefreshTimersWithMods() -{ - Unit* caster = GetCaster(); - m_maxDuration = CalcMaxDuration(); - if ((caster && caster->HasAuraTypeWithAffectMask(SPELL_AURA_PERIODIC_HASTE, m_spellInfo)) || m_spellInfo->HasAttribute(SPELL_ATTR5_SPELL_HASTE_AFFECTS_PERIODIC)) - m_maxDuration = int32(m_maxDuration * caster->GetFloatValue(UNIT_MOD_CAST_SPEED)); + if (!caster) + return; - // xinef: we should take ModSpellDuration into account, but none of the spells using this function is affected by contents of ModSpellDuration - RefreshDuration(); for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) - if (HasEffect(i)) - GetEffect(i)->CalculatePeriodic(caster, false, false); + if (AuraEffect* aurEff = m_effects[i]) + aurEff->CalculatePeriodic(caster, periodicReset, false); } void Aura::SetCharges(uint8 charges) @@ -931,6 +938,9 @@ void Aura::SetStackAmount(uint8 stackAmount) m_stackAmount = stackAmount; Unit* caster = GetCaster(); + if (!caster) + return; + std::list applications; GetApplicationList(applications); diff --git a/src/server/game/Spells/Auras/SpellAuras.h b/src/server/game/Spells/Auras/SpellAuras.h index 7ff14716f..853ca8e27 100644 --- a/src/server/game/Spells/Auras/SpellAuras.h +++ b/src/server/game/Spells/Auras/SpellAuras.h @@ -121,9 +121,8 @@ public: int32 CalcMaxDuration(Unit* caster) const; int32 GetDuration() const { return m_duration; } void SetDuration(int32 duration, bool withMods = false); - void RefreshDuration(); + void RefreshDuration(bool withMods = false); void RefreshTimers(bool periodicReset = false); - void RefreshTimersWithMods(); bool IsExpired() const { return !GetDuration();} bool IsPermanent() const { return GetMaxDuration() == -1; } diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 4a7cbc2cd..7d1420398 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -506,6 +506,20 @@ void SpellCastTargets::Update(Unit* caster) } } +class SpellEvent : public BasicEvent +{ + public: + SpellEvent(Spell* spell); + ~SpellEvent(); + + bool Execute(uint64 e_time, uint32 p_time); + void Abort(uint64 e_time); + bool IsDeletable() const; + + protected: + Spell* m_Spell; +}; + void SpellCastTargets::OutDebug() const { if (!m_targetMask) @@ -543,7 +557,7 @@ SpellValue::SpellValue(SpellInfo const* proto) Spell::Spell(Unit* caster, SpellInfo const* info, TriggerCastFlags triggerFlags, ObjectGuid originalCasterGUID, bool skipCheck) : m_spellInfo(sSpellMgr->GetSpellForDifficultyFromSpell(info, caster)), m_caster((info->HasAttribute(SPELL_ATTR6_ORIGINATE_FROM_CONTROLLER) && caster->GetCharmerOrOwner()) ? caster->GetCharmerOrOwner() : caster) - , m_spellValue(new SpellValue(m_spellInfo)) + , m_spellValue(new SpellValue(m_spellInfo)), _spellEvent(nullptr) { m_customError = SPELL_CUSTOM_ERROR_NONE; m_skipCheck = skipCheck; @@ -825,8 +839,16 @@ void Spell::SelectSpellTargets() if (m_spellInfo->IsChanneled()) { + // maybe do this for all spells? + if (!focusObject && m_UniqueTargetInfo.empty() && m_UniqueGOTargetInfo.empty() && m_UniqueItemInfo.empty() && !m_targets.HasDst()) + { + SendCastResult(SPELL_FAILED_BAD_IMPLICIT_TARGETS); + finish(false); + return; + } + uint8 mask = (1 << i); - for (std::list::iterator ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) + for (auto ihit = m_UniqueTargetInfo.begin(); ihit != m_UniqueTargetInfo.end(); ++ihit) { if (ihit->effectMask & mask) { @@ -838,22 +860,18 @@ void Spell::SelectSpellTargets() else if (m_auraScaleMask) { bool checkLvl = !m_UniqueTargetInfo.empty(); - for (std::list::iterator itr = m_UniqueTargetInfo.begin(); itr != m_UniqueTargetInfo.end(); ++itr) + m_UniqueTargetInfo.erase(std::remove_if(std::begin(m_UniqueTargetInfo), std::end(m_UniqueTargetInfo), [&](TargetInfo const& targetInfo) -> bool { // remove targets which did not pass min level check - if (m_auraScaleMask && itr->effectMask == m_auraScaleMask) + if (m_auraScaleMask && targetInfo.effectMask == m_auraScaleMask) { - bool needErase = false; - - if (!itr->scaleAura && itr->targetGUID != m_caster->GetGUID()) - needErase = true; - - sScriptMgr->OnRemoveAuraScaleTargets(this, *itr, m_auraScaleMask, needErase); - - if (needErase) - m_UniqueTargetInfo.erase(itr); + if (!targetInfo.scaleAura && targetInfo.targetGUID != m_caster->GetGUID()) + return true; } - } + + return false; + }), std::end(m_UniqueTargetInfo)); + if (checkLvl && m_UniqueTargetInfo.empty()) { SendCastResult(SPELL_FAILED_LOWLEVEL); @@ -862,20 +880,35 @@ void Spell::SelectSpellTargets() } } + if (uint64 dstDelay = CalculateDelayMomentForDst()) + m_delayMoment = dstDelay; +} + +uint64 Spell::CalculateDelayMomentForDst() const +{ if (m_targets.HasDst()) { if (m_targets.HasTraj()) { float speed = m_targets.GetSpeedXY(); if (speed > 0.0f) - m_delayTrajectory = (uint64)floor(m_targets.GetDist2d() / speed * 1000.0f); + return (uint64)floor(m_targets.GetDist2d() / speed * 1000.0f); } else if (m_spellInfo->Speed > 0.0f) { - float dist = m_caster->GetExactDist(m_targets.GetDstPos()); - m_delayTrajectory = (uint64) floor(dist / m_spellInfo->Speed * 1000.0f); + // We should not subtract caster size from dist calculation (fixes execution time desync with animation on client, eg. Malleable Goo cast by PP) + float dist = m_caster->GetExactDist(*m_targets.GetDstPos()); + return (uint64)std::floor(dist / m_spellInfo->Speed * 1000.0f); } } + + return 0; +} + +void Spell::RecalculateDelayMomentForDst() +{ + m_delayMoment = CalculateDelayMomentForDst(); + m_caster->m_Events.ModifyEventTime(_spellEvent, Milliseconds(GetDelayStart() + m_delayMoment)); } void Spell::SelectEffectImplicitTargets(SpellEffIndex effIndex, SpellImplicitTargetInfo const& targetType, uint32& processedEffectMask) @@ -898,11 +931,12 @@ void Spell::SelectEffectImplicitTargets(SpellEffIndex effIndex, SpellImplicitTar for (uint32 j = effIndex + 1; j < MAX_SPELL_EFFECTS; ++j) { SpellEffectInfo const* effects = GetSpellInfo()->Effects; - if (effects[effIndex].TargetA.GetTarget() == effects[j].TargetA.GetTarget() && - effects[effIndex].TargetB.GetTarget() == effects[j].TargetB.GetTarget() && - effects[effIndex].ImplicitTargetConditions == effects[j].ImplicitTargetConditions && - effects[effIndex].CalcRadius(m_caster) == effects[j].CalcRadius(m_caster) && - CheckScriptEffectImplicitTargets(effIndex, j)) + if (effects[j].IsEffect() && + effects[effIndex].TargetA.GetTarget() == effects[j].TargetA.GetTarget() && + effects[effIndex].TargetB.GetTarget() == effects[j].TargetB.GetTarget() && + effects[effIndex].ImplicitTargetConditions == effects[j].ImplicitTargetConditions && + effects[effIndex].CalcRadius(m_caster) == effects[j].CalcRadius(m_caster) && + CheckScriptEffectImplicitTargets(effIndex, j)) { effectMask |= 1 << j; } @@ -928,9 +962,8 @@ void Spell::SelectEffectImplicitTargets(SpellEffIndex effIndex, SpellImplicitTar SelectImplicitAreaTargets(effIndex, targetType, effectMask); break; case TARGET_SELECT_CATEGORY_TRAJ: - // xinef: just in case there is no dest, explanation in SelectImplicitDestDestTargets - if (!m_targets.HasDst()) - m_targets.SetDst(*m_caster); + // just in case there is no dest, explanation in SelectImplicitDestDestTargets + CheckDst(); SelectImplicitTrajTargets(effIndex, targetType); break; @@ -1513,7 +1546,7 @@ void Spell::SelectImplicitCasterObjectTargets(SpellEffIndex effIndex, SpellImpli break; case TARGET_UNIT_SUMMONER: if (m_caster->IsSummon()) - target = m_caster->ToTempSummon()->GetSummoner(); + target = m_caster->ToTempSummon()->GetSummonerUnit(); break; case TARGET_UNIT_VEHICLE: target = m_caster->GetVehicleBase(); @@ -3208,8 +3241,8 @@ SpellCastResult Spell::prepare(SpellCastTargets const* targets, AuraEffect const } // create and add update event for this spell - SpellEvent* Event = new SpellEvent(this); - m_caster->m_Events.AddEvent(Event, m_caster->m_Events.CalculateTime(1)); + _spellEvent = new SpellEvent(this); + m_caster->m_Events.AddEvent(_spellEvent, m_caster->m_Events.CalculateTime(1)); if (DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, m_spellInfo->Id, m_caster)) { diff --git a/src/server/game/Spells/Spell.h b/src/server/game/Spells/Spell.h index 355068743..8d9ff7a88 100644 --- a/src/server/game/Spells/Spell.h +++ b/src/server/game/Spells/Spell.h @@ -20,7 +20,9 @@ class DynamicObject; class WorldObject; class Aura; class SpellScript; +class SpellEvent; class ByteBuffer; +class BasicEvent; #define SPELL_CHANNEL_UPDATE_INTERVAL (1 * IN_MILLISECONDS) @@ -521,6 +523,8 @@ public: uint64 GetDelayMoment() const { return m_delayMoment; } uint64 GetDelayTrajectory() const { return m_delayTrajectory; } + uint64 CalculateDelayMomentForDst() const; + void RecalculateDelayMomentForDst(); bool IsNeedSendToClient(bool go) const; CurrentSpellTypes GetCurrentContainer() const; @@ -710,6 +714,7 @@ protected: uint32 m_spellState; int32 m_timer; + SpellEvent* _spellEvent; TriggerCastFlags _triggeredCastFlags; // if need this can be replaced by Aura copy @@ -788,29 +793,16 @@ namespace Acore typedef void(Spell::*pEffect)(SpellEffIndex effIndex); -class SpellEvent : public BasicEvent -{ -public: - SpellEvent(Spell* spell); - ~SpellEvent() override; - - bool Execute(uint64 e_time, uint32 p_time) override; - void Abort(uint64 e_time) override; - bool IsDeletable() const override; -protected: - Spell* m_Spell; -}; - class ReflectEvent : public BasicEvent { -public: - ReflectEvent(Unit* caster, ObjectGuid targetGUID, const SpellInfo* spellInfo) : _caster(caster), _targetGUID(targetGUID), _spellInfo(spellInfo) { } - bool Execute(uint64 e_time, uint32 p_time) override; + public: + ReflectEvent(Unit* caster, ObjectGuid targetGUID, const SpellInfo* spellInfo) : _caster(caster), _targetGUID(targetGUID), _spellInfo(spellInfo) { } + bool Execute(uint64 e_time, uint32 p_time) override; -protected: - Unit* _caster; - ObjectGuid _targetGUID; - const SpellInfo* _spellInfo; + protected: + Unit* _caster; + ObjectGuid _targetGUID; + const SpellInfo* _spellInfo; }; #endif diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index 49af948b9..df410649c 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -840,8 +840,9 @@ SpellInfo::SpellInfo(SpellEntry const* spellEntry) SchoolMask = spellEntry->SchoolMask; for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) Effects[i] = SpellEffectInfo(spellEntry, this, i); - ExplicitTargetMask = _GetExplicitTargetMask(); + ChainEntry = nullptr; + ExplicitTargetMask = 0; // Mine _isStackableWithRanks = false; @@ -2537,7 +2538,7 @@ bool SpellInfo::IsHighRankOf(SpellInfo const* spellInfo) const return false; } -uint32 SpellInfo::_GetExplicitTargetMask() const +void SpellInfo::_InitializeExplicitTargetMask() { bool srcSet = false; bool dstSet = false; @@ -2562,7 +2563,7 @@ uint32 SpellInfo::_GetExplicitTargetMask() const effectTargetMask &= ~(TARGET_FLAG_UNIT_MASK | TARGET_FLAG_GAMEOBJECT | TARGET_FLAG_CORPSE_MASK | TARGET_FLAG_DEST_LOCATION); targetMask |= effectTargetMask; } - return targetMask; + ExplicitTargetMask = targetMask; } bool SpellInfo::_IsPositiveEffect(uint8 effIndex, bool deep) const diff --git a/src/server/game/Spells/SpellInfo.h b/src/server/game/Spells/SpellInfo.h index 7557bc022..35a220333 100644 --- a/src/server/game/Spells/SpellInfo.h +++ b/src/server/game/Spells/SpellInfo.h @@ -503,7 +503,7 @@ public: bool IsHighRankOf(SpellInfo const* spellInfo) const; // loading helpers - uint32 _GetExplicitTargetMask() const; + void _InitializeExplicitTargetMask(); bool _IsPositiveEffect(uint8 effIndex, bool deep) const; bool _IsPositiveSpell() const; static bool _IsPositiveTarget(uint32 targetA, uint32 targetB); diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 1c19e704f..0a86a76e2 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -2665,10 +2665,8 @@ void SpellMgr::LoadSpellInfoStore() void SpellMgr::UnloadSpellInfoStore() { for (uint32 i = 0; i < mSpellInfoMap.size(); ++i) - { - if (mSpellInfoMap[i]) - delete mSpellInfoMap[i]; - } + delete mSpellInfoMap[i]; + mSpellInfoMap.clear(); } @@ -3282,6 +3280,7 @@ void SpellMgr::LoadSpellCustomAttr() spellInfo->Effects[EFFECT_0].MiscValue = 127; break; } + spellInfo->_InitializeExplicitTargetMask(); } // Xinef: addition for binary spells, ommit spells triggering other spells diff --git a/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp b/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp index 2baef74ac..05c191376 100644 --- a/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp +++ b/src/server/scripts/EasternKingdoms/Karazhan/boss_midnight.cpp @@ -252,7 +252,7 @@ public: if (type == POINT_MOTION_TYPE && point == POINT_MOVE_TO_MIDNIGHT) { if (TempSummon* summon = me->ToTempSummon()) - if (Unit* midnight = summon->GetSummoner()) + if (Unit* midnight = summon->GetSummonerUnit()) midnight->GetAI()->SetData(DATA_ATTUMEN_READY, 0); } } @@ -356,7 +356,7 @@ public: if (type == POINT_MOTION_TYPE && point == POINT_MOVE_TO_MIDNIGHT) { if (TempSummon* summon = me->ToTempSummon()) - if (Unit* midnight = summon->GetSummoner()) + if (Unit* midnight = summon->GetSummonerUnit()) midnight->GetAI()->SetData(DATA_ATTUMEN_READY, 0); } } diff --git a/src/server/scripts/EasternKingdoms/ScarletEnclave/zone_the_scarlet_enclave.cpp b/src/server/scripts/EasternKingdoms/ScarletEnclave/zone_the_scarlet_enclave.cpp index ee0efcd38..214c0865a 100644 --- a/src/server/scripts/EasternKingdoms/ScarletEnclave/zone_the_scarlet_enclave.cpp +++ b/src/server/scripts/EasternKingdoms/ScarletEnclave/zone_the_scarlet_enclave.cpp @@ -65,7 +65,7 @@ public: Player* player = nullptr; if (me->IsSummon()) { - if (Unit * summoner = me->ToTempSummon()->GetSummoner()) + if (Unit * summoner = me->ToTempSummon()->GetSummonerUnit()) { player = summoner->ToPlayer(); } diff --git a/src/server/scripts/EasternKingdoms/zone_eastern_plaguelands.cpp b/src/server/scripts/EasternKingdoms/zone_eastern_plaguelands.cpp index 34979a0a1..fdfd06d01 100644 --- a/src/server/scripts/EasternKingdoms/zone_eastern_plaguelands.cpp +++ b/src/server/scripts/EasternKingdoms/zone_eastern_plaguelands.cpp @@ -265,7 +265,7 @@ public: return; if (TempSummon* summon = me->ToTempSummon()) - if (Unit* creature = summon->GetSummoner()) + if (Unit* creature = summon->GetSummonerUnit()) creature->GetAI()->DoAction(1); me->DespawnOrUnsummon(1); @@ -274,7 +274,7 @@ public: void JustDied(Unit*) override { if (TempSummon* summon = me->ToTempSummon()) - if (Unit* creature = summon->GetSummoner()) + if (Unit* creature = summon->GetSummonerUnit()) creature->GetAI()->DoAction(2); } diff --git a/src/server/scripts/EasternKingdoms/zone_stormwind_city.cpp b/src/server/scripts/EasternKingdoms/zone_stormwind_city.cpp index a1a04a1d6..9aad91390 100644 --- a/src/server/scripts/EasternKingdoms/zone_stormwind_city.cpp +++ b/src/server/scripts/EasternKingdoms/zone_stormwind_city.cpp @@ -299,7 +299,7 @@ public: if (me->IsSummon()) { - if (Unit* summoner = me->ToTempSummon()->GetSummoner()) + if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit()) { if (summoner->GetTypeId() == TYPEID_UNIT && summoner->IsAlive() && !summoner->IsInCombat()) summoner->ToCreature()->AI()->AttackStart(who); @@ -313,7 +313,7 @@ public: if (me->IsSummon()) { - if (Unit* summoner = me->ToTempSummon()->GetSummoner()) + if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit()) { if (summoner->GetTypeId() == TYPEID_UNIT && summoner->IsAlive()) summoner->ToCreature()->DisappearAndDie(); @@ -328,7 +328,7 @@ public: if (me->IsSummon()) { - Unit* summoner = me->ToTempSummon()->GetSummoner(); + Unit* summoner = me->ToTempSummon()->GetSummonerUnit(); if (summoner && summoner->GetTypeId() == TYPEID_UNIT && summoner->IsAIEnabled) { npc_lord_gregor_lescovar::npc_lord_gregor_lescovarAI* ai = diff --git a/src/server/scripts/Events/brewfest.cpp b/src/server/scripts/Events/brewfest.cpp index 6816d9f80..92657423b 100644 --- a/src/server/scripts/Events/brewfest.cpp +++ b/src/server/scripts/Events/brewfest.cpp @@ -281,7 +281,7 @@ public: Creature* GetSummoner() { if (me->IsSummon()) - if (Unit* coren = me->ToTempSummon()->GetSummoner()) + if (Unit* coren = me->ToTempSummon()->GetSummonerUnit()) return coren->ToCreature(); return nullptr; diff --git a/src/server/scripts/Events/hallows_end.cpp b/src/server/scripts/Events/hallows_end.cpp index 06a0a3181..63114155c 100644 --- a/src/server/scripts/Events/hallows_end.cpp +++ b/src/server/scripts/Events/hallows_end.cpp @@ -1274,7 +1274,7 @@ public: Unit* GetOwner() { if (me->ToTempSummon()) - return me->ToTempSummon()->GetSummoner(); + return me->ToTempSummon()->GetSummonerUnit(); return nullptr; } diff --git a/src/server/scripts/Events/love_in_air.cpp b/src/server/scripts/Events/love_in_air.cpp index f67f832bc..7f3e3c49a 100644 --- a/src/server/scripts/Events/love_in_air.cpp +++ b/src/server/scripts/Events/love_in_air.cpp @@ -261,7 +261,7 @@ public: if (Talk(actionCounter)) { if (me->ToTempSummon()) - if (Unit* owner = me->ToTempSummon()->GetSummoner()) + if (Unit* owner = me->ToTempSummon()->GetSummonerUnit()) me->CastSpell(owner, SPELL_SNIVEL_GUN, true); me->DespawnOrUnsummon(1000); diff --git a/src/server/scripts/Events/pilgrims_bounty.cpp b/src/server/scripts/Events/pilgrims_bounty.cpp index 4a6fe43bd..5c9a58bb4 100644 --- a/src/server/scripts/Events/pilgrims_bounty.cpp +++ b/src/server/scripts/Events/pilgrims_bounty.cpp @@ -296,7 +296,7 @@ public: case SPELL_VISUAL_THROW_CRANBERRY: case SPELL_VISUAL_THROW_SWEET_POTATO: if (TempSummon* ts = me->ToTempSummon()) - if (Unit* owner = ts->GetSummoner()) + if (Unit* owner = ts->GetSummonerUnit()) owner->ToCreature()->AI()->DoAction(spellInfo->Id); break; } @@ -376,7 +376,7 @@ public: else { if (TempSummon* ts = target->ToTempSummon()) - if (Unit* owner = ts->GetSummoner()) + if (Unit* owner = ts->GetSummonerUnit()) if (owner->GetEntry() == GetCaster()->GetEntry()) return; diff --git a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp index 07f11914e..a3eb5c163 100644 --- a/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp +++ b/src/server/scripts/Kalimdor/TempleOfAhnQiraj/boss_cthun.cpp @@ -1286,7 +1286,7 @@ public: void JustDied(Unit* /*killer*/) override { if (TempSummon* summon = me->ToTempSummon()) - if (Unit* summoner = summon->GetSummoner()) + if (Unit* summoner = summon->GetSummonerUnit()) if (summoner->IsAIEnabled) summoner->GetAI()->DoAction(ACTION_FLESH_TENTACLE_KILLED); } diff --git a/src/server/scripts/Kalimdor/zone_durotar.cpp b/src/server/scripts/Kalimdor/zone_durotar.cpp index da5c729bc..0ffadfc2d 100644 --- a/src/server/scripts/Kalimdor/zone_durotar.cpp +++ b/src/server/scripts/Kalimdor/zone_durotar.cpp @@ -106,7 +106,7 @@ public: if (!(*itr)->IsSummon()) continue; - if (Unit* summoner = (*itr)->ToTempSummon()->GetSummoner()) + if (Unit* summoner = (*itr)->ToTempSummon()->GetSummonerUnit()) if (!summoner->HasAura(SPELL_NO_SUMMON_AURA) && !summoner->HasAura(SPELL_SUMMON_ZENTABRA_TRIGGER) && !summoner->IsInCombat()) { @@ -168,7 +168,7 @@ public: if (victim->GetTypeId() != TYPEID_UNIT || !victim->IsSummon()) return; - if (Unit* vehSummoner = victim->ToTempSummon()->GetSummoner()) + if (Unit* vehSummoner = victim->ToTempSummon()->GetSummonerUnit()) { vehSummoner->RemoveAurasDueToSpell(SPELL_NO_SUMMON_AURA); vehSummoner->RemoveAurasDueToSpell(SPELL_DETECT_INVIS); @@ -187,7 +187,7 @@ public: { damage = 0; me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); - if (Unit* vehSummoner = attacker->ToTempSummon()->GetSummoner()) + if (Unit* vehSummoner = attacker->ToTempSummon()->GetSummonerUnit()) { vehSummoner->AddAura(SPELL_SUMMON_ZENTABRA_TRIGGER, vehSummoner); vehSummoner->CastSpell(vehSummoner, SPELL_SUMMON_ZENTABRA, true); @@ -224,7 +224,7 @@ public: if (Unit* tiger = ObjectAccessor::GetUnit(*me, _tigerGuid)) { if (tiger->IsSummon()) - if (Unit* vehSummoner = tiger->ToTempSummon()->GetSummoner()) + if (Unit* vehSummoner = tiger->ToTempSummon()->GetSummonerUnit()) me->AddAura(SPELL_NO_SUMMON_AURA, vehSummoner); } _events.ScheduleEvent(EVENT_NOSUMMON, 50000); diff --git a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_hadronox.cpp b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_hadronox.cpp index cf7e24c2a..e36bf9af7 100644 --- a/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_hadronox.cpp +++ b/src/server/scripts/Northrend/AzjolNerub/AzjolNerub/boss_hadronox.cpp @@ -216,7 +216,7 @@ public: events.Reset(); if (me->ToTempSummon()) - if (Unit* summoner = me->ToTempSummon()->GetSummoner()) + if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit()) if (summoner->GetEntry() == me->GetEntry()) { me->CastSpell(me, RAND(SPELL_SUMMON_ANUBAR_CHAMPION, SPELL_SUMMON_ANUBAR_CRYPT_FIEND, SPELL_SUMMON_ANUBAR_NECROMANCER), true); @@ -246,7 +246,7 @@ public: void EnterCombat(Unit*) override { if (me->ToTempSummon()) - if (Unit* summoner = me->ToTempSummon()->GetSummoner()) + if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit()) if (summoner->GetEntry() != me->GetEntry()) { summoner->GetAI()->DoAction(ACTION_START_EVENT); diff --git a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp index f39caaf01..0b430add7 100644 --- a/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp +++ b/src/server/scripts/Northrend/ChamberOfAspects/RubySanctum/boss_halion.cpp @@ -237,7 +237,7 @@ public: summon->CastSpell(summon, SPELL_METEOR_STRIKE_FIRE_AURA_2, true); if (summons.GetEntryCount(NPC_METEOR_STRIKE_FLAME) <= 16) summon->CastSpell(summon, SPELL_METEOR_STRIKE_SPREAD, true); - if (Unit* summoner = summon->ToTempSummon()->GetSummoner()) + if (Unit* summoner = summon->ToTempSummon()->GetSummonerUnit()) summon->SetOrientation(summoner->GetAngle(summon)); break; } diff --git a/src/server/scripts/Northrend/Gundrak/boss_drakkari_colossus.cpp b/src/server/scripts/Northrend/Gundrak/boss_drakkari_colossus.cpp index ad4ccce58..96dd2468d 100644 --- a/src/server/scripts/Northrend/Gundrak/boss_drakkari_colossus.cpp +++ b/src/server/scripts/Northrend/Gundrak/boss_drakkari_colossus.cpp @@ -344,7 +344,7 @@ public: if (me->ToTempSummon()) { if (who->GetTypeId() == TYPEID_PLAYER || who->GetOwnerGUID().IsPlayer()) - if (Unit* summoner = me->ToTempSummon()->GetSummoner()) + if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit()) summoner->GetAI()->DoAction(ACTION_INFORM); return; } diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp index fbcbf6f82..7600537e2 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_lord_marrowgar.cpp @@ -378,7 +378,7 @@ public: return; if (TempSummon* summ = me->ToTempSummon()) - if (Unit* trapped = summ->GetSummoner()) + if (Unit* trapped = summ->GetSummonerUnit()) { Position exitPos = {me->GetPositionX(), me->GetPositionY(), 60.0f, me->GetOrientation()}; trapped->UpdateAllowedPositionZ(exitPos.GetPositionX(), exitPos.GetPositionY(), exitPos.m_positionZ); @@ -430,7 +430,7 @@ public: if (TempSummon* summ = me->ToTempSummon()) { - if (Unit* trapped = summ->GetSummoner()) + if (Unit* trapped = summ->GetSummonerUnit()) { if (!trapped->IsOnVehicle(me) || !trapped->IsAlive() || !me->GetInstanceScript() || me->GetInstanceScript()->GetBossState(DATA_LORD_MARROWGAR) != IN_PROGRESS || trapped->HasAuraType(SPELL_AURA_SPIRIT_OF_REDEMPTION)) { diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp index e5f48d793..3149b2055 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_rotface.cpp @@ -373,7 +373,7 @@ public: DoResetThreat(); me->SetInCombatWithZone(); if (TempSummon* ts = me->ToTempSummon()) - if (Unit* summoner = ts->GetSummoner()) + if (Unit* summoner = ts->GetSummonerUnit()) { me->AddThreat(summoner, 500000.0f); AttackStart(summoner); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp index dca5d86c3..76a669fac 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_the_lich_king.cpp @@ -2312,7 +2312,7 @@ public: bool valid = false; me->CastSpell(me, SPELL_RAGING_SPIRIT_VISUAL, true); if (TempSummon* summon = me->ToTempSummon()) - if (Unit* summoner = summon->GetSummoner()) + if (Unit* summoner = summon->GetSummonerUnit()) if (summoner->GetTypeId() == TYPEID_PLAYER && summoner->IsAlive() && !summoner->ToPlayer()->IsBeingTeleported() && summoner->FindMap() == me->GetMap()) { valid = true; @@ -2373,7 +2373,7 @@ public: { bool valid = false; if (TempSummon* summon = me->ToTempSummon()) - if (Unit* summoner = summon->GetSummoner()) + if (Unit* summoner = summon->GetSummonerUnit()) if (summoner->GetTypeId() == TYPEID_PLAYER && summoner->IsAlive() && !summoner->ToPlayer()->IsBeingTeleported() && summoner->FindMap() == me->GetMap()) { valid = true; @@ -3038,7 +3038,7 @@ public: return; if (TempSummon* summon = GetCaster()->ToTempSummon()) - if (Unit* summoner = summon->GetSummoner()) + if (Unit* summoner = summon->GetSummonerUnit()) summoner->GetAI()->SetData(DATA_VILE, 1); if (Creature* c = GetCaster()->ToCreature()) @@ -3154,7 +3154,7 @@ public: if (TempSummon* summ = me->ToTempSummon()) { - if (Unit* summoner = summ->GetSummoner()) + if (Unit* summoner = summ->GetSummonerUnit()) { bool buff = _instance->GetBossState(DATA_THE_LICH_KING) == IN_PROGRESS && summoner->GetTypeId() == TYPEID_PLAYER && (!summoner->IsAlive() || summoner->ToPlayer()->IsBeingTeleported() || summoner->FindMap() != me->GetMap()); if (summoner->GetTypeId() == TYPEID_PLAYER && !summoner->ToPlayer()->IsBeingTeleported() && summoner->FindMap() == me->GetMap()) @@ -3191,7 +3191,7 @@ public: me->GetMotionMaster()->Clear(false); me->GetMotionMaster()->MoveIdle(); if (TempSummon* summ = me->ToTempSummon()) - if (Unit* summoner = summ->GetSummoner()) + if (Unit* summoner = summ->GetSummonerUnit()) { if (summoner->IsAlive() && summoner->GetTypeId() == TYPEID_PLAYER) { diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp index 867f9ea3b..feae11a32 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_hodir.cpp @@ -663,7 +663,7 @@ public: timer = 2500; if (me->IsSummon()) { - if (Unit* s = me->ToTempSummon()->GetSummoner()) + if (Unit* s = me->ToTempSummon()->GetSummonerUnit()) { if ((s->GetTypeId() == TYPEID_PLAYER && !s->HasAura(SPELL_FLASH_FREEZE_TRAPPED_PLAYER)) || (s->GetTypeId() == TYPEID_UNIT && !s->HasAura(SPELL_FLASH_FREEZE_TRAPPED_NPC))) me->DespawnOrUnsummon(2000); diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp index 16e74c09d..6a5fa537c 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_mimiron.cpp @@ -2405,7 +2405,7 @@ public: case SPELL_WATER_SPRAY: { if (me->IsSummon()) - if (Unit* summoner = me->ToTempSummon()->GetSummoner()) + if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit()) if (Creature* c = summoner->ToCreature()) if (c->AI()) CAST_AI(npc_ulduar_flames_initial::npc_ulduar_flames_initialAI, c->AI())->RemoveFlame(me->GetGUID()); diff --git a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yoggsaron.cpp b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yoggsaron.cpp index a2d6f230b..5a6ec6c99 100644 --- a/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yoggsaron.cpp +++ b/src/server/scripts/Northrend/Ulduar/Ulduar/boss_yoggsaron.cpp @@ -1769,7 +1769,7 @@ public: void JustDied(Unit*) override { if (me->IsSummon()) - if (Unit* sara = me->ToTempSummon()->GetSummoner()) + if (Unit* sara = me->ToTempSummon()->GetSummonerUnit()) sara->GetAI()->DoAction(ACTION_INFLUENCE_TENTACLE_DIED); } }; diff --git a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp index 4ed2d4915..d8b176f87 100644 --- a/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp +++ b/src/server/scripts/Northrend/UtgardeKeep/UtgardeKeep/boss_keleseth.cpp @@ -58,7 +58,7 @@ public: npc_frost_tombAI(Creature* c) : NullCreatureAI(c) { if (TempSummon* t = c->ToTempSummon()) - if (Unit* s = t->GetSummoner()) + if (Unit* s = t->GetSummonerUnit()) { PrisonerGUID = s->GetGUID(); if( me->GetInstanceScript() && me->GetInstanceScript()->instance->IsHeroic() ) diff --git a/src/server/scripts/Northrend/VioletHold/boss_zuramat.cpp b/src/server/scripts/Northrend/VioletHold/boss_zuramat.cpp index 4807c6899..91e5ed568 100644 --- a/src/server/scripts/Northrend/VioletHold/boss_zuramat.cpp +++ b/src/server/scripts/Northrend/VioletHold/boss_zuramat.cpp @@ -229,7 +229,7 @@ public: checkTimer = 5000; bool good = false; if (me->IsSummon()) - if (Unit* s = me->ToTempSummon()->GetSummoner()) + if (Unit* s = me->ToTempSummon()->GetSummonerUnit()) if (s->IsAlive()) good = true; if (!good) diff --git a/src/server/scripts/Northrend/zone_dragonblight.cpp b/src/server/scripts/Northrend/zone_dragonblight.cpp index ab119654f..1114a6a96 100644 --- a/src/server/scripts/Northrend/zone_dragonblight.cpp +++ b/src/server/scripts/Northrend/zone_dragonblight.cpp @@ -310,7 +310,7 @@ public: void InitializeAI() override { if (me->ToTempSummon()) - if (Unit* summoner = me->ToTempSummon()->GetSummoner()) + if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit()) { summonerGUID = summoner->GetGUID(); float x, y, z; @@ -478,8 +478,8 @@ public: void Reset() override { - if (me->ToTempSummon() && me->ToTempSummon()->GetSummoner()) - me->setFaction(me->ToTempSummon()->GetSummoner()->getFaction()); + if (me->ToTempSummon() && me->ToTempSummon()->GetSummonerUnit()) + me->setFaction(me->ToTempSummon()->GetSummonerUnit()->getFaction()); } void MoveInLineOfSight(Unit* who) override @@ -568,7 +568,7 @@ public: me->RemoveAllAuras(); me->DespawnOrUnsummon(1000); if (TempSummon* summon = me->ToTempSummon()) - if (Unit* owner = summon->GetSummoner()) + if (Unit* owner = summon->GetSummonerUnit()) if (Player* player = owner->ToPlayer()) player->KilledMonsterCredit(me->GetEntry()); } diff --git a/src/server/scripts/Northrend/zone_howling_fjord.cpp b/src/server/scripts/Northrend/zone_howling_fjord.cpp index 70b16cb35..4dc314d1e 100644 --- a/src/server/scripts/Northrend/zone_howling_fjord.cpp +++ b/src/server/scripts/Northrend/zone_howling_fjord.cpp @@ -36,7 +36,7 @@ public: { me->SetDisableGravity(true); if (me->IsSummon()) - if (Unit* owner = me->ToTempSummon()->GetSummoner()) + if (Unit* owner = me->ToTempSummon()->GetSummonerUnit()) me->GetMotionMaster()->MovePoint(0, *owner); } @@ -49,7 +49,7 @@ public: cow->CastSpell(cow, 44460, true); cow->DespawnOrUnsummon(10000); if (me->IsSummon()) - if (Unit* owner = me->ToTempSummon()->GetSummoner()) + if (Unit* owner = me->ToTempSummon()->GetSummonerUnit()) owner->CastSpell(owner, 44463, true); } } @@ -101,7 +101,7 @@ public: void setphase(short newPhase) { - Unit* summoner = me->ToTempSummon() ? me->ToTempSummon()->GetSummoner() : nullptr; + Unit* summoner = me->ToTempSummon() ? me->ToTempSummon()->GetSummonerUnit() : nullptr; if (!summoner || summoner->GetTypeId() != TYPEID_PLAYER) return; @@ -271,7 +271,7 @@ public: { ObjectGuid summonerGUID; if (me->IsSummon()) - if (Unit* summoner = me->ToTempSummon()->GetSummoner()) + if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit()) if (summoner->GetTypeId() == TYPEID_PLAYER) summonerGUID = summoner->GetGUID(); diff --git a/src/server/scripts/Northrend/zone_icecrown.cpp b/src/server/scripts/Northrend/zone_icecrown.cpp index 8ba91bf12..0bc5f1b0b 100644 --- a/src/server/scripts/Northrend/zone_icecrown.cpp +++ b/src/server/scripts/Northrend/zone_icecrown.cpp @@ -1258,7 +1258,7 @@ public: Unit* GetSummoner() { if (TempSummon* tempSummon = me->ToTempSummon()) - return tempSummon->GetSummoner(); + return tempSummon->GetSummonerUnit(); return nullptr; } @@ -2072,7 +2072,7 @@ public: if (id == POINT_GRAB_DECOY) if (TempSummon* summon = me->ToTempSummon()) - if (Unit* summoner = summon->GetSummoner()) + if (Unit* summoner = summon->GetSummonerUnit()) DoCast(summoner, SPELL_GRAB); } diff --git a/src/server/scripts/Northrend/zone_sholazar_basin.cpp b/src/server/scripts/Northrend/zone_sholazar_basin.cpp index 81a447a43..c6393be62 100644 --- a/src/server/scripts/Northrend/zone_sholazar_basin.cpp +++ b/src/server/scripts/Northrend/zone_sholazar_basin.cpp @@ -680,7 +680,7 @@ public: return; if (TempSummon* summ = me->ToTempSummon()) - if (Unit* summoner = summ->GetSummoner()) + if (Unit* summoner = summ->GetSummonerUnit()) me->GetMotionMaster()->MovePoint(0, summoner->GetPositionX(), summoner->GetPositionY(), summoner->GetPositionZ()); Reset(); diff --git a/src/server/scripts/Northrend/zone_storm_peaks.cpp b/src/server/scripts/Northrend/zone_storm_peaks.cpp index b4aef8456..5b8d74a29 100644 --- a/src/server/scripts/Northrend/zone_storm_peaks.cpp +++ b/src/server/scripts/Northrend/zone_storm_peaks.cpp @@ -78,7 +78,7 @@ public: break; case 19: me->MonsterTextEmote("The frosthound has located the thief's hiding place. Confront him!", 0, true); - if (Unit* summoner = me->ToTempSummon()->GetSummoner()) + if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit()) summoner->ToPlayer()->KilledMonsterCredit(29677); break; } diff --git a/src/server/scripts/Northrend/zone_zuldrak.cpp b/src/server/scripts/Northrend/zone_zuldrak.cpp index 5ce8399b2..89e3cf995 100644 --- a/src/server/scripts/Northrend/zone_zuldrak.cpp +++ b/src/server/scripts/Northrend/zone_zuldrak.cpp @@ -293,7 +293,7 @@ public: ghoul->GetMotionMaster()->MoveTargetedHome(); } - if (Unit* owner = me->ToTempSummon()->GetSummoner()) + if (Unit* owner = me->ToTempSummon()->GetSummonerUnit()) if (Player* player = owner->ToPlayer()) player->KilledMonsterCredit(me->GetEntry()); diff --git a/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp b/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp index 94196885f..d6edae149 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_reliquary_of_souls.cpp @@ -103,7 +103,7 @@ public: bool Execute(uint64 /*eventTime*/, uint32 /*diff*/) override { if (_owner.IsSummon()) - if (Unit* summoner = _owner.ToTempSummon()->GetSummoner()) + if (Unit* summoner = _owner.ToTempSummon()->GetSummonerUnit()) { summoner->GetAI()->DoAction(_action); _owner.SetStandState(UNIT_STAND_STATE_SUBMERGED); @@ -514,7 +514,7 @@ public: { Talk(ANGER_SAY_DEATH); if (me->IsSummon()) - if (Unit* summoner = me->ToTempSummon()->GetSummoner()) + if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit()) Unit::Kill(summoner, summoner); } diff --git a/src/server/scripts/Pet/pet_generic.cpp b/src/server/scripts/Pet/pet_generic.cpp index 0adeb28cb..a94494a29 100644 --- a/src/server/scripts/Pet/pet_generic.cpp +++ b/src/server/scripts/Pet/pet_generic.cpp @@ -648,7 +648,7 @@ public: NullCreatureAI::InitializeAI(); if (TempSummon* summon = me->ToTempSummon()) - if (Unit* owner = summon->GetSummoner()) + if (Unit* owner = summon->GetSummonerUnit()) if (owner->GetTypeId() == TYPEID_PLAYER) { _ownerGUID = owner->GetGUID(); diff --git a/src/server/scripts/Pet/pet_priest.cpp b/src/server/scripts/Pet/pet_priest.cpp index c32b53d35..efe22e2c8 100644 --- a/src/server/scripts/Pet/pet_priest.cpp +++ b/src/server/scripts/Pet/pet_priest.cpp @@ -34,7 +34,7 @@ public: void InitializeAI() override { - if (Unit* owner = me->ToTempSummon()->GetSummoner()) + if (Unit* owner = me->ToTempSummon()->GetSummonerUnit()) { uint32 hp = uint32(owner->GetMaxHealth() * 0.3f); me->SetMaxHealth(hp); @@ -75,7 +75,7 @@ public: void JustDied(Unit* /*killer*/) override { if (me->IsSummon()) - if (Unit* owner = me->ToTempSummon()->GetSummoner()) + if (Unit* owner = me->ToTempSummon()->GetSummonerUnit()) if (owner->HasAura(SPELL_PRIEST_GLYPH_OF_SHADOWFIEND)) owner->CastSpell(owner, SPELL_PRIEST_GLYPH_OF_SHADOWFIEND_MANA, true); } diff --git a/src/server/scripts/Spells/spell_dk.cpp b/src/server/scripts/Spells/spell_dk.cpp index f0001b6e3..eb712550e 100644 --- a/src/server/scripts/Spells/spell_dk.cpp +++ b/src/server/scripts/Spells/spell_dk.cpp @@ -851,7 +851,7 @@ public: void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/) { PreventDefaultAction(); - if (Unit* owner = GetUnitOwner()->ToTempSummon()->GetSummoner()) + if (Unit* owner = GetUnitOwner()->ToTempSummon()->GetSummonerUnit()) { GetUnitOwner()->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID, owner->GetUInt32Value(PLAYER_VISIBLE_ITEM_16_ENTRYID)); GetUnitOwner()->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, owner->GetUInt32Value(PLAYER_VISIBLE_ITEM_17_ENTRYID)); diff --git a/src/server/scripts/Spells/spell_druid.cpp b/src/server/scripts/Spells/spell_druid.cpp index f0bf7ce6e..f38210ff7 100644 --- a/src/server/scripts/Spells/spell_druid.cpp +++ b/src/server/scripts/Spells/spell_druid.cpp @@ -224,7 +224,7 @@ public: // xinef: chance of success stores proper amount of damage increase // xinef: little hack because GetSpellModOwner will return nullptr pointer at this point (early summoning stage) if (GetUnitOwner()->IsSummon()) - if (Unit* owner = GetUnitOwner()->ToTempSummon()->GetSummoner()) + if (Unit* owner = GetUnitOwner()->ToTempSummon()->GetSummonerUnit()) if (Player* player = owner->GetSpellModOwner()) player->ApplySpellMod(SPELL_DRUID_BARKSKIN, SPELLMOD_CHANCE_OF_SUCCESS, amount); } diff --git a/src/server/scripts/Spells/spell_generic.cpp b/src/server/scripts/Spells/spell_generic.cpp index 5e30d9600..a0cae31f1 100644 --- a/src/server/scripts/Spells/spell_generic.cpp +++ b/src/server/scripts/Spells/spell_generic.cpp @@ -3847,7 +3847,7 @@ public: { if (Unit* caster = GetCaster()) if (TempSummon* vehicle = caster->ToTempSummon()) - if (Unit* rider = vehicle->GetSummoner()) + if (Unit* rider = vehicle->GetSummonerUnit()) rider->RemoveAurasDueToSpell(GetId()); } diff --git a/src/server/scripts/Spells/spell_priest.cpp b/src/server/scripts/Spells/spell_priest.cpp index 86c7d01cd..75d1a9f85 100644 --- a/src/server/scripts/Spells/spell_priest.cpp +++ b/src/server/scripts/Spells/spell_priest.cpp @@ -580,7 +580,7 @@ public: if (Unit* unitTarget = GetHitUnit()) if (AuraEffect* aur = unitTarget->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_PRIEST, 0x8000, 0, 0, GetCaster()->GetGUID())) { - aur->GetBase()->RefreshTimersWithMods(); + aur->GetBase()->RefreshTimers(); aur->ChangeAmount(aur->CalculateAmount(aur->GetCaster()), false); } } diff --git a/src/server/scripts/Spells/spell_quest.cpp b/src/server/scripts/Spells/spell_quest.cpp index 49fde3a2a..76894fe1e 100644 --- a/src/server/scripts/Spells/spell_quest.cpp +++ b/src/server/scripts/Spells/spell_quest.cpp @@ -239,7 +239,7 @@ public: void HandleScriptEffect(SpellEffIndex /*effIndex*/) { if (Unit* target = GetHitUnit()) - if (Unit* owner = target->ToTempSummon()->GetSummoner()) + if (Unit* owner = target->ToTempSummon()->GetSummonerUnit()) if (owner->GetTypeId() == TYPEID_PLAYER) owner->ToPlayer()->KilledMonsterCredit(23327); // Some trigger, just count } diff --git a/src/server/scripts/Spells/spell_warlock.cpp b/src/server/scripts/Spells/spell_warlock.cpp index f9b780baa..e8d115002 100644 --- a/src/server/scripts/Spells/spell_warlock.cpp +++ b/src/server/scripts/Spells/spell_warlock.cpp @@ -764,7 +764,7 @@ public: // Refresh corruption on target if (AuraEffect* aur = unitTarget->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_WARLOCK, 0x2, 0, 0, GetCaster()->GetGUID())) { - aur->GetBase()->RefreshTimersWithMods(); + aur->GetBase()->RefreshTimers(); aur->ChangeAmount(aur->CalculateAmount(aur->GetCaster()), false); } } diff --git a/src/server/scripts/World/npcs_special.cpp b/src/server/scripts/World/npcs_special.cpp index 354b5efb4..2effd8403 100644 --- a/src/server/scripts/World/npcs_special.cpp +++ b/src/server/scripts/World/npcs_special.cpp @@ -1707,7 +1707,7 @@ public: { if (creature->IsSummon()) { - if (player == creature->ToTempSummon()->GetSummoner()) + if (player == creature->ToTempSummon()->GetSummonerUnit()) { AddGossipItemFor(player, GOSSIP_ICON_CHAT, GOSSIP_ENGINEERING1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1); AddGossipItemFor(player, GOSSIP_ICON_CHAT, GOSSIP_ENGINEERING2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2);