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 
)
8958 : _caster(caster), _referer(referer), _spellInfo(spellInfo),
8959 _targetSelectionType(selectionType), _condList(condList)
8960 {
8961 if (condList)
8962 _condSrcInfo = new ConditionSourceInfo(nullptr, caster);
8963 else
8964 _condSrcInfo = nullptr;
8965 }
Definition: ConditionMgr.h:182
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

References _condSrcInfo.

◆ ~WorldObjectSpellTargetCheck()

Acore::WorldObjectSpellTargetCheck::~WorldObjectSpellTargetCheck ( )
8968 {
8969 if (_condSrcInfo)
8970 delete _condSrcInfo;
8971 }

References _condSrcInfo.

Member Function Documentation

◆ operator()()

bool Acore::WorldObjectSpellTargetCheck::operator() ( WorldObject target)
8974 {
8975 if (_spellInfo->CheckTarget(_caster, target, true) != SPELL_CAST_OK)
8976 return false;
8977 Unit* unitTarget = target->ToUnit();
8978 if (Corpse* corpseTarget = target->ToCorpse())
8979 {
8980 // use ofter for party/assistance checks
8981 if (Player* owner = ObjectAccessor::FindPlayer(corpseTarget->GetOwnerGUID()))
8982 unitTarget = owner;
8983 else
8984 return false;
8985 }
8986 if (unitTarget)
8987 {
8988 switch (_targetSelectionType)
8989 {
8990 case TARGET_CHECK_ENEMY:
8991 if (unitTarget->IsTotem())
8992 return false;
8993 if (!_caster->_IsValidAttackTarget(unitTarget, _spellInfo))
8994 return false;
8995 break;
8996 case TARGET_CHECK_ALLY:
8997 if (unitTarget->IsTotem())
8998 return false;
8999 if (!_caster->_IsValidAssistTarget(unitTarget, _spellInfo))
9000 return false;
9001 break;
9002 case TARGET_CHECK_PARTY:
9003 if (unitTarget->IsTotem())
9004 return false;
9005 if (!_caster->_IsValidAssistTarget(unitTarget, _spellInfo))
9006 return false;
9007 if (!_referer->IsInPartyWith(unitTarget))
9008 return false;
9009 break;
9011 if (_referer->getClass() != unitTarget->getClass())
9012 return false;
9013 [[fallthrough]];
9014 case TARGET_CHECK_RAID:
9015 if (unitTarget->IsTotem())
9016 return false;
9017 if (!_caster->_IsValidAssistTarget(unitTarget, _spellInfo))
9018 return false;
9019 if (!_referer->IsInRaidWith(unitTarget))
9020 return false;
9021 break;
9023 if (_caster->IsFriendlyTo(unitTarget))
9024 return false;
9025 break;
9026 default:
9027 break;
9028 }
9029 }
9030 if (!_condSrcInfo)
9031 return true;
9032 _condSrcInfo->mConditionTargets[0] = target;
9033 return sConditionMgr->IsObjectMeetToConditions(*_condSrcInfo, *_condList);
9034 }
@ 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
#define sConditionMgr
Definition: ConditionMgr.h:290
Player * FindPlayer(ObjectGuid const guid)
Definition: ObjectAccessor.cpp:245
WorldObject * mConditionTargets[MAX_CONDITION_TARGETS]
Definition: ConditionMgr.h:183
Definition: Corpse.h:49
Corpse * ToCorpse()
Definition: Object.h:217
Unit * ToUnit()
Definition: Object.h:209
Definition: Player.h:1081
Definition: Unit.h:630
bool _IsValidAssistTarget(Unit const *target, SpellInfo const *bySpell) const
Definition: Unit.cpp:14000
uint8 getClass() const
Definition: Unit.h:800
bool IsInRaidWith(Unit const *unit) const
Definition: Unit.cpp:18797
bool IsFriendlyTo(Unit const *unit) const
Definition: Unit.cpp:10241
bool IsTotem() const
Definition: Unit.h:756
bool IsInPartyWith(Unit const *unit) const
Definition: Unit.cpp:18774
bool _IsValidAttackTarget(Unit const *target, SpellInfo const *bySpell, WorldObject const *obj=nullptr) const
Definition: Unit.cpp:13877
SpellCastResult CheckTarget(Unit const *caster, WorldObject const *target, bool implicit=true) const
Definition: SpellInfo.cpp:1759

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