With [Game] real time combat on: - An attack's fatigue cost is paid when the swing is released, not when it lands. The base cost (fFatigueAttackBase plus fFatigueAttackMult times encumbrance) scales from half at no wind-up to full at full wind-up; the weapon part stays weight * strength * fWeaponFatigueMult. - No weapon attack can start at zero fatigue or below the new [Game] attack fatigue threshold (0.1 of max). The player gets a "too tired to attack" message once per press; combat AI waits for fatigue to recover instead of winding up. Spells aren't affected. - Below [Game] attack fatigue cap (0.5 of max), the strongest possible attack falls linearly to a quarter strength at zero fatigue. The rules are in mwmechanics/stamina.cpp, with unit tests. Behavior with real time combat off is unchanged. Closes #21 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
47 lines
2.3 KiB
C++
47 lines
2.3 KiB
C++
#ifndef OPENMW_MECHANICS_STAMINA_H
|
|
#define OPENMW_MECHANICS_STAMINA_H
|
|
|
|
namespace MWWorld
|
|
{
|
|
class Ptr;
|
|
}
|
|
|
|
namespace MWMechanics
|
|
{
|
|
// Ashlar stamina-driven attacks. With [Game] real time combat on, an attack's fatigue cost is paid when the swing
|
|
// is released and scales with wind-up strength and weapon weight. An actor below [Game] attack fatigue threshold
|
|
// can't start an attack, and below [Game] attack fatigue cap its maximum attack strength drops.
|
|
|
|
/// Lowest maximum attack strength, reached at zero fatigue.
|
|
constexpr float sMinAttackStrengthCap = 0.25f;
|
|
|
|
/// Fatigue cost of a real-time attack. The base part (\a base plus \a normalizedEncumbrance times
|
|
/// \a encumbranceMult) costs half at no wind-up and in full at full wind-up; the weapon part is
|
|
/// \a weaponWeight times \a attackStrength times \a weaponMult, as in the classic formula.
|
|
float getAttackFatigueCost(float base, float encumbranceMult, float normalizedEncumbrance, float weaponWeight,
|
|
float weaponMult, float attackStrength);
|
|
|
|
/// True if an actor with \a currentFatigue out of \a maxFatigue may start an attack. Attacks need positive
|
|
/// fatigue and, when \a maxFatigue is positive, a fatigue ratio of at least \a threshold.
|
|
bool hasFatigueToAttack(float currentFatigue, float maxFatigue, float threshold);
|
|
|
|
/// Highest attack strength allowed at \a currentFatigue out of \a maxFatigue. 1 at or above a ratio of
|
|
/// \a capRatio, falling linearly to sMinAttackStrengthCap at zero fatigue. A \a capRatio of 0 disables the cap.
|
|
float getAttackStrengthCap(float currentFatigue, float maxFatigue, float capRatio);
|
|
|
|
/// True if \a actor uses the stamina-driven attack rules (real time combat on).
|
|
bool usesStaminaAttacks();
|
|
|
|
/// True if \a actor is too tired to start a weapon attack under the stamina rules. Always false with the rules off
|
|
/// or in god mode for the player.
|
|
bool isTooTiredToAttack(const MWWorld::Ptr& actor);
|
|
|
|
/// Caps \a attackStrength by \a actor's current fatigue under the stamina rules.
|
|
float capAttackStrength(const MWWorld::Ptr& actor, float attackStrength);
|
|
|
|
/// Pays the fatigue cost of a released real-time attack with \a weapon (empty for hand-to-hand or natural attacks).
|
|
void applyAttackFatigueCost(const MWWorld::Ptr& attacker, const MWWorld::Ptr& weapon, float attackStrength);
|
|
}
|
|
|
|
#endif
|