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 
)
8904 : _caster(caster), _referer(referer), _spellInfo(spellInfo),
8905 _targetSelectionType(selectionType), _condList(condList)
8906 {
8907 if (condList)
8908 _condSrcInfo = new ConditionSourceInfo(nullptr, caster);
8909 else
8910 _condSrcInfo = nullptr;
8911 }
Definition: ConditionMgr.h:181
SpellTargetCheckTypes _targetSelectionType
Definition: Spell.h:798
Unit * _referer
Definition: Spell.h:796
ConditionSourceInfo * _condSrcInfo
Definition: Spell.h:799
SpellInfo const * _spellInfo
Definition: Spell.h:797
ConditionList * _condList
Definition: Spell.h:800
Unit * _caster
Definition: Spell.h:795

References _condSrcInfo.

◆ ~WorldObjectSpellTargetCheck()

Acore::WorldObjectSpellTargetCheck::~WorldObjectSpellTargetCheck ( )
8914 {
8915 if (_condSrcInfo)
8916 delete _condSrcInfo;
8917 }

References _condSrcInfo.

Member Function Documentation

◆ operator()()

bool Acore::WorldObjectSpellTargetCheck::operator() ( WorldObject target)
8920 {
8921 if (_spellInfo->CheckTarget(_caster, target, true) != SPELL_CAST_OK)
8922 return false;
8923 Unit* unitTarget = target->ToUnit();
8924 if (Corpse* corpseTarget = target->ToCorpse())
8925 {
8926 // use ofter for party/assistance checks
8927 if (Player* owner = ObjectAccessor::FindPlayer(corpseTarget->GetOwnerGUID()))
8928 unitTarget = owner;
8929 else
8930 return false;
8931 }
8932 if (unitTarget)
8933 {
8934 switch (_targetSelectionType)
8935 {
8936 case TARGET_CHECK_ENEMY:
8937 if (unitTarget->IsTotem())
8938 return false;
8939 if (!_caster->_IsValidAttackTarget(unitTarget, _spellInfo))
8940 return false;
8941 break;
8942 case TARGET_CHECK_ALLY:
8943 if (unitTarget->IsTotem())
8944 return false;
8945 if (!_caster->_IsValidAssistTarget(unitTarget, _spellInfo))
8946 return false;
8947 break;
8948 case TARGET_CHECK_PARTY:
8949 if (unitTarget->IsTotem())
8950 return false;
8951 if (!_caster->_IsValidAssistTarget(unitTarget, _spellInfo))
8952 return false;
8953 if (!_referer->IsInPartyWith(unitTarget))
8954 return false;
8955 break;
8957 if (_referer->getClass() != unitTarget->getClass())
8958 return false;
8959 [[fallthrough]];
8960 case TARGET_CHECK_RAID:
8961 if (unitTarget->IsTotem())
8962 return false;
8963 if (!_caster->_IsValidAssistTarget(unitTarget, _spellInfo))
8964 return false;
8965 if (!_referer->IsInRaidWith(unitTarget))
8966 return false;
8967 break;
8969 if (_caster->IsFriendlyTo(unitTarget))
8970 return false;
8971 break;
8972 default:
8973 break;
8974 }
8975 }
8976 if (!_condSrcInfo)
8977 return true;
8978 _condSrcInfo->mConditionTargets[0] = target;
8979 return sConditionMgr->IsObjectMeetToConditions(*_condSrcInfo, *_condList);
8980 }
#define sConditionMgr
Definition: ConditionMgr.h:289
@ 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
@ SPELL_CAST_OK
Definition: SharedDefines.h:1110
Player * FindPlayer(ObjectGuid const guid)
Definition: ObjectAccessor.cpp:250
WorldObject * mConditionTargets[MAX_CONDITION_TARGETS]
Definition: ConditionMgr.h:182
Definition: Corpse.h:49
Corpse * ToCorpse()
Definition: Object.h:205
Unit * ToUnit()
Definition: Object.h:200
Definition: Player.h:1046
Definition: Unit.h:1290
bool _IsValidAssistTarget(Unit const *target, SpellInfo const *bySpell) const
Definition: Unit.cpp:13902
uint8 getClass() const
Definition: Unit.h:1426
bool IsInRaidWith(Unit const *unit) const
Definition: Unit.cpp:18965
bool IsFriendlyTo(Unit const *unit) const
Definition: Unit.cpp:10214
bool IsTotem() const
Definition: Unit.h:1415
bool IsInPartyWith(Unit const *unit) const
Definition: Unit.cpp:18942
bool _IsValidAttackTarget(Unit const *target, SpellInfo const *bySpell, WorldObject const *obj=nullptr) const
Definition: Unit.cpp:13782
SpellCastResult CheckTarget(Unit const *caster, WorldObject const *target, bool implicit=true) const
Definition: SpellInfo.cpp:1744

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()().