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 
)
8948 : _caster(caster), _referer(referer), _spellInfo(spellInfo),
8949 _targetSelectionType(selectionType), _condList(condList)
8950 {
8951 if (condList)
8952 _condSrcInfo = new ConditionSourceInfo(nullptr, caster);
8953 else
8954 _condSrcInfo = nullptr;
8955 }
SpellTargetCheckTypes _targetSelectionType
Definition Spell.h:806
Unit * _referer
Definition Spell.h:804
ConditionSourceInfo * _condSrcInfo
Definition Spell.h:807
SpellInfo const * _spellInfo
Definition Spell.h:805
ConditionList * _condList
Definition Spell.h:808
Unit * _caster
Definition Spell.h:803
Definition ConditionMgr.h:183

References _condSrcInfo.

◆ ~WorldObjectSpellTargetCheck()

Acore::WorldObjectSpellTargetCheck::~WorldObjectSpellTargetCheck ( )
8958 {
8959 if (_condSrcInfo)
8960 delete _condSrcInfo;
8961 }

References _condSrcInfo.

Member Function Documentation

◆ operator()()

bool Acore::WorldObjectSpellTargetCheck::operator() ( WorldObject target)
8964 {
8965 if (_spellInfo->CheckTarget(_caster, target, true) != SPELL_CAST_OK)
8966 return false;
8967 Unit* unitTarget = target->ToUnit();
8968 if (Corpse* corpseTarget = target->ToCorpse())
8969 {
8970 // use ofter for party/assistance checks
8971 if (Player* owner = ObjectAccessor::FindPlayer(corpseTarget->GetOwnerGUID()))
8972 unitTarget = owner;
8973 else
8974 return false;
8975 }
8976 if (unitTarget)
8977 {
8978 switch (_targetSelectionType)
8979 {
8980 case TARGET_CHECK_ENEMY:
8981 if (unitTarget->IsTotem())
8982 return false;
8983 if (!_caster->_IsValidAttackTarget(unitTarget, _spellInfo))
8984 return false;
8985 break;
8986 case TARGET_CHECK_ALLY:
8987 if (unitTarget->IsTotem())
8988 return false;
8989 if (!_caster->_IsValidAssistTarget(unitTarget, _spellInfo))
8990 return false;
8991 break;
8992 case TARGET_CHECK_PARTY:
8993 if (unitTarget->IsTotem())
8994 return false;
8995 if (unitTarget->IsGuardian() && !unitTarget->IsControllableGuardian())
8996 return false;
8997 if (!_caster->_IsValidAssistTarget(unitTarget, _spellInfo))
8998 return false;
8999 if (!_referer->IsInPartyWith(unitTarget))
9000 return false;
9001 break;
9003 if (_referer->getClass() != unitTarget->getClass())
9004 return false;
9005 [[fallthrough]];
9006 case TARGET_CHECK_RAID:
9007 if (unitTarget->IsTotem())
9008 return false;
9009 if (unitTarget->IsGuardian() && !unitTarget->IsControllableGuardian())
9010 return false;
9011 if (!_caster->_IsValidAssistTarget(unitTarget, _spellInfo))
9012 return false;
9013 if (!_referer->IsInRaidWith(unitTarget))
9014 return false;
9015 break;
9017 if (_caster->IsFriendlyTo(unitTarget))
9018 return false;
9019 break;
9020 default:
9021 break;
9022 }
9023 }
9024 if (!_condSrcInfo)
9025 return true;
9026 _condSrcInfo->mConditionTargets[0] = target;
9027 return sConditionMgr->IsObjectMeetToConditions(*_condSrcInfo, *_condList);
9028 }
#define sConditionMgr
Definition ConditionMgr.h:291
@ SPELL_CAST_OK
Definition SharedDefines.h:1149
@ 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:1071
SpellCastResult CheckTarget(Unit const *caster, WorldObject const *target, bool implicit=true) const
Definition SpellInfo.cpp:1643
Definition Unit.h:655
bool _IsValidAssistTarget(Unit const *target, SpellInfo const *bySpell) const
Definition Unit.cpp:14168
uint8 getClass() const
Definition Unit.h:831
bool IsGuardian() const
Definition Unit.h:783
bool IsInRaidWith(Unit const *unit) const
Definition Unit.cpp:19034
bool IsFriendlyTo(Unit const *unit) const
Definition Unit.cpp:10420
bool IsControllableGuardian() const
Definition Unit.h:784
bool IsTotem() const
Definition Unit.h:787
bool IsInPartyWith(Unit const *unit) const
Definition Unit.cpp:19011
bool _IsValidAttackTarget(Unit const *target, SpellInfo const *bySpell, WorldObject const *obj=nullptr) const
Definition Unit.cpp:14030
Player * FindPlayer(ObjectGuid const guid)
Definition ObjectAccessor.cpp:245
WorldObject * mConditionTargets[MAX_CONDITION_TARGETS]
Definition ConditionMgr.h:184

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: