diff options
author | QAston <none@none> | 2009-07-27 18:05:30 +0200 |
---|---|---|
committer | QAston <none@none> | 2009-07-27 18:05:30 +0200 |
commit | 491051e194c12f3bb968c6d6f702a10e3b22cdb2 (patch) | |
tree | 968cfc6a8516d1cbbd61fb15424aa06ead3c3a65 /src/game/Unit.cpp | |
parent | e8f8b66636cbcd5d9995ce8b3bb64afb5a835851 (diff) |
*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
Diffstat (limited to 'src/game/Unit.cpp')
-rw-r--r-- | src/game/Unit.cpp | 66 |
1 files changed, 49 insertions, 17 deletions
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)); +} |