diff --git a/artifacts/ddraw.ini b/artifacts/ddraw.ini index be4128f3..d72e8b5b 100644 --- a/artifacts/ddraw.ini +++ b/artifacts/ddraw.ini @@ -556,8 +556,10 @@ CritterInvSizeLimit=100 ;2 - Motion sensor doesn't require charges MotionScannerFlags=1 -;Set to non-0 to adjust the maximum encounter table size -;Default is 40, and the maximum is 127 +;Set a value greater than 40 to change the maximum encounter table size (enc_## in worldmap.txt) +;Note: Setting this greater than 50 requires renumbering all message lines for the encounter tables in worldmap.msg +;so that the message numbers for each table will start from (3000 + table number * 100) +;Default is 40, and the maximum is 100 EncounterTableSize=0 ;Set to 1 to disable the pipboy alarm button diff --git a/artifacts/scripting/sfall function notes.txt b/artifacts/scripting/sfall function notes.txt index 444dae40..999dc6ba 100644 --- a/artifacts/scripting/sfall function notes.txt +++ b/artifacts/scripting/sfall function notes.txt @@ -67,7 +67,7 @@ get/set_proto_data are used to manipulate the in memory copies of the .pro files the list_xxx functions can be used to loop over all items on a map. list_begin takes an argument telling sfall what you want to list. (Defined in sfall.h) It returns a list pointer, which you iterate through with list_next. Finally, when you've finished with the list use list_end on it. Not calling list_end will result in a memory leak. Alternatively, use list_as_array to get the whole list at once as a temp array variable, which can be looped over using len_array and which you don't need to remember to free afterwards. play_sfall_sound and stop_sfall_sound are used to play mp3/wav/wma files. The path given is relative to the Fallout folder. Specify mode as 1 to loop the file continuously, 2 to replace the current background game music with playing the specified file in loop mode, or 0 to play the file once. If you don't wish to loop, play_sfall_sound returns 0. If you do loop, it returns an id which can be passed back to stop_sfall_sound when you want to stop the effect. All sounds effects will be stopped on game reload, looping or not. These functions do not require 'AllowDShowSound' to be set to 1 in ddraw.ini. -Starting from sfall 4.2.8/3.8.28, you can pass a value in range from 0 to 32767 in the 'mode' argument for a reduced sound volume; the value 32767 is the minimum volume (mute). To set the volume, You need to convert the number to hexadecimal and use the argument format 0xZZZZ000Y, where ZZZZ is the volume value, and Y is the playback mode. +Starting from sfall 4.2.8/3.8.28, you can pass a value in the 'mode' argument for a reduced sound volume. To set the volume, You need to convert the number to hexadecimal and use the argument format 0xZZZZ000Y, where ZZZZ is the volume reduction value in range from 0 to 32767 (the value 32767 is mute), and Y is the playback mode. arrays are created and manipulated with the xxx_array functions. An array must first be created with create_array or temp_array, specifying how many data elements the array can hold. You can store any of ints, floats and strings in an array, and can mix all 3 in a single array. The id returned by create/temp_array can then be used with the other array functions. Arrays are shared between all scripts. (i.e. you can call create_array from one script, and then use the returned id from another script.) They are also saved across savegames. You must remember to free any arrays you create with create_array when you are done with them, or you will leak memory. arrays created with temp_array will be automatically freed at the end of the frame. These functions are safe, in that supplying a bad id or trying to access out of range elements will not crash the script. create_array is the only function that returns a permanent array, all other functions which return arrays (string_split, list_as_array etc,) all return temp arrays. You can use fix_array to make a temp array permanent. diff --git a/sfall/Modules/BugFixes.cpp b/sfall/Modules/BugFixes.cpp index d4ebd3de..69436580 100644 --- a/sfall/Modules/BugFixes.cpp +++ b/sfall/Modules/BugFixes.cpp @@ -919,6 +919,19 @@ static void __declspec(naked) NPCStage6Fix2() { } } +static void __declspec(naked) make_path_func_hook() { + __asm { + mov ebx, [edx + tile]; // object tile + cmp ebx, [esp + 0x5C - 0x1C + 4]; // target tile + je fix; + jmp fo::funcoffs::anim_can_use_door_; +fix: + mov ebx, [esp + 0x5C - 0x14 + 4]; // current tile + mov [esp + 0x5C - 0x1C + 4], ebx; // target tile + retn; + } +} + // Haenlomal: Check path to critter for attack static void __declspec(naked) MultiHexFix() { __asm { @@ -3045,6 +3058,7 @@ void BugFixes::init() //if (GetConfigInt("Misc", "MultiHexPathingFix", 1)) { dlog("Applying MultiHex Pathing Fix.", DL_INIT); + HookCall(0x416144, make_path_func_hook); // Fix for building the path to the central hex of a multihex object MakeCalls(MultiHexFix, {0x42901F, 0x429170}); // Fix for multihex critters moving too close and overlapping their targets in combat MakeCall(0x42A14F, MultiHexCombatRunFix, 1); diff --git a/sfall/Modules/MiscPatches.cpp b/sfall/Modules/MiscPatches.cpp index 317132c5..40b3c349 100644 --- a/sfall/Modules/MiscPatches.cpp +++ b/sfall/Modules/MiscPatches.cpp @@ -500,15 +500,28 @@ static void MotionScannerFlagsPatch() { } } +static void __declspec(naked) ResizeEncounterMessagesTable() { + __asm { + add eax, eax; // double the increment + add eax, 3000; + retn; + } +} + static void EncounterTableSizePatch() { const DWORD EncounterTableSize[] = { 0x4BD1A3, 0x4BD1D9, 0x4BD270, 0x4BD604, 0x4BDA14, 0x4BDA44, 0x4BE707, 0x4C0815, 0x4C0D4A, 0x4C0FD4, }; - DWORD tableSize = GetConfigInt("Misc", "EncounterTableSize", 0); - if (tableSize > 40 && tableSize <= 127) { + int tableSize = GetConfigInt("Misc", "EncounterTableSize", 0); + if (tableSize > 40) { dlog("Applying EncounterTableSize patch.", DL_INIT); + if (tableSize > 50) { + if (tableSize > 100) tableSize = 100; + // Increase the count of message lines from 50 to 100 for the encounter tables in worldmap.msg + MakeCalls(ResizeEncounterMessagesTable, {0x4C102C, 0x4C0B57}); + } SafeWrite8(0x4BDB17, (BYTE)tableSize); DWORD nsize = (tableSize + 1) * 180 + 0x50; SafeWriteBatch(nsize, EncounterTableSize);