Courage.Actors#
require("Courage.Actors") exposes functions to spawn actors (dynamic game objects like enemies, NPCs, and items) in the game world.
Loading the module#
API#
Actors.spawn(name, x, y, z, angleY?, room?, params?) (returns integer or nil)#
Spawns an actor in the world by its process name. Returns the spawned actor's runtime ID on success, or nil on failure.
| Parameter | Type | Description |
|---|---|---|
name | string | The process name of the actor to spawn (such as "E_DF") |
x, y, z | number | World coordinates where the actor should spawn |
angleY | integer? | Yaw rotation angle in degrees. Defaults to 0 |
room | integer? | Room ID to spawn the actor in. Defaults to -1 (current room) |
params | number? | Initialization parameter bitmask. Defaults to 0 |
Actors.spawn_id(procId, x, y, z, angleY?, room?, params?, argument?) (returns integer or nil)#
Spawns an actor in the world by its numeric process ID. Returns the spawned actor's runtime ID on success, or nil on failure.
| Parameter | Type | Description |
|---|---|---|
procId | integer | The numeric process ID of the actor to spawn |
x, y, z | number | World coordinates where the actor should spawn |
angleY | integer? | Yaw rotation angle in degrees. Defaults to 0 |
room | integer? | Room ID to spawn the actor in. Defaults to -1 (current room) |
params | number? | Initialization parameter bitmask. Defaults to 0 |
argument | integer? | Optional spawn argument. Defaults to -1 |
Joint inspection API#
Actors.joint_count(actor) (returns integer)#
Returns the number of joints in an actor's J3D model skeleton. actor is a raw actor pointer (lightuserdata or NativePtr). Returns 0 if actor is invalid or has no model.
Actors.joint_index(actor, name) (returns integer)#
Looks up the 0-based joint index by bone/joint name string. actor is a raw actor pointer. Returns -1 if not found.
Actors.joint_pos(actor, jointIndex) (returns x, y, z or nil)#
Returns the world-space coordinates (x, y, z) of jointIndex on actor's skeleton, or nil on failure. actor is a raw actor pointer.
Actors.joint_name(actor, jointIndex) (returns string or nil)#
Returns the name string of jointIndex, or nil if jointIndex is out of range. actor is a raw actor pointer.
import * as Actors from "Courage.Actors"
import * as Hook from "Augment.Hook"
Hook.daAlink_c_execute.before((ctx) => {
const link = ctx.self
const headIdx = Actors.joint_index(link, "head")
if (headIdx >= 0) {
const [x, y, z] = Actors.joint_pos(link, headIdx)
// x, y, z are world coordinates of head joint
}
})