From 99044236413f5b7d2d722c97ee517bdce8cdd6b0 Mon Sep 17 00:00:00 2001 From: NovaRain Date: Thu, 14 Nov 2019 12:49:06 +0800 Subject: [PATCH] Added "reg_anim_callback" script function(opcode) (#257) Updated documents. --- artifacts/scripting/sfall function notes.txt | 3 +++ artifacts/scripting/sfall opcode list.txt | 1 + sfall/FalloutEngine/Functions_def.h | 1 + sfall/Modules/DebugEditor.cpp | 2 +- sfall/Modules/Scripting/Handlers/Anims.cpp | 9 +++++++++ sfall/Modules/Scripting/Handlers/Anims.h | 2 ++ sfall/Modules/Scripting/Opcodes.cpp | 1 + 7 files changed, 18 insertions(+), 1 deletion(-) diff --git a/artifacts/scripting/sfall function notes.txt b/artifacts/scripting/sfall function notes.txt index 6311862b..052190a5 100644 --- a/artifacts/scripting/sfall function notes.txt +++ b/artifacts/scripting/sfall function notes.txt @@ -218,6 +218,9 @@ Some additional reg_anim_* functions were introduced. They all work in the same > void reg_anim_turn_towards(object, tile/target, delay) - makes object change its direction to face given tile num or target object. +> void reg_anim_callback(procedure proc) +- registers the given procedure and executes it after previously registered animations are finished. + > int/array metarule2_explosions(int arg1, int arg2, int arg3) was made as a dirty easy hack to allow dynamically change some explosion parameters (ranged attack). All changed parameters are reset to vanilla state automatically after each attack action. Following macros are available in sfall.h: diff --git a/artifacts/scripting/sfall opcode list.txt b/artifacts/scripting/sfall opcode list.txt index 79f0026f..7aedf936 100644 --- a/artifacts/scripting/sfall opcode list.txt +++ b/artifacts/scripting/sfall opcode list.txt @@ -358,6 +358,7 @@ 0x827c - any sfall_func6(string funcName, arg1, arg2, arg3, arg4, arg5, arg6) 0x827d - void register_hook_proc_spec(int hook, procedure proc) +0x827e - void reg_anim_callback(procedure proc) * These functions require AllowUnsafeScripting to be enabled in ddraw.ini diff --git a/sfall/FalloutEngine/Functions_def.h b/sfall/FalloutEngine/Functions_def.h index 439c1ce0..1669ae9c 100644 --- a/sfall/FalloutEngine/Functions_def.h +++ b/sfall/FalloutEngine/Functions_def.h @@ -28,6 +28,7 @@ WRAP_WATCOM_FFUNC7(void, make_straight_path_func, GameObject*, objFrom, DWORD, t WRAP_WATCOM_FFUNC4(long, mouse_click_in, long, x, long, y, long, x_end, long, y_end) WRAP_WATCOM_FFUNC3(GameObject*, obj_blocking_at, GameObject*, object, long, tile, long, elevation) WRAP_WATCOM_FFUNC3(long, object_under_mouse, long, crSwitch, long, inclDude, long, elevation) +WRAP_WATCOM_FFUNC4(void, register_object_call, long*, target, long*, source, void*, func, long, delay) WRAP_WATCOM_FFUNC3(long, scr_get_local_var, long, sid, long, varId, long*, value) WRAP_WATCOM_FFUNC3(long, scr_set_local_var, long, sid, long, varId, long, value) WRAP_WATCOM_FFUNC3(long, tile_num_in_direction, long, tile, long, rotation,long, distance) diff --git a/sfall/Modules/DebugEditor.cpp b/sfall/Modules/DebugEditor.cpp index afe5a0dc..d8190f7b 100644 --- a/sfall/Modules/DebugEditor.cpp +++ b/sfall/Modules/DebugEditor.cpp @@ -322,7 +322,7 @@ artNotExist: push artDbgMsg; call fo::funcoffs::debug_printf_; add esp, 8; - BREAKPOINT; // break program + int 3; // break program retn; } } diff --git a/sfall/Modules/Scripting/Handlers/Anims.cpp b/sfall/Modules/Scripting/Handlers/Anims.cpp index 2e5ee370..eda6b737 100644 --- a/sfall/Modules/Scripting/Handlers/Anims.cpp +++ b/sfall/Modules/Scripting/Handlers/Anims.cpp @@ -116,6 +116,15 @@ void sf_reg_anim_turn_towards(OpcodeContext& ctx) { } } +void sf_reg_anim_callback(OpcodeContext& ctx) { + fo::func::register_object_call( + reinterpret_cast(ctx.program()), + reinterpret_cast(ctx.arg(0).rawValue()), // callback procedure + reinterpret_cast(fo::funcoffs::executeProcedure_), + -1 + ); +} + void sf_explosions_metarule(OpcodeContext& ctx) { int mode = ctx.arg(0).asInt(), result = ExplosionsMetaruleFunc(mode, ctx.arg(1).asInt(), ctx.arg(2).asInt()); diff --git a/sfall/Modules/Scripting/Handlers/Anims.h b/sfall/Modules/Scripting/Handlers/Anims.h index 082bd1fc..8191cb65 100644 --- a/sfall/Modules/Scripting/Handlers/Anims.h +++ b/sfall/Modules/Scripting/Handlers/Anims.h @@ -37,6 +37,8 @@ void sf_reg_anim_change_fid(OpcodeContext&); void sf_reg_anim_take_out(OpcodeContext&); void sf_reg_anim_turn_towards(OpcodeContext&); +void sf_reg_anim_callback(OpcodeContext&); + void sf_explosions_metarule(OpcodeContext&); void sf_art_cache_flush(OpcodeContext&); diff --git a/sfall/Modules/Scripting/Opcodes.cpp b/sfall/Modules/Scripting/Opcodes.cpp index fb0f18cd..d64f2855 100644 --- a/sfall/Modules/Scripting/Opcodes.cpp +++ b/sfall/Modules/Scripting/Opcodes.cpp @@ -215,6 +215,7 @@ static SfallOpcodeInfo opcodeInfoArray[] = { {0x27c, "sfall_func6", HandleMetarule, 7, true}, // if you need more arguments - use arrays {0x27d, "register_hook_proc_spec", sf_register_hook, 2, false, {ARG_INT, ARG_INT}}, + {0x27e, "reg_anim_callback", sf_reg_anim_callback, 1, false, {ARG_INT}}, }; // A hash-table for opcode info, indexed by opcode.