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, WorldObject *caster)
 
void Write (ByteBuffer &data)
 
uint32 GetTargetMask () const
 
void SetTargetMask (uint32 newMask)
 
void SetTargetFlag (SpellCastTargetFlags flag)
 
ObjectGuid GetUnitTargetGUID () const
 
Unit * GetUnitTarget () const
 
void SetUnitTarget (Unit *target)
 
ObjectGuid GetGOTargetGUID () const
 
GameObject * GetGOTarget () const
 
void SetGOTarget (GameObject *target)
 
ObjectGuid GetCorpseTargetGUID () const
 
Corpse * GetCorpseTarget () const
 
void SetCorpseTarget (Corpse *target)
 
WorldObject * GetObjectTarget () const
 
ObjectGuid GetObjectTargetGUID () const
 
void RemoveObjectTarget ()
 
ObjectGuid GetItemTargetGUID () const
 
Item * GetItemTarget () 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 (WorldObject *caster)
 
void OutDebug () const
 
void SetObjectTargetChannel (ObjectGuid targetGUID)
 
void SetDstChannel (SpellDestination const &spellDest)
 
WorldObject * GetObjectTargetChannel (WorldObject *caster) const
 
bool HasDstChannel () const
 
SpellDestination const * GetDstChannel () const
 

Private Attributes

uint32 m_targetMask
 
WorldObject * m_objectTarget
 
Item * m_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 ( )
150{
151 m_objectTarget = nullptr;
152 m_itemTarget = nullptr;
153
155
156 m_targetMask = 0;
157}
std::string m_strTarget
Definition Spell.h:215
float m_speed
Definition Spell.h:214
float m_elevation
Definition Spell.h:214
uint32 m_targetMask
Definition Spell.h:200
WorldObject * m_objectTarget
Definition Spell.h:203
uint32 m_itemTargetEntry
Definition Spell.h:209
Item * m_itemTarget
Definition Spell.h:204

◆ ~SpellCastTargets()

SpellCastTargets::~SpellCastTargets ( )
160{
161}

Member Function Documentation

◆ GetCorpseTarget()

Corpse * SpellCastTargets::GetCorpseTarget ( ) const
332{
333 if (m_objectTarget)
334 return m_objectTarget->ToCorpse();
335 return nullptr;
336}
Corpse * ToCorpse()
Definition Object.h:224

References m_objectTarget, and Object::ToCorpse().

Referenced by Spell::SelectEffectTypeImplicitTargets().

◆ GetCorpseTargetGUID()

ObjectGuid SpellCastTargets::GetCorpseTargetGUID ( ) const
319{
320 switch (m_objectTargetGUID.GetHigh())
321 {
322 case HighGuid::Corpse:
323 return m_objectTargetGUID;
324 default:
325 break;
326 }
327
328 return ObjectGuid::Empty;
329}
static ObjectGuid const Empty
Definition ObjectGuid.h:123
HighGuid GetHigh() const
Definition ObjectGuid.h:146
ObjectGuid m_objectTargetGUID
Definition Spell.h:207

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

Referenced by Spell::CheckEffectTarget().

◆ GetDist2d()

float SpellCastTargets::GetDist2d ( ) const
inline
SpellDestination m_dst
Definition Spell.h:212
SpellDestination m_src
Definition Spell.h:211
float GetExactDist2d(const float x, const float y) const
Definition Position.h:170
WorldLocation _position
Definition Spell.h:115

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

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

◆ GetDst()

SpellDestination const * SpellCastTargets::GetDst ( ) const
434{
435 return &m_dst;
436}

References m_dst.

Referenced by Spell::SelectImplicitDestDestTargets(), and Spell::SelectSpellTargets().

◆ GetDstChannel()

SpellDestination const * SpellCastTargets::GetDstChannel ( ) const
512{
513 return &m_dstChannel;
514}
SpellDestination m_dstChannel
Definition Spell.h:218

References m_dstChannel.

Referenced by Spell::SelectImplicitChannelTargets().

◆ GetDstPos()

◆ GetElevation()

float SpellCastTargets::GetElevation ( ) const
inline

◆ GetGOTarget()

GameObject * SpellCastTargets::GetGOTarget ( ) const

◆ GetGOTargetGUID()

ObjectGuid SpellCastTargets::GetGOTargetGUID ( ) const
287{
288 switch (m_objectTargetGUID.GetHigh())
289 {
293 return m_objectTargetGUID;
294 default:
295 break;
296 }
297
298 return ObjectGuid::Empty;
299}

References ObjectGuid::Empty, GameObject, ObjectGuid::GetHigh(), m_objectTargetGUID, Mo_Transport, and Transport.

◆ GetItemTarget()

◆ GetItemTargetEntry()

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

References m_itemTargetEntry.

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

◆ GetItemTargetGUID()

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

References m_itemTargetGUID.

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

◆ GetObjectTarget()

◆ GetObjectTargetChannel()

WorldObject * SpellCastTargets::GetObjectTargetChannel ( WorldObject *  caster) const
502{
504}
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:120
ObjectGuid m_objectTargetGUIDChannel
Definition Spell.h:219
Definition ObjectAccessor.h:61
WorldObject * GetWorldObject(WorldObject const &, ObjectGuid const &guid)
Definition ObjectAccessor.cpp:139

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

Referenced by Spell::SelectImplicitChannelTargets().

◆ GetObjectTargetGUID()

ObjectGuid SpellCastTargets::GetObjectTargetGUID ( ) const

◆ GetSpeed()

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

References m_speed.

◆ GetSpeedXY()

float SpellCastTargets::GetSpeedXY ( ) const
inline

◆ GetSpeedZ()

float SpellCastTargets::GetSpeedZ ( ) const
inline
187{ 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
395{
396 return &m_src;
397}

References m_src.

◆ GetSrcPos()

Position const * SpellCastTargets::GetSrcPos ( ) const

◆ GetTargetMask()

uint32 SpellCastTargets::GetTargetMask ( ) const
inline

◆ GetUnitTarget()

◆ GetUnitTargetGUID()

ObjectGuid SpellCastTargets::GetUnitTargetGUID ( ) const
254{
255 switch (m_objectTargetGUID.GetHigh())
256 {
257 case HighGuid::Player:
259 case HighGuid::Unit:
260 case HighGuid::Pet:
261 return m_objectTargetGUID;
262 default:
263 break;
264 }
265
266 return ObjectGuid::Empty;
267}

References ObjectGuid::Empty, ObjectGuid::GetHigh(), m_objectTargetGUID, Pet, Player, Unit, and Vehicle.

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

◆ HasDst()

◆ HasDstChannel()

bool SpellCastTargets::HasDstChannel ( ) const
507{
508 return m_dstChannel._position.GetExactDist(0, 0, 0) > 0.001f;
509}
float GetExactDist(float x, float y, float z) const
Definition Position.h:182

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
570{
571 if (!m_targetMask)
572 LOG_INFO("spells", "No targets");
573
574 LOG_INFO("spells", "target mask: {}", m_targetMask);
576 LOG_INFO("spells", "Object target: {}", m_objectTargetGUID.ToString());
578 LOG_INFO("spells", "Item target: {}", m_itemTargetGUID.ToString());
580 LOG_INFO("spells", "Trade item target: {}", m_itemTargetGUID.ToString());
582 LOG_INFO("spells", "Source location: transport guid: {} trans offset: {} position: {}",
585 LOG_INFO("spells", "Destination location: transport guid: {} trans offset: {} position: {}",
588 LOG_INFO("spells", "String: {}", m_strTarget);
589 LOG_INFO("spells", "speed: {}", m_speed);
590 LOG_INFO("spells", "elevation: {}", m_elevation);
591}
#define LOG_INFO(filterType__,...)
Definition Log.h:153
@ TARGET_FLAG_TRADE_ITEM
Definition SpellInfo.h:59
@ TARGET_FLAG_STRING
Definition SpellInfo.h:60
@ TARGET_FLAG_ITEM
Definition SpellInfo.h:51
@ TARGET_FLAG_UNIT_MASK
Definition SpellInfo.h:69
@ TARGET_FLAG_CORPSE_MASK
Definition SpellInfo.h:72
@ TARGET_FLAG_GAMEOBJECT_MASK
Definition SpellInfo.h:71
std::string ToString() const
Definition ObjectGuid.cpp:48
std::string ToString() const
Definition Position.cpp:59
Position _transportOffset
Definition Spell.h:117
ObjectGuid _transportGUID
Definition Spell.h:116

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,
WorldObject *  caster 
)
164{
165 data >> m_targetMask;
166
168 return;
169
172
175
177 {
181 else
183 }
184 else
185 {
189 else
190 m_src._position.Relocate(caster);
191 }
192
194 {
198 else
200 }
201 else
202 {
206 else
207 m_dst._position.Relocate(caster);
208 }
209
211 data >> m_strTarget;
212
213 Update(caster);
214}
@ TARGET_FLAG_GAMEOBJECT
Definition SpellInfo.h:58
@ TARGET_FLAG_NONE
Definition SpellInfo.h:46
@ TARGET_FLAG_CORPSE_ALLY
Definition SpellInfo.h:62
@ TARGET_FLAG_UNIT_MINIPET
Definition SpellInfo.h:63
@ TARGET_FLAG_UNIT
Definition SpellInfo.h:48
@ TARGET_FLAG_CORPSE_ENEMY
Definition SpellInfo.h:56
PackedGuidReader ReadAsPacked()
Definition ObjectGuid.h:138
void Update(WorldObject *caster)
Definition Spell.cpp:516
float GetTransOffsetX() const
Definition Object.h:702
float GetTransOffsetY() const
Definition Object.h:703
float GetTransOffsetZ() const
Definition Object.h:704
virtual ObjectGuid GetTransGUID() const
Definition Object.cpp:3137
float GetTransOffsetO() const
Definition Object.h:705
Position::PositionXYZStreamer PositionXYZStream()
Definition Position.h:149
void Relocate(float x, float y)
Definition Position.h:77

References SpellDestination::_position, SpellDestination::_transportGUID, SpellDestination::_transportOffset, WorldObject::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)
339{
340 if (!target)
341 return;
342
343 m_objectTarget = target;
344 m_objectTargetGUID = target->GetGUID();
346}

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)
468{
469 m_dst = spellTargets.m_dst;
471}

References m_dst, m_targetMask, and TARGET_FLAG_DEST_LOCATION.

◆ SetDst() [4/5]

void SpellCastTargets::SetDst ( SpellDestination const &  spellDest)
462{
463 m_dst = spellDest;
465}

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)

◆ 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
132{ m_targetMask |= flag; }

References m_targetMask.

Referenced by Spell::SelectSpellTargets().

◆ SetTargetMask()

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

References m_targetMask.

◆ SetTradeItemTarget()

void SpellCastTargets::SetTradeItemTarget ( Player *  caster)
377{
381
382 Update(caster);
383}
std::uint64_t uint64
Definition Define.h:106
@ TRADE_SLOT_NONTRADED
Definition TradeData.h:31
void Set(uint64 guid)
Definition ObjectGuid.h:140

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 ( WorldObject *  caster)
517{
519
520 m_itemTarget = nullptr;
521 if (caster->IsPlayer())
522 {
523 Player* player = caster->ToPlayer();
527 if (m_itemTargetGUID.GetRawValue() == TRADE_SLOT_NONTRADED) // here it is not guid but slot. Also prevents hacking slots
528 if (TradeData* pTrade = player->GetTradeData())
529 m_itemTarget = pTrade->GetTraderData()->GetItem(TRADE_SLOT_NONTRADED);
530
531 if (m_itemTarget)
533 }
534
535 // update positions by transport move
536 if (HasSrc() && m_src._transportGUID)
537 {
539 {
540 m_src._position.Relocate(transport);
542 }
543 }
544
545 if (HasDst() && m_dst._transportGUID)
546 {
548 {
549 m_dst._position.Relocate(transport);
551 }
552 }
553}
uint64 GetRawValue() const
Definition ObjectGuid.h:145
bool IsPlayer() const
Definition Object.h:207
Player * ToPlayer()
Definition Object.h:208
Definition Player.h:1086
TradeData * GetTradeData() const
Definition Player.h:1400
Item * GetItemByGuid(ObjectGuid guid) const
Definition PlayerStorage.cpp:411
bool HasSrc() const
Definition Spell.h:176
bool HasDst() const
Definition Spell.h:177
Definition TradeData.h:36
Definition Object.h:482
void RelocateOffset(Position const &offset)
Definition Position.cpp:66

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)
217{
218 data << uint32(m_targetMask);
219
222
224 {
225 if (m_itemTarget)
226 data << m_itemTarget->GetPackGUID();
227 else
228 data << uint8(0);
229 }
230
232 {
233 data << m_src._transportGUID.WriteAsPacked(); // relative position guid here - transport for example
236 else
238 }
239
241 {
242 data << m_dst._transportGUID.WriteAsPacked(); // relative position guid here - transport for example
245 else
247 }
248
250 data << m_strTarget;
251}
std::uint8_t uint8
Definition Define.h:109
std::uint32_t uint32
Definition Define.h:107
PackedGuid WriteAsPacked() const
Definition ObjectGuid.h:325
PackedGuid const & GetPackGUID() const
Definition Object.h:122

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

◆ 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


The documentation for this class was generated from the following files: