Added a tweak to restore the sneak state when switching between maps

(can be overridden with map_enter/exit_p_proc in global scripts)

Minor edit to function notes.
This commit is contained in:
NovaRain
2024-07-31 08:23:03 +08:00
parent 486c897243
commit 20bf2ce145
2 changed files with 20 additions and 1 deletions
+1 -1
View File
@@ -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)`
+19
View File
@@ -1004,12 +1004,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:
@@ -1017,6 +1022,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 {
@@ -1134,6 +1151,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_