AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
SpellCastTargets Class Reference

#include "Spell.h"

Public Member Functions

 SpellCastTargets ()
 
 ~SpellCastTargets ()
 
void Read (ByteBuffer &data, Unit *caster)
 
void Write (ByteBuffer &data)
 
uint32 GetTargetMask () const
 
void SetTargetMask (uint32 newMask)
 
void SetTargetFlag (SpellCastTargetFlags flag)
 
ObjectGuid GetUnitTargetGUID () const
 
UnitGetUnitTarget () const
 
void SetUnitTarget (Unit *target)
 
ObjectGuid GetGOTargetGUID () const
 
GameObjectGetGOTarget () const
 
void SetGOTarget (GameObject *target)
 
ObjectGuid GetCorpseTargetGUID () const
 
CorpseGetCorpseTarget () const
 
void SetCorpseTarget (Corpse *target)
 
WorldObjectGetObjectTarget () const
 
ObjectGuid GetObjectTargetGUID () const
 
void RemoveObjectTarget ()
 
ObjectGuid GetItemTargetGUID () const
 
ItemGetItemTarget () const
 
uint32 GetItemTargetEntry () const
 
void SetItemTarget (Item *item)
 
void SetTradeItemTarget (Player *caster)
 
void UpdateTradeSlotItem ()
 
SpellDestination const * GetSrc () const
 
Position const * GetSrcPos () const
 
void SetSrc (float x, float y, float z)
 
void SetSrc (Position const &pos)
 
void SetSrc (WorldObject const &wObj)
 
void ModSrc (Position const &pos)
 
void RemoveSrc ()
 
SpellDestination const * GetDst () const
 
WorldLocation const * GetDstPos () const
 
void SetDst (float x, float y, float z, float orientation, uint32 mapId=MAPID_INVALID)
 
void SetDst (Position const &pos)
 
void SetDst (WorldObject const &wObj)
 
void SetDst (SpellDestination const &spellDest)
 
void SetDst (SpellCastTargets const &spellTargets)
 
void ModDst (Position const &pos)
 
void ModDst (SpellDestination const &spellDest)
 
void RemoveDst ()
 
bool HasSrc () const
 
bool HasDst () const
 
bool HasTraj () const
 
float GetElevation () const
 
void SetElevation (float elevation)
 
float GetSpeed () const
 
void SetSpeed (float speed)
 
float GetDist2d () const
 
float GetSpeedXY () const
 
float GetSpeedZ () const
 
void Update (Unit *caster)
 
void OutDebug () const
 
void SetObjectTargetChannel (ObjectGuid targetGUID)
 
void SetDstChannel (SpellDestination const &spellDest)
 
WorldObjectGetObjectTargetChannel (Unit *caster) const
 
bool HasDstChannel () const
 
SpellDestination const * GetDstChannel () const
 

Private Attributes

uint32 m_targetMask
 
WorldObjectm_objectTarget
 
Itemm_itemTarget
 
ObjectGuid m_objectTargetGUID
 
ObjectGuid m_itemTargetGUID
 
uint32 m_itemTargetEntry
 
SpellDestination m_src
 
SpellDestination m_dst
 
float m_elevation
 
float m_speed
 
std::string m_strTarget
 
SpellDestination m_dstChannel
 
ObjectGuid m_objectTargetGUIDChannel
 

Detailed Description

Constructor & Destructor Documentation

◆ SpellCastTargets()

SpellCastTargets::SpellCastTargets ( )
114{
115 m_objectTarget = nullptr;
116 m_itemTarget = nullptr;
117
119
120 m_targetMask = 0;
121}
std::string m_strTarget
Definition: Spell.h:203
float m_speed
Definition: Spell.h:202
float m_elevation
Definition: Spell.h:202
uint32 m_targetMask
Definition: Spell.h:188
WorldObject * m_objectTarget
Definition: Spell.h:191
uint32 m_itemTargetEntry
Definition: Spell.h:197
Item * m_itemTarget
Definition: Spell.h:192

References m_itemTarget, m_itemTargetEntry, m_objectTarget, and m_targetMask.

◆ ~SpellCastTargets()

SpellCastTargets::~SpellCastTargets ( )
124{
125}

Member Function Documentation

◆ GetCorpseTarget()

Corpse * SpellCastTargets::GetCorpseTarget ( ) const
296{
297 if (m_objectTarget)
298 return m_objectTarget->ToCorpse();
299 return nullptr;
300}
Corpse * ToCorpse()
Definition: Object.h:214

References m_objectTarget, and Object::ToCorpse().

Referenced by Spell::SelectEffectTypeImplicitTargets().

◆ GetCorpseTargetGUID()

ObjectGuid SpellCastTargets::GetCorpseTargetGUID ( ) const
283{
284 switch (m_objectTargetGUID.GetHigh())
285 {
286 case HighGuid::Corpse:
287 return m_objectTargetGUID;
288 default:
289 break;
290 }
291
292 return ObjectGuid::Empty;
293}
static ObjectGuid const Empty
Definition: ObjectGuid.h:120
HighGuid GetHigh() const
Definition: ObjectGuid.h:143
ObjectGuid m_objectTargetGUID
Definition: Spell.h:195

References ObjectGuid::Empty, ObjectGuid::GetHigh(), and m_objectTargetGUID.

Referenced by Spell::CheckEffectTarget().

◆ GetDist2d()

float SpellCastTargets::GetDist2d ( ) const
inline
float GetExactDist2d(const float x, const float y) const
Definition: Position.h:166
WorldLocation _position
Definition: Spell.h:103
SpellDestination m_dst
Definition: Spell.h:200
SpellDestination m_src
Definition: Spell.h:199

References SpellDestination::_position, Position::GetExactDist2d(), m_dst, and m_src.

Referenced by Spell::CalculateDelayMomentForDst(), and Spell::SelectImplicitTrajTargets().

◆ GetDst()

SpellDestination const * SpellCastTargets::GetDst ( ) const

◆ GetDstChannel()

SpellDestination const * SpellCastTargets::GetDstChannel ( ) const
476{
477 return &m_dstChannel;
478}
SpellDestination m_dstChannel
Definition: Spell.h:206

References m_dstChannel.

Referenced by Spell::SelectImplicitChannelTargets().

◆ GetDstPos()

◆ GetElevation()

float SpellCastTargets::GetElevation ( ) const
inline

◆ GetGOTarget()

GameObject * SpellCastTargets::GetGOTarget ( ) const

◆ GetGOTargetGUID()

ObjectGuid SpellCastTargets::GetGOTargetGUID ( ) const
251{
252 switch (m_objectTargetGUID.GetHigh())
253 {
254 case HighGuid::Transport:
255 case HighGuid::Mo_Transport:
256 case HighGuid::GameObject:
257 return m_objectTargetGUID;
258 default:
259 break;
260 }
261
262 return ObjectGuid::Empty;
263}

References ObjectGuid::Empty, ObjectGuid::GetHigh(), and m_objectTargetGUID.

◆ GetItemTarget()

◆ GetItemTargetEntry()

uint32 SpellCastTargets::GetItemTargetEntry ( ) const
inline
140{ return m_itemTargetEntry; }

References m_itemTargetEntry.

Referenced by Spell::CheckItems(), and Spell::TakeReagents().

◆ GetItemTargetGUID()

ObjectGuid SpellCastTargets::GetItemTargetGUID ( ) const
inline
138{ return m_itemTargetGUID; }
ObjectGuid m_itemTargetGUID
Definition: Spell.h:196

References m_itemTargetGUID.

Referenced by Spell::CheckCast(), and Spell::CheckItems().

◆ GetObjectTarget()

◆ GetObjectTargetChannel()

WorldObject * SpellCastTargets::GetObjectTargetChannel ( Unit caster) const
466{
468}
WorldObject * GetWorldObject(WorldObject const &, ObjectGuid const guid)
Definition: ObjectAccessor.cpp:118
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:109
ObjectGuid m_objectTargetGUIDChannel
Definition: Spell.h:207

References Object::GetGUID(), ObjectAccessor::GetWorldObject(), and m_objectTargetGUIDChannel.

Referenced by Spell::SelectImplicitChannelTargets().

◆ GetObjectTargetGUID()

ObjectGuid SpellCastTargets::GetObjectTargetGUID ( ) const
318{
319 return m_objectTargetGUID;
320}

References m_objectTargetGUID.

Referenced by Spell::_cast(), and Spell::SendChannelStart().

◆ GetSpeed()

float SpellCastTargets::GetSpeed ( ) const
inline
170{ return m_speed; }

References m_speed.

◆ GetSpeedXY()

float SpellCastTargets::GetSpeedXY ( ) const
inline

◆ GetSpeedZ()

float SpellCastTargets::GetSpeedZ ( ) const
inline
175{ return m_speed * std::sin(m_elevation); }

References m_elevation, and m_speed.

Referenced by spell_vehicle_throw_passenger::HandleScript().

◆ GetSrc()

SpellDestination const * SpellCastTargets::GetSrc ( ) const
359{
360 return &m_src;
361}

References m_src.

◆ GetSrcPos()

Position const * SpellCastTargets::GetSrcPos ( ) const

◆ GetTargetMask()

uint32 SpellCastTargets::GetTargetMask ( ) const
inline

◆ GetUnitTarget()

◆ GetUnitTargetGUID()

ObjectGuid SpellCastTargets::GetUnitTargetGUID ( ) const
218{
219 switch (m_objectTargetGUID.GetHigh())
220 {
221 case HighGuid::Player:
222 case HighGuid::Vehicle:
223 case HighGuid::Unit:
224 case HighGuid::Pet:
225 return m_objectTargetGUID;
226 default:
227 break;
228 }
229
230 return ObjectGuid::Empty;
231}

References ObjectGuid::Empty, ObjectGuid::GetHigh(), and m_objectTargetGUID.

Referenced by Spell::DoAllEffectOnTarget(), Spell::TakePower(), and Spell::update().

◆ HasDst()

◆ HasDstChannel()

bool SpellCastTargets::HasDstChannel ( ) const
471{
472 return m_dstChannel._position.GetExactDist(0, 0, 0) > 0.001f;
473}
float GetExactDist(float x, float y, float z) const
Definition: Position.h:178

References SpellDestination::_position, Position::GetExactDist(), and m_dstChannel.

Referenced by Unit::DealDamage(), and Spell::SelectImplicitChannelTargets().

◆ HasSrc()

bool SpellCastTargets::HasSrc ( ) const
inline

◆ HasTraj()

bool SpellCastTargets::HasTraj ( ) const
inline

◆ ModDst() [1/2]

void SpellCastTargets::ModDst ( Position const &  pos)

◆ ModDst() [2/2]

void SpellCastTargets::ModDst ( SpellDestination const &  spellDest)

◆ ModSrc()

◆ OutDebug()

void SpellCastTargets::OutDebug ( ) const
534{
535 if (!m_targetMask)
536 LOG_INFO("spells", "No targets");
537
538 LOG_INFO("spells", "target mask: {}", m_targetMask);
540 LOG_INFO("spells", "Object target: {}", m_objectTargetGUID.ToString());
542 LOG_INFO("spells", "Item target: {}", m_itemTargetGUID.ToString());
544 LOG_INFO("spells", "Trade item target: {}", m_itemTargetGUID.ToString());
546 LOG_INFO("spells", "Source location: transport guid: {} trans offset: {} position: {}",
549 LOG_INFO("spells", "Destination location: transport guid: {} trans offset: {} position: {}",
552 LOG_INFO("spells", "String: {}", m_strTarget);
553 LOG_INFO("spells", "speed: {}", m_speed);
554 LOG_INFO("spells", "elevation: {}", m_elevation);
555}
#define LOG_INFO(filterType__,...)
Definition: Log.h:164
@ TARGET_FLAG_TRADE_ITEM
Definition: SpellInfo.h:58
@ TARGET_FLAG_STRING
Definition: SpellInfo.h:59
@ TARGET_FLAG_ITEM
Definition: SpellInfo.h:50
@ TARGET_FLAG_UNIT_MASK
Definition: SpellInfo.h:68
@ TARGET_FLAG_CORPSE_MASK
Definition: SpellInfo.h:71
@ TARGET_FLAG_GAMEOBJECT_MASK
Definition: SpellInfo.h:70
std::string ToString() const
Definition: ObjectGuid.cpp:47
std::string ToString() const
Definition: Position.cpp:51
Position _transportOffset
Definition: Spell.h:105
ObjectGuid _transportGUID
Definition: Spell.h:104

References SpellDestination::_position, SpellDestination::_transportGUID, SpellDestination::_transportOffset, LOG_INFO, m_dst, m_elevation, m_itemTargetGUID, m_objectTargetGUID, m_speed, m_src, m_strTarget, m_targetMask, TARGET_FLAG_CORPSE_MASK, TARGET_FLAG_DEST_LOCATION, TARGET_FLAG_GAMEOBJECT_MASK, TARGET_FLAG_ITEM, TARGET_FLAG_SOURCE_LOCATION, TARGET_FLAG_STRING, TARGET_FLAG_TRADE_ITEM, TARGET_FLAG_UNIT_MASK, ObjectGuid::ToString(), and Position::ToString().

◆ Read()

void SpellCastTargets::Read ( ByteBuffer data,
Unit caster 
)
128{
129 data >> m_targetMask;
130
132 return;
133
136
139
141 {
145 else
147 }
148 else
149 {
153 else
154 m_src._position.Relocate(caster);
155 }
156
158 {
162 else
164 }
165 else
166 {
170 else
171 m_dst._position.Relocate(caster);
172 }
173
175 data >> m_strTarget;
176
177 Update(caster);
178}
@ TARGET_FLAG_GAMEOBJECT
Definition: SpellInfo.h:57
@ TARGET_FLAG_NONE
Definition: SpellInfo.h:45
@ TARGET_FLAG_CORPSE_ALLY
Definition: SpellInfo.h:61
@ TARGET_FLAG_UNIT_MINIPET
Definition: SpellInfo.h:62
@ TARGET_FLAG_UNIT
Definition: SpellInfo.h:47
@ TARGET_FLAG_CORPSE_ENEMY
Definition: SpellInfo.h:55
float GetTransOffsetX() const
Definition: Object.h:600
float GetTransOffsetY() const
Definition: Object.h:601
float GetTransOffsetZ() const
Definition: Object.h:602
float GetTransOffsetO() const
Definition: Object.h:603
PackedGuidReader ReadAsPacked()
Definition: ObjectGuid.h:135
Position::PositionXYZStreamer PositionXYZStream()
Definition: Position.h:145
void Relocate(float x, float y)
Definition: Position.h:73
ObjectGuid GetTransGUID() const override
Definition: Unit.cpp:18712
void Update(Unit *caster)
Definition: Spell.cpp:480

References SpellDestination::_position, SpellDestination::_transportGUID, SpellDestination::_transportOffset, Unit::GetTransGUID(), WorldObject::GetTransOffsetO(), WorldObject::GetTransOffsetX(), WorldObject::GetTransOffsetY(), WorldObject::GetTransOffsetZ(), m_dst, m_itemTargetGUID, m_objectTargetGUID, m_src, m_strTarget, m_targetMask, Position::PositionXYZStream(), ObjectGuid::ReadAsPacked(), Position::Relocate(), TARGET_FLAG_CORPSE_ALLY, TARGET_FLAG_CORPSE_ENEMY, TARGET_FLAG_DEST_LOCATION, TARGET_FLAG_GAMEOBJECT, TARGET_FLAG_ITEM, TARGET_FLAG_NONE, TARGET_FLAG_SOURCE_LOCATION, TARGET_FLAG_STRING, TARGET_FLAG_TRADE_ITEM, TARGET_FLAG_UNIT, TARGET_FLAG_UNIT_MINIPET, and Update().

Referenced by WorldSession::HandleCastSpellOpcode(), WorldSession::HandlePetCastSpellOpcode(), and WorldSession::HandleUseItemOpcode().

◆ RemoveDst()

void SpellCastTargets::RemoveDst ( )

◆ RemoveObjectTarget()

◆ RemoveSrc()

void SpellCastTargets::RemoveSrc ( )

◆ SetCorpseTarget()

void SpellCastTargets::SetCorpseTarget ( Corpse target)
303{
304 if (!target)
305 return;
306
307 m_objectTarget = target;
308 m_objectTargetGUID = target->GetGUID();
310}

References Object::GetGUID(), m_objectTarget, m_objectTargetGUID, m_targetMask, and TARGET_FLAG_CORPSE_MASK.

◆ SetDst() [1/5]

◆ SetDst() [2/5]

void SpellCastTargets::SetDst ( Position const &  pos)

◆ SetDst() [3/5]

void SpellCastTargets::SetDst ( SpellCastTargets const &  spellTargets)
432{
433 m_dst = spellTargets.m_dst;
435}

References m_dst, m_targetMask, and TARGET_FLAG_DEST_LOCATION.

◆ SetDst() [4/5]

void SpellCastTargets::SetDst ( SpellDestination const &  spellDest)
426{
427 m_dst = spellDest;
429}

References m_dst, m_targetMask, and TARGET_FLAG_DEST_LOCATION.

◆ SetDst() [5/5]

void SpellCastTargets::SetDst ( WorldObject const &  wObj)

◆ SetDstChannel()

void SpellCastTargets::SetDstChannel ( SpellDestination const &  spellDest)

◆ SetElevation()

void SpellCastTargets::SetElevation ( float  elevation)
inline

◆ SetGOTarget()

void SpellCastTargets::SetGOTarget ( GameObject target)
273{
274 if (!target)
275 return;
276
277 m_objectTarget = target;
278 m_objectTargetGUID = target->GetGUID();
280}

References Object::GetGUID(), m_objectTarget, m_objectTargetGUID, m_targetMask, and TARGET_FLAG_GAMEOBJECT.

Referenced by Unit::CastSpell().

◆ SetItemTarget()

void SpellCastTargets::SetItemTarget ( Item item)

◆ SetObjectTargetChannel()

void SpellCastTargets::SetObjectTargetChannel ( ObjectGuid  targetGUID)

◆ SetSpeed()

void SpellCastTargets::SetSpeed ( float  speed)
inline

◆ SetSrc() [1/3]

void SpellCastTargets::SetSrc ( float  x,
float  y,
float  z 
)

◆ SetSrc() [2/3]

void SpellCastTargets::SetSrc ( Position const &  pos)

◆ SetSrc() [3/3]

void SpellCastTargets::SetSrc ( WorldObject const &  wObj)

◆ SetTargetFlag()

void SpellCastTargets::SetTargetFlag ( SpellCastTargetFlags  flag)
inline
120{ m_targetMask |= flag; }

References m_targetMask.

Referenced by Spell::SelectSpellTargets().

◆ SetTargetMask()

void SpellCastTargets::SetTargetMask ( uint32  newMask)
inline
118{ m_targetMask = newMask; }

References m_targetMask.

◆ SetTradeItemTarget()

void SpellCastTargets::SetTradeItemTarget ( Player caster)
341{
345
346 Update(caster);
347}
std::uint64_t uint64
Definition: Define.h:106
@ TRADE_SLOT_NONTRADED
Definition: TradeData.h:31
void Set(uint64 guid)
Definition: ObjectGuid.h:137

References m_itemTargetEntry, m_itemTargetGUID, m_targetMask, ObjectGuid::Set(), TARGET_FLAG_TRADE_ITEM, TRADE_SLOT_NONTRADED, and Update().

Referenced by WorldSession::HandleAcceptTradeOpcode().

◆ SetUnitTarget()

◆ Update()

void SpellCastTargets::Update ( Unit caster)
481{
483
484 m_itemTarget = nullptr;
485 if (caster->IsPlayer())
486 {
487 Player* player = caster->ToPlayer();
491 if (m_itemTargetGUID.GetRawValue() == TRADE_SLOT_NONTRADED) // here it is not guid but slot. Also prevents hacking slots
492 if (TradeData* pTrade = player->GetTradeData())
493 m_itemTarget = pTrade->GetTraderData()->GetItem(TRADE_SLOT_NONTRADED);
494
495 if (m_itemTarget)
497 }
498
499 // update positions by transport move
500 if (HasSrc() && m_src._transportGUID)
501 {
503 {
504 m_src._position.Relocate(transport);
506 }
507 }
508
509 if (HasDst() && m_dst._transportGUID)
510 {
512 {
513 m_dst._position.Relocate(transport);
515 }
516 }
517}
bool IsPlayer() const
Definition: Object.h:197
Player * ToPlayer()
Definition: Object.h:198
Definition: Object.h:405
uint64 GetRawValue() const
Definition: ObjectGuid.h:142
void RelocateOffset(const Position &offset)
Definition: Position.cpp:58
Definition: Player.h:1064
TradeData * GetTradeData() const
Definition: Player.h:1368
Item * GetItemByGuid(ObjectGuid guid) const
Definition: PlayerStorage.cpp:413
Definition: TradeData.h:36
bool HasSrc() const
Definition: Spell.h:164
bool HasDst() const
Definition: Spell.h:165

References SpellDestination::_position, SpellDestination::_transportGUID, SpellDestination::_transportOffset, Object::GetEntry(), Object::GetGUID(), Player::GetItemByGuid(), ObjectGuid::GetRawValue(), Player::GetTradeData(), ObjectAccessor::GetWorldObject(), HasDst(), HasSrc(), Object::IsPlayer(), m_dst, m_itemTarget, m_itemTargetEntry, m_itemTargetGUID, m_objectTarget, m_objectTargetGUID, m_src, m_targetMask, Position::Relocate(), Position::RelocateOffset(), TARGET_FLAG_ITEM, TARGET_FLAG_TRADE_ITEM, Object::ToPlayer(), and TRADE_SLOT_NONTRADED.

Referenced by Read(), SetTradeItemTarget(), and Spell::UpdatePointers().

◆ UpdateTradeSlotItem()

◆ Write()

void SpellCastTargets::Write ( ByteBuffer data)
181{
182 data << uint32(m_targetMask);
183
186
188 {
189 if (m_itemTarget)
190 data << m_itemTarget->GetPackGUID();
191 else
192 data << uint8(0);
193 }
194
196 {
197 data << m_src._transportGUID.WriteAsPacked(); // relative position guid here - transport for example
200 else
202 }
203
205 {
206 data << m_dst._transportGUID.WriteAsPacked(); // relative position guid here - transport for example
209 else
211 }
212
214 data << m_strTarget;
215}
std::uint8_t uint8
Definition: Define.h:109
std::uint32_t uint32
Definition: Define.h:107
PackedGuid const & GetPackGUID() const
Definition: Object.h:111
PackedGuid WriteAsPacked() const
Definition: ObjectGuid.h:316

References SpellDestination::_position, SpellDestination::_transportGUID, SpellDestination::_transportOffset, Object::GetPackGUID(), m_dst, m_itemTarget, m_objectTargetGUID, m_src, m_strTarget, m_targetMask, Position::PositionXYZStream(), TARGET_FLAG_CORPSE_ALLY, TARGET_FLAG_CORPSE_ENEMY, TARGET_FLAG_DEST_LOCATION, TARGET_FLAG_GAMEOBJECT, TARGET_FLAG_ITEM, TARGET_FLAG_SOURCE_LOCATION, TARGET_FLAG_STRING, TARGET_FLAG_TRADE_ITEM, TARGET_FLAG_UNIT, TARGET_FLAG_UNIT_MINIPET, and ObjectGuid::WriteAsPacked().

Referenced by Spell::SendSpellGo(), and Spell::SendSpellStart().

Member Data Documentation

◆ m_dst

SpellDestination SpellCastTargets::m_dst
private

◆ m_dstChannel

SpellDestination SpellCastTargets::m_dstChannel
private

◆ m_elevation

float SpellCastTargets::m_elevation
private

◆ m_itemTarget

Item* SpellCastTargets::m_itemTarget
private

◆ m_itemTargetEntry

uint32 SpellCastTargets::m_itemTargetEntry
private

◆ m_itemTargetGUID

ObjectGuid SpellCastTargets::m_itemTargetGUID
private

◆ m_objectTarget

◆ m_objectTargetGUID

◆ m_objectTargetGUIDChannel

ObjectGuid SpellCastTargets::m_objectTargetGUIDChannel
private

◆ m_speed

float SpellCastTargets::m_speed
private

◆ m_src

SpellDestination SpellCastTargets::m_src
private

◆ m_strTarget

std::string SpellCastTargets::m_strTarget
private

Referenced by OutDebug(), Read(), and Write().

◆ m_targetMask