Files
ashlar/docker/scenarios/combat/scripts/ashlarcombat/npc.lua
T
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

39 lines
1.4 KiB
Lua

-- Ashlar headless combat scenario (CC0): the duelist equips its kit and fights the player with normal combat AI.
local self = require('openmw.self')
local types = require('openmw.types')
local I = require('openmw.interfaces')
local Actor = types.Actor
-- Stats can only be changed by the actor's own local script.
local function toughen(actor)
local stats = types.Actor.stats
for _, name in ipairs({ 'health', 'fatigue' }) do
local stat = stats.dynamic[name](actor)
stat.base = 5000
stat.current = 5000
end
stats.attributes.agility(actor).base = 100
stats.attributes.strength(actor).base = 60
types.NPC.stats.skills.block(actor).base = 100
types.NPC.stats.skills.shortblade(actor).base = 100
end
I.Combat.addOnHitHandler(function(attack)
local health = attack.damage and attack.damage.health or 0
print(string.format('ASHLAR_COMBAT npc hit successful=%s health=%.2f', tostring(attack.successful), health))
end)
return {
eventHandlers = {
AshlarCombatStart = function(data)
toughen(self)
local eq = Actor.getEquipment(self)
eq[Actor.EQUIPMENT_SLOT.CarriedLeft] = data.shield
eq[Actor.EQUIPMENT_SLOT.CarriedRight] = data.blade
Actor.setEquipment(self, eq)
I.AI.startPackage({ type = 'Combat', target = data.enemy })
print('ASHLAR_COMBAT npc ready')
end,
},
}