TrinityCore
DamageInfo Class Reference

#include <Unit.h>

Public Member Functions

 DamageInfo (Unit *attacker, Unit *victim, uint32 damage, SpellInfo const *spellInfo, SpellSchoolMask schoolMask, DamageEffectType damageType, WeaponAttackType attackType)
 
 DamageInfo (CalcDamageInfo const &dmgInfo)
 
 DamageInfo (SpellNonMeleeDamage const &spellNonMeleeDamage, DamageEffectType damageType, WeaponAttackType attackType, uint32 hitMask)
 
void ModifyDamage (int32 amount)
 
void AbsorbDamage (uint32 amount)
 
void ResistDamage (uint32 amount)
 
void BlockDamage (uint32 amount)
 
UnitGetAttacker () const
 
UnitGetVictim () const
 
SpellInfo const * GetSpellInfo () const
 
SpellSchoolMask GetSchoolMask () const
 
DamageEffectType GetDamageType () const
 
WeaponAttackType GetAttackType () const
 
uint32 GetDamage () const
 
uint32 GetOriginalDamage () const
 
uint32 GetAbsorb () const
 
uint32 GetResist () const
 
uint32 GetBlock () const
 
uint32 GetHitMask () const
 

Private Attributes

Unit *const m_attacker
 
Unit *const m_victim
 
uint32 m_damage
 
uint32 const m_originalDamage
 
SpellInfo const *const m_spellInfo
 
SpellSchoolMask const m_schoolMask
 
DamageEffectType const m_damageType
 
WeaponAttackType m_attackType
 
uint32 m_absorb
 
uint32 m_resist
 
uint32 m_block
 
uint32 m_hitMask
 

Constructor & Destructor Documentation

◆ DamageInfo() [1/3]

DamageInfo::DamageInfo ( Unit attacker,
Unit victim,
uint32  damage,
SpellInfo const *  spellInfo,
SpellSchoolMask  schoolMask,
DamageEffectType  damageType,
WeaponAttackType  attackType 
)
127  : m_attacker(attacker), m_victim(victim), m_damage(damage), m_originalDamage(damage), m_spellInfo(spellInfo), m_schoolMask(schoolMask), m_damageType(damageType), m_attackType(attackType),
128  m_absorb(0), m_resist(0), m_block(0), m_hitMask(0)
129 {
130 }
uint32 m_hitMask
Definition: Unit.h:421
uint32 m_absorb
Definition: Unit.h:418
WeaponAttackType m_attackType
Definition: Unit.h:417
uint32 const m_originalDamage
Definition: Unit.h:413
Unit *const m_victim
Definition: Unit.h:411
Unit *const m_attacker
Definition: Unit.h:410
uint32 m_block
Definition: Unit.h:420
SpellSchoolMask const m_schoolMask
Definition: Unit.h:415
DamageEffectType const m_damageType
Definition: Unit.h:416
uint32 m_damage
Definition: Unit.h:412
SpellInfo const *const m_spellInfo
Definition: Unit.h:414
uint32 m_resist
Definition: Unit.h:419

◆ DamageInfo() [2/3]

DamageInfo::DamageInfo ( CalcDamageInfo const &  dmgInfo)
explicit
133  : m_attacker(dmgInfo.Attacker), m_victim(dmgInfo.Target), m_damage(dmgInfo.Damage), m_originalDamage(dmgInfo.Damage), m_spellInfo(nullptr), m_schoolMask(SpellSchoolMask(dmgInfo.DamageSchoolMask)),
134  m_damageType(DIRECT_DAMAGE), m_attackType(dmgInfo.AttackType), m_absorb(dmgInfo.Absorb), m_resist(dmgInfo.Resist), m_block(dmgInfo.Blocked), m_hitMask(0)
135 {
136  switch (dmgInfo.TargetState)
137  {
140  break;
141  case VICTIMSTATE_BLOCKS:
143  break;
144  }
145 
146  if (dmgInfo.HitInfo & (HITINFO_PARTIAL_ABSORB | HITINFO_FULL_ABSORB))
148 
149  if (dmgInfo.HitInfo & HITINFO_FULL_RESIST)
151 
152  if (m_block)
154 
155  bool const damageNullified = (dmgInfo.HitInfo & (HITINFO_FULL_ABSORB | HITINFO_FULL_RESIST)) != 0 ||
157  switch (dmgInfo.HitOutCome)
158  {
159  case MELEE_HIT_MISS:
161  break;
162  case MELEE_HIT_DODGE:
164  break;
165  case MELEE_HIT_PARRY:
167  break;
168  case MELEE_HIT_EVADE:
170  break;
171  case MELEE_HIT_BLOCK:
172  case MELEE_HIT_CRUSHING:
173  case MELEE_HIT_GLANCING:
174  case MELEE_HIT_NORMAL:
175  if (!damageNullified)
177  break;
178  case MELEE_HIT_CRIT:
179  if (!damageNullified)
181  break;
182  }
183 }
Definition: SpellMgr.h:246
Definition: Unit.h:372
Definition: Unit.h:331
Definition: Unit.h:372
Definition: UnitDefines.h:335
uint32 m_hitMask
Definition: Unit.h:421
Definition: SpellMgr.h:251
uint32 m_absorb
Definition: Unit.h:418
WeaponAttackType m_attackType
Definition: Unit.h:417
Definition: SpellMgr.h:252
uint32 const m_originalDamage
Definition: Unit.h:413
Definition: SpellMgr.h:254
Unit *const m_victim
Definition: Unit.h:411
SpellSchoolMask
Definition: SharedDefines.h:306
Definition: Unit.h:372
Definition: Unit.h:373
Unit *const m_attacker
Definition: Unit.h:410
uint32 m_block
Definition: Unit.h:420
Definition: Unit.h:55
Definition: Unit.h:372
Definition: SpellMgr.h:259
Definition: SpellMgr.h:253
Definition: SpellMgr.h:249
Definition: Unit.h:373
Definition: Unit.h:372
Definition: UnitDefines.h:334
Definition: SpellMgr.h:248
Definition: Unit.h:57
Definition: SpellMgr.h:250
Definition: SpellMgr.h:256
Definition: UnitDefines.h:336
Definition: Unit.h:373
SpellSchoolMask const m_schoolMask
Definition: Unit.h:415
Definition: SpellMgr.h:247
DamageEffectType const m_damageType
Definition: Unit.h:416
uint32 m_damage
Definition: Unit.h:412
SpellInfo const *const m_spellInfo
Definition: Unit.h:414
uint32 m_resist
Definition: Unit.h:419
Definition: Unit.h:373

◆ DamageInfo() [3/3]

DamageInfo::DamageInfo ( SpellNonMeleeDamage const &  spellNonMeleeDamage,
DamageEffectType  damageType,
WeaponAttackType  attackType,
uint32  hitMask 
)
186  : m_attacker(spellNonMeleeDamage.attacker), m_victim(spellNonMeleeDamage.target), m_damage(spellNonMeleeDamage.damage), m_originalDamage(spellNonMeleeDamage.originalDamage),
187  m_spellInfo(spellNonMeleeDamage.Spell), m_schoolMask(SpellSchoolMask(spellNonMeleeDamage.schoolMask)), m_damageType(damageType),
188  m_attackType(attackType), m_absorb(spellNonMeleeDamage.absorb), m_resist(spellNonMeleeDamage.resist), m_block(spellNonMeleeDamage.blocked), m_hitMask(hitMask)
189 {
190  if (spellNonMeleeDamage.blocked)
192  if (spellNonMeleeDamage.absorb)
194 }
uint32 m_hitMask
Definition: Unit.h:421
uint32 m_absorb
Definition: Unit.h:418
WeaponAttackType m_attackType
Definition: Unit.h:417
Definition: SpellMgr.h:252
uint32 const m_originalDamage
Definition: Unit.h:413
Unit *const m_victim
Definition: Unit.h:411
SpellSchoolMask
Definition: SharedDefines.h:306
Unit *const m_attacker
Definition: Unit.h:410
uint32 m_block
Definition: Unit.h:420
Definition: SpellMgr.h:256
SpellSchoolMask const m_schoolMask
Definition: Unit.h:415
DamageEffectType const m_damageType
Definition: Unit.h:416
uint32 m_damage
Definition: Unit.h:412
SpellInfo const *const m_spellInfo
Definition: Unit.h:414
uint32 m_resist
Definition: Unit.h:419

Member Function Documentation

◆ AbsorbDamage()

void DamageInfo::AbsorbDamage ( uint32  amount)
203 {
204  amount = std::min(amount, GetDamage());
205  m_absorb += amount;
206  m_damage -= amount;
208 }
uint32 m_hitMask
Definition: Unit.h:421
uint32 m_absorb
Definition: Unit.h:418
Definition: SpellMgr.h:256
uint32 m_damage
Definition: Unit.h:412
uint32 GetDamage() const
Definition: Unit.h:438
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ BlockDamage()

void DamageInfo::BlockDamage ( uint32  amount)
223 {
224  amount = std::min(amount, GetDamage());
225  m_block += amount;
226  m_damage -= amount;
228  if (!m_damage)
229  {
232  }
233 }
Definition: SpellMgr.h:246
uint32 m_hitMask
Definition: Unit.h:421
Definition: SpellMgr.h:252
uint32 m_block
Definition: Unit.h:420
Definition: SpellMgr.h:259
Definition: SpellMgr.h:247
uint32 m_damage
Definition: Unit.h:412
uint32 GetDamage() const
Definition: Unit.h:438
+ Here is the call graph for this function:

◆ GetAbsorb()

uint32 DamageInfo::GetAbsorb ( ) const
inline
440 { return m_absorb; }
uint32 m_absorb
Definition: Unit.h:418
+ Here is the caller graph for this function:

◆ GetAttacker()

Unit* DamageInfo::GetAttacker ( ) const
inline
432 { return m_attacker; }
Unit *const m_attacker
Definition: Unit.h:410
+ Here is the caller graph for this function:

◆ GetAttackType()

WeaponAttackType DamageInfo::GetAttackType ( ) const
inline
437 { return m_attackType; }
WeaponAttackType m_attackType
Definition: Unit.h:417
+ Here is the caller graph for this function:

◆ GetBlock()

uint32 DamageInfo::GetBlock ( ) const
inline
442 { return m_block; }
uint32 m_block
Definition: Unit.h:420

◆ GetDamage()

uint32 DamageInfo::GetDamage ( ) const
inline
438 { return m_damage; }
uint32 m_damage
Definition: Unit.h:412
+ Here is the caller graph for this function:

◆ GetDamageType()

DamageEffectType DamageInfo::GetDamageType ( ) const
inline
436 { return m_damageType; }
DamageEffectType const m_damageType
Definition: Unit.h:416

◆ GetHitMask()

uint32 DamageInfo::GetHitMask ( ) const
236 {
237  return m_hitMask;
238 }
uint32 m_hitMask
Definition: Unit.h:421
+ Here is the caller graph for this function:

◆ GetOriginalDamage()

uint32 DamageInfo::GetOriginalDamage ( ) const
inline
439 { return m_originalDamage; }
uint32 const m_originalDamage
Definition: Unit.h:413
+ Here is the caller graph for this function:

◆ GetResist()

uint32 DamageInfo::GetResist ( ) const
inline
441 { return m_resist; }
uint32 m_resist
Definition: Unit.h:419
+ Here is the caller graph for this function:

◆ GetSchoolMask()

SpellSchoolMask DamageInfo::GetSchoolMask ( ) const
inline
435 { return m_schoolMask; }
SpellSchoolMask const m_schoolMask
Definition: Unit.h:415
+ Here is the caller graph for this function:

◆ GetSpellInfo()

SpellInfo const* DamageInfo::GetSpellInfo ( ) const
inline
434 { return m_spellInfo; }
SpellInfo const *const m_spellInfo
Definition: Unit.h:414
+ Here is the caller graph for this function:

◆ GetVictim()

Unit* DamageInfo::GetVictim ( ) const
inline
433 { return m_victim; }
Unit *const m_victim
Definition: Unit.h:411
+ Here is the caller graph for this function:

◆ ModifyDamage()

void DamageInfo::ModifyDamage ( int32  amount)
197 {
198  amount = std::max(amount, -static_cast<int32>(GetDamage()));
199  m_damage += amount;
200 }
uint32 m_damage
Definition: Unit.h:412
uint32 GetDamage() const
Definition: Unit.h:438
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ResistDamage()

void DamageInfo::ResistDamage ( uint32  amount)
211 {
212  amount = std::min(amount, GetDamage());
213  m_resist += amount;
214  m_damage -= amount;
215  if (!m_damage)
216  {
219  }
220 }
Definition: SpellMgr.h:246
uint32 m_hitMask
Definition: Unit.h:421
Definition: SpellMgr.h:249
Definition: SpellMgr.h:247
uint32 m_damage
Definition: Unit.h:412
uint32 m_resist
Definition: Unit.h:419
uint32 GetDamage() const
Definition: Unit.h:438
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ m_absorb

uint32 DamageInfo::m_absorb
private

◆ m_attacker

Unit* const DamageInfo::m_attacker
private

◆ m_attackType

WeaponAttackType DamageInfo::m_attackType
private

◆ m_block

uint32 DamageInfo::m_block
private

◆ m_damage

uint32 DamageInfo::m_damage
private

◆ m_damageType

DamageEffectType const DamageInfo::m_damageType
private

◆ m_hitMask

uint32 DamageInfo::m_hitMask
private

◆ m_originalDamage

uint32 const DamageInfo::m_originalDamage
private

◆ m_resist

uint32 DamageInfo::m_resist
private

◆ m_schoolMask

SpellSchoolMask const DamageInfo::m_schoolMask
private

◆ m_spellInfo

SpellInfo const* const DamageInfo::m_spellInfo
private

◆ m_victim

Unit* const DamageInfo::m_victim
private

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