*Rage is now generated by damage absorbed

*Fix rage calculation for level > 70
*Allow rage generation for NPC using rage
*Make mitigated damage not add rage
*Fix Warriors' Berserker Rage
Author of all of these: thenecromancer

--HG--
branch : trunk
This commit is contained in:
QAston
2009-07-27 18:05:30 +02:00
parent e8f8b66636
commit 491051e194
5 changed files with 62 additions and 53 deletions
-27
View File
@@ -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() void Player::RegenerateAll()
{ {
if (m_regenTimer != 0) if (m_regenTimer != 0)
-1
View File
@@ -1305,7 +1305,6 @@ class TRINITY_DLL_SPEC Player : public Unit
void SetBindPoint(uint64 guid); void SetBindPoint(uint64 guid);
void SendTalentWipeConfirm(uint64 guid); void SendTalentWipeConfirm(uint64 guid);
void RewardRage( uint32 damage, uint32 weaponSpeedHitFactor, bool attacker );
void SendPetSkillWipeConfirm(); void SendPetSkillWipeConfirm();
void CalcRage( uint32 damage,bool attacker ); void CalcRage( uint32 damage,bool attacker );
void RegenerateAll(); void RegenerateAll();
+5 -5
View File
@@ -6150,7 +6150,7 @@ void AuraEffect::PeriodicTick()
uint32 absorb=0; uint32 absorb=0;
uint32 resist=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 // ignore non positive values (can be result apply spellmods to aura damage
//uint32 amount = GetModifierValuePerStack() > 0 ? GetModifierValuePerStack() : 0; //uint32 amount = GetModifierValuePerStack() > 0 ? GetModifierValuePerStack() : 0;
@@ -6166,7 +6166,7 @@ void AuraEffect::PeriodicTick()
GetEffectMechanic(GetSpellProto(), m_effIndex) != MECHANIC_BLEED) GetEffectMechanic(GetSpellProto(), m_effIndex) != MECHANIC_BLEED)
{ {
uint32 pdamageReductedArmor = pCaster->CalcArmorReducedDamage(m_target, pdamage, GetSpellProto()); uint32 pdamageReductedArmor = pCaster->CalcArmorReducedDamage(m_target, pdamage, GetSpellProto());
cleanDamage.damage += pdamage - pdamageReductedArmor; cleanDamage.mitigated_damage += pdamage - pdamageReductedArmor;
pdamage = pdamageReductedArmor; pdamage = pdamageReductedArmor;
} }
@@ -6250,7 +6250,7 @@ void AuraEffect::PeriodicTick()
uint32 absorb=0; uint32 absorb=0;
uint32 resist=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 = GetModifierValuePerStack() > 0 ? GetModifierValuePerStack() : 0;
uint32 pdamage = GetAmount() > 0 ? GetAmount() : 0; uint32 pdamage = GetAmount() > 0 ? GetAmount() : 0;
@@ -6260,7 +6260,7 @@ void AuraEffect::PeriodicTick()
if (GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_NORMAL) if (GetSpellSchoolMask(GetSpellProto()) & SPELL_SCHOOL_MASK_NORMAL)
{ {
uint32 pdamageReductedArmor = pCaster->CalcArmorReducedDamage(m_target, pdamage, GetSpellProto()); uint32 pdamageReductedArmor = pCaster->CalcArmorReducedDamage(m_target, pdamage, GetSpellProto());
cleanDamage.damage += pdamage - pdamageReductedArmor; cleanDamage.mitigated_damage += pdamage - pdamageReductedArmor;
pdamage = pdamageReductedArmor; pdamage = pdamageReductedArmor;
} }
@@ -6420,7 +6420,7 @@ void AuraEffect::PeriodicTick()
pCaster->DealDamageMods(pCaster,damage,&absorb); pCaster->DealDamageMods(pCaster,damage,&absorb);
pCaster->SendSpellNonMeleeDamageLog(pCaster, GetId(), damage, GetSpellSchoolMask(GetSpellProto()), absorb, 0, false, 0, false); 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); pCaster->DealDamage(pCaster, damage, &cleanDamage, NODAMAGE, GetSpellSchoolMask(GetSpellProto()), GetSpellProto(), true);
} }
} }
+49 -17
View File
@@ -643,9 +643,9 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
if(!damage) if(!damage)
{ {
// Rage from physical damage received . // Rage from absorbed damage
if(cleanDamage && cleanDamage->damage && (damageSchoolMask & SPELL_SCHOOL_MASK_NORMAL) && pVictim->GetTypeId() == TYPEID_PLAYER && (pVictim->getPowerType() == POWER_RAGE)) if(cleanDamage && cleanDamage->absorbed_damage && pVictim->getPowerType() == POWER_RAGE)
((Player*)pVictim)->RewardRage(cleanDamage->damage, 0, false); pVictim->RewardRage(cleanDamage->absorbed_damage, 0, false);
return 0; 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) // 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 weaponSpeedHitFactor;
uint32 rage_damage = damage + cleanDamage->absorbed_damage;
switch(cleanDamage->attackType) switch(cleanDamage->attackType)
{ {
@@ -703,7 +704,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
else else
weaponSpeedHitFactor = uint32(GetAttackTime(cleanDamage->attackType)/1000.0f * 3.5f); weaponSpeedHitFactor = uint32(GetAttackTime(cleanDamage->attackType)/1000.0f * 3.5f);
((Player*)this)->RewardRage(damage, weaponSpeedHitFactor, true); RewardRage(rage_damage, weaponSpeedHitFactor, true);
break; break;
} }
@@ -714,7 +715,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
else else
weaponSpeedHitFactor = uint32(GetAttackTime(cleanDamage->attackType)/1000.0f * 1.75f); weaponSpeedHitFactor = uint32(GetAttackTime(cleanDamage->attackType)/1000.0f * 1.75f);
((Player*)this)->RewardRage(damage, weaponSpeedHitFactor, true); RewardRage(rage_damage, weaponSpeedHitFactor, true);
break; break;
} }
@@ -948,13 +949,6 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
} }
else // victim is a player 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) // random durability for items (HIT TAKEN)
if (roll_chance_f(sWorld.getRate(RATE_DURABILITY_LOSS_DAMAGE))) 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) if(GetTypeId()==TYPEID_PLAYER)
{ {
// random durability for items (HIT DONE) // random durability for items (HIT DONE)
@@ -1404,7 +1405,7 @@ void Unit::DealSpellDamage(SpellNonMeleeDamage *damageInfo, bool durabilityLoss)
} }
// Call default DealDamage // 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); 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 // 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); 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 // 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); 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); 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); 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); DealDamage(caster, splitted, &cleanDamage, DIRECT_DAMAGE, schoolMask, (*i)->GetSpellProto(), false);
} }
} }
@@ -15026,3 +15027,34 @@ void Unit::SendRemoveFromThreatListOpcode(HostilReference* pHostilReference)
data.appendPackGUID(pHostilReference->getUnitGuid()); data.appendPackGUID(pHostilReference->getUnitGuid());
SendMessageToSet(&data, false); 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));
}
+8 -3
View File
@@ -771,10 +771,12 @@ enum MeleeHitOutcome
struct CleanDamage struct CleanDamage
{ {
CleanDamage(uint32 _damage, WeaponAttackType _attackType, MeleeHitOutcome _hitOutCome) : CleanDamage(uint32 mitigated, uint32 absorbed, WeaponAttackType _attackType, MeleeHitOutcome _hitOutCome) :
damage(_damage), attackType(_attackType), hitOutCome(_hitOutCome) {} mitigated_damage(mitigated), absorbed_damage(absorbed), attackType(_attackType), hitOutCome(_hitOutCome) {}
uint32 absorbed_damage;
uint32 mitigated_damage;
uint32 damage;
WeaponAttackType attackType; WeaponAttackType attackType;
MeleeHitOutcome hitOutCome; MeleeHitOutcome hitOutCome;
}; };
@@ -1806,6 +1808,9 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
bool canFly() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FLY_MODE); } bool canFly() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FLY_MODE); }
bool IsFlying() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FLYING); } bool IsFlying() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FLYING); }
void SetFlying(bool apply); void SetFlying(bool apply);
void RewardRage( uint32 damage, uint32 weaponSpeedHitFactor, bool attacker );
virtual float GetFollowAngle() const { return M_PI/2; } virtual float GetFollowAngle() const { return M_PI/2; }
protected: protected:
explicit Unit (); explicit Unit ();