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

#include <ThreatManager.h>

Static Public Member Functions

static float calcThreat (Unit *hatedUnit, Unit *hatingUnit, float threat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL, SpellInfo const *threatSpell=NULL)
 
static bool isValidProcess (Unit *hatedUnit, Unit *hatingUnit, SpellInfo const *threatSpell=NULL)
 

Member Function Documentation

float ThreatCalcHelper::calcThreat ( Unit hatedUnit,
Unit hatingUnit,
float  threat,
SpellSchoolMask  schoolMask = SPELL_SCHOOL_MASK_NORMAL,
SpellInfo const threatSpell = NULL 
)
static
35 {
36  if (threatSpell)
37  {
38  if (SpellThreatEntry const* threatEntry = sSpellMgr->GetSpellThreatEntry(threatSpell->Id))
39  if (threatEntry->pctMod != 1.0f)
40  threat *= threatEntry->pctMod;
41 
42  // Energize is not affected by Mods
43  for (SpellEffectInfo const* effect : threatSpell->GetEffectsForDifficulty(hatedUnit->GetMap()->GetDifficultyID()))
44  if (effect && (effect->Effect == SPELL_EFFECT_ENERGIZE || effect->ApplyAuraName == SPELL_AURA_PERIODIC_ENERGIZE))
45  return threat;
46 
47  if (Player* modOwner = hatedUnit->GetSpellModOwner())
48  modOwner->ApplySpellMod(threatSpell->Id, SPELLMOD_THREAT, threat);
49  }
50 
51  return hatedUnit->ApplyTotalThreatModifier(threat, schoolMask);
52 }
Map * GetMap() const
Definition: Object.h:543
Definition: SharedDefines.h:1040
Difficulty GetDifficultyID() const
Definition: Map.h:390
float ApplyTotalThreatModifier(float fThreat, SpellSchoolMask schoolMask=SPELL_SCHOOL_MASK_NORMAL)
Definition: Unit.cpp:10679
Definition: SpellMgr.h:349
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: SpellInfo.h:238
Definition: SpellAuraDefines.h:84
Player * GetSpellModOwner() const
Definition: Unit.cpp:12691
Definition: Unit.h:88

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ThreatCalcHelper::isValidProcess ( Unit hatedUnit,
Unit hatingUnit,
SpellInfo const threatSpell = NULL 
)
static
55 {
56  //function deals with adding threat and adding players and pets into ThreatList
57  //mobs, NPCs, guards have ThreatList and HateOfflineList
58  //players and pets have only InHateListOf
59  //HateOfflineList is used co contain unattackable victims (in-flight, in-water, GM etc.)
60 
61  if (!hatedUnit || !hatingUnit)
62  return false;
63 
64  // not to self
65  if (hatedUnit == hatingUnit)
66  return false;
67 
68  // not to GM
69  if (hatedUnit->GetTypeId() == TYPEID_PLAYER && hatedUnit->ToPlayer()->IsGameMaster())
70  return false;
71 
72  // not to dead and not for dead
73  if (!hatedUnit->IsAlive() || !hatingUnit->IsAlive())
74  return false;
75 
76  // not in same map or phase
77  if (!hatedUnit->IsInMap(hatingUnit) || !hatedUnit->IsInPhase(hatingUnit))
78  return false;
79 
80  // spell not causing threat
81  if (threatSpell && threatSpell->HasAttribute(SPELL_ATTR1_NO_THREAT))
82  return false;
83 
84  ASSERT(hatingUnit->GetTypeId() == TYPEID_UNIT);
85 
86  return true;
87 }
Definition: ObjectGuid.h:32
bool IsInMap(WorldObject const *obj) const
Definition: Object.cpp:1631
Player * ToPlayer()
Definition: Object.h:191
TypeID GetTypeId() const
Definition: Object.h:113
Definition: SharedDefines.h:402
bool IsAlive() const
Definition: Unit.h:1692
bool IsInPhase(uint32 phase) const
Definition: Object.h:462
Definition: ObjectGuid.h:33
#define ASSERT
Definition: Errors.h:55

+ Here is the call graph for this function:

+ Here is the caller graph for this function:


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