fix(Core/Misc): bunch of crashfixes (#7307)
This commit is contained in:
@@ -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<uint64, BasicEvent*>(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<uint64, BasicEvent*>(newTime.count(), event));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
uint64 EventProcessor::CalculateTime(uint64 t_offset) const
|
||||
{
|
||||
return (m_time + t_offset);
|
||||
|
||||
@@ -8,58 +8,77 @@
|
||||
#define __EVENTPROCESSOR_H
|
||||
|
||||
#include "Define.h"
|
||||
#include "Duration.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
// 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<uint64, BasicEvent*> 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
|
||||
|
||||
@@ -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())
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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<float>(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 T>
|
||||
class GridObject
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -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<AuraApplication*> applications;
|
||||
GetApplicationList(applications);
|
||||
|
||||
|
||||
@@ -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; }
|
||||
|
||||
|
||||
@@ -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<TargetInfo>::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<TargetInfo>::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))
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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 =
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -1274,7 +1274,7 @@ public:
|
||||
Unit* GetOwner()
|
||||
{
|
||||
if (me->ToTempSummon())
|
||||
return me->ToTempSummon()->GetSummoner();
|
||||
return me->ToTempSummon()->GetSummonerUnit();
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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());
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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() )
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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());
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user