From d4f011913c431cd4bfd9522c9e96615c32673ed5 Mon Sep 17 00:00:00 2001 From: NovaRain Date: Sat, 6 Nov 2021 22:44:14 +0800 Subject: [PATCH] Changed the fix in commit 583105a to an option (#412) --- artifacts/ddraw.ini | 5 +++++ sfall/FalloutEngine/Functions_def.h | 10 +++++----- sfall/Modules/Animations.cpp | 8 ++++++-- sfall/Modules/DamageMod.cpp | 13 ++++++------- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/artifacts/ddraw.ini b/artifacts/ddraw.ini index 30366a8e..0ce3397b 100644 --- a/artifacts/ddraw.ini +++ b/artifacts/ddraw.ini @@ -620,6 +620,11 @@ AttackComplexFix=0 ;Note that enabling this option may cause unexpected results with some existing game scripts CreateObjectSidFix=0 +;Set to 1 to make grave type containers in the open state run the 'use_p_proc' procedure of attached script when being used +;By default, using open graves does not run the 'use_p_proc' procedure of attached script like other containers +;Note that enabling this option will cause problems for many existing graves +GraveUseProcFix=0 + ;Set to 1 to fix the issue with the division operator treating negative integers as unsigned ;Note: To perform the unsigned integer division, use the new 'div' operator DivisionOperatorFix=1 diff --git a/sfall/FalloutEngine/Functions_def.h b/sfall/FalloutEngine/Functions_def.h index a67ea048..c5948110 100644 --- a/sfall/FalloutEngine/Functions_def.h +++ b/sfall/FalloutEngine/Functions_def.h @@ -102,7 +102,7 @@ WRAP_WATCOM_FUNC0(void, display_stats) WRAP_WATCOM_FUNC1(long, critter_kill_count_type, fo::GameObject*, critter) WRAP_WATCOM_FUNC1(void, EndLoad, fo::DbFile*, file) // Execute script proc by internal proc number (from script's proc table, basically a sequential number of a procedure as defined in code, starting from 1) -WRAP_WATCOM_FUNC2(void, executeProcedure, fo::Program*, sptr, long, procPosition) +WRAP_WATCOM_FUNC2(void, executeProcedure, fo::Program*, sptr, long, procNum) WRAP_WATCOM_FUNC1(long, folder_print_line, const char*, text) WRAP_WATCOM_FUNC1(long, folder_print_seperator, const char*, text) WRAP_WATCOM_FUNC1(const char*, findCurrentProc, fo::Program*, program) // Returns the name of current procedure by program pointer @@ -265,12 +265,12 @@ WRAP_WATCOM_FUNC0(void, tile_refresh_display) // Redraws the whole screen WRAP_WATCOM_FUNC2(void, tile_refresh_rect, fo::BoundRect*, boundRect, long, elevation) // Redraws the given rectangle on screen WRAP_WATCOM_FUNC1(long, trait_level, long, traitID) WRAP_WATCOM_FUNC6(long, win_add, long, x, long, y, long, width, long, height, long, bgColorIndex, long, flags) -WRAP_WATCOM_FUNC1(void, win_show, DWORD, winRef) -WRAP_WATCOM_FUNC1(void, win_hide, DWORD, winRef) -WRAP_WATCOM_FUNC1(BYTE*, win_get_buf, DWORD, winRef) +WRAP_WATCOM_FUNC1(void, win_delete, DWORD, winRef) WRAP_WATCOM_FUNC1(void, win_draw, DWORD, winRef) WRAP_WATCOM_FUNC2(void, win_draw_rect, DWORD, winRef, RECT*, rect) -WRAP_WATCOM_FUNC1(void, win_delete, DWORD, winRef) +WRAP_WATCOM_FUNC1(BYTE*, win_get_buf, DWORD, winRef) +WRAP_WATCOM_FUNC1(void, win_hide, DWORD, winRef) +WRAP_WATCOM_FUNC1(void, win_show, DWORD, winRef) WRAP_WATCOM_FUNC0(long, windowWidth) WRAP_WATCOM_FUNC1(void, wmCarUseGas, long, gasAmount) WRAP_WATCOM_FUNC1(long, wmEvalTileNumForPlacement, long, tile) diff --git a/sfall/Modules/Animations.cpp b/sfall/Modules/Animations.cpp index 1c3cecbc..16a8d9a2 100644 --- a/sfall/Modules/Animations.cpp +++ b/sfall/Modules/Animations.cpp @@ -616,8 +616,12 @@ void Animations::init() { MakeCall(0x419A17, art_alias_fid_hack); // Fix for grave type containers in the open state not executing the use_p_proc procedure - HookCall(0x49CFAC, obj_use_container_hook); - SafeWrite16(0x4122D9, 0x9090); // action_get_an_object_ + if (IniReader::GetConfigInt("Misc", "GraveUseProcFix", 0) != 0) { + dlog("Applying use_p_proc fix for grave type containers.", DL_INIT); + HookCall(0x49CFAC, obj_use_container_hook); + SafeWrite16(0x4122D9, 0x9090); // action_get_an_object_ + dlogr(" Done", DL_INIT); + } } //void Animations::exit() { diff --git a/sfall/Modules/DamageMod.cpp b/sfall/Modules/DamageMod.cpp index 38f9fd1c..50c8fffc 100644 --- a/sfall/Modules/DamageMod.cpp +++ b/sfall/Modules/DamageMod.cpp @@ -59,17 +59,16 @@ void DamageMod::DamageGlovz(fo::ComputeAttackResult &ctd, DWORD &accumulatedDama long ammoY = fo::func::item_w_dam_div(ctd.weapon); // ammoY value (divisor) if (ammoY <= 0) ammoY = 1; - long calcDT = armorDT; - if (armorDT > 0) calcDT = DivRound(armorDT, ammoY); // compare the armorDT value to 0 - long ammoX = fo::func::item_w_dam_mult(ctd.weapon); // ammoX value if (ammoX <= 0) ammoX = 1; long ammoDRM = fo::func::item_w_dr_adjust(ctd.weapon); // ammoDRM value - if (ammoDRM > 0) ammoDRM = -ammoDRM; + if (ammoDRM > 0) ammoDRM = -ammoDRM; // to negative + + long calcDT = (armorDT > 0) ? DivRound(armorDT, ammoY) : armorDT; long calcDR = armorDR; - if (armorDR > 0) { // compare the armorDR value to 0 + if (armorDR > 0) { if (difficulty > 100) { // if the CD value is greater than 100 calcDR -= 20; // subtract 20 from the armorDR value } else if (difficulty < 100) { // if the CD value is less than 100 @@ -77,7 +76,7 @@ void DamageMod::DamageGlovz(fo::ComputeAttackResult &ctd, DWORD &accumulatedDama } calcDR += ammoDRM; // add the ammoDRM value to the armorDR value calcDR = DivRound(calcDR, ammoX); // goto divTwo - if (calcDR >= 100) return; // if armorDR >= 100, stop damage calculation and exit + if (calcDR >= 100) return; // if armorDR >= 100, skip damage calculation } // start of damage calculation loop @@ -143,7 +142,7 @@ void DamageMod::DamageYAAM(fo::ComputeAttackResult &ctd, DWORD &accumulatedDamag if (calcDR < 0) { // Is DR >= 0? calcDR = 0; // If no, set DR = 0 } else if (calcDR >= 100) { // Is DR >= 100? - return; // If yes, damage will be zero, so stop calculating and exit + return; // If yes, damage will be zero, so stop calculating } // Start of damage calculation loop