mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-21 15:27:47 -04:00
Core/Entities: implement secondary damage for some weapons and removal of old voodoo
- Fixed correct Retaliation damage spell according to sniffs is 20240 - CalcArmorReducedDamage insisted on dealing a minimum of 1 damage even if damage was 0 - CalculateDamage was zero-phobic too: it defaulted to arbitrary max 5 damage Closes #19081
This commit is contained in:
@@ -62,25 +62,31 @@ void Unit::UpdateAllResistances()
|
||||
|
||||
void Unit::UpdateDamagePhysical(WeaponAttackType attType)
|
||||
{
|
||||
float minDamage = 0.0f;
|
||||
float maxDamage = 0.0f;
|
||||
float totalMin = 0.f;
|
||||
float totalMax = 0.f;
|
||||
|
||||
CalculateMinMaxDamage(attType, false, true, minDamage, maxDamage);
|
||||
float tmpMin, tmpMax;
|
||||
for (uint8 i = 0; i < MAX_ITEM_PROTO_DAMAGES; ++i)
|
||||
{
|
||||
CalculateMinMaxDamage(attType, false, true, tmpMin, tmpMax, i);
|
||||
totalMin += tmpMin;
|
||||
totalMax += tmpMax;
|
||||
}
|
||||
|
||||
switch (attType)
|
||||
{
|
||||
case BASE_ATTACK:
|
||||
default:
|
||||
SetStatFloatValue(UNIT_FIELD_MINDAMAGE, minDamage);
|
||||
SetStatFloatValue(UNIT_FIELD_MAXDAMAGE, maxDamage);
|
||||
SetStatFloatValue(UNIT_FIELD_MINDAMAGE, totalMin);
|
||||
SetStatFloatValue(UNIT_FIELD_MAXDAMAGE, totalMax);
|
||||
break;
|
||||
case OFF_ATTACK:
|
||||
SetStatFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE, minDamage);
|
||||
SetStatFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE, maxDamage);
|
||||
SetStatFloatValue(UNIT_FIELD_MINOFFHANDDAMAGE, totalMin);
|
||||
SetStatFloatValue(UNIT_FIELD_MAXOFFHANDDAMAGE, totalMax);
|
||||
break;
|
||||
case RANGED_ATTACK:
|
||||
SetStatFloatValue(UNIT_FIELD_MINRANGEDDAMAGE, minDamage);
|
||||
SetStatFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE, maxDamage);
|
||||
SetStatFloatValue(UNIT_FIELD_MINRANGEDDAMAGE, totalMin);
|
||||
SetStatFloatValue(UNIT_FIELD_MAXRANGEDDAMAGE, totalMax);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -509,7 +515,7 @@ void Player::UpdateShieldBlockValue()
|
||||
SetUInt32Value(PLAYER_SHIELD_BLOCK, GetShieldBlockValue());
|
||||
}
|
||||
|
||||
void Player::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, float& minDamage, float& maxDamage) const
|
||||
void Player::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, float& minDamage, float& maxDamage, uint8 damageIndex) const
|
||||
{
|
||||
UnitMods unitMod;
|
||||
|
||||
@@ -529,16 +535,27 @@ void Player::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bo
|
||||
|
||||
float const attackPowerMod = std::max(GetAPMultiplier(attType, normalized), 0.25f);
|
||||
|
||||
float baseValue = GetFlatModifierValue(unitMod, BASE_VALUE) + GetTotalAttackPowerValue(attType) / 14.0f * attackPowerMod;
|
||||
float baseValue = GetFlatModifierValue(unitMod, BASE_VALUE);
|
||||
if (damageIndex == 0) // apply AP bonus only to primary weapon damage
|
||||
baseValue += GetTotalAttackPowerValue(attType) / 14.0f * attackPowerMod;
|
||||
|
||||
float basePct = GetPctModifierValue(unitMod, BASE_PCT);
|
||||
float totalValue = GetFlatModifierValue(unitMod, TOTAL_VALUE);
|
||||
float totalPct = addTotalPct ? GetPctModifierValue(unitMod, TOTAL_PCT) : 1.0f;
|
||||
|
||||
float weaponMinDamage = GetWeaponDamageRange(attType, MINDAMAGE);
|
||||
float weaponMaxDamage = GetWeaponDamageRange(attType, MAXDAMAGE);
|
||||
float weaponMinDamage = GetWeaponDamageRange(attType, MINDAMAGE, damageIndex);
|
||||
float weaponMaxDamage = GetWeaponDamageRange(attType, MAXDAMAGE, damageIndex);
|
||||
|
||||
if (IsInFeralForm()) // check if player is druid and in cat or bear forms
|
||||
// check if player is druid and in cat or bear forms (only primary damage)
|
||||
if (IsInFeralForm())
|
||||
{
|
||||
if (damageIndex != 0)
|
||||
{
|
||||
minDamage = 0.f;
|
||||
maxDamage = 0.f;
|
||||
return;
|
||||
}
|
||||
|
||||
uint8 lvl = getLevel();
|
||||
if (lvl > 60)
|
||||
lvl = 60;
|
||||
@@ -549,16 +566,18 @@ void Player::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bo
|
||||
else if (!CanUseAttackType(attType)) // check if player not in form but still can't use (disarm case)
|
||||
{
|
||||
// cannot use ranged/off attack, set values to 0
|
||||
if (attType != BASE_ATTACK)
|
||||
// set secondary damages to 0 by default
|
||||
if (damageIndex != 0 || attType != BASE_ATTACK)
|
||||
{
|
||||
minDamage = 0;
|
||||
maxDamage = 0;
|
||||
minDamage = 0.f;
|
||||
maxDamage = 0.f;
|
||||
return;
|
||||
}
|
||||
|
||||
weaponMinDamage = BASE_MINDAMAGE;
|
||||
weaponMaxDamage = BASE_MAXDAMAGE;
|
||||
}
|
||||
else if (attType == RANGED_ATTACK) // add ammo DPS to ranged damage
|
||||
else if (damageIndex == 0 && attType == RANGED_ATTACK) // add ammo DPS to ranged primary damage
|
||||
{
|
||||
weaponMinDamage += GetAmmoDPS() * attackPowerMod;
|
||||
weaponMaxDamage += GetAmmoDPS() * attackPowerMod;
|
||||
@@ -1047,7 +1066,7 @@ void Creature::UpdateAttackPowerAndDamage(bool ranged)
|
||||
}
|
||||
}
|
||||
|
||||
void Creature::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, float& minDamage, float& maxDamage) const
|
||||
void Creature::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, float& minDamage, float& maxDamage, uint8 /*damageIndex*/) const
|
||||
{
|
||||
float variance = 1.0f;
|
||||
UnitMods unitMod;
|
||||
|
||||
Reference in New Issue
Block a user