fix(Core/Misc): bunch of crashfixes (#7307)
This commit is contained in:
@@ -5,11 +5,20 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "EventProcessor.h"
|
#include "EventProcessor.h"
|
||||||
|
#include "Errors.h"
|
||||||
|
|
||||||
EventProcessor::EventProcessor()
|
void BasicEvent::ScheduleAbort()
|
||||||
{
|
{
|
||||||
m_time = 0;
|
ASSERT(IsRunning()
|
||||||
m_aborting = false;
|
&& "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()
|
EventProcessor::~EventProcessor()
|
||||||
@@ -27,63 +36,92 @@ void EventProcessor::Update(uint32 p_time)
|
|||||||
while (((i = m_events.begin()) != m_events.end()) && i->first <= m_time)
|
while (((i = m_events.begin()) != m_events.end()) && i->first <= m_time)
|
||||||
{
|
{
|
||||||
// get and remove event from queue
|
// get and remove event from queue
|
||||||
BasicEvent* Event = i->second;
|
BasicEvent* event = i->second;
|
||||||
m_events.erase(i);
|
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
|
// completely destroy event if it is not re-added
|
||||||
delete Event;
|
delete event;
|
||||||
}
|
}
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
if (event->IsAbortScheduled())
|
||||||
{
|
{
|
||||||
Event->Abort(m_time);
|
event->Abort(m_time);
|
||||||
delete Event;
|
// 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)
|
void EventProcessor::KillAllEvents(bool force)
|
||||||
{
|
{
|
||||||
// prevent event insertions
|
|
||||||
m_aborting = true;
|
|
||||||
|
|
||||||
// first, abort all existing events
|
// 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;
|
// Abort events which weren't aborted already
|
||||||
++i;
|
if (!itr->second->IsAborted())
|
||||||
|
|
||||||
i_old->second->to_Abort = true;
|
|
||||||
i_old->second->Abort(m_time);
|
|
||||||
if (force || i_old->second->IsDeletable())
|
|
||||||
{
|
{
|
||||||
delete i_old->second;
|
itr->second->SetAborted();
|
||||||
|
itr->second->Abort(m_time);
|
||||||
if (!force) // need per-element cleanup
|
|
||||||
{
|
|
||||||
m_events.erase (i_old);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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)
|
if (force)
|
||||||
{
|
|
||||||
m_events.clear();
|
m_events.clear();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventProcessor::AddEvent(BasicEvent* Event, uint64 e_time, bool set_addtime)
|
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;
|
Event->m_execTime = e_time;
|
||||||
m_events.insert(std::pair<uint64, BasicEvent*>(e_time, Event));
|
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
|
uint64 EventProcessor::CalculateTime(uint64 t_offset) const
|
||||||
{
|
{
|
||||||
return (m_time + t_offset);
|
return (m_time + t_offset);
|
||||||
|
|||||||
@@ -8,58 +8,77 @@
|
|||||||
#define __EVENTPROCESSOR_H
|
#define __EVENTPROCESSOR_H
|
||||||
|
|
||||||
#include "Define.h"
|
#include "Define.h"
|
||||||
|
#include "Duration.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
// Note. All times are in milliseconds here.
|
class EventProcessor;
|
||||||
|
|
||||||
|
// Note. All times are in milliseconds here.
|
||||||
class BasicEvent
|
class BasicEvent
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
BasicEvent()
|
friend class EventProcessor;
|
||||||
|
|
||||||
|
enum class AbortState : uint8
|
||||||
{
|
{
|
||||||
to_Abort = false;
|
STATE_RUNNING,
|
||||||
m_addTime = 0;
|
STATE_ABORT_SCHEDULED,
|
||||||
m_execTime = 0;
|
STATE_ABORTED
|
||||||
}
|
};
|
||||||
virtual ~BasicEvent() = default; // override destructor to perform some actions on event removal
|
|
||||||
|
|
||||||
// this method executes when the event is triggered
|
public:
|
||||||
// return false if event does not want to be deleted
|
BasicEvent()
|
||||||
// e_time is execution time, p_time is update interval
|
: m_abortState(AbortState::STATE_RUNNING), m_addTime(0), m_execTime(0) { }
|
||||||
virtual bool Execute(uint64 /*e_time*/, uint32 /*p_time*/) { return true; }
|
|
||||||
|
|
||||||
[[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
|
[[nodiscard]] virtual bool IsDeletable() const { return true; } // this event can be safely deleted
|
||||||
// and get Abort call when deleted
|
|
||||||
|
|
||||||
// these can be used for time offset control
|
virtual void Abort(uint64 /*e_time*/) { } // this method executes when the event is aborted
|
||||||
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
|
// 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;
|
typedef std::multimap<uint64, BasicEvent*> EventList;
|
||||||
|
|
||||||
class EventProcessor
|
class EventProcessor
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EventProcessor();
|
EventProcessor() : m_time(0) { }
|
||||||
~EventProcessor();
|
~EventProcessor();
|
||||||
|
|
||||||
void Update(uint32 p_time);
|
void Update(uint32 p_time);
|
||||||
void KillAllEvents(bool force);
|
void KillAllEvents(bool force);
|
||||||
void AddEvent(BasicEvent* Event, uint64 e_time, bool set_addtime = true);
|
void AddEvent(BasicEvent* Event, uint64 e_time, bool set_addtime = true);
|
||||||
[[nodiscard]] uint64 CalculateTime(uint64 t_offset) const;
|
void ModifyEventTime(BasicEvent* event, Milliseconds newTime);
|
||||||
|
[[nodiscard]] uint64 CalculateTime(uint64 t_offset) const;
|
||||||
|
|
||||||
// Xinef: calculates next queue tick time
|
//calculates next queue tick time
|
||||||
[[nodiscard]] uint64 CalculateQueueTime(uint64 delay) const;
|
[[nodiscard]] uint64 CalculateQueueTime(uint64 delay) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
uint64 m_time;
|
uint64 m_time;
|
||||||
EventList m_events;
|
EventList m_events;
|
||||||
bool m_aborting;
|
bool m_aborting;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ void CreatureAI::DoZoneInCombat(Creature* creature /*= nullptr*/, float maxRange
|
|||||||
creature->AI()->AttackStart(nearTarget);
|
creature->AI()->AttackStart(nearTarget);
|
||||||
else if (creature->IsSummon())
|
else if (creature->IsSummon())
|
||||||
{
|
{
|
||||||
if (Unit* summoner = creature->ToTempSummon()->GetSummoner())
|
if (Unit* summoner = creature->ToTempSummon()->GetSummonerUnit())
|
||||||
{
|
{
|
||||||
Unit* target = summoner->getAttackerForHelper();
|
Unit* target = summoner->getAttackerForHelper();
|
||||||
if (!target && summoner->CanHaveThreatList() && !summoner->getThreatManager().isThreatListEmpty())
|
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()))
|
if (Unit* owner = ObjectAccessor::GetUnit(*me, me->GetCharmerOrOwnerGUID()))
|
||||||
l->push_back(owner);
|
l->push_back(owner);
|
||||||
// Xinef: dont add same unit twice
|
// Xinef: dont add same unit twice
|
||||||
else if (me->IsSummon() && me->ToTempSummon()->GetSummoner())
|
else if (me->IsSummon() && me->ToTempSummon()->GetSummonerUnit())
|
||||||
l->push_back(me->ToTempSummon()->GetSummoner());
|
l->push_back(me->ToTempSummon()->GetSummonerUnit());
|
||||||
}
|
}
|
||||||
else if (go)
|
else if (go)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -598,7 +598,7 @@ void BattlefieldWG::OnCreatureCreate(Creature* creature)
|
|||||||
if (!creature->IsSummon() || !creature->ToTempSummon()->GetSummonerGUID())
|
if (!creature->IsSummon() || !creature->ToTempSummon()->GetSummonerGUID())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Unit* owner = creature->ToTempSummon()->GetSummoner())
|
if (Unit* owner = creature->ToTempSummon()->GetSummonerUnit())
|
||||||
creature->setFaction(owner->getFaction());
|
creature->setFaction(owner->getFaction());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,13 +16,39 @@ TempSummon::TempSummon(SummonPropertiesEntry const* properties, ObjectGuid owner
|
|||||||
Creature(isWorldObject), m_Properties(properties), m_type(TEMPSUMMON_MANUAL_DESPAWN),
|
Creature(isWorldObject), m_Properties(properties), m_type(TEMPSUMMON_MANUAL_DESPAWN),
|
||||||
m_timer(0), m_lifetime(0)
|
m_timer(0), m_lifetime(0)
|
||||||
{
|
{
|
||||||
m_summonerGUID = owner;
|
if (owner)
|
||||||
|
{
|
||||||
|
m_summonerGUID = owner;
|
||||||
|
}
|
||||||
|
|
||||||
m_unitTypeMask |= UNIT_MASK_SUMMON;
|
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)
|
void TempSummon::Update(uint32 diff)
|
||||||
@@ -147,7 +173,7 @@ void TempSummon::InitStats(uint32 duration)
|
|||||||
{
|
{
|
||||||
ASSERT(!IsPet());
|
ASSERT(!IsPet());
|
||||||
|
|
||||||
Unit* owner = GetSummoner();
|
Unit* owner = GetSummonerUnit();
|
||||||
if (owner)
|
if (owner)
|
||||||
if (Player* player = owner->ToPlayer())
|
if (Player* player = owner->ToPlayer())
|
||||||
sScriptMgr->OnBeforeTempSummonInitStats(player, this, duration);
|
sScriptMgr->OnBeforeTempSummonInitStats(player, this, duration);
|
||||||
@@ -197,7 +223,7 @@ void TempSummon::InitStats(uint32 duration)
|
|||||||
|
|
||||||
void TempSummon::InitSummon()
|
void TempSummon::InitSummon()
|
||||||
{
|
{
|
||||||
Unit* owner = GetSummoner();
|
Unit* owner = GetSummonerUnit();
|
||||||
if (owner)
|
if (owner)
|
||||||
{
|
{
|
||||||
if (owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsAIEnabled)
|
if (owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsAIEnabled)
|
||||||
@@ -237,7 +263,7 @@ void TempSummon::UnSummon(uint32 msTime)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Unit* owner = GetSummoner();
|
Unit* owner = GetSummonerUnit();
|
||||||
if (owner && owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsAIEnabled)
|
if (owner && owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsAIEnabled)
|
||||||
owner->ToCreature()->AI()->SummonedCreatureDespawn(this);
|
owner->ToCreature()->AI()->SummonedCreatureDespawn(this);
|
||||||
|
|
||||||
@@ -257,7 +283,7 @@ void TempSummon::RemoveFromWorld()
|
|||||||
|
|
||||||
if (m_Properties)
|
if (m_Properties)
|
||||||
if (uint32 slot = m_Properties->Slot)
|
if (uint32 slot = m_Properties->Slot)
|
||||||
if (Unit* owner = GetSummoner())
|
if (Unit* owner = GetSummonerUnit())
|
||||||
if (owner->m_SummonSlot[slot] == GetGUID())
|
if (owner->m_SummonSlot[slot] == GetGUID())
|
||||||
owner->m_SummonSlot[slot].Clear();
|
owner->m_SummonSlot[slot].Clear();
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,10 @@ public:
|
|||||||
void RemoveFromWorld() override;
|
void RemoveFromWorld() override;
|
||||||
void SetTempSummonType(TempSummonType type);
|
void SetTempSummonType(TempSummonType type);
|
||||||
void SaveToDB(uint32 /*mapid*/, uint8 /*spawnMask*/, uint32 /*phaseMask*/) override {}
|
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; }
|
ObjectGuid GetSummonerGUID() { return m_summonerGUID; }
|
||||||
TempSummonType const& GetSummonType() { return m_type; }
|
TempSummonType const& GetSummonType() { return m_type; }
|
||||||
uint32 GetTimer() { return m_timer; }
|
uint32 GetTimer() { return m_timer; }
|
||||||
|
|||||||
@@ -465,48 +465,33 @@ struct Position
|
|||||||
|
|
||||||
[[nodiscard]] bool IsPositionValid() const;
|
[[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 dx = x - m_positionX;
|
||||||
float dy = m_positionY - y;
|
float dy = y - m_positionY;
|
||||||
return dx * dx + dy * dy;
|
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 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;
|
void GetPositionOffsetTo(const Position& endPos, Position& retOffset) const;
|
||||||
|
Position GetPositionWithOffset(Position const& offset) const;
|
||||||
|
|
||||||
float GetAngle(const Position* pos) const;
|
float GetAngle(const Position* pos) const;
|
||||||
[[nodiscard]] float GetAngle(float x, float y) 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));
|
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::PositionXYStreamer const& streamer);
|
ByteBuffer& operator >> (ByteBuffer& buf, Position::PositionXYStreamer const& streamer);
|
||||||
ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYZStreamer const& streamer);
|
ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYZStreamer const& streamer);
|
||||||
@@ -643,80 +703,6 @@ struct MovementInfo
|
|||||||
void OutDebug();
|
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>
|
template<class T>
|
||||||
class GridObject
|
class GridObject
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16960,7 +16960,7 @@ void Unit::Kill(Unit* killer, Unit* victim, bool durabilityLoss, WeaponAttackTyp
|
|||||||
creature->AI()->JustDied(killer ? killer : victim);
|
creature->AI()->JustDied(killer ? killer : victim);
|
||||||
|
|
||||||
if (TempSummon* summon = creature->ToTempSummon())
|
if (TempSummon* summon = creature->ToTempSummon())
|
||||||
if (Unit* summoner = summon->GetSummoner())
|
if (Unit* summoner = summon->GetSummonerUnit())
|
||||||
if (summoner->ToCreature() && summoner->IsAIEnabled)
|
if (summoner->ToCreature() && summoner->IsAIEnabled)
|
||||||
summoner->ToCreature()->AI()->SummonedCreatureDies(creature, killer);
|
summoner->ToCreature()->AI()->SummonedCreatureDies(creature, killer);
|
||||||
|
|
||||||
|
|||||||
@@ -250,7 +250,7 @@ bool SpellClickInfo::IsFitToRequirements(Unit const* clicker, Unit const* clicke
|
|||||||
Unit const* summoner = nullptr;
|
Unit const* summoner = nullptr;
|
||||||
// Check summoners for party
|
// Check summoners for party
|
||||||
if (clickee->IsSummon())
|
if (clickee->IsSummon())
|
||||||
summoner = clickee->ToTempSummon()->GetSummoner();
|
summoner = clickee->ToTempSummon()->GetSummonerUnit();
|
||||||
if (!summoner)
|
if (!summoner)
|
||||||
summoner = clickee;
|
summoner = clickee;
|
||||||
|
|
||||||
|
|||||||
@@ -453,12 +453,12 @@ int32 AuraEffect::CalculateAmount(Unit* caster)
|
|||||||
ItemRandomSuffixEntry const* item_rand_suffix = sItemRandomSuffixStore.LookupEntry(abs(castItem->GetItemRandomPropertyId()));
|
ItemRandomSuffixEntry const* item_rand_suffix = sItemRandomSuffixStore.LookupEntry(abs(castItem->GetItemRandomPropertyId()));
|
||||||
if (item_rand_suffix)
|
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]);
|
SpellItemEnchantmentEntry const* pEnchant = sSpellItemEnchantmentStore.LookupEntry(item_rand_suffix->enchant_id[k]);
|
||||||
if (pEnchant)
|
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)
|
if (pEnchant->spellid[t] == m_spellInfo->Id)
|
||||||
{
|
{
|
||||||
amount = uint32((item_rand_suffix->prefix[k] * castItem->GetItemSuffixFactor()) / 10000);
|
amount = uint32((item_rand_suffix->prefix[k] * castItem->GetItemSuffixFactor()) / 10000);
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ public:
|
|||||||
uint32 GetTickNumber() const { return m_tickNumber; }
|
uint32 GetTickNumber() const { return m_tickNumber; }
|
||||||
int32 GetTotalTicks() const { return m_amplitude ? (GetBase()->GetMaxDuration() / m_amplitude) : 1;}
|
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 ResetPeriodic(bool resetPeriodicTimer = false) { if (resetPeriodicTimer) m_periodicTimer = m_amplitude; m_tickNumber = 0;}
|
||||||
|
void ResetTicks() { m_tickNumber = 0; }
|
||||||
|
|
||||||
bool IsPeriodic() const { return m_isPeriodic; }
|
bool IsPeriodic() const { return m_isPeriodic; }
|
||||||
void SetPeriodic(bool isPeriodic) { m_isPeriodic = isPeriodic; }
|
void SetPeriodic(bool isPeriodic) { m_isPeriodic = isPeriodic; }
|
||||||
|
|||||||
@@ -847,12 +847,33 @@ void Aura::SetDuration(int32 duration, bool withMods)
|
|||||||
SetNeedClientUpdateForTargets();
|
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))
|
if ((m_spellInfo->ManaPerSecond || m_spellInfo->ManaPerSecondPerLevel) && !m_spellInfo->HasAttribute(SPELL_ATTR2_NO_TARGET_PER_SECOND_COST))
|
||||||
m_timeCla = 1 * IN_MILLISECONDS;
|
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*/)
|
void Aura::RefreshTimers(bool periodicReset /*= false*/)
|
||||||
@@ -860,27 +881,13 @@ void Aura::RefreshTimers(bool periodicReset /*= false*/)
|
|||||||
m_maxDuration = CalcMaxDuration();
|
m_maxDuration = CalcMaxDuration();
|
||||||
RefreshDuration();
|
RefreshDuration();
|
||||||
Unit* caster = GetCaster();
|
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
|
if (!caster)
|
||||||
void Aura::RefreshTimersWithMods()
|
return;
|
||||||
{
|
|
||||||
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));
|
|
||||||
|
|
||||||
// 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)
|
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
|
||||||
if (HasEffect(i))
|
if (AuraEffect* aurEff = m_effects[i])
|
||||||
GetEffect(i)->CalculatePeriodic(caster, false, false);
|
aurEff->CalculatePeriodic(caster, periodicReset, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Aura::SetCharges(uint8 charges)
|
void Aura::SetCharges(uint8 charges)
|
||||||
@@ -931,6 +938,9 @@ void Aura::SetStackAmount(uint8 stackAmount)
|
|||||||
m_stackAmount = stackAmount;
|
m_stackAmount = stackAmount;
|
||||||
Unit* caster = GetCaster();
|
Unit* caster = GetCaster();
|
||||||
|
|
||||||
|
if (!caster)
|
||||||
|
return;
|
||||||
|
|
||||||
std::list<AuraApplication*> applications;
|
std::list<AuraApplication*> applications;
|
||||||
GetApplicationList(applications);
|
GetApplicationList(applications);
|
||||||
|
|
||||||
|
|||||||
@@ -121,9 +121,8 @@ public:
|
|||||||
int32 CalcMaxDuration(Unit* caster) const;
|
int32 CalcMaxDuration(Unit* caster) const;
|
||||||
int32 GetDuration() const { return m_duration; }
|
int32 GetDuration() const { return m_duration; }
|
||||||
void SetDuration(int32 duration, bool withMods = false);
|
void SetDuration(int32 duration, bool withMods = false);
|
||||||
void RefreshDuration();
|
void RefreshDuration(bool withMods = false);
|
||||||
void RefreshTimers(bool periodicReset = false);
|
void RefreshTimers(bool periodicReset = false);
|
||||||
void RefreshTimersWithMods();
|
|
||||||
bool IsExpired() const { return !GetDuration();}
|
bool IsExpired() const { return !GetDuration();}
|
||||||
bool IsPermanent() const { return GetMaxDuration() == -1; }
|
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
|
void SpellCastTargets::OutDebug() const
|
||||||
{
|
{
|
||||||
if (!m_targetMask)
|
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) :
|
Spell::Spell(Unit* caster, SpellInfo const* info, TriggerCastFlags triggerFlags, ObjectGuid originalCasterGUID, bool skipCheck) :
|
||||||
m_spellInfo(sSpellMgr->GetSpellForDifficultyFromSpell(info, caster)),
|
m_spellInfo(sSpellMgr->GetSpellForDifficultyFromSpell(info, caster)),
|
||||||
m_caster((info->HasAttribute(SPELL_ATTR6_ORIGINATE_FROM_CONTROLLER) && caster->GetCharmerOrOwner()) ? caster->GetCharmerOrOwner() : 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_customError = SPELL_CUSTOM_ERROR_NONE;
|
||||||
m_skipCheck = skipCheck;
|
m_skipCheck = skipCheck;
|
||||||
@@ -825,8 +839,16 @@ void Spell::SelectSpellTargets()
|
|||||||
|
|
||||||
if (m_spellInfo->IsChanneled())
|
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);
|
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)
|
if (ihit->effectMask & mask)
|
||||||
{
|
{
|
||||||
@@ -838,22 +860,18 @@ void Spell::SelectSpellTargets()
|
|||||||
else if (m_auraScaleMask)
|
else if (m_auraScaleMask)
|
||||||
{
|
{
|
||||||
bool checkLvl = !m_UniqueTargetInfo.empty();
|
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
|
// 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 (!targetInfo.scaleAura && targetInfo.targetGUID != m_caster->GetGUID())
|
||||||
|
return true;
|
||||||
if (!itr->scaleAura && itr->targetGUID != m_caster->GetGUID())
|
|
||||||
needErase = true;
|
|
||||||
|
|
||||||
sScriptMgr->OnRemoveAuraScaleTargets(this, *itr, m_auraScaleMask, needErase);
|
|
||||||
|
|
||||||
if (needErase)
|
|
||||||
m_UniqueTargetInfo.erase(itr);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
return false;
|
||||||
|
}), std::end(m_UniqueTargetInfo));
|
||||||
|
|
||||||
if (checkLvl && m_UniqueTargetInfo.empty())
|
if (checkLvl && m_UniqueTargetInfo.empty())
|
||||||
{
|
{
|
||||||
SendCastResult(SPELL_FAILED_LOWLEVEL);
|
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.HasDst())
|
||||||
{
|
{
|
||||||
if (m_targets.HasTraj())
|
if (m_targets.HasTraj())
|
||||||
{
|
{
|
||||||
float speed = m_targets.GetSpeedXY();
|
float speed = m_targets.GetSpeedXY();
|
||||||
if (speed > 0.0f)
|
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)
|
else if (m_spellInfo->Speed > 0.0f)
|
||||||
{
|
{
|
||||||
float dist = m_caster->GetExactDist(m_targets.GetDstPos());
|
// We should not subtract caster size from dist calculation (fixes execution time desync with animation on client, eg. Malleable Goo cast by PP)
|
||||||
m_delayTrajectory = (uint64) floor(dist / m_spellInfo->Speed * 1000.0f);
|
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)
|
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)
|
for (uint32 j = effIndex + 1; j < MAX_SPELL_EFFECTS; ++j)
|
||||||
{
|
{
|
||||||
SpellEffectInfo const* effects = GetSpellInfo()->Effects;
|
SpellEffectInfo const* effects = GetSpellInfo()->Effects;
|
||||||
if (effects[effIndex].TargetA.GetTarget() == effects[j].TargetA.GetTarget() &&
|
if (effects[j].IsEffect() &&
|
||||||
effects[effIndex].TargetB.GetTarget() == effects[j].TargetB.GetTarget() &&
|
effects[effIndex].TargetA.GetTarget() == effects[j].TargetA.GetTarget() &&
|
||||||
effects[effIndex].ImplicitTargetConditions == effects[j].ImplicitTargetConditions &&
|
effects[effIndex].TargetB.GetTarget() == effects[j].TargetB.GetTarget() &&
|
||||||
effects[effIndex].CalcRadius(m_caster) == effects[j].CalcRadius(m_caster) &&
|
effects[effIndex].ImplicitTargetConditions == effects[j].ImplicitTargetConditions &&
|
||||||
CheckScriptEffectImplicitTargets(effIndex, j))
|
effects[effIndex].CalcRadius(m_caster) == effects[j].CalcRadius(m_caster) &&
|
||||||
|
CheckScriptEffectImplicitTargets(effIndex, j))
|
||||||
{
|
{
|
||||||
effectMask |= 1 << j;
|
effectMask |= 1 << j;
|
||||||
}
|
}
|
||||||
@@ -928,9 +962,8 @@ void Spell::SelectEffectImplicitTargets(SpellEffIndex effIndex, SpellImplicitTar
|
|||||||
SelectImplicitAreaTargets(effIndex, targetType, effectMask);
|
SelectImplicitAreaTargets(effIndex, targetType, effectMask);
|
||||||
break;
|
break;
|
||||||
case TARGET_SELECT_CATEGORY_TRAJ:
|
case TARGET_SELECT_CATEGORY_TRAJ:
|
||||||
// xinef: just in case there is no dest, explanation in SelectImplicitDestDestTargets
|
// just in case there is no dest, explanation in SelectImplicitDestDestTargets
|
||||||
if (!m_targets.HasDst())
|
CheckDst();
|
||||||
m_targets.SetDst(*m_caster);
|
|
||||||
|
|
||||||
SelectImplicitTrajTargets(effIndex, targetType);
|
SelectImplicitTrajTargets(effIndex, targetType);
|
||||||
break;
|
break;
|
||||||
@@ -1513,7 +1546,7 @@ void Spell::SelectImplicitCasterObjectTargets(SpellEffIndex effIndex, SpellImpli
|
|||||||
break;
|
break;
|
||||||
case TARGET_UNIT_SUMMONER:
|
case TARGET_UNIT_SUMMONER:
|
||||||
if (m_caster->IsSummon())
|
if (m_caster->IsSummon())
|
||||||
target = m_caster->ToTempSummon()->GetSummoner();
|
target = m_caster->ToTempSummon()->GetSummonerUnit();
|
||||||
break;
|
break;
|
||||||
case TARGET_UNIT_VEHICLE:
|
case TARGET_UNIT_VEHICLE:
|
||||||
target = m_caster->GetVehicleBase();
|
target = m_caster->GetVehicleBase();
|
||||||
@@ -3208,8 +3241,8 @@ SpellCastResult Spell::prepare(SpellCastTargets const* targets, AuraEffect const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// create and add update event for this spell
|
// create and add update event for this spell
|
||||||
SpellEvent* Event = new SpellEvent(this);
|
_spellEvent = new SpellEvent(this);
|
||||||
m_caster->m_Events.AddEvent(Event, m_caster->m_Events.CalculateTime(1));
|
m_caster->m_Events.AddEvent(_spellEvent, m_caster->m_Events.CalculateTime(1));
|
||||||
|
|
||||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, m_spellInfo->Id, m_caster))
|
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, m_spellInfo->Id, m_caster))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -20,7 +20,9 @@ class DynamicObject;
|
|||||||
class WorldObject;
|
class WorldObject;
|
||||||
class Aura;
|
class Aura;
|
||||||
class SpellScript;
|
class SpellScript;
|
||||||
|
class SpellEvent;
|
||||||
class ByteBuffer;
|
class ByteBuffer;
|
||||||
|
class BasicEvent;
|
||||||
|
|
||||||
#define SPELL_CHANNEL_UPDATE_INTERVAL (1 * IN_MILLISECONDS)
|
#define SPELL_CHANNEL_UPDATE_INTERVAL (1 * IN_MILLISECONDS)
|
||||||
|
|
||||||
@@ -521,6 +523,8 @@ public:
|
|||||||
uint64 GetDelayMoment() const { return m_delayMoment; }
|
uint64 GetDelayMoment() const { return m_delayMoment; }
|
||||||
uint64 GetDelayTrajectory() const { return m_delayTrajectory; }
|
uint64 GetDelayTrajectory() const { return m_delayTrajectory; }
|
||||||
|
|
||||||
|
uint64 CalculateDelayMomentForDst() const;
|
||||||
|
void RecalculateDelayMomentForDst();
|
||||||
bool IsNeedSendToClient(bool go) const;
|
bool IsNeedSendToClient(bool go) const;
|
||||||
|
|
||||||
CurrentSpellTypes GetCurrentContainer() const;
|
CurrentSpellTypes GetCurrentContainer() const;
|
||||||
@@ -710,6 +714,7 @@ protected:
|
|||||||
uint32 m_spellState;
|
uint32 m_spellState;
|
||||||
int32 m_timer;
|
int32 m_timer;
|
||||||
|
|
||||||
|
SpellEvent* _spellEvent;
|
||||||
TriggerCastFlags _triggeredCastFlags;
|
TriggerCastFlags _triggeredCastFlags;
|
||||||
|
|
||||||
// if need this can be replaced by Aura copy
|
// if need this can be replaced by Aura copy
|
||||||
@@ -788,29 +793,16 @@ namespace Acore
|
|||||||
|
|
||||||
typedef void(Spell::*pEffect)(SpellEffIndex effIndex);
|
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
|
class ReflectEvent : public BasicEvent
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ReflectEvent(Unit* caster, ObjectGuid targetGUID, const SpellInfo* spellInfo) : _caster(caster), _targetGUID(targetGUID), _spellInfo(spellInfo) { }
|
ReflectEvent(Unit* caster, ObjectGuid targetGUID, const SpellInfo* spellInfo) : _caster(caster), _targetGUID(targetGUID), _spellInfo(spellInfo) { }
|
||||||
bool Execute(uint64 e_time, uint32 p_time) override;
|
bool Execute(uint64 e_time, uint32 p_time) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Unit* _caster;
|
Unit* _caster;
|
||||||
ObjectGuid _targetGUID;
|
ObjectGuid _targetGUID;
|
||||||
const SpellInfo* _spellInfo;
|
const SpellInfo* _spellInfo;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -840,8 +840,9 @@ SpellInfo::SpellInfo(SpellEntry const* spellEntry)
|
|||||||
SchoolMask = spellEntry->SchoolMask;
|
SchoolMask = spellEntry->SchoolMask;
|
||||||
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
|
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
|
||||||
Effects[i] = SpellEffectInfo(spellEntry, this, i);
|
Effects[i] = SpellEffectInfo(spellEntry, this, i);
|
||||||
ExplicitTargetMask = _GetExplicitTargetMask();
|
|
||||||
ChainEntry = nullptr;
|
ChainEntry = nullptr;
|
||||||
|
ExplicitTargetMask = 0;
|
||||||
|
|
||||||
// Mine
|
// Mine
|
||||||
_isStackableWithRanks = false;
|
_isStackableWithRanks = false;
|
||||||
@@ -2537,7 +2538,7 @@ bool SpellInfo::IsHighRankOf(SpellInfo const* spellInfo) const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 SpellInfo::_GetExplicitTargetMask() const
|
void SpellInfo::_InitializeExplicitTargetMask()
|
||||||
{
|
{
|
||||||
bool srcSet = false;
|
bool srcSet = false;
|
||||||
bool dstSet = 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);
|
effectTargetMask &= ~(TARGET_FLAG_UNIT_MASK | TARGET_FLAG_GAMEOBJECT | TARGET_FLAG_CORPSE_MASK | TARGET_FLAG_DEST_LOCATION);
|
||||||
targetMask |= effectTargetMask;
|
targetMask |= effectTargetMask;
|
||||||
}
|
}
|
||||||
return targetMask;
|
ExplicitTargetMask = targetMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SpellInfo::_IsPositiveEffect(uint8 effIndex, bool deep) const
|
bool SpellInfo::_IsPositiveEffect(uint8 effIndex, bool deep) const
|
||||||
|
|||||||
@@ -503,7 +503,7 @@ public:
|
|||||||
bool IsHighRankOf(SpellInfo const* spellInfo) const;
|
bool IsHighRankOf(SpellInfo const* spellInfo) const;
|
||||||
|
|
||||||
// loading helpers
|
// loading helpers
|
||||||
uint32 _GetExplicitTargetMask() const;
|
void _InitializeExplicitTargetMask();
|
||||||
bool _IsPositiveEffect(uint8 effIndex, bool deep) const;
|
bool _IsPositiveEffect(uint8 effIndex, bool deep) const;
|
||||||
bool _IsPositiveSpell() const;
|
bool _IsPositiveSpell() const;
|
||||||
static bool _IsPositiveTarget(uint32 targetA, uint32 targetB);
|
static bool _IsPositiveTarget(uint32 targetA, uint32 targetB);
|
||||||
|
|||||||
@@ -2665,10 +2665,8 @@ void SpellMgr::LoadSpellInfoStore()
|
|||||||
void SpellMgr::UnloadSpellInfoStore()
|
void SpellMgr::UnloadSpellInfoStore()
|
||||||
{
|
{
|
||||||
for (uint32 i = 0; i < mSpellInfoMap.size(); ++i)
|
for (uint32 i = 0; i < mSpellInfoMap.size(); ++i)
|
||||||
{
|
delete mSpellInfoMap[i];
|
||||||
if (mSpellInfoMap[i])
|
|
||||||
delete mSpellInfoMap[i];
|
|
||||||
}
|
|
||||||
mSpellInfoMap.clear();
|
mSpellInfoMap.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3282,6 +3280,7 @@ void SpellMgr::LoadSpellCustomAttr()
|
|||||||
spellInfo->Effects[EFFECT_0].MiscValue = 127;
|
spellInfo->Effects[EFFECT_0].MiscValue = 127;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
spellInfo->_InitializeExplicitTargetMask();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Xinef: addition for binary spells, ommit spells triggering other spells
|
// 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 (type == POINT_MOTION_TYPE && point == POINT_MOVE_TO_MIDNIGHT)
|
||||||
{
|
{
|
||||||
if (TempSummon* summon = me->ToTempSummon())
|
if (TempSummon* summon = me->ToTempSummon())
|
||||||
if (Unit* midnight = summon->GetSummoner())
|
if (Unit* midnight = summon->GetSummonerUnit())
|
||||||
midnight->GetAI()->SetData(DATA_ATTUMEN_READY, 0);
|
midnight->GetAI()->SetData(DATA_ATTUMEN_READY, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -356,7 +356,7 @@ public:
|
|||||||
if (type == POINT_MOTION_TYPE && point == POINT_MOVE_TO_MIDNIGHT)
|
if (type == POINT_MOTION_TYPE && point == POINT_MOVE_TO_MIDNIGHT)
|
||||||
{
|
{
|
||||||
if (TempSummon* summon = me->ToTempSummon())
|
if (TempSummon* summon = me->ToTempSummon())
|
||||||
if (Unit* midnight = summon->GetSummoner())
|
if (Unit* midnight = summon->GetSummonerUnit())
|
||||||
midnight->GetAI()->SetData(DATA_ATTUMEN_READY, 0);
|
midnight->GetAI()->SetData(DATA_ATTUMEN_READY, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public:
|
|||||||
Player* player = nullptr;
|
Player* player = nullptr;
|
||||||
if (me->IsSummon())
|
if (me->IsSummon())
|
||||||
{
|
{
|
||||||
if (Unit * summoner = me->ToTempSummon()->GetSummoner())
|
if (Unit * summoner = me->ToTempSummon()->GetSummonerUnit())
|
||||||
{
|
{
|
||||||
player = summoner->ToPlayer();
|
player = summoner->ToPlayer();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -265,7 +265,7 @@ public:
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (TempSummon* summon = me->ToTempSummon())
|
if (TempSummon* summon = me->ToTempSummon())
|
||||||
if (Unit* creature = summon->GetSummoner())
|
if (Unit* creature = summon->GetSummonerUnit())
|
||||||
creature->GetAI()->DoAction(1);
|
creature->GetAI()->DoAction(1);
|
||||||
|
|
||||||
me->DespawnOrUnsummon(1);
|
me->DespawnOrUnsummon(1);
|
||||||
@@ -274,7 +274,7 @@ public:
|
|||||||
void JustDied(Unit*) override
|
void JustDied(Unit*) override
|
||||||
{
|
{
|
||||||
if (TempSummon* summon = me->ToTempSummon())
|
if (TempSummon* summon = me->ToTempSummon())
|
||||||
if (Unit* creature = summon->GetSummoner())
|
if (Unit* creature = summon->GetSummonerUnit())
|
||||||
creature->GetAI()->DoAction(2);
|
creature->GetAI()->DoAction(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -299,7 +299,7 @@ public:
|
|||||||
|
|
||||||
if (me->IsSummon())
|
if (me->IsSummon())
|
||||||
{
|
{
|
||||||
if (Unit* summoner = me->ToTempSummon()->GetSummoner())
|
if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit())
|
||||||
{
|
{
|
||||||
if (summoner->GetTypeId() == TYPEID_UNIT && summoner->IsAlive() && !summoner->IsInCombat())
|
if (summoner->GetTypeId() == TYPEID_UNIT && summoner->IsAlive() && !summoner->IsInCombat())
|
||||||
summoner->ToCreature()->AI()->AttackStart(who);
|
summoner->ToCreature()->AI()->AttackStart(who);
|
||||||
@@ -313,7 +313,7 @@ public:
|
|||||||
|
|
||||||
if (me->IsSummon())
|
if (me->IsSummon())
|
||||||
{
|
{
|
||||||
if (Unit* summoner = me->ToTempSummon()->GetSummoner())
|
if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit())
|
||||||
{
|
{
|
||||||
if (summoner->GetTypeId() == TYPEID_UNIT && summoner->IsAlive())
|
if (summoner->GetTypeId() == TYPEID_UNIT && summoner->IsAlive())
|
||||||
summoner->ToCreature()->DisappearAndDie();
|
summoner->ToCreature()->DisappearAndDie();
|
||||||
@@ -328,7 +328,7 @@ public:
|
|||||||
|
|
||||||
if (me->IsSummon())
|
if (me->IsSummon())
|
||||||
{
|
{
|
||||||
Unit* summoner = me->ToTempSummon()->GetSummoner();
|
Unit* summoner = me->ToTempSummon()->GetSummonerUnit();
|
||||||
if (summoner && summoner->GetTypeId() == TYPEID_UNIT && summoner->IsAIEnabled)
|
if (summoner && summoner->GetTypeId() == TYPEID_UNIT && summoner->IsAIEnabled)
|
||||||
{
|
{
|
||||||
npc_lord_gregor_lescovar::npc_lord_gregor_lescovarAI* ai =
|
npc_lord_gregor_lescovar::npc_lord_gregor_lescovarAI* ai =
|
||||||
|
|||||||
@@ -281,7 +281,7 @@ public:
|
|||||||
Creature* GetSummoner()
|
Creature* GetSummoner()
|
||||||
{
|
{
|
||||||
if (me->IsSummon())
|
if (me->IsSummon())
|
||||||
if (Unit* coren = me->ToTempSummon()->GetSummoner())
|
if (Unit* coren = me->ToTempSummon()->GetSummonerUnit())
|
||||||
return coren->ToCreature();
|
return coren->ToCreature();
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|||||||
@@ -1274,7 +1274,7 @@ public:
|
|||||||
Unit* GetOwner()
|
Unit* GetOwner()
|
||||||
{
|
{
|
||||||
if (me->ToTempSummon())
|
if (me->ToTempSummon())
|
||||||
return me->ToTempSummon()->GetSummoner();
|
return me->ToTempSummon()->GetSummonerUnit();
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -261,7 +261,7 @@ public:
|
|||||||
if (Talk(actionCounter))
|
if (Talk(actionCounter))
|
||||||
{
|
{
|
||||||
if (me->ToTempSummon())
|
if (me->ToTempSummon())
|
||||||
if (Unit* owner = me->ToTempSummon()->GetSummoner())
|
if (Unit* owner = me->ToTempSummon()->GetSummonerUnit())
|
||||||
me->CastSpell(owner, SPELL_SNIVEL_GUN, true);
|
me->CastSpell(owner, SPELL_SNIVEL_GUN, true);
|
||||||
|
|
||||||
me->DespawnOrUnsummon(1000);
|
me->DespawnOrUnsummon(1000);
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ public:
|
|||||||
case SPELL_VISUAL_THROW_CRANBERRY:
|
case SPELL_VISUAL_THROW_CRANBERRY:
|
||||||
case SPELL_VISUAL_THROW_SWEET_POTATO:
|
case SPELL_VISUAL_THROW_SWEET_POTATO:
|
||||||
if (TempSummon* ts = me->ToTempSummon())
|
if (TempSummon* ts = me->ToTempSummon())
|
||||||
if (Unit* owner = ts->GetSummoner())
|
if (Unit* owner = ts->GetSummonerUnit())
|
||||||
owner->ToCreature()->AI()->DoAction(spellInfo->Id);
|
owner->ToCreature()->AI()->DoAction(spellInfo->Id);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -376,7 +376,7 @@ public:
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (TempSummon* ts = target->ToTempSummon())
|
if (TempSummon* ts = target->ToTempSummon())
|
||||||
if (Unit* owner = ts->GetSummoner())
|
if (Unit* owner = ts->GetSummonerUnit())
|
||||||
if (owner->GetEntry() == GetCaster()->GetEntry())
|
if (owner->GetEntry() == GetCaster()->GetEntry())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -1286,7 +1286,7 @@ public:
|
|||||||
void JustDied(Unit* /*killer*/) override
|
void JustDied(Unit* /*killer*/) override
|
||||||
{
|
{
|
||||||
if (TempSummon* summon = me->ToTempSummon())
|
if (TempSummon* summon = me->ToTempSummon())
|
||||||
if (Unit* summoner = summon->GetSummoner())
|
if (Unit* summoner = summon->GetSummonerUnit())
|
||||||
if (summoner->IsAIEnabled)
|
if (summoner->IsAIEnabled)
|
||||||
summoner->GetAI()->DoAction(ACTION_FLESH_TENTACLE_KILLED);
|
summoner->GetAI()->DoAction(ACTION_FLESH_TENTACLE_KILLED);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ public:
|
|||||||
if (!(*itr)->IsSummon())
|
if (!(*itr)->IsSummon())
|
||||||
continue;
|
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)
|
if (!summoner->HasAura(SPELL_NO_SUMMON_AURA) && !summoner->HasAura(SPELL_SUMMON_ZENTABRA_TRIGGER)
|
||||||
&& !summoner->IsInCombat())
|
&& !summoner->IsInCombat())
|
||||||
{
|
{
|
||||||
@@ -168,7 +168,7 @@ public:
|
|||||||
if (victim->GetTypeId() != TYPEID_UNIT || !victim->IsSummon())
|
if (victim->GetTypeId() != TYPEID_UNIT || !victim->IsSummon())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Unit* vehSummoner = victim->ToTempSummon()->GetSummoner())
|
if (Unit* vehSummoner = victim->ToTempSummon()->GetSummonerUnit())
|
||||||
{
|
{
|
||||||
vehSummoner->RemoveAurasDueToSpell(SPELL_NO_SUMMON_AURA);
|
vehSummoner->RemoveAurasDueToSpell(SPELL_NO_SUMMON_AURA);
|
||||||
vehSummoner->RemoveAurasDueToSpell(SPELL_DETECT_INVIS);
|
vehSummoner->RemoveAurasDueToSpell(SPELL_DETECT_INVIS);
|
||||||
@@ -187,7 +187,7 @@ public:
|
|||||||
{
|
{
|
||||||
damage = 0;
|
damage = 0;
|
||||||
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
|
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->AddAura(SPELL_SUMMON_ZENTABRA_TRIGGER, vehSummoner);
|
||||||
vehSummoner->CastSpell(vehSummoner, SPELL_SUMMON_ZENTABRA, true);
|
vehSummoner->CastSpell(vehSummoner, SPELL_SUMMON_ZENTABRA, true);
|
||||||
@@ -224,7 +224,7 @@ public:
|
|||||||
if (Unit* tiger = ObjectAccessor::GetUnit(*me, _tigerGuid))
|
if (Unit* tiger = ObjectAccessor::GetUnit(*me, _tigerGuid))
|
||||||
{
|
{
|
||||||
if (tiger->IsSummon())
|
if (tiger->IsSummon())
|
||||||
if (Unit* vehSummoner = tiger->ToTempSummon()->GetSummoner())
|
if (Unit* vehSummoner = tiger->ToTempSummon()->GetSummonerUnit())
|
||||||
me->AddAura(SPELL_NO_SUMMON_AURA, vehSummoner);
|
me->AddAura(SPELL_NO_SUMMON_AURA, vehSummoner);
|
||||||
}
|
}
|
||||||
_events.ScheduleEvent(EVENT_NOSUMMON, 50000);
|
_events.ScheduleEvent(EVENT_NOSUMMON, 50000);
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ public:
|
|||||||
events.Reset();
|
events.Reset();
|
||||||
|
|
||||||
if (me->ToTempSummon())
|
if (me->ToTempSummon())
|
||||||
if (Unit* summoner = me->ToTempSummon()->GetSummoner())
|
if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit())
|
||||||
if (summoner->GetEntry() == me->GetEntry())
|
if (summoner->GetEntry() == me->GetEntry())
|
||||||
{
|
{
|
||||||
me->CastSpell(me, RAND(SPELL_SUMMON_ANUBAR_CHAMPION, SPELL_SUMMON_ANUBAR_CRYPT_FIEND, SPELL_SUMMON_ANUBAR_NECROMANCER), true);
|
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
|
void EnterCombat(Unit*) override
|
||||||
{
|
{
|
||||||
if (me->ToTempSummon())
|
if (me->ToTempSummon())
|
||||||
if (Unit* summoner = me->ToTempSummon()->GetSummoner())
|
if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit())
|
||||||
if (summoner->GetEntry() != me->GetEntry())
|
if (summoner->GetEntry() != me->GetEntry())
|
||||||
{
|
{
|
||||||
summoner->GetAI()->DoAction(ACTION_START_EVENT);
|
summoner->GetAI()->DoAction(ACTION_START_EVENT);
|
||||||
|
|||||||
@@ -237,7 +237,7 @@ public:
|
|||||||
summon->CastSpell(summon, SPELL_METEOR_STRIKE_FIRE_AURA_2, true);
|
summon->CastSpell(summon, SPELL_METEOR_STRIKE_FIRE_AURA_2, true);
|
||||||
if (summons.GetEntryCount(NPC_METEOR_STRIKE_FLAME) <= 16)
|
if (summons.GetEntryCount(NPC_METEOR_STRIKE_FLAME) <= 16)
|
||||||
summon->CastSpell(summon, SPELL_METEOR_STRIKE_SPREAD, true);
|
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));
|
summon->SetOrientation(summoner->GetAngle(summon));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -344,7 +344,7 @@ public:
|
|||||||
if (me->ToTempSummon())
|
if (me->ToTempSummon())
|
||||||
{
|
{
|
||||||
if (who->GetTypeId() == TYPEID_PLAYER || who->GetOwnerGUID().IsPlayer())
|
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);
|
summoner->GetAI()->DoAction(ACTION_INFORM);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -378,7 +378,7 @@ public:
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (TempSummon* summ = me->ToTempSummon())
|
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()};
|
Position exitPos = {me->GetPositionX(), me->GetPositionY(), 60.0f, me->GetOrientation()};
|
||||||
trapped->UpdateAllowedPositionZ(exitPos.GetPositionX(), exitPos.GetPositionY(), exitPos.m_positionZ);
|
trapped->UpdateAllowedPositionZ(exitPos.GetPositionX(), exitPos.GetPositionY(), exitPos.m_positionZ);
|
||||||
@@ -430,7 +430,7 @@ public:
|
|||||||
|
|
||||||
if (TempSummon* summ = me->ToTempSummon())
|
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))
|
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();
|
DoResetThreat();
|
||||||
me->SetInCombatWithZone();
|
me->SetInCombatWithZone();
|
||||||
if (TempSummon* ts = me->ToTempSummon())
|
if (TempSummon* ts = me->ToTempSummon())
|
||||||
if (Unit* summoner = ts->GetSummoner())
|
if (Unit* summoner = ts->GetSummonerUnit())
|
||||||
{
|
{
|
||||||
me->AddThreat(summoner, 500000.0f);
|
me->AddThreat(summoner, 500000.0f);
|
||||||
AttackStart(summoner);
|
AttackStart(summoner);
|
||||||
|
|||||||
@@ -2312,7 +2312,7 @@ public:
|
|||||||
bool valid = false;
|
bool valid = false;
|
||||||
me->CastSpell(me, SPELL_RAGING_SPIRIT_VISUAL, true);
|
me->CastSpell(me, SPELL_RAGING_SPIRIT_VISUAL, true);
|
||||||
if (TempSummon* summon = me->ToTempSummon())
|
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())
|
if (summoner->GetTypeId() == TYPEID_PLAYER && summoner->IsAlive() && !summoner->ToPlayer()->IsBeingTeleported() && summoner->FindMap() == me->GetMap())
|
||||||
{
|
{
|
||||||
valid = true;
|
valid = true;
|
||||||
@@ -2373,7 +2373,7 @@ public:
|
|||||||
{
|
{
|
||||||
bool valid = false;
|
bool valid = false;
|
||||||
if (TempSummon* summon = me->ToTempSummon())
|
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())
|
if (summoner->GetTypeId() == TYPEID_PLAYER && summoner->IsAlive() && !summoner->ToPlayer()->IsBeingTeleported() && summoner->FindMap() == me->GetMap())
|
||||||
{
|
{
|
||||||
valid = true;
|
valid = true;
|
||||||
@@ -3038,7 +3038,7 @@ public:
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (TempSummon* summon = GetCaster()->ToTempSummon())
|
if (TempSummon* summon = GetCaster()->ToTempSummon())
|
||||||
if (Unit* summoner = summon->GetSummoner())
|
if (Unit* summoner = summon->GetSummonerUnit())
|
||||||
summoner->GetAI()->SetData(DATA_VILE, 1);
|
summoner->GetAI()->SetData(DATA_VILE, 1);
|
||||||
|
|
||||||
if (Creature* c = GetCaster()->ToCreature())
|
if (Creature* c = GetCaster()->ToCreature())
|
||||||
@@ -3154,7 +3154,7 @@ public:
|
|||||||
|
|
||||||
if (TempSummon* summ = me->ToTempSummon())
|
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());
|
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())
|
if (summoner->GetTypeId() == TYPEID_PLAYER && !summoner->ToPlayer()->IsBeingTeleported() && summoner->FindMap() == me->GetMap())
|
||||||
@@ -3191,7 +3191,7 @@ public:
|
|||||||
me->GetMotionMaster()->Clear(false);
|
me->GetMotionMaster()->Clear(false);
|
||||||
me->GetMotionMaster()->MoveIdle();
|
me->GetMotionMaster()->MoveIdle();
|
||||||
if (TempSummon* summ = me->ToTempSummon())
|
if (TempSummon* summ = me->ToTempSummon())
|
||||||
if (Unit* summoner = summ->GetSummoner())
|
if (Unit* summoner = summ->GetSummonerUnit())
|
||||||
{
|
{
|
||||||
if (summoner->IsAlive() && summoner->GetTypeId() == TYPEID_PLAYER)
|
if (summoner->IsAlive() && summoner->GetTypeId() == TYPEID_PLAYER)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -663,7 +663,7 @@ public:
|
|||||||
timer = 2500;
|
timer = 2500;
|
||||||
if (me->IsSummon())
|
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)))
|
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);
|
me->DespawnOrUnsummon(2000);
|
||||||
|
|||||||
@@ -2405,7 +2405,7 @@ public:
|
|||||||
case SPELL_WATER_SPRAY:
|
case SPELL_WATER_SPRAY:
|
||||||
{
|
{
|
||||||
if (me->IsSummon())
|
if (me->IsSummon())
|
||||||
if (Unit* summoner = me->ToTempSummon()->GetSummoner())
|
if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit())
|
||||||
if (Creature* c = summoner->ToCreature())
|
if (Creature* c = summoner->ToCreature())
|
||||||
if (c->AI())
|
if (c->AI())
|
||||||
CAST_AI(npc_ulduar_flames_initial::npc_ulduar_flames_initialAI, c->AI())->RemoveFlame(me->GetGUID());
|
CAST_AI(npc_ulduar_flames_initial::npc_ulduar_flames_initialAI, c->AI())->RemoveFlame(me->GetGUID());
|
||||||
|
|||||||
@@ -1769,7 +1769,7 @@ public:
|
|||||||
void JustDied(Unit*) override
|
void JustDied(Unit*) override
|
||||||
{
|
{
|
||||||
if (me->IsSummon())
|
if (me->IsSummon())
|
||||||
if (Unit* sara = me->ToTempSummon()->GetSummoner())
|
if (Unit* sara = me->ToTempSummon()->GetSummonerUnit())
|
||||||
sara->GetAI()->DoAction(ACTION_INFLUENCE_TENTACLE_DIED);
|
sara->GetAI()->DoAction(ACTION_INFLUENCE_TENTACLE_DIED);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public:
|
|||||||
npc_frost_tombAI(Creature* c) : NullCreatureAI(c)
|
npc_frost_tombAI(Creature* c) : NullCreatureAI(c)
|
||||||
{
|
{
|
||||||
if (TempSummon* t = c->ToTempSummon())
|
if (TempSummon* t = c->ToTempSummon())
|
||||||
if (Unit* s = t->GetSummoner())
|
if (Unit* s = t->GetSummonerUnit())
|
||||||
{
|
{
|
||||||
PrisonerGUID = s->GetGUID();
|
PrisonerGUID = s->GetGUID();
|
||||||
if( me->GetInstanceScript() && me->GetInstanceScript()->instance->IsHeroic() )
|
if( me->GetInstanceScript() && me->GetInstanceScript()->instance->IsHeroic() )
|
||||||
|
|||||||
@@ -229,7 +229,7 @@ public:
|
|||||||
checkTimer = 5000;
|
checkTimer = 5000;
|
||||||
bool good = false;
|
bool good = false;
|
||||||
if (me->IsSummon())
|
if (me->IsSummon())
|
||||||
if (Unit* s = me->ToTempSummon()->GetSummoner())
|
if (Unit* s = me->ToTempSummon()->GetSummonerUnit())
|
||||||
if (s->IsAlive())
|
if (s->IsAlive())
|
||||||
good = true;
|
good = true;
|
||||||
if (!good)
|
if (!good)
|
||||||
|
|||||||
@@ -310,7 +310,7 @@ public:
|
|||||||
void InitializeAI() override
|
void InitializeAI() override
|
||||||
{
|
{
|
||||||
if (me->ToTempSummon())
|
if (me->ToTempSummon())
|
||||||
if (Unit* summoner = me->ToTempSummon()->GetSummoner())
|
if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit())
|
||||||
{
|
{
|
||||||
summonerGUID = summoner->GetGUID();
|
summonerGUID = summoner->GetGUID();
|
||||||
float x, y, z;
|
float x, y, z;
|
||||||
@@ -478,8 +478,8 @@ public:
|
|||||||
|
|
||||||
void Reset() override
|
void Reset() override
|
||||||
{
|
{
|
||||||
if (me->ToTempSummon() && me->ToTempSummon()->GetSummoner())
|
if (me->ToTempSummon() && me->ToTempSummon()->GetSummonerUnit())
|
||||||
me->setFaction(me->ToTempSummon()->GetSummoner()->getFaction());
|
me->setFaction(me->ToTempSummon()->GetSummonerUnit()->getFaction());
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoveInLineOfSight(Unit* who) override
|
void MoveInLineOfSight(Unit* who) override
|
||||||
@@ -568,7 +568,7 @@ public:
|
|||||||
me->RemoveAllAuras();
|
me->RemoveAllAuras();
|
||||||
me->DespawnOrUnsummon(1000);
|
me->DespawnOrUnsummon(1000);
|
||||||
if (TempSummon* summon = me->ToTempSummon())
|
if (TempSummon* summon = me->ToTempSummon())
|
||||||
if (Unit* owner = summon->GetSummoner())
|
if (Unit* owner = summon->GetSummonerUnit())
|
||||||
if (Player* player = owner->ToPlayer())
|
if (Player* player = owner->ToPlayer())
|
||||||
player->KilledMonsterCredit(me->GetEntry());
|
player->KilledMonsterCredit(me->GetEntry());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public:
|
|||||||
{
|
{
|
||||||
me->SetDisableGravity(true);
|
me->SetDisableGravity(true);
|
||||||
if (me->IsSummon())
|
if (me->IsSummon())
|
||||||
if (Unit* owner = me->ToTempSummon()->GetSummoner())
|
if (Unit* owner = me->ToTempSummon()->GetSummonerUnit())
|
||||||
me->GetMotionMaster()->MovePoint(0, *owner);
|
me->GetMotionMaster()->MovePoint(0, *owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -49,7 +49,7 @@ public:
|
|||||||
cow->CastSpell(cow, 44460, true);
|
cow->CastSpell(cow, 44460, true);
|
||||||
cow->DespawnOrUnsummon(10000);
|
cow->DespawnOrUnsummon(10000);
|
||||||
if (me->IsSummon())
|
if (me->IsSummon())
|
||||||
if (Unit* owner = me->ToTempSummon()->GetSummoner())
|
if (Unit* owner = me->ToTempSummon()->GetSummonerUnit())
|
||||||
owner->CastSpell(owner, 44463, true);
|
owner->CastSpell(owner, 44463, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -101,7 +101,7 @@ public:
|
|||||||
|
|
||||||
void setphase(short newPhase)
|
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)
|
if (!summoner || summoner->GetTypeId() != TYPEID_PLAYER)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -271,7 +271,7 @@ public:
|
|||||||
{
|
{
|
||||||
ObjectGuid summonerGUID;
|
ObjectGuid summonerGUID;
|
||||||
if (me->IsSummon())
|
if (me->IsSummon())
|
||||||
if (Unit* summoner = me->ToTempSummon()->GetSummoner())
|
if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit())
|
||||||
if (summoner->GetTypeId() == TYPEID_PLAYER)
|
if (summoner->GetTypeId() == TYPEID_PLAYER)
|
||||||
summonerGUID = summoner->GetGUID();
|
summonerGUID = summoner->GetGUID();
|
||||||
|
|
||||||
|
|||||||
@@ -1258,7 +1258,7 @@ public:
|
|||||||
Unit* GetSummoner()
|
Unit* GetSummoner()
|
||||||
{
|
{
|
||||||
if (TempSummon* tempSummon = me->ToTempSummon())
|
if (TempSummon* tempSummon = me->ToTempSummon())
|
||||||
return tempSummon->GetSummoner();
|
return tempSummon->GetSummonerUnit();
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2072,7 +2072,7 @@ public:
|
|||||||
|
|
||||||
if (id == POINT_GRAB_DECOY)
|
if (id == POINT_GRAB_DECOY)
|
||||||
if (TempSummon* summon = me->ToTempSummon())
|
if (TempSummon* summon = me->ToTempSummon())
|
||||||
if (Unit* summoner = summon->GetSummoner())
|
if (Unit* summoner = summon->GetSummonerUnit())
|
||||||
DoCast(summoner, SPELL_GRAB);
|
DoCast(summoner, SPELL_GRAB);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -680,7 +680,7 @@ public:
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (TempSummon* summ = me->ToTempSummon())
|
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());
|
me->GetMotionMaster()->MovePoint(0, summoner->GetPositionX(), summoner->GetPositionY(), summoner->GetPositionZ());
|
||||||
|
|
||||||
Reset();
|
Reset();
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ public:
|
|||||||
break;
|
break;
|
||||||
case 19:
|
case 19:
|
||||||
me->MonsterTextEmote("The frosthound has located the thief's hiding place. Confront him!", 0, true);
|
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);
|
summoner->ToPlayer()->KilledMonsterCredit(29677);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ public:
|
|||||||
ghoul->GetMotionMaster()->MoveTargetedHome();
|
ghoul->GetMotionMaster()->MoveTargetedHome();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Unit* owner = me->ToTempSummon()->GetSummoner())
|
if (Unit* owner = me->ToTempSummon()->GetSummonerUnit())
|
||||||
if (Player* player = owner->ToPlayer())
|
if (Player* player = owner->ToPlayer())
|
||||||
player->KilledMonsterCredit(me->GetEntry());
|
player->KilledMonsterCredit(me->GetEntry());
|
||||||
|
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ public:
|
|||||||
bool Execute(uint64 /*eventTime*/, uint32 /*diff*/) override
|
bool Execute(uint64 /*eventTime*/, uint32 /*diff*/) override
|
||||||
{
|
{
|
||||||
if (_owner.IsSummon())
|
if (_owner.IsSummon())
|
||||||
if (Unit* summoner = _owner.ToTempSummon()->GetSummoner())
|
if (Unit* summoner = _owner.ToTempSummon()->GetSummonerUnit())
|
||||||
{
|
{
|
||||||
summoner->GetAI()->DoAction(_action);
|
summoner->GetAI()->DoAction(_action);
|
||||||
_owner.SetStandState(UNIT_STAND_STATE_SUBMERGED);
|
_owner.SetStandState(UNIT_STAND_STATE_SUBMERGED);
|
||||||
@@ -514,7 +514,7 @@ public:
|
|||||||
{
|
{
|
||||||
Talk(ANGER_SAY_DEATH);
|
Talk(ANGER_SAY_DEATH);
|
||||||
if (me->IsSummon())
|
if (me->IsSummon())
|
||||||
if (Unit* summoner = me->ToTempSummon()->GetSummoner())
|
if (Unit* summoner = me->ToTempSummon()->GetSummonerUnit())
|
||||||
Unit::Kill(summoner, summoner);
|
Unit::Kill(summoner, summoner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -648,7 +648,7 @@ public:
|
|||||||
NullCreatureAI::InitializeAI();
|
NullCreatureAI::InitializeAI();
|
||||||
|
|
||||||
if (TempSummon* summon = me->ToTempSummon())
|
if (TempSummon* summon = me->ToTempSummon())
|
||||||
if (Unit* owner = summon->GetSummoner())
|
if (Unit* owner = summon->GetSummonerUnit())
|
||||||
if (owner->GetTypeId() == TYPEID_PLAYER)
|
if (owner->GetTypeId() == TYPEID_PLAYER)
|
||||||
{
|
{
|
||||||
_ownerGUID = owner->GetGUID();
|
_ownerGUID = owner->GetGUID();
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public:
|
|||||||
|
|
||||||
void InitializeAI() override
|
void InitializeAI() override
|
||||||
{
|
{
|
||||||
if (Unit* owner = me->ToTempSummon()->GetSummoner())
|
if (Unit* owner = me->ToTempSummon()->GetSummonerUnit())
|
||||||
{
|
{
|
||||||
uint32 hp = uint32(owner->GetMaxHealth() * 0.3f);
|
uint32 hp = uint32(owner->GetMaxHealth() * 0.3f);
|
||||||
me->SetMaxHealth(hp);
|
me->SetMaxHealth(hp);
|
||||||
@@ -75,7 +75,7 @@ public:
|
|||||||
void JustDied(Unit* /*killer*/) override
|
void JustDied(Unit* /*killer*/) override
|
||||||
{
|
{
|
||||||
if (me->IsSummon())
|
if (me->IsSummon())
|
||||||
if (Unit* owner = me->ToTempSummon()->GetSummoner())
|
if (Unit* owner = me->ToTempSummon()->GetSummonerUnit())
|
||||||
if (owner->HasAura(SPELL_PRIEST_GLYPH_OF_SHADOWFIEND))
|
if (owner->HasAura(SPELL_PRIEST_GLYPH_OF_SHADOWFIEND))
|
||||||
owner->CastSpell(owner, SPELL_PRIEST_GLYPH_OF_SHADOWFIEND_MANA, true);
|
owner->CastSpell(owner, SPELL_PRIEST_GLYPH_OF_SHADOWFIEND_MANA, true);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -851,7 +851,7 @@ public:
|
|||||||
void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
|
void HandleEffectApply(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
|
||||||
{
|
{
|
||||||
PreventDefaultAction();
|
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, owner->GetUInt32Value(PLAYER_VISIBLE_ITEM_16_ENTRYID));
|
||||||
GetUnitOwner()->SetUInt32Value(UNIT_VIRTUAL_ITEM_SLOT_ID + 1, owner->GetUInt32Value(PLAYER_VISIBLE_ITEM_17_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: chance of success stores proper amount of damage increase
|
||||||
// xinef: little hack because GetSpellModOwner will return nullptr pointer at this point (early summoning stage)
|
// xinef: little hack because GetSpellModOwner will return nullptr pointer at this point (early summoning stage)
|
||||||
if (GetUnitOwner()->IsSummon())
|
if (GetUnitOwner()->IsSummon())
|
||||||
if (Unit* owner = GetUnitOwner()->ToTempSummon()->GetSummoner())
|
if (Unit* owner = GetUnitOwner()->ToTempSummon()->GetSummonerUnit())
|
||||||
if (Player* player = owner->GetSpellModOwner())
|
if (Player* player = owner->GetSpellModOwner())
|
||||||
player->ApplySpellMod(SPELL_DRUID_BARKSKIN, SPELLMOD_CHANCE_OF_SUCCESS, amount);
|
player->ApplySpellMod(SPELL_DRUID_BARKSKIN, SPELLMOD_CHANCE_OF_SUCCESS, amount);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3847,7 +3847,7 @@ public:
|
|||||||
{
|
{
|
||||||
if (Unit* caster = GetCaster())
|
if (Unit* caster = GetCaster())
|
||||||
if (TempSummon* vehicle = caster->ToTempSummon())
|
if (TempSummon* vehicle = caster->ToTempSummon())
|
||||||
if (Unit* rider = vehicle->GetSummoner())
|
if (Unit* rider = vehicle->GetSummonerUnit())
|
||||||
rider->RemoveAurasDueToSpell(GetId());
|
rider->RemoveAurasDueToSpell(GetId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -580,7 +580,7 @@ public:
|
|||||||
if (Unit* unitTarget = GetHitUnit())
|
if (Unit* unitTarget = GetHitUnit())
|
||||||
if (AuraEffect* aur = unitTarget->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_PRIEST, 0x8000, 0, 0, GetCaster()->GetGUID()))
|
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);
|
aur->ChangeAmount(aur->CalculateAmount(aur->GetCaster()), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -239,7 +239,7 @@ public:
|
|||||||
void HandleScriptEffect(SpellEffIndex /*effIndex*/)
|
void HandleScriptEffect(SpellEffIndex /*effIndex*/)
|
||||||
{
|
{
|
||||||
if (Unit* target = GetHitUnit())
|
if (Unit* target = GetHitUnit())
|
||||||
if (Unit* owner = target->ToTempSummon()->GetSummoner())
|
if (Unit* owner = target->ToTempSummon()->GetSummonerUnit())
|
||||||
if (owner->GetTypeId() == TYPEID_PLAYER)
|
if (owner->GetTypeId() == TYPEID_PLAYER)
|
||||||
owner->ToPlayer()->KilledMonsterCredit(23327); // Some trigger, just count
|
owner->ToPlayer()->KilledMonsterCredit(23327); // Some trigger, just count
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -764,7 +764,7 @@ public:
|
|||||||
// Refresh corruption on target
|
// Refresh corruption on target
|
||||||
if (AuraEffect* aur = unitTarget->GetAuraEffect(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_WARLOCK, 0x2, 0, 0, GetCaster()->GetGUID()))
|
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);
|
aur->ChangeAmount(aur->CalculateAmount(aur->GetCaster()), false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1707,7 +1707,7 @@ public:
|
|||||||
{
|
{
|
||||||
if (creature->IsSummon())
|
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_ENGINEERING1, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
|
||||||
AddGossipItemFor(player, GOSSIP_ICON_CHAT, GOSSIP_ENGINEERING2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2);
|
AddGossipItemFor(player, GOSSIP_ICON_CHAT, GOSSIP_ENGINEERING2, GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2);
|
||||||
|
|||||||
Reference in New Issue
Block a user