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 
)
8903 : _caster(caster), _referer(referer), _spellInfo(spellInfo),
8904 _targetSelectionType(selectionType), _condList(condList)
8905 {
8906 if (condList)
8907 _condSrcInfo = new ConditionSourceInfo(nullptr, caster);
8908 else
8909 _condSrcInfo = nullptr;
8910 }
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 ( )
8913 {
8914 if (_condSrcInfo)
8915 delete _condSrcInfo;
8916 }

References _condSrcInfo.

Member Function Documentation

◆ operator()()

bool Acore::WorldObjectSpellTargetCheck::operator() ( WorldObject target)
8919 {
8920 if (_spellInfo->CheckTarget(_caster, target, true) != SPELL_CAST_OK)
8921 return false;
8922 Unit* unitTarget = target->ToUnit();
8923 if (Corpse* corpseTarget = target->ToCorpse())
8924 {
8925 // use ofter for party/assistance checks
8926 if (Player* owner = ObjectAccessor::FindPlayer(corpseTarget->GetOwnerGUID()))
8927 unitTarget = owner;
8928 else
8929 return false;
8930 }
8931 if (unitTarget)
8932 {
8933 switch (_targetSelectionType)
8934 {
8935 case TARGET_CHECK_ENEMY:
8936 if (unitTarget->IsTotem())
8937 return false;
8938 if (!_caster->_IsValidAttackTarget(unitTarget, _spellInfo))
8939 return false;
8940 break;
8941 case TARGET_CHECK_ALLY:
8942 if (unitTarget->IsTotem())
8943 return false;
8944 if (!_caster->_IsValidAssistTarget(unitTarget, _spellInfo))
8945 return false;
8946 break;
8947 case TARGET_CHECK_PARTY:
8948 if (unitTarget->IsTotem())
8949 return false;
8950 if (!_caster->_IsValidAssistTarget(unitTarget, _spellInfo))
8951 return false;
8952 if (!_referer->IsInPartyWith(unitTarget))
8953 return false;
8954 break;
8956 if (_referer->getClass() != unitTarget->getClass())
8957 return false;
8958 [[fallthrough]];
8959 case TARGET_CHECK_RAID:
8960 if (unitTarget->IsTotem())
8961 return false;
8962 if (!_caster->_IsValidAssistTarget(unitTarget, _spellInfo))
8963 return false;
8964 if (!_referer->IsInRaidWith(unitTarget))
8965 return false;
8966 break;
8968 if (_caster->IsFriendlyTo(unitTarget))
8969 return false;
8970 break;
8971 default:
8972 break;
8973 }
8974 }
8975 if (!_condSrcInfo)
8976 return true;
8977 _condSrcInfo->mConditionTargets[0] = target;
8978 return sConditionMgr->IsObjectMeetToConditions(*_condSrcInfo, *_condList);
8979 }
#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:1138
Player * FindPlayer(ObjectGuid const guid)
Definition: ObjectAccessor.cpp:248
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:1056
Definition: Unit.h:1302
bool _IsValidAssistTarget(Unit const *target, SpellInfo const *bySpell) const
Definition: Unit.cpp:13988
uint8 getClass() const
Definition: Unit.h:1438
bool IsInRaidWith(Unit const *unit) const
Definition: Unit.cpp:19061
bool IsFriendlyTo(Unit const *unit) const
Definition: Unit.cpp:10249
bool IsTotem() const
Definition: Unit.h:1427
bool IsInPartyWith(Unit const *unit) const
Definition: Unit.cpp:19038
bool _IsValidAttackTarget(Unit const *target, SpellInfo const *bySpell, WorldObject const *obj=nullptr) const
Definition: Unit.cpp:13865
SpellCastResult CheckTarget(Unit const *caster, WorldObject const *target, bool implicit=true) const
Definition: SpellInfo.cpp:1746

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