gameob_script - Outerra/anteworld GitHub Wiki

Methods

virtual bool resolve_path(ot::path_rel_to ref, const coid::token& path, ifc_out coid::charstr& dst) const;
Parameter Description Returns Description
ref: reference path
path: relative path
dst: resolved path
returns: false on argument error Resolve relative path
virtual iref<ot::geomob> get_geomob(int id = 0) const;
Parameter Description Returns Description
id: 0 for the main body - Retrieve geom object
virtual bool get_objdef_info(ifc_out ot::pkginfo::obj& info) const;
Parameter Description Returns Description
info: object definition information returns: true if successful Retrieve objdef information
virtual coid::token get_objdef_param(const coid::token& key, const coid::token& group = coid::token()) const;
Parameter Description Returns Description
key: parameter key
group: parameter group
returns: parameter from objdef Get parameter from objdef
virtual uint get_collision_group(ifc_out uint* mask) const;
Parameter Description Returns Description
mask: optional mask value returns: collision group id Get collision group and mask
virtual void set_collision_group(uint group, uint mask);
Parameter Description Returns Description
group: collision group
mask: collision mask
- Set collision group and mask
virtual void fade(const coid::token& text) const;
Parameter Description Returns Description
text: message to post to the fading log - Post message to the fading log
virtual ot::ECameraMode get_camera_mode() const;
Parameter Description Returns Description
- returns: current camera mode Get camera mode
virtual uint64 get_custom_data_value() const;
Parameter Description Returns Description
- returns: custom data value Titan hack
virtual float3 heading_pitch_roll() const;
Parameter Description Returns Description
- returns: heading/pitch/roll angles in radians Get heading/pitch/roll angles
virtual void extra_force(const float3& mpos, const float3& force, bool worldspace = false);
Parameter Description Returns Description
mpos: model-space position to act on
force: model or world-space force vector
worldspace: true for world-space, false for model-space force vector
- Add extra force to be applied to the object
virtual void extra_impulse(const float3& mpos, const float3& impulse, bool worldspace = false);
Parameter Description Returns Description
mpos: model-space position to act on
impulse: model or world-space force impulse vector
worldspace: true for world-space, false for model-space force vector
- Apply extra force impulse (force * dt), one-time impulse, non-persistent
virtual uint get_joint_id(const coid::token& name) const;
Parameter Description Returns Description
name: joint/bone name returns: joint/bone id or -1 if doesn't exist Get joint/bone id for given bone name
virtual uint get_mesh_id(const coid::token& name, uint8 lod_group = 0xff, uint8 mat_group = 0xff) const;
Parameter Description Returns Description
name: mesh name
lod_group: log group for given base name (0xff if all lod groups)
mat_group: material group for given base name (0xff if all material groups)
returns: mesh id for given params or -1 if doesn't exist Get mesh id
virtual void fire(const float3& pos, const float3& dir, float speed, float caliber, const float3& color, uint joint = pkg::InvalidBoneId);
Parameter Description Returns Description
pos: model-space launch position
dir: model-space launch direction
speed: firing velocity in m/s
caliber: diameter of the ray [m]
color: plasma color
joint: bone id to attach to
- Fire a colored plasma thing
virtual void explode_ground(const ot::ground_explosion& ge);
Parameter Description Returns Description
ge: explosion parameters - Explode ground at model position
virtual float elevation_test(const float3& pos, float maxdist, float negdist = -FLT_MIN, uint joint = pkg::InvalidBoneId) const;
Parameter Description Returns Description
pos: model-space position
maxdist: max distance/height to check
negdist: max negative distance to test
joint: [optional] bone id to be relative to
returns: height above terrain or >= maxdist if no hit, <= negdist if under terrain Elevation test
virtual float elevation_test_ext(const float3& pos, float maxdist, float negdist = -FLT_MIN, ifc_out ot::hitpoint* hp = 0, ot::hit_flags hpflags = {.hit = true, .normal = true}, uint joint = pkg::InvalidBoneId) const;
Parameter Description Returns Description
pos: model-space position
maxdist: max distance/height to check
negdist: max negative distance to test
hp: [out, optional] hitpoint result
hpflags: query flags (ot::hit_flags)
joint: [optional] bone id to be relative to
returns: height above terrain or >= maxdist if no hit, <= negdist if under terrain Elevation test with extended info
virtual float ray_test(const float3& pos, const float3& dir, float maxdist, float negdist = -FLT_MIN, ifc_out ot::hitpoint* hp = 0, ot::hit_flags hpflags = {.hit = true, .normal = true}, uint joint = pkg::InvalidBoneId) const;
Parameter Description Returns Description
pos: model-space (or bone-space) position
dir: model-space (or bone-space) ray direction
maxdist: max distance/height to check
negdist: max negative distance to test
hp: [out, optional] hitpoint result
hpflags: query flags (ot::hit_flags)
joint: [optional] bone id to be relative to
returns: intersection distance or >= maxdist if no hit, <= negdist if under terrain Test if ray from model intersects with terrain
virtual iref<ot::object> object_test(const float3& pos, const float3& dir, float maxdist, ifc_out ot::hitpoint* hp = 0, ot::hit_flags hpflags = {.hit = true, .normal = true, .objects = true, .dynamic = true, .selftest = false}, uint joint = pkg::InvalidBoneId) const;
Parameter Description Returns Description
pos: model-space (or bone-space) position
dir: model-space (or bone-space) ray direction
maxdist: max ray distance to check (keep short if possible)
hp: [out, optional] hitpoint result
hpflags: query flags (ot::hit_flags)
joint: bone id to be relative to
returns: object hit Test if ray from model hits an object
virtual void attach_object(const iref<ot::object>& obj, uint joint_id, const float3& pos, const quat& rot, uint custom_id);
Parameter Description Returns Description
obj: object to attach
joint_id: bone id
pos: relative attachment offset
rot: relative attachment rotation
custom_id: id that can be used to identify the attached object when detaching
- Attach object
virtual iref<ot::object> detach_object(uint custom_id, bool activate);
Parameter Description Returns Description
custom_id: id set previously by attach_geom
activate: activate object (if it's not a static one)
returns: detached object, if found Detach specified object
virtual iref<ot::object> get_attached_to() const;
Parameter Description Returns Description
- returns: the object this object is attached to or nullptr if this object is free Get object we are attached to
virtual bool detach_ot_object(const iref<ot::object>& object, bool activate);
Parameter Description Returns Description
object: attached object
activate: activate object (if it's not a static one)
returns: true if successful Detach specified object
virtual void set_fps_camera_pos(const float3& pos, uint joint_id = UMAX32, ot::EJointRotationMode joint_rotation = ot::JointRotModeEnable);
Parameter Description Returns Description
pos: model space position for FPS camera
joint_id: [optional] bone id
joint_rotation: joint rotation mode
- Set model space position for FPS camera
virtual void set_fps_camera_rot(const quat& rot, ot::ERotationMode mouse_rotation);
Parameter Description Returns Description
rot: model space rotation
mouse_rotation: mouse rotation mode: 0 freeze, 1 reset & disable, 2 enable, 3 reset & enable
- Set model space rotation frame
virtual void set_fps_camera_fov(float hfov, float vfov = 0);
Parameter Description Returns Description
hfov: horizontal FOV in degrees, 0 to reset to the default one
vfov: [optional] vertical FOV in degrees, otherwise computed from aspect ratio
- Set FOV to chassis FPS preset and also to current camera if vehicle is entered and FPS camera is active
virtual float3 get_fps_camera_pos() const;
Parameter Description Returns Description
- returns: current FPS camera position Get current FPS camera position
virtual quat get_fps_camera_rot(bool base = false) const;
Parameter Description Returns Description
base: true for the base orientation frame, false for current camera orientation as altered by mouse returns: current FPS camera rotation in model space Get current FPS camera rotation
virtual float2 get_fps_camera_fov() const;
Parameter Description Returns Description
- returns: FPS camera preset FOV for this chassis Get FPS camera preset FOV for this chassis
virtual void set_fps_camera_ypr(float yaw, float pitch, float roll, ot::ERotationMode mouse_rotation);
Parameter Description Returns Description
yaw: yaw angle in radians, positive values to the right
pitch: pitch angle in radians, positive up
roll: roll angle in radians, positive clockwise
mouse_rotation: mouse rotation mode: 0 freeze, 1 reset & disable, 2 enable, 3 reset & enable
- Set model space orientation for FPS camera
virtual float3 get_fps_camera_ypr(bool base = false) const;
Parameter Description Returns Description
base: true for the base orientation frame, false for current camera orientation as altered by mouse returns: current yaw/pitch/roll angles of the camera in model space in radians Get current yaw/pitch/roll angles of the camera
virtual bool set_fps_camera_tracking_point(const double3& target, bool level_horizon);
Parameter Description Returns Description
target: ECEF coordinates of the point
level_horizon: keep horizon level (roll the camera)
returns: true if tracking was enabled, false if center wasn't on terrain or the current camera mode is not FPS Enable tracking of world point
virtual bool set_fps_camera_tracking(bool level_horizon);
Parameter Description Returns Description
level_horizon: keep horizon level (roll the camera) returns: true if tracking was enabled, false if center wasn't on terrain or the current camera mode is not FPS Enable tracking of the current world point (in screen center)
virtual bool set_fps_camera_tracking_off();
Parameter Description Returns Description
- returns: true if tracking was disabled Disable tracking
iref<ot::sndgrp> sound();
Parameter Description Returns Description
- returns: of::snd_group interface Get sound group interface
int register_handler_ext(const coid::token& name, uint group = 0);
Parameter Description Returns Description
name: hierarchic action name, file/group/action
group: activation group where the action is assigned (default = 0)
returns: slot id or -1 on failure Register action handler for an existing knob
int register_event_ext(const coid::token& name, bool release_event, uint group = 0);
Parameter Description Returns Description
name: hierarchic action name, file/group/action
release_event: receive release events (true/false)
group: activation group (default = 0)
returns: slot id or -1 on failure Register event action handler
int register_axis_ext(const coid::token& name, const ot::ramp_params& ramp, uint group = 0);
Parameter Description Returns Description
name: hierarchic action name
ramp: value limiter parameters
group: activation group (default = 0)
returns: slot id or -1 on failure Register axis action handler
int register_handler(const coid::token& name, ot::fn_event_action&& handler, int handler_id = 0, uint group = 0);
Parameter Description Returns Description
name: hierarchic action name
handler: event handler (void fn(int flags, uint code, uint channel, int handler_id))
handler_id: optional extra data for handler
group: activation group (default = 0)
returns: slot id or -1 on failure Register input action for an existing knob
int register_handler_default(const coid::token& name, ot::fn_event_action&& handler, const ot::ramp_params& def_ramp, int handler_id = 0, const float* def_val = nullptr, uint group = 0);
Parameter Description Returns Description
name: hierarchic action name
handler: event handler (void fn(int flags, uint code, uint channel, int handler_id))
def_ramp: ramp parameters for new knob
handler_id: optional extra data
def_val: optional default action value
group: activation group (default = 0)
returns: slot id or -1 on failure Register input action for existing or new knob
int register_axis_handler(const coid::token& name, ot::fn_axis_action&& handler, const ot::ramp_params& ramp, int handler_id = 0, const float* def_val = nullptr, uint group = 0);
Parameter Description Returns Description
name: hierarchic action name
handler: optional axis handler (void fn(float val, uint code, uint channel, int handler_id))
ramp: ramp parameters
handler_id: optional extra data
def_val: optional default action value
group: activation group (default = 0)
returns: slot id or -1 on failure Register input action for axis event
int register_event_handler(const coid::token& name, ot::fn_event_action&& handler, int handler_id = 0, uint group = 0, uint extra_channels = 0);
Parameter Description Returns Description
name: hierarchic action name
handler: optional event handler (void fn(int flags, uint code, uint channel, int handler_id))
handler_id: optional extra data
group: activation group (default = 0)
extra_channels: number of extra channels
returns: slot id or -1 on failure Register input action for button event
void action_group(uint group, bool activate);
Parameter Description Returns Description
group: group id
activate: activate or deactivate the group
- Activate or deactivate given action group
void set_center_value(int action, float center);
Parameter Description Returns Description
action: action id
center: center value, clamped to minval..maxval range
- Set the center value for an action
void set_action_value(int action, float value, bool hold);
Parameter Description Returns Description
action: action id
value: action value (clamped)
hold: hold value (disable centering)
- Set action value and optionally hold
void set_instant_action_value(int action, float value, bool notify);
Parameter Description Returns Description
action: action id
value: action value (clamped)
notify: notify handler (true/false)
- Set action value and optionally notify handler
uint add_spot_light(const float3& offset, const float3& dir, const ot::light_params& lp, const coid::token& joint = coid::token());
Parameter Description Returns Description
offset: model-space offset
dir: light direction
lp: light parameters
joint: joint to attach the light to (optional)
returns: light emitter id Define a circular spotlight source
uint add_point_light(const float3& offset, const ot::light_params& lp, const coid::token& joint = coid::token());
Parameter Description Returns Description
offset: model-space offset
lp: light parameters
joint: joint to attach the light to (optional)
returns: light emitter id Define a point light source
void light(uint id, bool on);
Parameter Description Returns Description
id: light emitter id
on: turn on (true) or off (false)
- Turn light on or off
void light_mask(uint mask, bool on, uint offset = 0);
Parameter Description Returns Description
mask: bitmask of lights
on: turn on (true) or off (false)
offset: offset for bitmask (default = 0)
- Turn lights on or off by mask
void light_toggle(uint id);
Parameter Description Returns Description
id: light emitter id - Toggle light on or off
void light_toggle_mask(uint mask, uint offset = 0);
Parameter Description Returns Description
mask: bitmask of lights
offset: offset for bitmask (default = 0)
- Toggle lights by mask
void light_color(uint id, const float4& color, float range = 0);
Parameter Description Returns Description
id: light emitter id
color: light color
range: light intensity (default = 0)
- Set light color and intensity
void lights_off(bool instant = false);
Parameter Description Returns Description
instant: turn off lights instantly (default = false) - Turn off all lights
void solar_time(ifc_out double& time, ifc_out float& sun_coef) const;
Parameter Description Returns Description
time: solar time at vehicle location (out)
sun_coef: sun position relative to horizon (out)
- Return current solar time and sun-zenith angle
int add_display(float width, float height, const coid::token& mesh_name);
Parameter Description Returns Description
width: width of the display
height: height of the display
mesh_name: name of the display's mesh in geomob
returns: id of the display Add a new display
iref<ot::canvas> get_display_canvas(uint display_id);
Parameter Description Returns Description
display_id: id of the display returns: iref of ot::canvas Get the canvas for the specified display
coid::dynarray<coid::charstr> get_display_names();
Parameter Description Returns Description
- returns: dynarray of display names Get a list of display names
uint add_smoke_emitter(const coid::token& joint, const coid::token& texture, const ot::particle_emitter_params& params);
Parameter Description Returns Description
joint: name of the joint the emitter will be attached to
texture: relative path of the texture (must be RGBA8 dds)
params: emitter parameters
returns: emitter id Add a smoke emitter
uint add_dust_emitter(const coid::token& joint, const coid::token& texture);
Parameter Description Returns Description
joint: name of the joint the emitter will be attached to
texture: relative path of the texture
returns: emitter id Add a dust emitter
void set_emitter_color(uint emitter, ot::color color);
Parameter Description Returns Description
emitter: emitter id
color: particle color
- Set the overall color for the emitter
void pause_emitter(uint emitter, bool pause);
Parameter Description Returns Description
emitter: emitter id
pause: pause (true/false)
- Pause or resume the emitter
uint load_sound(const coid::token& filename);
Parameter Description Returns Description
filename: path to the sound file returns: sound buffer id Load a sound buffer from a file
uint add_sound_emitter(const coid::token& joint, int type = 0, float ref_distance = 0);
Parameter Description Returns Description
joint: bone name to attach to
type: sound type (-1 interior only, 0 universal, 1 exterior only)
ref_distance: reference distance for sound attenuation
returns: sound emitter id Attach sound emitter to a model joint by name
uint add_sound_emitter_id(uint joint_id, int type = 0, float ref_distance = 0);
Parameter Description Returns Description
joint_id: bone id to attach to
type: sound type (-1 interior only, 0 universal, 1 exterior only)
ref_distance: reference distance for sound attenuation
returns: sound emitter id Attach sound emitter to a model joint by id
void set_interior_sound_attenuation(float att);
Parameter Description Returns Description
att: attenuation factor - Set the attenuation for sounds from outside
void fetch_controls(coid::dynarray32<int32>& buf, bool append);
Parameter Description Returns Description
buf: buffer to store controls
append: append to the buffer (true/false)
- Fetch control inputs
void apply_controls(const int32* cmd, uint ncmds);
Parameter Description Returns Description
cmd: control commands
ncmds: number of commands
- Apply control inputs
void open(int openid, ot::kbd_modifier modifiers);
Parameter Description Returns Description
openid: id of the openable part
modifiers: keyboard modifiers (LSHIFT=1, RSHIFT=2, LCTRL=4, RCTRL=8)
- Insert an open door command
coref<ot::component::animator> get_animator();
Parameter Description Returns Description
- returns: animator reference Get the animator component
iref<ot::object> spawn_object(const coid::token& model, const float3& pos, const glm::quat& rot, bool persistent);
Parameter Description Returns Description
model: full model path under packages dir
pos: relative position of the pivot point
rot: relative orientation of the model
persistent: true if the object should be placed persistently into the world
returns: iref of the object Spawn an object
iref<ot::object> object_test_from_camera(float maxdist, ifc_out ot::hitpoint* hp = 0, ot::hit_flags hpflags = {.hit = true, .normal = true, .objects = true, .dynamic = true, .selftest = false}) const;
Parameter Description Returns Description
maxdist: maximum test distance
hp: hitpoint object to store results (optional)
hpflags: hit flags (optional)
returns: iref of the object Test object interaction from camera view
iref<ot::object> get_object_in_focus() const;
Parameter Description Returns Description
return: object in interactive focus Returns the object that is currently in the interactive focus of the character.
void move(const float3& pos, float yawd = 0.0f, float pitch = 0.0f, float roll = 0.0f);
Parameter Description Returns Description
pos: Relative position in tangent space (x: side, y: forward, z: up)
yawd: Yaw angle delta in radians (default: 0.0)
pitch: Pitch angle in radians (default: 0.0)
roll: Roll angle in radians (default: 0.0)
Moves the character relative to its current position in tangent space.3
Only dynamic game objects can move.
void rotate(const float3& fwd);
Parameter Description Returns Description
fwd: Forward vector to align to (in ECEF space) Sets the rotation of the object. This method is primarily for initial setup of the object's rotation. For runtime rotation, the move method is recommended.
float height() const;
Parameter Description Returns Description
return: height above terrain Returns the current height of the object above the terrain.
iref<ot::interactor> enter_vehicle(const iref<ot::object>& obj, uint bone_id = pkg::InvalidBoneId, bool preserve_position = true, const float3& pos = float3(), const quat& rot = quat(), ot::ECameraMode camode = ot::CamPrevious, ot::EControlsBinding bindio = ot::BindControls);
Parameter Description Returns Description
obj: Object to enter (can be null if re-entering a different bone)
bone_id: Bone to attach to (default is the model pivot)
preserve_position: True to preserve the current world position relative to the bone, false to reset
pos: Relative position
rot: Relative rotation
camode: Camera mode to use
bindio: Bind user controls
return: entered object (can be different than the one passed in, in case static object was awakened) Enters a vehicle/interactor object.
void exit_vehicle(bool preserve_position, const float3& pos = float3(), const quat& rot = quat(), ot::ECameraMode camode = ot::CamPrevious);
Parameter Description Returns Description
preserve_position: True to preserve current position relative to the exited object
pos: Relative position to the exited object
rot: Relative rotation to the exited object
camode: Camera mode to use after exit
Exits the entered object.
Note: currently, this method is only usable for vehicles.

Events

virtual ot::chassis_params init_chassis(const coid::charstr& params);
Parameter Description Returns Description
params: custom parameters from objdef returns: chassis_params Initialize chassis (shared across all instances)
virtual ot::chassis_params init_chassis_script(const coid::charstr& params);
Parameter Description Returns Description
params: custom parameters from objdef returns: chassis_params Initialize chassis through script
virtual void update_actions_script(float dt, const coid::range<int32>& actbuf);
Parameter Description Returns Description
dt: delta time
actbuf: action buffer
- Invoke script-side registered actions
virtual void engine(bool start);
Parameter Description Returns Description
start: start (true) or stop (false) - Start or stop the engine
virtual float ext_param(const coid::token& name, const float* value);
Parameter Description Returns Description
name: parameter name
value: value to set (null means requesting value)
returns: param value Set or get an externally provided parameter
virtual void initialize(bool reload);
Parameter Description Returns Description
reload: reload flag - Initialize object instance
virtual void visual_update(float dt, float dtinterp);
Parameter Description Returns Description
dt: delta time since last update
dtinterp: interpolation time ahead from the last simulation state
- Update model instance for rendering
virtual void simulation_step(float dt);
Parameter Description Returns Description
dt: delta time -
virtual bool wants_tps_focus();
Parameter Description Returns Description
- returns:
virtual void force_bind_script_events();
Parameter Description Returns Description
- - Force bind script events
⚠️ **GitHub.com Fallback** ⚠️