AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Acore::WorldObjectSpellTargetCheck Struct Reference

#include "Spell.h"

Inheritance diagram for Acore::WorldObjectSpellTargetCheck:
Acore::WorldObjectSpellAreaTargetCheck Acore::WorldObjectSpellNearbyTargetCheck Acore::WorldObjectSpellConeTargetCheck Acore::WorldObjectSpellTrajTargetCheck

Public Member Functions

 WorldObjectSpellTargetCheck (Unit *caster, Unit *referer, SpellInfo const *spellInfo, SpellTargetCheckTypes selectionType, ConditionList *condList)
 
 ~WorldObjectSpellTargetCheck ()
 
bool operator() (WorldObject *target)
 

Public Attributes

Unit_caster
 
Unit_referer
 
SpellInfo const * _spellInfo
 
SpellTargetCheckTypes _targetSelectionType
 
ConditionSourceInfo_condSrcInfo
 
ConditionList_condList
 

Detailed Description

Constructor & Destructor Documentation

◆ WorldObjectSpellTargetCheck()

Acore::WorldObjectSpellTargetCheck::WorldObjectSpellTargetCheck ( Unit caster,
Unit referer,
SpellInfo const *  spellInfo,
SpellTargetCheckTypes  selectionType,
ConditionList condList 
)
8908 : _caster(caster), _referer(referer), _spellInfo(spellInfo),
8909 _targetSelectionType(selectionType), _condList(condList)
8910 {
8911 if (condList)
8912 _condSrcInfo = new ConditionSourceInfo(nullptr, caster);
8913 else
8914 _condSrcInfo = nullptr;
8915 }
SpellTargetCheckTypes _targetSelectionType
Definition Spell.h:803
Unit * _referer
Definition Spell.h:801
ConditionSourceInfo * _condSrcInfo
Definition Spell.h:804
SpellInfo const * _spellInfo
Definition Spell.h:802
ConditionList * _condList
Definition Spell.h:805
Unit * _caster
Definition Spell.h:800
Definition ConditionMgr.h:183

References _condSrcInfo.

◆ ~WorldObjectSpellTargetCheck()

Acore::WorldObjectSpellTargetCheck::~WorldObjectSpellTargetCheck ( )
8918 {
8919 if (_condSrcInfo)
8920 delete _condSrcInfo;
8921 }

References _condSrcInfo.

Member Function Documentation

◆ operator()()

bool Acore::WorldObjectSpellTargetCheck::operator() ( WorldObject target)
8924 {
8925 if (_spellInfo->CheckTarget(_caster, target, true) != SPELL_CAST_OK)
8926 return false;
8927 Unit* unitTarget = target->ToUnit();
8928 if (Corpse* corpseTarget = target->ToCorpse())
8929 {
8930 // use ofter for party/assistance checks
8931 if (Player* owner = ObjectAccessor::FindPlayer(corpseTarget->GetOwnerGUID()))
8932 unitTarget = owner;
8933 else
8934 return false;
8935 }
8936 if (unitTarget)
8937 {
8938 switch (_targetSelectionType)
8939 {
8940 case TARGET_CHECK_ENEMY:
8941 if (unitTarget->IsTotem())
8942 return false;
8943 if (!_caster->_IsValidAttackTarget(unitTarget, _spellInfo))
8944 return false;
8945 break;
8946 case TARGET_CHECK_ALLY:
8947 if (unitTarget->IsTotem())
8948 return false;
8949 if (!_caster->_IsValidAssistTarget(unitTarget, _spellInfo))
8950 return false;
8951 break;
8952 case TARGET_CHECK_PARTY:
8953 if (unitTarget->IsTotem())
8954 return false;
8955 if (unitTarget->IsGuardian() && !unitTarget->IsControllableGuardian())
8956 return false;
8957 if (!_caster->_IsValidAssistTarget(unitTarget, _spellInfo))
8958 return false;
8959 if (!_referer->IsInPartyWith(unitTarget))
8960 return false;
8961 break;
8963 if (_referer->getClass() != unitTarget->getClass())
8964 return false;
8965 [[fallthrough]];
8966 case TARGET_CHECK_RAID:
8967 if (unitTarget->IsTotem())
8968 return false;
8969 if (unitTarget->IsGuardian() && !unitTarget->IsControllableGuardian())
8970 return false;
8971 if (!_caster->_IsValidAssistTarget(unitTarget, _spellInfo))
8972 return false;
8973 if (!_referer->IsInRaidWith(unitTarget))
8974 return false;
8975 break;
8977 if (_caster->IsFriendlyTo(unitTarget))
8978 return false;
8979 break;
8980 default:
8981 break;
8982 }
8983 }
8984 if (!_condSrcInfo)
8985 return true;
8986 _condSrcInfo->mConditionTargets[0] = target;
8987 return sConditionMgr->IsObjectMeetToConditions(*_condSrcInfo, *_condList);
8988 }
#define sConditionMgr
Definition ConditionMgr.h:291
@ SPELL_CAST_OK
Definition SharedDefines.h:1149
@ TARGET_CHECK_CORPSE
Definition SpellInfo.h:122
@ TARGET_CHECK_PARTY
Definition SpellInfo.h:118
@ TARGET_CHECK_ENEMY
Definition SpellInfo.h:116
@ TARGET_CHECK_RAID_CLASS
Definition SpellInfo.h:120
@ TARGET_CHECK_ALLY
Definition SpellInfo.h:117
@ TARGET_CHECK_RAID
Definition SpellInfo.h:119
Definition Corpse.h:49
Corpse * ToCorpse()
Definition Object.h:218
Unit * ToUnit()
Definition Object.h:210
Definition Player.h:1071
SpellCastResult CheckTarget(Unit const *caster, WorldObject const *target, bool implicit=true) const
Definition SpellInfo.cpp:1759
Definition Unit.h:628
bool _IsValidAssistTarget(Unit const *target, SpellInfo const *bySpell) const
Definition Unit.cpp:14084
uint8 getClass() const
Definition Unit.h:804
bool IsGuardian() const
Definition Unit.h:756
bool IsInRaidWith(Unit const *unit) const
Definition Unit.cpp:18878
bool IsFriendlyTo(Unit const *unit) const
Definition Unit.cpp:10292
bool IsControllableGuardian() const
Definition Unit.h:757
bool IsTotem() const
Definition Unit.h:760
bool IsInPartyWith(Unit const *unit) const
Definition Unit.cpp:18855
bool _IsValidAttackTarget(Unit const *target, SpellInfo const *bySpell, WorldObject const *obj=nullptr) const
Definition Unit.cpp:13961
Player * FindPlayer(ObjectGuid const guid)
Definition ObjectAccessor.cpp:245
WorldObject * mConditionTargets[MAX_CONDITION_TARGETS]
Definition ConditionMgr.h:184

References _caster, _condList, _condSrcInfo, Unit::_IsValidAssistTarget(), Unit::_IsValidAttackTarget(), _referer, _spellInfo, _targetSelectionType, SpellInfo::CheckTarget(), ObjectAccessor::FindPlayer(), Unit::getClass(), Unit::IsControllableGuardian(), Unit::IsFriendlyTo(), Unit::IsGuardian(), Unit::IsInPartyWith(), Unit::IsInRaidWith(), Unit::IsTotem(), ConditionSourceInfo::mConditionTargets, sConditionMgr, SPELL_CAST_OK, TARGET_CHECK_ALLY, TARGET_CHECK_CORPSE, TARGET_CHECK_ENEMY, TARGET_CHECK_PARTY, TARGET_CHECK_RAID, TARGET_CHECK_RAID_CLASS, Object::ToCorpse(), and Object::ToUnit().

Referenced by Acore::WorldObjectSpellAreaTargetCheck::operator()(), and Acore::WorldObjectSpellTrajTargetCheck::operator()().

Member Data Documentation

◆ _caster

◆ _condList

ConditionList* Acore::WorldObjectSpellTargetCheck::_condList

Referenced by operator()().

◆ _condSrcInfo

ConditionSourceInfo* Acore::WorldObjectSpellTargetCheck::_condSrcInfo

◆ _referer

Unit* Acore::WorldObjectSpellTargetCheck::_referer

Referenced by operator()().

◆ _spellInfo

SpellInfo const* Acore::WorldObjectSpellTargetCheck::_spellInfo

◆ _targetSelectionType

SpellTargetCheckTypes Acore::WorldObjectSpellTargetCheck::_targetSelectionType

Referenced by operator()().


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