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 
)
9015 : _caster(caster), _referer(referer), _spellInfo(spellInfo),
9016 _targetSelectionType(selectionType), _condList(condList)
9017 {
9018 if (condList)
9019 _condSrcInfo = new ConditionSourceInfo(nullptr, caster);
9020 else
9021 _condSrcInfo = nullptr;
9022 }
SpellTargetCheckTypes _targetSelectionType
Definition Spell.h:816
Unit * _referer
Definition Spell.h:814
ConditionSourceInfo * _condSrcInfo
Definition Spell.h:817
SpellInfo const * _spellInfo
Definition Spell.h:815
ConditionList * _condList
Definition Spell.h:818
Unit * _caster
Definition Spell.h:813
Definition ConditionMgr.h:185

References _condSrcInfo.

◆ ~WorldObjectSpellTargetCheck()

Acore::WorldObjectSpellTargetCheck::~WorldObjectSpellTargetCheck ( )
9025 {
9026 if (_condSrcInfo)
9027 delete _condSrcInfo;
9028 }

References _condSrcInfo.

Member Function Documentation

◆ operator()()

bool Acore::WorldObjectSpellTargetCheck::operator() ( WorldObject target)
9031 {
9032 if (_spellInfo->CheckTarget(_caster, target, true) != SPELL_CAST_OK)
9033 return false;
9034 Unit* unitTarget = target->ToUnit();
9035 if (Corpse* corpseTarget = target->ToCorpse())
9036 {
9037 // use ofter for party/assistance checks
9038 if (Player* owner = ObjectAccessor::FindPlayer(corpseTarget->GetOwnerGUID()))
9039 unitTarget = owner;
9040 else
9041 return false;
9042 }
9043 if (unitTarget)
9044 {
9045 switch (_targetSelectionType)
9046 {
9047 case TARGET_CHECK_ENEMY:
9048 if (unitTarget->IsTotem())
9049 return false;
9050 if (!_caster->_IsValidAttackTarget(unitTarget, _spellInfo))
9051 return false;
9052 break;
9053 case TARGET_CHECK_ALLY:
9054 if (unitTarget->IsTotem())
9055 return false;
9056 if (!_caster->_IsValidAssistTarget(unitTarget, _spellInfo))
9057 return false;
9058 break;
9059 case TARGET_CHECK_PARTY:
9060 if (unitTarget->IsTotem())
9061 return false;
9062 if (unitTarget->IsGuardian() && !unitTarget->IsControllableGuardian())
9063 return false;
9064 if (!_caster->_IsValidAssistTarget(unitTarget, _spellInfo))
9065 return false;
9066 if (!_referer->IsInPartyWith(unitTarget))
9067 return false;
9068 break;
9070 if (_referer->getClass() != unitTarget->getClass())
9071 return false;
9072 [[fallthrough]];
9073 case TARGET_CHECK_RAID:
9074 if (unitTarget->IsTotem())
9075 return false;
9076 if (unitTarget->IsGuardian() && !unitTarget->IsControllableGuardian())
9077 return false;
9078 if (!_caster->_IsValidAssistTarget(unitTarget, _spellInfo))
9079 return false;
9080 if (!_referer->IsInRaidWith(unitTarget))
9081 return false;
9082 break;
9084 if (_caster->IsFriendlyTo(unitTarget))
9085 return false;
9086 break;
9087 default:
9088 break;
9089 }
9090 }
9091 if (!_condSrcInfo)
9092 return true;
9093 _condSrcInfo->mConditionTargets[0] = target;
9094 return sConditionMgr->IsObjectMeetToConditions(*_condSrcInfo, *_condList);
9095 }
#define sConditionMgr
Definition ConditionMgr.h:296
@ SPELL_CAST_OK
Definition SharedDefines.h:1126
@ TARGET_CHECK_CORPSE
Definition SpellInfo.h:123
@ TARGET_CHECK_PARTY
Definition SpellInfo.h:119
@ TARGET_CHECK_ENEMY
Definition SpellInfo.h:117
@ TARGET_CHECK_RAID_CLASS
Definition SpellInfo.h:121
@ TARGET_CHECK_ALLY
Definition SpellInfo.h:118
@ TARGET_CHECK_RAID
Definition SpellInfo.h:120
Definition Corpse.h:49
Corpse * ToCorpse()
Definition Object.h:218
Unit * ToUnit()
Definition Object.h:210
Definition Player.h:1085
SpellCastResult CheckTarget(Unit const *caster, WorldObject const *target, bool implicit=true) const
Definition SpellInfo.cpp:1653
Definition Unit.h:665
bool _IsValidAssistTarget(Unit const *target, SpellInfo const *bySpell) const
Definition Unit.cpp:10835
uint8 getClass() const
Definition Unit.h:844
bool IsGuardian() const
Definition Unit.h:796
bool IsInRaidWith(Unit const *unit) const
Definition Unit.cpp:15023
bool IsFriendlyTo(Unit const *unit) const
Definition Unit.cpp:7254
bool IsControllableGuardian() const
Definition Unit.h:797
bool IsTotem() const
Definition Unit.h:800
bool IsInPartyWith(Unit const *unit) const
Definition Unit.cpp:15000
bool _IsValidAttackTarget(Unit const *target, SpellInfo const *bySpell, WorldObject const *obj=nullptr) const
Definition Unit.cpp:10697
Player * FindPlayer(ObjectGuid const guid)
Definition ObjectAccessor.cpp:245
WorldObject * mConditionTargets[MAX_CONDITION_TARGETS]
Definition ConditionMgr.h:186

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: