Skip to content

Commit

Permalink
Added reg_anim_animate_and_move script function (closes #497)
Browse files Browse the repository at this point in the history
  • Loading branch information
NovaRain committed Dec 27, 2023
1 parent cfcc66a commit 7e47607
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 106 deletions.
10 changes: 9 additions & 1 deletion artifacts/scripting/functions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,9 @@
opcode: 0x825a
- name: reg_anim_animate_and_hide
detail: void reg_anim_animate_and_hide(ObjectPtr, int animID, int delay)
doc: Exactly like `reg_anim_animate` but the object will automatically disappear after the last animation frame (but not destroyed).
doc: |
Works exactly like `reg_anim_animate` but the object will automatically disappear after the last animation frame (but not destroyed).
- `delay`: delay from the previous animation. A value of -1 will execute the specified animation immediately after the previous one in the sequence ends.
opcode: 0x825b
- name: reg_anim_light
detail: void reg_anim_light(ObjectPtr, int light, int delay)
Expand All @@ -799,6 +801,12 @@
detail: void reg_anim_callback(procedure proc)
doc: Adds the given procedure to an animation sequence-list and executes it in the registered sequence.
opcode: 0x827e
- name: reg_anim_animate_and_move
detail: void reg_anim_animate_and_move(ObjectPtr, int tile, int animID, int delay)
doc: |
Plays the specified animation while simultaneously moving the object to the given tile.
- `delay`: delay from the previous animation. A value of -1 will execute the specified animation immediately after the previous one in the sequence ends.
macro: sfall.h

- name: Art and appearance
items:
Expand Down
1 change: 1 addition & 0 deletions artifacts/scripting/headers/sfall.h
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@
#define overlay_clear_rectangle(winType, x, y, w, h) sfall_func6("interface_overlay", winType, 2, x, y, w, h)
#define overlay_destroy(winType) sfall_func2("interface_overlay", winType, 0)
#define real_dude_obj sfall_func0("real_dude_obj")
#define reg_anim_animate_and_move(obj, tile, animID, delay) sfall_func4("reg_anim_animate_and_move", obj, tile, animID, delay)
#define remove_all_timer_events sfall_func0("remove_timer_event")
#define remove_timer_event(fixedParam) sfall_func1("remove_timer_event", fixedParam)
#define set_can_rest_on_map(map, elev, value) sfall_func3("set_can_rest_on_map", map, elev, value)
Expand Down
9 changes: 8 additions & 1 deletion artifacts/scripting/sfall function notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ FUNCTION REFERENCE

-----
##### `void reg_anim_animate_and_hide(object obj, int animID, int delay)`
- Exactly like `reg_anim_animate` but the object will automatically disappear after the last animation frame (but not destroyed).
- Works exactly like `reg_anim_animate` but the object will automatically disappear after the last animation frame (but not destroyed).
- `delay`: delay from the previous animation. A value of -1 will execute the specified animation immediately after the previous one in the sequence ends.

-----
##### `void reg_anim_light(object obj, int light, int delay)`
Expand Down Expand Up @@ -1127,6 +1128,12 @@ sfall_funcX metarule functions
**Optional argument:**
- `pos`: the position at which to start the search. If negative, it indicates a position starting from the end of the string

----
#### reg_anim_animate_and_move
`void sfall_func4("reg_anim_animate_and_move", object obj, int tile, int animID, int delay)`
- Plays the specified animation while simultaneously moving the object to the given tile
- `delay`: delay from the previous animation. A value of -1 will execute the specified animation immediately after the previous one in the sequence ends


****
_See other documentation files (arrays.md, hookscripts.md) for related functions reference._
1 change: 1 addition & 0 deletions sfall/FalloutEngine/Functions_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ WRAP_WATCOM_FFUNC3(long, obj_new_sid_inst, fo::GameObject*, object, long, sType,
WRAP_WATCOM_FFUNC3(fo::GameObject*, object_under_mouse, long, crSwitch, long, inclDude, long, elevation)
WRAP_WATCOM_FFUNC4(void, qsort, void*, base, long, number, long, elSize, DWORD, comp)
WRAP_WATCOM_FFUNC4(long, queue_add, long, time, fo::GameObject*, object, void*, data, long, qType)
WRAP_WATCOM_FFUNC5(long, register_object_animate_and_move_straight, fo::GameObject*, object, long, tile, long, elevation, long, anim, long, delay)
WRAP_WATCOM_FFUNC4(void, register_object_call, long*, target, long*, source, void*, func, long, delay)
WRAP_WATCOM_FFUNC4(long, register_object_move_to_object, fo::GameObject*, source, fo::GameObject*, target, long, distance, long, delay)
WRAP_WATCOM_FFUNC4(long, register_object_run_to_object, fo::GameObject*, source, fo::GameObject*, target, long, distance, long, delay)
Expand Down
21 changes: 16 additions & 5 deletions sfall/Modules/Scripting/Handlers/Anims.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void op_reg_anim_animate_and_hide(OpcodeContext& ctx) {
if (!checkCombatMode()) {
auto obj = ctx.arg(0).object();
int animId = ctx.arg(1).rawValue(),
delay = ctx.arg(2).rawValue();
delay = ctx.arg(2).rawValue();

fo::func::register_object_animate_and_hide(obj, animId, delay);
}
Expand All @@ -74,7 +74,7 @@ void op_reg_anim_light(OpcodeContext& ctx) {
if (!checkCombatMode()) {
auto obj = ctx.arg(0).object();
int radius = ctx.arg(1).rawValue(),
delay = ctx.arg(2).rawValue();
delay = ctx.arg(2).rawValue();

if (radius < 0) {
radius = 0;
Expand All @@ -89,7 +89,7 @@ void op_reg_anim_change_fid(OpcodeContext& ctx) {
if (!checkCombatMode()) {
auto obj = ctx.arg(0).object();
int fid = ctx.arg(1).rawValue(),
delay = ctx.arg(2).rawValue();
delay = ctx.arg(2).rawValue();

fo::func::register_object_change_fid(obj, fid, delay);
}
Expand All @@ -99,7 +99,7 @@ void op_reg_anim_take_out(OpcodeContext& ctx) {
if (!checkCombatMode()) {
auto obj = ctx.arg(0).object();
int holdFrame = ctx.arg(1).rawValue(),
nothing = ctx.arg(2).rawValue(); // not used by engine
nothing = ctx.arg(2).rawValue(); // not used by engine

fo::func::register_object_take_out(obj, holdFrame, nothing);
}
Expand All @@ -109,7 +109,7 @@ void op_reg_anim_turn_towards(OpcodeContext& ctx) {
if (!checkCombatMode()) {
auto obj = ctx.arg(0).object();
int tile = ctx.arg(1).rawValue(),
nothing = ctx.arg(2).rawValue();
nothing = ctx.arg(2).rawValue();

fo::func::register_object_turn_towards(obj, tile, nothing);
}
Expand All @@ -131,6 +131,17 @@ void op_reg_anim_callback(OpcodeContext& ctx) {
);
}

void mf_reg_anim_animate_and_move(OpcodeContext& ctx) {
if (!checkCombatMode()) {
auto obj = ctx.arg(0).object();
int tile = ctx.arg(1).rawValue(),
animId = ctx.arg(2).rawValue(),
delay = ctx.arg(3).rawValue();

fo::func::register_object_animate_and_move_straight(obj, tile, obj->elevation, animId, delay);
}
}

void op_explosions_metarule(OpcodeContext& ctx) {
int mode = ctx.arg(0).rawValue(),
result = ExplosionsMetaruleFunc(mode, ctx.arg(1).rawValue(), ctx.arg(2).rawValue());
Expand Down
2 changes: 2 additions & 0 deletions sfall/Modules/Scripting/Handlers/Anims.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ void op_reg_anim_take_out(OpcodeContext&);
void op_reg_anim_turn_towards(OpcodeContext&);
void op_reg_anim_callback(OpcodeContext&);

void mf_reg_anim_animate_and_move(OpcodeContext&);

void op_explosions_metarule(OpcodeContext&);

void op_art_exists(OpcodeContext&);
Expand Down
Loading

0 comments on commit 7e47607

Please sign in to comment.