Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
Core/Units: fixed a rounding issue that caused very low damage uninte…
Browse files Browse the repository at this point in the history
…ntionally being reduced to zero

*also feed the AttackerStateUpdate  SubDamage with the correct values
  • Loading branch information
Ovahlord committed Dec 10, 2023
1 parent 8c3d501 commit 6cb2bd9
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/server/game/Entities/Unit/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1553,8 +1553,7 @@ static float GetArmorReduction(float armor, uint8 attackerLevel)
}

float armorReduction = 100.f - GetArmorReduction(armor, attacker ? attacker->getLevel() : attackerLevel);

return std::max<uint32>(CalculatePct(damage, armorReduction), 0);
return std::max<uint32>(std::ceil(damage * armorReduction / 100.f), 0);
}

/*static*/ uint32 Unit::CalcSpellResistedDamage(Unit const* attacker, Unit* victim, uint32 damage, SpellSchoolMask schoolMask, SpellInfo const* spellInfo)
Expand Down Expand Up @@ -5144,8 +5143,8 @@ void Unit::SendAttackStateUpdate(CalcDamageInfo* damageInfo)

packet.SubDmg.emplace();
packet.SubDmg->SchoolMask = damageInfo->DamageSchoolMask; // School of sub damage
packet.SubDmg->FDamage = damageInfo->Damage; // sub damage
packet.SubDmg->Damage = damageInfo->Damage; // Sub Damage
packet.SubDmg->FDamage = damageInfo->CleanDamage; // sub damage
packet.SubDmg->Damage = damageInfo->CleanDamage; // Sub Damage
packet.SubDmg->Absorbed = damageInfo->Absorb;
packet.SubDmg->Resisted = damageInfo->Resist;

Expand Down Expand Up @@ -7765,8 +7764,7 @@ int32 Unit::MeleeDamageBonusTaken(Unit* attacker, int32 pdamage, WeaponAttackTyp
TakenTotalMod = 1.0f - damageReduction;
}

float tmpDamage = float(pdamage + TakenFlatBenefit) * TakenTotalMod;
return int32(std::max(tmpDamage, 0.0f));
return int32(std::max(std::ceil(static_cast<float>(pdamage + TakenFlatBenefit) * TakenTotalMod), 0.0f));
}

void Unit::ApplySpellImmune(uint32 spellId, uint32 op, uint32 type, bool apply)
Expand Down

0 comments on commit 6cb2bd9

Please sign in to comment.