Files
ashlar/files/lua_api/openmw/self.lua
T
claudeandClaude Opus 5.5 9e28969629
Ashlar checks / tooling (push) Successful in 5s
Add ledge mantling
New [Game] mantling setting, on by default, with mantle max height (1.1
times the actor's height above its feet) and mantle duration (0.4 s).
When the player jumps or falls into a wall while moving towards it
(within 60 degrees), the movement solver casts the player's collision
shape up, across the edge and down. If it finds a surface flat enough to
stand on, above the feet and within reach, with headroom and room on top,
the player moves up, across and onto it along that checked path. Movement
and jump input are ignored meanwhile, and the climb ends any fall without
fall damage. No animation is needed. A script move or teleport, noclip or
paralysis cancels a climb.

Lua: self.controls.mantle (true by default) vetoes climbs while false,
and the actor's scripts get an AshlarMantle event with the ledge height
when one starts. The engine logs "Ashlar mantle:" lines at verbose level.
Player only; with the setting off nothing changes.

The geometry rules (reach, headroom, room on top, slope, too high, too
low) and the climb path are in mwphysics/mantle.cpp, apart from the
physics calls, with unit tests. The new mantle scenario uses a CC0 box
mesh written for it: the player climbs an 80 unit ledge, doesn't climb it
with the Lua veto, and doesn't climb a 240 unit wall.

Closes #28

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 15:44:40 -05:00

61 lines
2.9 KiB
Lua

---
-- Provides full access to the object the script is attached to.
-- All fields and function of `GameObject` are also available for `openmw.self`.
-- @context local
-- @module Self
-- @extends openmw.core#GameObject
-- @usage local self = require('openmw.self')
-- local types = require('openmw.types')
-- if self.type == types.Player then -- All fields and functions of `GameObject` are available.
-- self:sendEvent("something", self.position)
-- end
---
-- Returns true if the script isActive (the object it is attached to is in an active cell).
-- If it is not active, then `openmw.nearby` can not be used.
-- @function [parent=#Self] isActive
-- @param Self
-- @return #boolean
---
-- The object the script is attached to (readonly)
-- @field [parent=#Self] openmw.core#GameObject object
---
-- Movement controls (only for actors)
-- @field [parent=#Self] #ActorControls controls
---
-- @type ATTACK_TYPE
-- @field #number NoAttack
-- @field #number Any
-- @field #number Chop
-- @field #number Slash
-- @field #number Thrust
---
-- Allows to view and/or modify controls of an actor. All fields are mutable.
-- @type ActorControls
-- @field [parent=#ActorControls] #number movement +1 - move forward, -1 - move backward
-- @field [parent=#ActorControls] #number sideMovement +1 - move right, -1 - move left
-- @field [parent=#ActorControls] #number yawChange Turn right (radians); if negative - turn left
-- @field [parent=#ActorControls] #number pitchChange Look down (radians); if negative - look up
-- @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 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] #boolean sprint Ashlar: if true, sprint while moving forward. Has an effect with [Game] sprint on, for NPCs and the player; see the setting for the conditions.
-- @field [parent=#ActorControls] #boolean mantle Ashlar: true by default. Set to false to stop the actor from climbing ledges (see [Game] mantling, player only) until it is set back to true. The actor's scripts get an `AshlarMantle` event when a climb starts.
-- @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.
---
-- Enables or disables standard AI (enabled by default).
-- @function [parent=#Self] enableAI
-- @param Self
-- @param #boolean v
return nil