Add active blocking for NPCs and creatures

With real time combat and the new [Game] 'ai active blocking' setting
(on by default), NPCs and creatures block through the same stance and
arc rules as the player instead of the classic roll.

In combat, an actor with a shield ready and its weapon drawn raises the
stance when an enemy in front of it winds up a melee attack within
reach. Whether it reacts is rolled once per wind-up (10% at 0 Block
skill and agility, up to 90%, scaled by fatigue), and its reaction
delay falls from 0.6 s to 0.15 s with skill. It keeps the block up for
half a second after the wind-up ends so it catches the swing, drops it
after two seconds at most so a held wind-up can't pin it, and starts
no attacks while blocking.

The decision lives in mwmechanics/aiblock.cpp. Combat AI sets a
separate, unsaved CreatureStats flag that is cleared every frame before
AI runs, so a block never outlives the combat package and a Lua block
request is left alone. Actors without a shield never block, and a
creature blocks only if it can carry a shield.

Closes #20

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-13 04:31:38 -05:00
co-authored by Claude Opus 5.5
parent 78f1f9516d
commit 4e152c7c4e
15 changed files with 460 additions and 16 deletions
+1 -1
View File
@@ -104,7 +104,7 @@ add_openmw_dir (mwmechanics
aicast aiescort aiface aiactivate aicombat recharge repair enchanting pathfinding pathgrid security spellcasting spellresistance
disease pickpocket levelledlist combat steering obstacle autocalcspell difficultyscaling aicombataction summoning
character actors objects aistate weaponpriority spellpriority weapontype spellutil
spelleffects activeblock
spelleffects activeblock aiblock
)
add_openmw_dir (mwstate
+12 -11
View File
@@ -35,14 +35,15 @@ namespace MWMechanics
return getWeaponType(record->mData.mType)->mWeaponClass == ESM::WeaponType::Melee;
}
float getAttackAngleDegrees(const MWWorld::Ptr& attacker, const MWWorld::Ptr& blocker)
{
const osg::Vec3f toAttacker
= attacker.getRefData().getPosition().asVec3() - blocker.getRefData().getPosition().asVec3();
const osg::Vec3f facing = blocker.getRefData().getBaseNode()->getAttitude() * osg::Vec3f(0, 1, 0);
const osg::Vec3f up(0, 0, 1);
return osg::RadiansToDegrees(std::atan2(up * (toAttacker ^ facing), toAttacker * facing));
}
}
float getAttackAngleDegrees(const MWWorld::Ptr& attacker, const MWWorld::Ptr& blocker)
{
const osg::Vec3f toAttacker
= attacker.getRefData().getPosition().asVec3() - blocker.getRefData().getPosition().asVec3();
const osg::Vec3f facing = blocker.getRefData().getBaseNode()->getAttitude() * osg::Vec3f(0, 1, 0);
const osg::Vec3f up(0, 0, 1);
return osg::RadiansToDegrees(std::atan2(up * (toAttacker ^ facing), toAttacker * facing));
}
bool isInBlockArc(float angleDegrees, float leftAngle, float rightAngle)
@@ -68,8 +69,8 @@ namespace MWMechanics
bool usesActiveBlocking(const MWWorld::Ptr& actor)
{
// NPCs and creatures keep the classic roll until they get their own block stance (#20).
return Settings::game().mRealTimeCombat && actor == getPlayer();
// NPCs and creatures use the stance too unless [Game] ai active blocking is off (see aiblock.cpp).
return Settings::game().mRealTimeCombat && (actor == getPlayer() || Settings::game().mAiActiveBlocking);
}
bool hasShieldReady(const MWWorld::Ptr& actor)
@@ -87,7 +88,7 @@ namespace MWMechanics
if (!actor.getClass().isActor())
return false;
const CreatureStats& stats = actor.getClass().getCreatureStats(actor);
if (!stats.getBlockHeld() || !usesActiveBlocking(actor))
if (!(stats.getBlockHeld() || stats.getAiBlockHeld()) || !usesActiveBlocking(actor))
return false;
if (!actor.getClass().hasInventoryStore(actor))
return false;
+3
View File
@@ -25,6 +25,9 @@ namespace MWMechanics
/// Damage that gets through a weapon block. \a damageTaken is the share that gets through, 0 to 1.
float weaponBlockDamage(float damage, float damageTaken);
/// 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);
+4
View File
@@ -1620,6 +1620,10 @@ namespace MWMechanics
return; // for now abort update of the old cell when cell changes by teleportation magic effect
// a better solution might be to apply cell changes at the end of the frame
}
// Ashlar: combat AI sets this again every frame it wants the block stance.
if (!isPlayer)
actorPtr.getClass().getCreatureStats(actorPtr).setAiBlockHeld(false);
if (aiActive && inProcessingRange)
{
if (engageCombatTimerStatus == Misc::TimerStatus::Elapsed)
+180
View File
@@ -0,0 +1,180 @@
#include "aiblock.hpp"
#include <algorithm>
#include <components/esm3/loadgmst.hpp>
#include <components/esm3/loadweap.hpp>
#include <components/settings/values.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/class.hpp"
#include "../mwworld/esmstore.hpp"
#include "../mwworld/inventorystore.hpp"
#include "activeblock.hpp"
#include "combat.hpp"
#include "creaturestats.hpp"
#include "weapontype.hpp"
#include <components/misc/rng.hpp>
namespace MWMechanics
{
namespace
{
// Same weighting as the classic block roll: Block skill plus a fifth of agility, as a 0..1 fraction.
float blockTerm(float blockSkill, float agility)
{
return std::clamp((std::max(blockSkill, 0.f) + 0.2f * std::max(agility, 0.f)) / 100.f, 0.f, 1.2f);
}
// Melee threats are noticed a little before the attacker is in reach, since it may step in while swinging.
constexpr float sThreatReachMult = 1.5f;
}
float getAiBlockChance(float blockSkill, float agility, float fatigueTerm)
{
const float chance = std::min(0.1f + 0.7f * blockTerm(blockSkill, agility), 0.9f);
return chance * std::clamp(fatigueTerm, 0.f, 1.f);
}
float getAiBlockReactionTime(float blockSkill, float agility)
{
return 0.6f - 0.45f * std::min(blockTerm(blockSkill, agility), 1.f);
}
bool updateAiBlock(AiBlockState& state, bool canBlock, bool threatened, float duration,
const std::function<float()>& roll, const AiBlockParams& params)
{
state.mCooldown = std::max(0.f, state.mCooldown - duration);
if (!canBlock)
{
state.mBlocking = false;
state.mDecided = false;
state.mWillBlock = false;
return false;
}
if (state.mBlocking)
{
state.mBlockTime += duration;
if (threatened)
state.mTimer = params.mHoldTime;
else
state.mTimer -= duration;
const bool tooLong = state.mBlockTime >= params.mMaxBlockTime;
if (state.mTimer <= 0.f || tooLong)
{
state.mBlocking = false;
state.mWillBlock = false;
// Don't roll again for a wind-up that is still going on.
state.mDecided = threatened;
if (tooLong)
state.mCooldown = params.mRetryDelay;
}
return state.mBlocking;
}
if (!threatened)
{
state.mDecided = false;
state.mWillBlock = false;
return false;
}
if (!state.mDecided)
{
if (state.mCooldown > 0.f)
return false;
state.mDecided = true;
state.mWillBlock = roll() < params.mChance;
state.mTimer = params.mReactionTime;
}
else if (state.mWillBlock)
state.mTimer -= duration;
if (state.mWillBlock && state.mTimer <= 0.f)
{
state.mBlocking = true;
state.mBlockTime = 0.f;
state.mTimer = params.mHoldTime;
}
return state.mBlocking;
}
bool usesAiActiveBlocking()
{
return Settings::game().mRealTimeCombat && Settings::game().mAiActiveBlocking;
}
bool isMeleeThreat(const MWWorld::Ptr& blocker, const MWWorld::Ptr& attacker)
{
if (attacker.isEmpty() || !attacker.getClass().isActor() || !blocker.getRefData().getBaseNode())
return false;
const CreatureStats& stats = attacker.getClass().getCreatureStats(attacker);
if (stats.isDead() || stats.getDrawState() != DrawState::Weapon)
return false;
if (!MWBase::Environment::get().getMechanicsManager()->isAttackPreparing(attacker))
return false;
MWWorld::Ptr weapon;
if (attacker.getClass().hasInventoryStore(attacker))
{
MWWorld::InventoryStore& inv = attacker.getClass().getInventoryStore(attacker);
const auto item = inv.getSlot(MWWorld::InventoryStore::Slot_CarriedRight);
if (item != inv.end() && item->getType() == ESM::Weapon::sRecordId)
{
const ESM::Weapon* record = item->get<ESM::Weapon>()->mBase;
if (getWeaponType(record->mData.mType)->mWeaponClass != ESM::WeaponType::Melee)
return false;
weapon = *item;
}
}
const float reach = getMeleeWeaponReach(attacker, weapon) * sThreatReachMult;
if (getDistanceToBounds(attacker, blocker) > reach)
return false;
const MWWorld::Store<ESM::GameSetting>& gmst
= MWBase::Environment::get().getESMStore()->get<ESM::GameSetting>();
static const float fCombatBlockLeftAngle = gmst.find("fCombatBlockLeftAngle")->mValue.getFloat();
static const float fCombatBlockRightAngle = gmst.find("fCombatBlockRightAngle")->mValue.getFloat();
return isInBlockArc(getAttackAngleDegrees(attacker, blocker), fCombatBlockLeftAngle, fCombatBlockRightAngle);
}
bool canAiBlock(const MWWorld::Ptr& actor, bool busy)
{
if (busy || !usesAiActiveBlocking() || !actor.getClass().isActor())
return false;
const CreatureStats& stats = actor.getClass().getCreatureStats(actor);
return stats.getDrawState() == DrawState::Weapon && hasShieldReady(actor);
}
bool updateAiCombatBlock(
const MWWorld::Ptr& actor, const MWWorld::Ptr& target, AiBlockState& state, bool busy, float duration)
{
const bool canBlock = canAiBlock(actor, busy);
const bool threatened = canBlock && isMeleeThreat(actor, target);
AiBlockParams params;
if (canBlock)
{
const CreatureStats& stats = actor.getClass().getCreatureStats(actor);
const float skill = actor.getClass().getSkill(actor, ESM::Skill::Block);
const float agility = stats.getAttribute(ESM::Attribute::Agility).getModified();
params.mChance = getAiBlockChance(skill, agility, stats.getFatigueTerm());
params.mReactionTime = getAiBlockReactionTime(skill, agility);
}
auto& prng = MWBase::Environment::get().getWorld()->getPrng();
const bool blocking = updateAiBlock(
state, canBlock, threatened, duration, [&] { return Misc::Rng::rollProbability(prng); }, params);
actor.getClass().getCreatureStats(actor).setAiBlockHeld(blocking);
return blocking;
}
}
+66
View File
@@ -0,0 +1,66 @@
#ifndef OPENMW_MECHANICS_AIBLOCK_H
#define OPENMW_MECHANICS_AIBLOCK_H
#include <functional>
namespace MWWorld
{
class Ptr;
}
namespace MWMechanics
{
// Ashlar active blocking for NPCs and creatures. With [Game] real time combat and [Game] ai active blocking on,
// combat AI raises the same block stance the player uses when an enemy winds up a melee attack within reach.
/// Per-actor state of the AI block decision. Lives in the combat AI's temporary storage.
struct AiBlockState
{
bool mDecided = false; ///< A block was already rolled for the current enemy wind-up.
bool mWillBlock = false; ///< Result of that roll.
bool mBlocking = false; ///< The AI wants the block stance.
float mTimer = 0.f; ///< Reaction delay before blocking, then the hold time after the threat ends.
float mBlockTime = 0.f; ///< How long the current block has been held.
float mCooldown = 0.f; ///< Time before the AI may react again after giving up a long block.
};
struct AiBlockParams
{
float mChance = 0.f; ///< Probability of reacting to a wind-up, 0 to 1.
float mReactionTime = 0.f; ///< Delay between seeing a wind-up and raising the block, in seconds.
float mHoldTime = 0.5f; ///< How long the block stays up after the wind-up ends, to catch the swing.
float mMaxBlockTime = 2.f; ///< Longest block before dropping it, so a held wind-up can't pin the AI.
float mRetryDelay = 1.f; ///< Pause before reacting again after dropping a block at mMaxBlockTime.
};
/// Chance that an actor reacts to a wind-up with a block. Rises with Block skill and agility and falls with
/// fatigue: 10% at 0 skill and agility, capped at 90%.
float getAiBlockChance(float blockSkill, float agility, float fatigueTerm);
/// Reaction delay before an actor raises its block: 0.6 s at 0 skill and agility, down to 0.15 s.
float getAiBlockReactionTime(float blockSkill, float agility);
/// Advances the block decision by \a duration and returns whether the actor should hold the block stance.
/// \a canBlock is false while the actor can't block (no shield, attacking, fleeing...), which drops the block.
/// \a threatened is true while an enemy winds up a melee attack against it. \a roll returns a number in [0, 1)
/// and is called once per wind-up.
bool updateAiBlock(AiBlockState& state, bool canBlock, bool threatened, float duration,
const std::function<float()>& roll, const AiBlockParams& params);
/// True if [Game] ai active blocking applies: NPCs and creatures block only through the stance.
bool usesAiActiveBlocking();
/// True if \a attacker is winding up a melee attack that could reach \a blocker from inside its block arc.
bool isMeleeThreat(const MWWorld::Ptr& blocker, const MWWorld::Ptr& attacker);
/// True if the AI-controlled \a actor could raise a block now: active blocking applies, a shield is ready and the
/// weapon is drawn. \a busy is true while the actor's own attack is in progress.
bool canAiBlock(const MWWorld::Ptr& actor, bool busy);
/// Updates the block decision of the AI-controlled \a actor fighting \a target and sets its AI block flag.
/// Returns whether the actor is blocking.
bool updateAiCombatBlock(
const MWWorld::Ptr& actor, const MWWorld::Ptr& target, AiBlockState& state, bool busy, float duration);
}
#endif
+7 -2
View File
@@ -148,6 +148,10 @@ namespace MWMechanics
if (!storage.isFleeing())
{
// Ashlar: raise the block stance against an enemy's melee wind-up. Not while attacking.
updateAiCombatBlock(actor, target, storage.mBlock,
storage.mAttack || !characterController.readyToStartAttack(), duration);
bool isRangedCombat = false;
if (storage.mCurrentAction.get()) // need to wait to init action with its attack range
@@ -296,8 +300,9 @@ namespace MWMechanics
if (storage.mReadyToAttack)
{
storage.startCombatMove(isRangedCombat, distToTarget, rangeAttack, actor, target);
// start new attack
storage.startAttackIfReady(actor, characterController, weapon, isRangedCombat);
// start new attack, unless holding a block (Ashlar), which drops on its own once the threat passes
if (!storage.mBlock.mBlocking)
storage.startAttackIfReady(actor, characterController, weapon, isRangedCombat);
}
else
{
+4
View File
@@ -1,6 +1,7 @@
#ifndef GAME_MWMECHANICS_AICOMBAT_H
#define GAME_MWMECHANICS_AICOMBAT_H
#include "aiblock.hpp"
#include "aitemporarybase.hpp"
#include "aitimer.hpp"
#include "movement.hpp"
@@ -58,6 +59,9 @@ namespace MWMechanics
bool mUseCustomDestination;
osg::Vec3f mCustomDestination;
// Ashlar active blocking
AiBlockState mBlock;
AiCombatStorage();
void startCombatMove(bool isDistantCombat, float distToTarget, float rangeAttack, const MWWorld::Ptr& actor,
@@ -60,6 +60,7 @@ namespace MWMechanics
bool mHitRecovery = false;
bool mBlock = false;
bool mBlockHeld = false;
bool mAiBlockHeld = false;
unsigned int mMovementFlags = 0;
float mFallHeight = 0.f;
@@ -234,6 +235,9 @@ namespace MWMechanics
// Ashlar active blocking: whether the actor is holding the Block control. Not saved.
void setBlockHeld(bool value) { mBlockHeld = value; }
bool getBlockHeld() const { return mBlockHeld; }
// Ashlar: block stance requested by combat AI. Cleared every frame before AI runs. Not saved.
void setAiBlockHeld(bool value) { mAiBlockHeld = value; }
bool getAiBlockHeld() const { return mAiBlockHeld; }
std::multimap<ESM::RefId, ESM::RefNum>& getSummonedCreatureMap(); // <Effect, summoned creature>
+1
View File
@@ -23,6 +23,7 @@ file(GLOB UNITTEST_SRC_FILES
mwlua/testmwscriptbindings.cpp
mwmechanics/testactiveblock.cpp
mwmechanics/testaiblock.cpp
mwmechanics/testcombat.cpp
mwscript/testscripts.cpp
@@ -0,0 +1,154 @@
#include <apps/openmw/mwmechanics/aiblock.hpp>
#include <gtest/gtest.h>
namespace
{
using namespace MWMechanics;
constexpr float frame = 0.05f;
AiBlockParams makeParams(float chance, float reaction)
{
AiBlockParams params;
params.mChance = chance;
params.mReactionTime = reaction;
params.mHoldTime = 0.5f;
params.mMaxBlockTime = 2.f;
params.mRetryDelay = 1.f;
return params;
}
float rollZero()
{
return 0.f;
}
float rollHigh()
{
return 0.99f;
}
// Runs \a seconds of frames and returns whether the actor was blocking at the end.
bool run(AiBlockState& state, bool canBlock, bool threatened, float seconds, const AiBlockParams& params,
float (*roll)() = rollZero)
{
bool blocking = false;
for (float t = 0.f; t < seconds - 1e-4f; t += frame)
blocking = updateAiBlock(state, canBlock, threatened, frame, roll, params);
return blocking;
}
TEST(MWMechanicsAiBlockTest, chanceRisesWithBlockSkillAndAgility)
{
EXPECT_FLOAT_EQ(getAiBlockChance(0.f, 0.f, 1.f), 0.1f);
EXPECT_LT(getAiBlockChance(30.f, 40.f, 1.f), getAiBlockChance(60.f, 40.f, 1.f));
EXPECT_LT(getAiBlockChance(50.f, 20.f, 1.f), getAiBlockChance(50.f, 80.f, 1.f));
EXPECT_FLOAT_EQ(getAiBlockChance(100.f, 100.f, 1.f), 0.9f);
EXPECT_FLOAT_EQ(getAiBlockChance(500.f, 500.f, 1.f), 0.9f);
}
TEST(MWMechanicsAiBlockTest, chanceFallsWithFatigue)
{
EXPECT_FLOAT_EQ(getAiBlockChance(50.f, 50.f, 0.5f), 0.5f * getAiBlockChance(50.f, 50.f, 1.f));
EXPECT_FLOAT_EQ(getAiBlockChance(50.f, 50.f, 0.f), 0.f);
EXPECT_FLOAT_EQ(getAiBlockChance(50.f, 50.f, 2.f), getAiBlockChance(50.f, 50.f, 1.f));
}
TEST(MWMechanicsAiBlockTest, reactionGetsFasterWithSkill)
{
EXPECT_FLOAT_EQ(getAiBlockReactionTime(0.f, 0.f), 0.6f);
EXPECT_LT(getAiBlockReactionTime(80.f, 50.f), getAiBlockReactionTime(20.f, 50.f));
EXPECT_FLOAT_EQ(getAiBlockReactionTime(100.f, 0.f), 0.15f);
EXPECT_FLOAT_EQ(getAiBlockReactionTime(200.f, 200.f), 0.15f);
EXPECT_FLOAT_EQ(getAiBlockReactionTime(-20.f, -20.f), 0.6f);
}
TEST(MWMechanicsAiBlockTest, blocksAfterReactionDelay)
{
AiBlockState state;
const AiBlockParams params = makeParams(1.f, 0.3f);
EXPECT_FALSE(run(state, true, true, 0.2f, params));
EXPECT_TRUE(run(state, true, true, 0.2f, params));
}
TEST(MWMechanicsAiBlockTest, zeroReactionBlocksAtOnce)
{
AiBlockState state;
EXPECT_TRUE(updateAiBlock(state, true, true, frame, rollZero, makeParams(1.f, 0.f)));
}
TEST(MWMechanicsAiBlockTest, failedRollMeansNoBlockForThatWindUp)
{
AiBlockState state;
const AiBlockParams params = makeParams(0.5f, 0.f);
EXPECT_FALSE(run(state, true, true, 1.f, params, rollHigh));
// The roll is made once per wind-up, so a later lucky roll doesn't matter until the next one.
EXPECT_FALSE(run(state, true, true, 0.5f, params, rollZero));
// A new wind-up gets a new roll.
EXPECT_FALSE(run(state, true, false, 0.1f, params));
EXPECT_TRUE(run(state, true, true, 0.1f, params, rollZero));
}
TEST(MWMechanicsAiBlockTest, rollIsMadeOncePerWindUp)
{
AiBlockState state;
int calls = 0;
const std::function<float()> roll = [&] {
++calls;
return 0.99f;
};
const AiBlockParams params = makeParams(0.5f, 0.f);
for (int i = 0; i < 20; ++i)
updateAiBlock(state, true, true, frame, roll, params);
EXPECT_EQ(calls, 1);
updateAiBlock(state, true, false, frame, roll, params);
updateAiBlock(state, true, true, frame, roll, params);
EXPECT_EQ(calls, 2);
}
TEST(MWMechanicsAiBlockTest, holdsBlockBrieflyAfterWindUpEnds)
{
AiBlockState state;
const AiBlockParams params = makeParams(1.f, 0.f);
EXPECT_TRUE(run(state, true, true, 0.3f, params));
// The swing lands after the wind-up, so the block stays up for the hold time.
EXPECT_TRUE(run(state, true, false, 0.4f, params));
EXPECT_FALSE(run(state, true, false, 0.2f, params));
}
TEST(MWMechanicsAiBlockTest, dropsBlockWhenItCannotBlock)
{
AiBlockState state;
const AiBlockParams params = makeParams(1.f, 0.f);
EXPECT_TRUE(run(state, true, true, 0.2f, params));
EXPECT_FALSE(updateAiBlock(state, false, true, frame, rollZero, params));
EXPECT_FALSE(state.mBlocking);
}
TEST(MWMechanicsAiBlockTest, neverBlocksWithoutAThreat)
{
AiBlockState state;
EXPECT_FALSE(run(state, true, false, 3.f, makeParams(1.f, 0.f)));
}
TEST(MWMechanicsAiBlockTest, neverBlocksWhenUnable)
{
AiBlockState state;
EXPECT_FALSE(run(state, false, true, 3.f, makeParams(1.f, 0.f)));
}
TEST(MWMechanicsAiBlockTest, endlessWindUpCannotPinTheBlocker)
{
AiBlockState state;
const AiBlockParams params = makeParams(1.f, 0.f);
EXPECT_TRUE(run(state, true, true, 1.5f, params));
// After the longest block the actor drops it so it can attack, and waits before blocking again.
EXPECT_FALSE(run(state, true, true, 0.6f, params));
EXPECT_FALSE(run(state, true, true, 0.3f, params));
// The same wind-up still doesn't get a second roll; a new one does once the pause is over.
EXPECT_FALSE(run(state, true, true, 1.f, params));
EXPECT_FALSE(run(state, true, false, 0.1f, params));
EXPECT_TRUE(run(state, true, true, 0.1f, params));
}
}
+1
View File
@@ -81,6 +81,7 @@ namespace Settings
makeClampSanitizerFloat(0, 1) };
SettingValue<float> mWeaponBlockDamage{ mIndex, "Game", "weapon block damage",
makeClampSanitizerFloat(0, 1) };
SettingValue<bool> mAiActiveBlocking{ mIndex, "Game", "ai active blocking" };
};
}
@@ -529,7 +529,7 @@ Game Settings
with a shield, completely, as before, with shield durability loss; without a shield, a drawn melee weapon parries the
hit, letting the weapon block damage share through and taking the rest as weapon wear.
Both cost fatigue and train Block, and the fatigue cost of a block falls with Block skill, to half at 100.
Without the stance the player doesn't block at all. NPCs and creatures keep the classic block roll.
Without the stance the player doesn't block at all. NPCs and creatures follow the ai active blocking setting.
.. omw-setting::
:title: block stance speed
@@ -548,3 +548,19 @@ Game Settings
Ashlar setting. Share of melee damage that still gets through when the player blocks with a weapon instead of a
shield. 0 makes weapon blocks as good as shields. Only used when real time combat is enabled.
.. omw-setting::
:title: ai active blocking
:type: boolean
:range: true, false
:default: true
Ashlar setting. If enabled together with real time combat, NPCs and creatures block through the same stance and arc
rules as the player instead of the classic block roll. In combat, an actor with a shield ready and its weapon drawn
raises the stance when an enemy in front of it winds up a melee attack within reach, and lowers it about half a
second after the swing, or after two seconds at most, so that it can attack again.
It can't attack while blocking. Whether it reacts to a wind-up is rolled once per wind-up: 10% at 0 Block skill and
agility, rising with Block skill and a fifth of agility to at most 90%, and scaled by fatigue. The reaction delay
falls from 0.6 to 0.15 seconds over the same range.
Actors without a shield never block, and a creature blocks only if it can carry a shield.
Disable to give NPCs and creatures the classic block roll. Only used when real time combat is enabled.
+1 -1
View File
@@ -46,7 +46,7 @@
-- @field [parent=#ActorControls] #boolean run true - run, false - walk
-- @field [parent=#ActorControls] #boolean sneak If true - sneak
-- @field [parent=#ActorControls] #boolean jump If true - initiate a jump
-- @field [parent=#ActorControls] #boolean block Ashlar: if true, hold the block stance. Has an effect only for the player with real time combat on and the weapon drawn, with a shield or a melee weapon equipped.
-- @field [parent=#ActorControls] #boolean block Ashlar: if true, hold the block stance. Has an effect with real time combat on (for NPCs and creatures, also ai active blocking) and the weapon drawn, with a shield or a melee weapon equipped. Combat AI raises its own block separately, and that is not reported here.
-- @field [parent=#ActorControls] #ATTACK_TYPE use Activates the readied weapon/spell according to a provided value. For weapons, keeping this value modified will charge the attack until set to @{#ATTACK_TYPE.NoAttack}. If an @{#ATTACK_TYPE} not appropriate for a currently equipped weapon provided - an appropriate @{#ATTACK_TYPE} will be used instead.
---
+5
View File
@@ -406,6 +406,11 @@ block stance speed = 0.5
# with a weapon instead of a shield. A shield blocks the whole hit.
weapon block damage = 0.5
# Ashlar: with real time combat on, NPCs and creatures with a shield block
# through the same stance as the player, raising it when an enemy winds up a
# melee attack. Disable to give them the classic block roll instead.
ai active blocking = true
[General]
# Anisotropy reduces distortion in textures at low angles (e.g. 0 to 16).