Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2216

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Fix #2216

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions skymp5-server/cpp/server_guest_lib/formulas/TES5DamageFormula.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

namespace internal {

bool IsUnarmedAttack(const uint32_t sourceFormId)
bool IsUnarmedAttack(const uint32_t sourceFormId, bool isBashAttack)
{
return sourceFormId == 0x1f4;
return isBashAttack ? false : sourceFormId == 0x1f4;
}

class TES5DamageFormulaImpl
Expand All @@ -36,7 +36,7 @@ class TES5DamageFormulaImpl
const Inventory::Entry& opponentEquipmentEntry) const;
[[nodiscard]] float CalcOpponentArmorRating() const;
[[nodiscard]] float CalcMagicEffects(const Effects& effects) const;
[[nodiscard]] float DetermineDamageFromSource(uint32_t source) const;
[[nodiscard]] float DetermineDamageFromSource(uint32_t source, bool isBashAttack) const;
[[nodiscard]] float CalcUnarmedDamage() const;
[[nodiscard]] float CalcArmorDamagePenalty() const;
};
Expand Down Expand Up @@ -118,9 +118,9 @@ float TES5DamageFormulaImpl::CalcUnarmedDamage() const
return espm::GetData<espm::RACE>(raceId, espmProvider).unarmedDamage;
}

float TES5DamageFormulaImpl::DetermineDamageFromSource(uint32_t source) const
float TES5DamageFormulaImpl::DetermineDamageFromSource(uint32_t source, bool isBashAttack) const
{
return IsUnarmedAttack(source) ? CalcUnarmedDamage() : CalcWeaponRating();
return IsUnarmedAttack(source, isBashAttack) ? CalcUnarmedDamage() : CalcWeaponRating();
}

float TES5DamageFormulaImpl::CalcArmorDamagePenalty() const
Expand All @@ -141,7 +141,7 @@ float TES5DamageFormulaImpl::CalcArmorDamagePenalty() const

float TES5DamageFormulaImpl::CalculateDamage() const
{
const float incomingDamage = DetermineDamageFromSource(hitData.source);
const float incomingDamage = DetermineDamageFromSource(hitData.source, hitData.isBashAttack);

// TODO(#461): add difficulty multiplier
// TODO(#463): add sneak modifier
Expand All @@ -151,6 +151,10 @@ float TES5DamageFormulaImpl::CalculateDamage() const
damage *= 2.f;
}

if (hitData.isBashAttack) {
damage *= 0.3f;
}

if (hitData.isHitBlocked) {
// TODO(#460): implement correct block formula
damage *= 0.1f;
Expand Down
Loading