Files
claudeandClaude Opus 5.5 bc600b3359
Ashlar checks / tooling (push) Successful in 6s
Add a headless combat scenario with a hostile duelist
SCENARIO=combat docker/ashlar-run.sh loads docker/scenarios/combat on top
of the Game Template: our own CC0 Lua content that gives the player a
shield and blade and spawns a hostile duelist with the same kit, cloned
from the template's player record. The player holds Block, then attacks,
and the run prints block counts. The default boot is unchanged.

The engine now logs each successful shield block or parry at verbose
level ("Ashlar block: ..."), so runs can count them.

Documented in docs/ashlar/SCENARIOS.md.

Closes #24

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 03:30:23 -05:00

52 lines
2.5 KiB
C++

#ifndef OPENMW_MECHANICS_ACTIVEBLOCK_H
#define OPENMW_MECHANICS_ACTIVEBLOCK_H
namespace MWWorld
{
class Ptr;
}
namespace MWMechanics
{
// Ashlar active blocking. With [Game] real time combat on, the player blocks by holding the Block action
// instead of relying on a random roll. A shield blocks a hit completely; without one, a drawn melee weapon
// parries part of the damage.
/// True if an attacker at \a angleDegrees (signed, relative to the blocker's facing) is inside the block arc.
bool isInBlockArc(float angleDegrees, float leftAngle, float rightAngle);
/// True if an actor holding Block is actually in the block stance. \a canBlockWith is true when a shield is
/// ready or a melee weapon is equipped.
bool canHoldBlockStance(bool blockHeld, bool weaponDrawn, bool canBlockWith, bool incapacitated);
/// Reduces the fatigue cost of a block as Block skill rises: full cost at 0, half cost at 100 and above.
float scaleBlockFatigueLoss(float fatigueLoss, float blockSkill);
/// Damage that gets through a weapon block. \a damageTaken is the share that gets through, 0 to 1.
float weaponBlockDamage(float damage, float damageTaken);
/// Writes a verbose log line for a successful block, so headless test scenarios can count blocks. \a kind is
/// "shield" or "weapon".
void logBlock(const MWWorld::Ptr& attacker, const MWWorld::Ptr& blocker, const char* kind, float damageThrough);
/// Signed angle of \a attacker relative to the facing of \a blocker, in degrees. \a blocker needs a base node.
float getAttackAngleDegrees(const MWWorld::Ptr& attacker, const MWWorld::Ptr& blocker);
/// True if \a actor resolves blocks through the held stance rather than the classic roll.
bool usesActiveBlocking(const MWWorld::Ptr& actor);
/// True if \a actor has a shield equipped and visible, so it would block with it.
bool hasShieldReady(const MWWorld::Ptr& actor);
/// True if \a actor uses active blocking and is currently in the block stance.
bool isInBlockStance(const MWWorld::Ptr& actor);
/// Ashlar weapon block: if \a blocker is in the block stance with no shield, parries a melee hit from the front
/// with its weapon. Returns the damage that gets through, which is \a damage when there's no parry.
float weaponBlockMeleeAttack(
const MWWorld::Ptr& attacker, const MWWorld::Ptr& blocker, const MWWorld::Ptr& weapon, float damage,
float attackStrength);
}
#endif