Fixed EncounterTableSize option (#333)

* the encounter messages were still limited to 50 entries per table when
the value for encounters is set to greater than 50.

Fixed building the path to multihex objects.
This commit is contained in:
NovaRain
2020-09-03 14:24:00 +08:00
parent 849ae49bfb
commit 6a2a7ee82f
6 changed files with 37 additions and 5 deletions
+4 -2
View File
@@ -541,8 +541,10 @@ CritterInvSizeLimit=100
;4 - Motion sensor is required to use the item highlight feature ;4 - Motion sensor is required to use the item highlight feature
MotionScannerFlags=1 MotionScannerFlags=1
;Set to non-0 to adjust the maximum encounter table size ;Set a value greater than 40 to change the maximum encounter table size (enc_## in worldmap.txt)
;Default is 40, and the maximum is 127 ;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 EncounterTableSize=0
;Set to 1 to disable the pipboy alarm button ;Set to 1 to disable the pipboy alarm button
+1 -1
View File
@@ -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. 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. 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. 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.
+14
View File
@@ -902,6 +902,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 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 // Haenlomal: Check path to critter for attack
static void __declspec(naked) MultiHexFix() { static void __declspec(naked) MultiHexFix() {
__asm { __asm {
@@ -3030,6 +3043,7 @@ void BugFixesInit()
//if (GetConfigInt("Misc", "MultiHexPathingFix", 1)) { //if (GetConfigInt("Misc", "MultiHexPathingFix", 1)) {
dlog("Applying MultiHex Pathing Fix.", DL_INIT); 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
const DWORD multiHexFixAddr[] = {0x42901F, 0x429170}; const DWORD multiHexFixAddr[] = {0x42901F, 0x429170};
MakeCalls(MultiHexFix, multiHexFixAddr); MakeCalls(MultiHexFix, multiHexFixAddr);
// Fix for multihex critters moving too close and overlapping their targets in combat // Fix for multihex critters moving too close and overlapping their targets in combat
+1
View File
@@ -279,6 +279,7 @@ const DWORD add_bar_box_ = 0x4616F0;
const DWORD AddHotLines_ = 0x4998C0; const DWORD AddHotLines_ = 0x4998C0;
const DWORD adjust_ac_ = 0x4715F8; const DWORD adjust_ac_ = 0x4715F8;
const DWORD adjust_fid_ = 0x4716E8; const DWORD adjust_fid_ = 0x4716E8;
const DWORD anim_can_use_door_ = 0x415E24;
const DWORD art_alias_fid_ = 0x4199D4; const DWORD art_alias_fid_ = 0x4199D4;
const DWORD art_alias_num_ = 0x419998; const DWORD art_alias_num_ = 0x419998;
const DWORD art_exists_ = 0x4198C8; // eax - frameID, used for critter FIDs const DWORD art_exists_ = 0x4198C8; // eax - frameID, used for critter FIDs
+1
View File
@@ -558,6 +558,7 @@ extern const DWORD ai_check_drugs_;
extern const DWORD ai_run_away_; extern const DWORD ai_run_away_;
extern const DWORD ai_search_inven_armor_; extern const DWORD ai_search_inven_armor_;
extern const DWORD ai_try_attack_; extern const DWORD ai_try_attack_;
extern const DWORD anim_can_use_door_;
extern const DWORD art_alias_fid_; extern const DWORD art_alias_fid_;
extern const DWORD art_alias_num_; extern const DWORD art_alias_num_;
extern const DWORD art_exists_; // eax - frameID, used for critter FIDs extern const DWORD art_exists_; // eax - frameID, used for critter FIDs
+16 -2
View File
@@ -418,15 +418,29 @@ static void MotionScannerFlagsPatch() {
} }
} }
static void __declspec(naked) ResizeEncounterMessagesTable() {
__asm {
add eax, eax; // double the increment
add eax, 3000;
retn;
}
}
static void EncounterTableSizePatch() { static void EncounterTableSizePatch() {
const DWORD EncounterTableSize[] = { const DWORD EncounterTableSize[] = {
0x4BD1A3, 0x4BD1D9, 0x4BD270, 0x4BD604, 0x4BDA14, 0x4BDA44, 0x4BE707, 0x4BD1A3, 0x4BD1D9, 0x4BD270, 0x4BD604, 0x4BDA14, 0x4BDA44, 0x4BE707,
0x4C0815, 0x4C0D4A, 0x4C0FD4, 0x4C0815, 0x4C0D4A, 0x4C0FD4,
}; };
DWORD tableSize = GetConfigInt("Misc", "EncounterTableSize", 0); int tableSize = GetConfigInt("Misc", "EncounterTableSize", 0);
if (tableSize > 40 && tableSize <= 127) { if (tableSize > 40) {
dlog("Applying EncounterTableSize patch.", DL_INIT); 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
const DWORD encounterMsgsTableAddr[] = {0x4C102C, 0x4C0B57};
MakeCalls(ResizeEncounterMessagesTable, encounterMsgsTableAddr);
}
SafeWrite8(0x4BDB17, (BYTE)tableSize); SafeWrite8(0x4BDB17, (BYTE)tableSize);
DWORD nsize = (tableSize + 1) * 180 + 0x50; DWORD nsize = (tableSize + 1) * 180 + 0x50;
SafeWriteBatch<DWORD>(nsize, EncounterTableSize); SafeWriteBatch<DWORD>(nsize, EncounterTableSize);