aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/Player.cpp27
-rw-r--r--src/game/Player.h1
-rw-r--r--src/game/SpellAuras.cpp10
-rw-r--r--src/game/Unit.cpp66
-rw-r--r--src/game/Unit.h11
5 files changed, 62 insertions, 53 deletions
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index ec31194680c..d2dbdd1263c 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -1951,33 +1951,6 @@ void Player::RemoveFromWorld()
}
}
-void Player::RewardRage( uint32 damage, uint32 weaponSpeedHitFactor, bool attacker )
-{
- float addRage;
-
- float rageconversion = ((0.0091107836 * getLevel()*getLevel())+3.225598133*getLevel())+4.2652911;
-
- if(attacker)
- {
- addRage = ((damage/rageconversion*7.5 + weaponSpeedHitFactor)/2);
-
- // talent who gave more rage on attack
- addRage *= 1.0f + GetTotalAuraModifier(SPELL_AURA_MOD_RAGE_FROM_DAMAGE_DEALT) / 100.0f;
- }
- else
- {
- addRage = damage/rageconversion*2.5;
-
- // Berserker Rage effect
- if(HasAura(18499))
- addRage *= 1.3;
- }
-
- addRage *= sWorld.getRate(RATE_POWER_RAGE_INCOME);
-
- ModifyPower(POWER_RAGE, uint32(addRage*10));
-}
-
void Player::RegenerateAll()
{
if (m_regenTimer != 0)
diff --git a/src/game/Player.h b/src/game/Player.h
index 0affa3b82fd..a8ec9e80172 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -1305,7 +1305,6 @@ class TRINITY_DLL_SPEC Player : public Unit
void SetBindPoint(uint64 guid);
void SendTalentWipeConfirm(uint64 guid);
- void RewardRage( uint32 damage, uint32 weaponSpeedHitFactor, bool attacker );
void SendPetSkillWipeConfirm();
void CalcRage( uint32 damage,bool attacker );
void RegenerateAll();
diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp
index 3597c670e8b..7515126b6cd 100644
--- a/src/game/SpellAuras.cpp
+++ b/src/game/SpellAuras.cpp
@@ -6150,7 +6150,7 @@ void AuraEffect::PeriodicTick()
uint32 absorb=0;
uint32 resist=0;
- CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL );
+ CleanDamage cleanDamage = CleanDamage(0, 0, BASE_ATTACK, MELEE_HIT_NORMAL );
// ignore non positive values (can be result apply spellmods to aura damage
//uint32 amount = GetModifierValuePerStack() > 0 ? GetModifierValuePerStack() : 0;
@@ -6166,7 +6166,7 @@ void AuraEffect::PeriodicTick()
GetEffectMechanic(GetSpellProto(), m_effIndex) != MECHANIC_BLEED)
{
uint32 pdamageReductedArmor = pCaster->CalcArmorReducedDamage(m_target, pdamage, GetSpellProto());
- cleanDamage.damage += pdamage - pdamageReductedArmor;
+ cleanDamage.mitigated_damage += pdamage - pdamageReductedArmor;
pdamage = pdamageReductedArmor;
}
@@ -6250,7 +6250,7 @@ void AuraEffect::PeriodicTick()
uint32 absorb=0;
uint32 resist=0;
- CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL );
+ CleanDamage cleanDamage = CleanDamage(0, 0, BASE_ATTACK, MELEE_HIT_NORMAL );
//uint32 pdamage = GetModifierValuePerStack() > 0 ? GetModifierValuePerStack() : 0;
uint32 pdamage = GetAmount() > 0 ? GetAmount() : 0;
@@ -6260,7 +6260,7 @@ void AuraEffect::PeriodicTick()
if (GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_NORMAL)
{
uint32 pdamageReductedArmor = pCaster->CalcArmorReducedDamage(m_target, pdamage, GetSpellProto());
- cleanDamage.damage += pdamage - pdamageReductedArmor;
+ cleanDamage.mitigated_damage += pdamage - pdamageReductedArmor;
pdamage = pdamageReductedArmor;
}
@@ -6420,7 +6420,7 @@ void AuraEffect::PeriodicTick()
pCaster->DealDamageMods(pCaster,damage,&absorb);
pCaster->SendSpellNonMeleeDamageLog(pCaster, GetId(), damage, GetSpellSchoolMask(GetSpellProto()), absorb, 0, false, 0, false);
- CleanDamage cleanDamage = CleanDamage(0, BASE_ATTACK, MELEE_HIT_NORMAL );
+ CleanDamage cleanDamage = CleanDamage(0, 0, BASE_ATTACK, MELEE_HIT_NORMAL );
pCaster->DealDamage(pCaster, damage, &cleanDamage, NODAMAGE, GetSpellSchoolMask(GetSpellProto()), GetSpellProto(), true);
}
}
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 2b4c320fbeb..0990a7c3965 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -643,9 +643,9 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
if(!damage)
{
- // Rage from physical damage received .
- if(cleanDamage && cleanDamage->damage && (damageSchoolMask & SPELL_SCHOOL_MASK_NORMAL) && pVictim->GetTypeId() == TYPEID_PLAYER && (pVictim->getPowerType() == POWER_RAGE))
- ((Player*)pVictim)->RewardRage(cleanDamage->damage, 0, false);
+ // Rage from absorbed damage
+ if(cleanDamage && cleanDamage->absorbed_damage && pVictim->getPowerType() == POWER_RAGE)
+ pVictim->RewardRage(cleanDamage->absorbed_damage, 0, false);
return 0;
}
@@ -690,9 +690,10 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
}
// Rage from Damage made (only from direct weapon damage)
- if( cleanDamage && damagetype==DIRECT_DAMAGE && this != pVictim && GetTypeId() == TYPEID_PLAYER && (getPowerType() == POWER_RAGE))
+ if(cleanDamage && damagetype==DIRECT_DAMAGE && this != pVictim && getPowerType() == POWER_RAGE)
{
uint32 weaponSpeedHitFactor;
+ uint32 rage_damage = damage + cleanDamage->absorbed_damage;
switch(cleanDamage->attackType)
{
@@ -703,7 +704,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
else
weaponSpeedHitFactor = uint32(GetAttackTime(cleanDamage->attackType)/1000.0f * 3.5f);
- ((Player*)this)->RewardRage(damage, weaponSpeedHitFactor, true);
+ RewardRage(rage_damage, weaponSpeedHitFactor, true);
break;
}
@@ -714,7 +715,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
else
weaponSpeedHitFactor = uint32(GetAttackTime(cleanDamage->attackType)/1000.0f * 1.75f);
- ((Player*)this)->RewardRage(damage, weaponSpeedHitFactor, true);
+ RewardRage(rage_damage, weaponSpeedHitFactor, true);
break;
}
@@ -948,13 +949,6 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
}
else // victim is a player
{
- // Rage from damage received
- if(this != pVictim && pVictim->getPowerType() == POWER_RAGE)
- {
- uint32 rage_damage = damage + (cleanDamage ? cleanDamage->damage : 0);
- ((Player*)pVictim)->RewardRage(rage_damage, 0, false);
- }
-
// random durability for items (HIT TAKEN)
if (roll_chance_f(sWorld.getRate(RATE_DURABILITY_LOSS_DAMAGE)))
{
@@ -963,6 +957,13 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
}
}
+ // Rage from damage received
+ if(this != pVictim && pVictim->getPowerType() == POWER_RAGE)
+ {
+ uint32 rage_damage = damage + (cleanDamage ? cleanDamage->absorbed_damage : 0);
+ pVictim->RewardRage(rage_damage, 0, false);
+ }
+
if(GetTypeId()==TYPEID_PLAYER)
{
// random durability for items (HIT DONE)
@@ -1404,7 +1405,7 @@ void Unit::DealSpellDamage(SpellNonMeleeDamage *damageInfo, bool durabilityLoss)
}
// Call default DealDamage
- CleanDamage cleanDamage(damageInfo->cleanDamage, BASE_ATTACK, MELEE_HIT_NORMAL);
+ CleanDamage cleanDamage(damageInfo->cleanDamage, damageInfo->absorb, BASE_ATTACK, MELEE_HIT_NORMAL);
DealDamage(pVictim, damageInfo->damage, &cleanDamage, SPELL_DIRECT_DAMAGE, SpellSchoolMask(damageInfo->schoolMask), spellProto, durabilityLoss);
}
@@ -1682,7 +1683,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo *damageInfo, bool durabilityLoss)
}
// Call default DealDamage
- CleanDamage cleanDamage(damageInfo->cleanDamage,damageInfo->attackType,damageInfo->hitOutCome);
+ CleanDamage cleanDamage(damageInfo->cleanDamage,damageInfo->absorb,damageInfo->attackType,damageInfo->hitOutCome);
DealDamage(pVictim, damageInfo->damage, &cleanDamage, DIRECT_DAMAGE, SpellSchoolMask(damageInfo->damageSchoolMask), NULL, durabilityLoss);
// If this is a creature and it attacks from behind it has a probability to daze it's victim
@@ -2189,7 +2190,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe
SendSpellNonMeleeDamageLog(caster, (*i)->GetSpellProto()->Id, splitted, schoolMask, splitted_absorb, 0, false, 0, false);
- CleanDamage cleanDamage = CleanDamage(splitted, BASE_ATTACK, MELEE_HIT_NORMAL);
+ CleanDamage cleanDamage = CleanDamage(splitted, 0, BASE_ATTACK, MELEE_HIT_NORMAL);
DealDamage(caster, splitted, &cleanDamage, DIRECT_DAMAGE, schoolMask, (*i)->GetSpellProto(), false);
}
@@ -2216,7 +2217,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim,SpellSchoolMask schoolMask, DamageEffe
SendSpellNonMeleeDamageLog(caster, (*i)->GetSpellProto()->Id, splitted, schoolMask, split_absorb, 0, false, 0, false);
- CleanDamage cleanDamage = CleanDamage(splitted, BASE_ATTACK, MELEE_HIT_NORMAL);
+ CleanDamage cleanDamage = CleanDamage(splitted, 0, BASE_ATTACK, MELEE_HIT_NORMAL);
DealDamage(caster, splitted, &cleanDamage, DIRECT_DAMAGE, schoolMask, (*i)->GetSpellProto(), false);
}
}
@@ -15026,3 +15027,34 @@ void Unit::SendRemoveFromThreatListOpcode(HostilReference* pHostilReference)
data.appendPackGUID(pHostilReference->getUnitGuid());
SendMessageToSet(&data, false);
}
+
+void Unit::RewardRage( uint32 damage, uint32 weaponSpeedHitFactor, bool attacker )
+{
+ float addRage;
+
+ float rageconversion = ((0.0091107836 * getLevel()*getLevel())+3.225598133*getLevel())+4.2652911;
+
+ // Unknown if correct, but lineary adjust rage conversion above level 70
+ if (getLevel() > 70)
+ rageconversion += 13.27f*(getLevel()-70);
+
+ if(attacker)
+ {
+ addRage = ((damage/rageconversion*7.5 + weaponSpeedHitFactor)/2);
+
+ // talent who gave more rage on attack
+ addRage *= 1.0f + GetTotalAuraModifier(SPELL_AURA_MOD_RAGE_FROM_DAMAGE_DEALT) / 100.0f;
+ }
+ else
+ {
+ addRage = damage/rageconversion*2.5;
+
+ // Berserker Rage effect
+ if(HasAura(18499))
+ addRage *= 2.0;
+ }
+
+ addRage *= sWorld.getRate(RATE_POWER_RAGE_INCOME);
+
+ ModifyPower(POWER_RAGE, uint32(addRage*10));
+}
diff --git a/src/game/Unit.h b/src/game/Unit.h
index 22fe4ccc687..cad248c7489 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -771,10 +771,12 @@ enum MeleeHitOutcome
struct CleanDamage
{
- CleanDamage(uint32 _damage, WeaponAttackType _attackType, MeleeHitOutcome _hitOutCome) :
- damage(_damage), attackType(_attackType), hitOutCome(_hitOutCome) {}
+ CleanDamage(uint32 mitigated, uint32 absorbed, WeaponAttackType _attackType, MeleeHitOutcome _hitOutCome) :
+ mitigated_damage(mitigated), absorbed_damage(absorbed), attackType(_attackType), hitOutCome(_hitOutCome) {}
+
+ uint32 absorbed_damage;
+ uint32 mitigated_damage;
- uint32 damage;
WeaponAttackType attackType;
MeleeHitOutcome hitOutCome;
};
@@ -1806,6 +1808,9 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
bool canFly() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FLY_MODE); }
bool IsFlying() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FLYING); }
void SetFlying(bool apply);
+
+ void RewardRage( uint32 damage, uint32 weaponSpeedHitFactor, bool attacker );
+
virtual float GetFollowAngle() const { return M_PI/2; }
protected:
explicit Unit ();