TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Trinity::WorldObjectSpellTargetCheck Struct Reference

#include <Spell.h>

Public Member Functions

 WorldObjectSpellTargetCheck (Unit *caster, Unit *referer, SpellInfo const *spellInfo, SpellTargetCheckTypes selectionType, ConditionContainer *condList)
 
 ~WorldObjectSpellTargetCheck ()
 
bool operator() (WorldObject *target)
 

Public Attributes

Unit_caster
 
Unit_referer
 
SpellInfo const_spellInfo
 
SpellTargetCheckTypes _targetSelectionType
 
ConditionSourceInfo_condSrcInfo
 
ConditionContainer_condList
 

Constructor & Destructor Documentation

Trinity::WorldObjectSpellTargetCheck::WorldObjectSpellTargetCheck ( Unit caster,
Unit referer,
SpellInfo const spellInfo,
SpellTargetCheckTypes  selectionType,
ConditionContainer condList 
)
7424  : _caster(caster), _referer(referer), _spellInfo(spellInfo),
7425  _targetSelectionType(selectionType), _condList(condList)
7426 {
7427  if (condList)
7428  _condSrcInfo = new ConditionSourceInfo(NULL, caster);
7429  else
7430  _condSrcInfo = NULL;
7431 }
SpellInfo const * _spellInfo
Definition: Spell.h:859
Unit * _caster
Definition: Spell.h:857
arena_t NULL
Definition: jemalloc_internal.h:624
ConditionSourceInfo * _condSrcInfo
Definition: Spell.h:861
Definition: ConditionMgr.h:181
Unit * _referer
Definition: Spell.h:858
ConditionContainer * _condList
Definition: Spell.h:862
SpellTargetCheckTypes _targetSelectionType
Definition: Spell.h:860
Trinity::WorldObjectSpellTargetCheck::~WorldObjectSpellTargetCheck ( )
7434 {
7435  delete _condSrcInfo;
7436 }
ConditionSourceInfo * _condSrcInfo
Definition: Spell.h:861

Member Function Documentation

bool Trinity::WorldObjectSpellTargetCheck::operator() ( WorldObject target)
7439 {
7440  if (_spellInfo->CheckTarget(_caster, target, true) != SPELL_CAST_OK)
7441  return false;
7442  Unit* unitTarget = target->ToUnit();
7443  if (Corpse* corpseTarget = target->ToCorpse())
7444  {
7445  // use ofter for party/assistance checks
7446  if (Player* owner = ObjectAccessor::FindPlayer(corpseTarget->GetOwnerGUID()))
7447  unitTarget = owner;
7448  else
7449  return false;
7450  }
7451  if (unitTarget)
7452  {
7453  switch (_targetSelectionType)
7454  {
7455  case TARGET_CHECK_ENEMY:
7456  if (unitTarget->IsTotem())
7457  return false;
7458  if (!_caster->_IsValidAttackTarget(unitTarget, _spellInfo))
7459  return false;
7460  break;
7461  case TARGET_CHECK_ALLY:
7462  if (unitTarget->IsTotem())
7463  return false;
7464  if (!_caster->_IsValidAssistTarget(unitTarget, _spellInfo))
7465  return false;
7466  break;
7467  case TARGET_CHECK_PARTY:
7468  if (unitTarget->IsTotem())
7469  return false;
7470  if (!_caster->_IsValidAssistTarget(unitTarget, _spellInfo))
7471  return false;
7472  if (!_referer->IsInPartyWith(unitTarget))
7473  return false;
7474  break;
7476  if (_referer->getClass() != unitTarget->getClass())
7477  return false;
7478  // nobreak;
7479  case TARGET_CHECK_RAID:
7480  if (unitTarget->IsTotem())
7481  return false;
7482  if (!_caster->_IsValidAssistTarget(unitTarget, _spellInfo))
7483  return false;
7484  if (!_referer->IsInRaidWith(unitTarget))
7485  return false;
7486  break;
7487  default:
7488  break;
7489  }
7490  }
7491  if (!_condSrcInfo)
7492  return true;
7493  _condSrcInfo->mConditionTargets[0] = target;
7494  return sConditionMgr->IsObjectMeetToConditions(*_condSrcInfo, *_condList);
7495 }
SpellInfo const * _spellInfo
Definition: Spell.h:859
Definition: Corpse.h:49
Definition: SpellInfo.h:126
bool _IsValidAttackTarget(Unit const *target, SpellInfo const *bySpell, WorldObject const *obj=NULL) const
Definition: Unit.cpp:10008
Unit * _caster
Definition: Spell.h:857
Definition: SpellInfo.h:122
bool IsInPartyWith(Unit const *unit) const
Definition: Unit.cpp:14372
Definition: SpellInfo.h:123
Definition: SpellInfo.h:124
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
SpellCastResult CheckTarget(Unit const *caster, WorldObject const *target, bool implicit=true) const
Definition: SpellInfo.cpp:1875
ConditionSourceInfo * _condSrcInfo
Definition: Spell.h:861
Corpse * ToCorpse()
Definition: Object.h:203
Definition: SpellInfo.h:125
#define sConditionMgr
Definition: ConditionMgr.h:307
Unit * _referer
Definition: Spell.h:858
bool IsTotem() const
Definition: Unit.h:1405
uint8 getClass() const
Definition: Unit.h:1413
ConditionContainer * _condList
Definition: Spell.h:862
WorldObject * mConditionTargets[MAX_CONDITION_TARGETS]
Definition: ConditionMgr.h:183
bool IsInRaidWith(Unit const *unit) const
Definition: Unit.cpp:14391
SpellTargetCheckTypes _targetSelectionType
Definition: Spell.h:860
Definition: Unit.h:1305
bool _IsValidAssistTarget(Unit const *target, SpellInfo const *bySpell) const
Definition: Unit.cpp:10129
Definition: SharedDefines.h:1538
Unit * ToUnit()
Definition: Object.h:197

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

Unit* Trinity::WorldObjectSpellTargetCheck::_caster
ConditionContainer* Trinity::WorldObjectSpellTargetCheck::_condList
ConditionSourceInfo* Trinity::WorldObjectSpellTargetCheck::_condSrcInfo
Unit* Trinity::WorldObjectSpellTargetCheck::_referer
SpellInfo const* Trinity::WorldObjectSpellTargetCheck::_spellInfo
SpellTargetCheckTypes Trinity::WorldObjectSpellTargetCheck::_targetSelectionType

The documentation for this struct was generated from the following files: