diff --git a/artifacts/ddraw.ini b/artifacts/ddraw.ini index 44065ad3..c755bf96 100644 --- a/artifacts/ddraw.ini +++ b/artifacts/ddraw.ini @@ -594,7 +594,7 @@ ObjCanSeeObj_ShootThru_Fix=0 ;Set to 1 to fix the broken obj_can_hear_obj script function ObjCanHearObjFix=0 -;Set to 1 to enable the mood argument of start_gdialog script function to be available for talking heads +;Set to 1 to enable the mood argument of start_gdialog script function for talking heads ;If the argument value is -1, the mood will be determined by the local variable 0 of the script (vanilla behavior) StartGDialogFix=0 @@ -604,8 +604,9 @@ StartGDialogFix=0 ;num_attacks - the number of free action points on the first turn only AttackComplexFix=0 -;Set to 1 to enable the create_object_sid script function to run the 'start' script procedure when creating an object -;It is recommended to enable this option only if you are developing a new project (TC), otherwise it may affect some existing game scripts +;Set to 1 to make the create_object_sid script function run the 'start' procedure of attached script upon object creation +;By default, the 'start' procedure of attached script is executed after the current script procedure is finished +;Note that enabling this option may cause unexpected results with some existing game scripts CreateObjectSidFix=0 ;Set to 1 to fix the issue with the division operator treating negative integers as unsigned diff --git a/sfall/BugFixes.cpp b/sfall/BugFixes.cpp index 8b25ed12..c815e477 100644 --- a/sfall/BugFixes.cpp +++ b/sfall/BugFixes.cpp @@ -2277,7 +2277,16 @@ skip: } } -static DWORD dudeScriptID; +static void __declspec(naked) map_load_file_hook() { + __asm { + mov eax, 0x04004650; // dude script ID + call scr_remove_; + jmp partyMemberRecoverLoad_; + } +} + +static DWORD dudeScriptID; // usually equal to 0x04004650 + static void __declspec(naked) obj_load_dude_hook0() { __asm { mov eax, ds:[FO_VAR_obj_dude]; @@ -2289,8 +2298,10 @@ static void __declspec(naked) obj_load_dude_hook0() { static void __declspec(naked) obj_load_dude_hook1() { __asm { - mov ebx, dudeScriptID; - mov [eax + scriptId], ebx; + call scr_clear_dude_script_; + mov ebx, ds:[FO_VAR_obj_dude]; + mov eax, dudeScriptID; + mov [ebx + scriptId], eax; retn; } } @@ -3641,6 +3652,7 @@ void BugFixes_Init() HookCall(0x499240, PrintAMList_hook); // Fix for a duplicate obj_dude script being created when loading a saved game + HookCall(0x48306E, map_load_file_hook); // removes the redundant saved dude script data from the scripts block HookCall(0x48D63E, obj_load_dude_hook0); HookCall(0x48D666, obj_load_dude_hook1); BlockCall(0x48D675); diff --git a/sfall/FalloutFuncOffs_def.h b/sfall/FalloutFuncOffs_def.h index 4beb00e1..8b522375 100644 --- a/sfall/FalloutFuncOffs_def.h +++ b/sfall/FalloutFuncOffs_def.h @@ -438,6 +438,8 @@ FUNC(partyMemberGetCurLevel_, 0x495FF0) FUNC(partyMemberIncLevels_, 0x495B60) FUNC(partyMemberPrepItemSaveAll_, 0x495140) FUNC(partyMemberPrepLoad_, 0x4947AC) +FUNC(partyMemberPrepSave_, 0x49460C) +FUNC(partyMemberRecoverLoad_, 0x4949C4) FUNC(partyMemberRemove_, 0x4944DC) FUNC(partyMemberSaveProtos_, 0x495870) FUNC(pause_for_tocks_, 0x4C937C) @@ -501,6 +503,7 @@ FUNC(reset_box_bar_win_, 0x4614A0) FUNC(roll_random_, 0x4A30C0) FUNC(runProgram_, 0x46E154) // eax - programPtr, called once for each program after first loaded - hooks program to game and UI events FUNC(scr_build_lookup_table_, 0x4A49D0) +FUNC(scr_clear_dude_script_, 0x4A5044) FUNC(scr_exec_map_enter_scripts_, 0x4A67DC) FUNC(scr_exec_map_exit_scripts_, 0x4A69A0) FUNC(scr_exec_map_update_scripts_, 0x4A67E4)