diff --git a/artifacts/scripting/functions.yml b/artifacts/scripting/functions.yml index 5d242d0c..01fb65ce 100644 --- a/artifacts/scripting/functions.yml +++ b/artifacts/scripting/functions.yml @@ -702,7 +702,7 @@ opcode: 0x8236 - name: party_member_list detail: array party_member_list(int includeHidden) - doc: Returns an array of all current party members (0 - only critter-type, alive and visible will be returned, 1 - all object, including Trunk, etc.) + doc: Returns an array of all current party members (0 - only critters that are alive and visible will be returned, 1 - all objects, including the car trunk, etc.) opcode: 0x8271 - name: Explosions diff --git a/artifacts/scripting/sfall function notes.md b/artifacts/scripting/sfall function notes.md index 2347174d..11f57a8e 100644 --- a/artifacts/scripting/sfall function notes.md +++ b/artifacts/scripting/sfall function notes.md @@ -450,7 +450,7 @@ FUNCTION REFERENCE ----- ##### `array party_member_list(int includeHidden)` -- Returns an array of all current party members (0 - only critter-type, alive and visible will be returned, 1 - all object, including Trunk, etc.) +- Returns an array of all current party members (0 - only critters that are alive and visible will be returned, 1 - all objects, including the car trunk, etc.) ----- ##### `array path_find_to(object objFrom, int tileTo, int blockingType)` diff --git a/sfall/Modules/ScriptExtender.cpp b/sfall/Modules/ScriptExtender.cpp index 13d2cc68..dc1bcaca 100644 --- a/sfall/Modules/ScriptExtender.cpp +++ b/sfall/Modules/ScriptExtender.cpp @@ -867,12 +867,17 @@ void SetGlobals(GlobalVar* globals) { } } +static DWORD pcFlagSneak; + static __declspec(naked) void map_save_in_game_hook() { __asm { test cl, 1; jz skip; mov ScriptExtender::OnMapLeave, 1; call fo::funcoffs::scr_exec_map_exit_scripts_; + xor eax, eax; + call fo::funcoffs::is_pc_flag_; + mov pcFlagSneak, eax; // save sneak state mov ScriptExtender::OnMapLeave, 0; retn; skip: @@ -880,6 +885,18 @@ skip: } } +static __declspec(naked) void map_load_file_hook() { + __asm { + cmp pcFlagSneak, 0; + jz skip; + xor eax, eax; + mov pcFlagSneak, eax; + call fo::funcoffs::pc_flag_on_; +skip: + jmp fo::funcoffs::scr_exec_map_enter_scripts_; + } +} + static void ClearEventsOnMapExit() { using namespace fo; __asm { @@ -985,6 +1002,8 @@ void ScriptExtender::init() { HookCall(0x483CC3, (void*)fo::funcoffs::partyMemberSaveProtos_); HookCall(0x483CC8, (void*)fo::funcoffs::partyMemberPrepLoad_); HookCall(0x483CCD, (void*)fo::funcoffs::partyMemberPrepItemSaveAll_); + // Tweak for restoring the sneak state when switching between maps + HookCall(0x4830B6, map_load_file_hook); // Set the DAM_BACKWASH flag for the attacker before calling compute_damage_ SafeWrite32(0x423DE7, 0x40164E80); // or [esi+ctd.flags3Source], DAM_BACKWASH_