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 
)
8985 : _caster(caster), _referer(referer), _spellInfo(spellInfo),
8986 _targetSelectionType(selectionType), _condList(condList)
8987 {
8988 if (condList)
8989 _condSrcInfo = new ConditionSourceInfo(nullptr, caster);
8990 else
8991 _condSrcInfo = nullptr;
8992 }
SpellTargetCheckTypes _targetSelectionType
Definition Spell.h:795
Unit * _referer
Definition Spell.h:793
ConditionSourceInfo * _condSrcInfo
Definition Spell.h:796
SpellInfo const * _spellInfo
Definition Spell.h:794
ConditionList * _condList
Definition Spell.h:797
Unit * _caster
Definition Spell.h:792
Definition ConditionMgr.h:182

References _condSrcInfo.

◆ ~WorldObjectSpellTargetCheck()

Acore::WorldObjectSpellTargetCheck::~WorldObjectSpellTargetCheck ( )
8995 {
8996 if (_condSrcInfo)
8997 delete _condSrcInfo;
8998 }

References _condSrcInfo.

Member Function Documentation

◆ operator()()

bool Acore::WorldObjectSpellTargetCheck::operator() ( WorldObject target)
9001 {
9002 if (_spellInfo->CheckTarget(_caster, target, true) != SPELL_CAST_OK)
9003 return false;
9004 Unit* unitTarget = target->ToUnit();
9005 if (Corpse* corpseTarget = target->ToCorpse())
9006 {
9007 // use ofter for party/assistance checks
9008 if (Player* owner = ObjectAccessor::FindPlayer(corpseTarget->GetOwnerGUID()))
9009 unitTarget = owner;
9010 else
9011 return false;
9012 }
9013 if (unitTarget)
9014 {
9015 switch (_targetSelectionType)
9016 {
9017 case TARGET_CHECK_ENEMY:
9018 if (unitTarget->IsTotem())
9019 return false;
9020 if (!_caster->_IsValidAttackTarget(unitTarget, _spellInfo))
9021 return false;
9022 break;
9023 case TARGET_CHECK_ALLY:
9024 if (unitTarget->IsTotem())
9025 return false;
9026 if (!_caster->_IsValidAssistTarget(unitTarget, _spellInfo))
9027 return false;
9028 break;
9029 case TARGET_CHECK_PARTY:
9030 if (unitTarget->IsTotem())
9031 return false;
9032 if (!_caster->_IsValidAssistTarget(unitTarget, _spellInfo))
9033 return false;
9034 if (!_referer->IsInPartyWith(unitTarget))
9035 return false;
9036 break;
9038 if (_referer->getClass() != unitTarget->getClass())
9039 return false;
9040 [[fallthrough]];
9041 case TARGET_CHECK_RAID:
9042 if (unitTarget->IsTotem())
9043 return false;
9044 if (!_caster->_IsValidAssistTarget(unitTarget, _spellInfo))
9045 return false;
9046 if (!_referer->IsInRaidWith(unitTarget))
9047 return false;
9048 break;
9050 if (_caster->IsFriendlyTo(unitTarget))
9051 return false;
9052 break;
9053 default:
9054 break;
9055 }
9056 }
9057 if (!_condSrcInfo)
9058 return true;
9059 _condSrcInfo->mConditionTargets[0] = target;
9060 return sConditionMgr->IsObjectMeetToConditions(*_condSrcInfo, *_condList);
9061 }
#define sConditionMgr
Definition ConditionMgr.h:290
@ SPELL_CAST_OK
Definition SharedDefines.h:1138
@ 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:217
Unit * ToUnit()
Definition Object.h:209
Definition Player.h:1081
SpellCastResult CheckTarget(Unit const *caster, WorldObject const *target, bool implicit=true) const
Definition SpellInfo.cpp:1759
Definition Unit.h:636
bool _IsValidAssistTarget(Unit const *target, SpellInfo const *bySpell) const
Definition Unit.cpp:14052
uint8 getClass() const
Definition Unit.h:809
bool IsInRaidWith(Unit const *unit) const
Definition Unit.cpp:18849
bool IsFriendlyTo(Unit const *unit) const
Definition Unit.cpp:10282
bool IsTotem() const
Definition Unit.h:765
bool IsInPartyWith(Unit const *unit) const
Definition Unit.cpp:18826
bool _IsValidAttackTarget(Unit const *target, SpellInfo const *bySpell, WorldObject const *obj=nullptr) const
Definition Unit.cpp:13929
Player * FindPlayer(ObjectGuid const guid)
Definition ObjectAccessor.cpp:245
WorldObject * mConditionTargets[MAX_CONDITION_TARGETS]
Definition ConditionMgr.h:183

References _caster, _condList, _condSrcInfo, Unit::_IsValidAssistTarget(), Unit::_IsValidAttackTarget(), _referer, _spellInfo, _targetSelectionType, SpellInfo::CheckTarget(), ObjectAccessor::FindPlayer(), Unit::getClass(), Unit::IsFriendlyTo(), 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()().

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: