diff --git a/artifacts/ddraw.ini b/artifacts/ddraw.ini index 24582bb7..05aea999 100644 --- a/artifacts/ddraw.ini +++ b/artifacts/ddraw.ini @@ -688,6 +688,7 @@ NumbersInDialogue=0 WorldMapFontPatch=0 ;Set to 1 to use Fallout's normal text font for death screen subtitles +;Requires changing the color of subtitles in death.pal palette (color index 220) to display the text correctly DeathScreenFontPatch=0 ;Set to 1 to display full item description for weapon/ammo in the barter screen diff --git a/sfall/BugFixes.cpp b/sfall/BugFixes.cpp index cd66abce..5ad3bb6e 100644 --- a/sfall/BugFixes.cpp +++ b/sfall/BugFixes.cpp @@ -1155,21 +1155,6 @@ static void __declspec(naked) action_explode_hack1() { } } -static void __declspec(naked) barter_attempt_transaction_hack() { - __asm { - cmp dword ptr [eax + protoId], PID_ACTIVE_GEIGER_COUNTER - je found - cmp dword ptr [eax + protoId], PID_ACTIVE_STEALTH_BOY - je found - mov eax, 0x474D34 - jmp eax -found: - call item_m_turn_off_ - mov eax, 0x474D17 - jmp eax // Is there any other activated items among the ones being sold? - } -} - static void __declspec(naked) barter_attempt_transaction_hook_weight() { __asm { call item_total_weight_; @@ -1181,10 +1166,25 @@ skip: } } +static void __declspec(naked) barter_attempt_transaction_hack() { + __asm { + mov edx, [eax + protoId]; + cmp edx, PID_ACTIVE_GEIGER_COUNTER; + je found; + cmp edx, PID_ACTIVE_STEALTH_BOY; + je found; + mov eax, 0x474D34; // Can't sell + jmp eax; +found: + push 0x474D17; // Is there any other activated items among the ones being sold? + jmp item_m_turn_off_; + } +} + static void __declspec(naked) item_m_turn_off_hook() { __asm { - and byte ptr [eax+0x25], 0xDF // Rest flag of used items - jmp queue_remove_this_ + and byte ptr [eax + 0x25], ~0x20; // Unset flag of used items + jmp queue_remove_this_; } } @@ -3075,9 +3075,9 @@ void BugFixesInit() // Fix for being unable to sell used geiger counters or stealth boys if (GetConfigInt("Misc", "CanSellUsedGeiger", 1)) { dlog("Applying fix for being unable to sell used geiger counters or stealth boys.", DL_INIT); - const DWORD itemQueuedAddr[] = {0x478115, 0x478138}; - SafeWriteBatch(0xBA, itemQueuedAddr); // mov eax, 1 > mov edx, 1 - MakeJump(0x474D22, barter_attempt_transaction_hack); + const DWORD itemQueuedAddr[] = {0x478115, 0x478138}; // item_queued_ (will return the found item) + SafeWriteBatch(0xBA, itemQueuedAddr); + MakeJump(0x474D22, barter_attempt_transaction_hack, 1); HookCall(0x4798B1, item_m_turn_off_hook); dlogr(" Done", DL_INIT); } diff --git a/sfall/DamageMod.cpp b/sfall/DamageMod.cpp index 3dc91573..a97fdd83 100644 --- a/sfall/DamageMod.cpp +++ b/sfall/DamageMod.cpp @@ -325,26 +325,26 @@ end: } //////////////////////////////////////////////////////////////////////////////// +// Display melee damage w/o perk bonus static __declspec(naked) void MeleeDmgDisplayPrintFix_hook() { __asm { + mov ecx, eax; // Store pointer to critter call stat_level_; // Get Melee Damage - mov ecx, eax; // Store value + xchg ecx, eax; // Store Melee Damage value mov edx, PERK_bonus_hth_damage; // perk_level_ argument: PERK_bonus_hth_damage - mov eax, dword ptr ds:[_obj_dude]; // Get pointer to PC call perk_level_; // Get rank of Bonus HtH Damage shl eax, 1; // Multiply by 2 - push eax; + sub ecx, eax; // Subtract from Melee Damage mov edx, STAT_melee_dmg; - mov eax, dword ptr ds:[_obj_dude]; - call stat_get_base_; - pop edx; - sub ecx, edx; // Subtract from Melee Damage - cmp ecx, eax; + mov eax, ds:[_obj_dude]; // Get pointer to PC + call stat_get_base_; // Get Melee Damage w/o bonuses + cmp ecx, eax; // HtH Damage vs Base Melee Damage cmovg eax, ecx; // Move back to eax in preparation of push retn; } } +// Display max melee damage w/o perk bonus static __declspec(naked) void CommonDmgRngDispFix_hook() { __asm { mov ebx, eax; // Store pointer to critter @@ -353,13 +353,11 @@ static __declspec(naked) void CommonDmgRngDispFix_hook() { mov edx, PERK_bonus_hth_damage; // perk_level_ argument: PERK_bonus_hth_damage call perk_level_; // Get rank of Bonus HtH Damage shl eax, 1; // Multiply by 2 - push eax; + sub ebx, eax; // Subtract from Melee Damage mov edx, STAT_melee_dmg; - mov eax, dword ptr ds:[_obj_dude]; - call stat_get_base_; - pop edx; - sub ebx, edx; // Subtract from Melee Damage - cmp ebx, eax; + mov eax, ds:[_stack]; + call stat_get_base_; // Get Melee Damage w/o bonuses + cmp ebx, eax; // HtH Damage vs Base Melee Damage cmovg eax, ebx; // Move back to eax in preparation of push retn; } @@ -367,16 +365,16 @@ static __declspec(naked) void CommonDmgRngDispFix_hook() { static __declspec(naked) void HtHDamageFix1a_hack() { __asm { - xor edx, edx; cmp ecx, dword ptr ds:[_obj_dude]; // Is the critter == PC? - jnz skip; // Skip if no + je fix; // Skip if no + mov edx, 1; // Min_Damage = 1 + retn; +fix: mov edx, PERK_bonus_hth_damage; // perk_level_ argument: PERK_bonus_hth_damage mov eax, ecx; // pointer to PC call perk_level_; // Return Rank_of_Bonus_HtH_Damage_perk shl eax, 1; // Rank_of_Bonus_HtH_Damage_perk *= 2 - mov edx, eax; // Min_Damage = Rank_of_Bonus_HtH_Damage_perk -skip: - add edx, 1; // Min_Damage += 1 + lea edx, [eax + 1]; // Min_Damage = 1 + Rank_of_Bonus_HtH_Damage_perk retn; } } @@ -385,7 +383,9 @@ static __declspec(naked) void HtHDamageFix1b_hook() { __asm { call stat_level_; // Get Total_Melee_Damage cmp ecx, dword ptr ds:[_obj_dude]; // Is the critter == PC? - jnz end; // Skip to exit if no + je fix; // Skip to exit if no + retn; +fix: push eax; mov edx, PERK_bonus_hth_damage; // perk_level_ argument: PERK_bonus_hth_damage mov eax, ecx; // pointer to PC @@ -393,7 +393,6 @@ static __declspec(naked) void HtHDamageFix1b_hook() { shl eax, 1; // Rank_of_Bonus_HtH_Damage_perk *= 2 add dword ptr [esp + 0x24 - 0x20 + 8], eax; // Min_Damage += Rank_of_Bonus_HtH_Damage_perk pop eax; -end: retn; } } @@ -403,7 +402,7 @@ static void __declspec(naked) DisplayBonusRangedDmg_hook() { mov edx, PERK_bonus_ranged_damage; mov eax, dword ptr ds:[_stack]; call perk_level_; - shl eax, 1; + shl eax, 1; // Multiply by 2 add dword ptr [esp + 4 * 4], eax; // min_dmg + perk bonus add dword ptr [esp + 4 * 5], eax; // max_dmg + perk bonus jmp sprintf_; @@ -415,14 +414,14 @@ static void __declspec(naked) DisplayBonusHtHDmg1_hook() { mov edx, PERK_bonus_hth_damage; mov eax, dword ptr ds:[_stack]; call perk_level_; - shl eax, 1; + shl eax, 1; // Multiply by 2 add dword ptr [esp + 4 * 4], eax; // min_dmg + perk bonus jmp sprintf_; } } static void __declspec(naked) DisplayBonusHtHDmg2_hack() { - static const DWORD DisplayBonusHtHDmg2Exit = 0x472569; + static const DWORD DisplayBonusHtHDmg2Exit = 0x47254E; __asm { mov ecx, eax; call stat_level_; @@ -431,16 +430,8 @@ static void __declspec(naked) DisplayBonusHtHDmg2_hack() { mov edx, PERK_bonus_hth_damage; mov eax, ecx; call perk_level_; - shl eax, 1; - add eax, 1; - push eax; // min dmg + bonus - mov ecx, dword ptr [esp + 0x98 + 0x4]; - push ecx; // message - push 0x509EDC; // '%s %d-%d' - lea eax, [esp + 0x0C + 0x4]; - push eax; // buf - call sprintf_; - add esp, 0x10 + 0x4; + shl eax, 1; // Multiply by 2 + inc eax; // min dmg (1 + bonus) jmp DisplayBonusHtHDmg2Exit; } } @@ -462,7 +453,7 @@ void DamageModInit() { int DisplayBonusDmg = GetConfigInt("Misc", "DisplayBonusDamage", 0); if (BonusHtHDmgFix) { dlog("Applying Bonus HtH Damage Perk fix.", DL_INIT); - if (!DisplayBonusDmg) { // Subtract damage from perk bonus (vanilla displaying) + if (DisplayBonusDmg == 0) { // Subtract damage from perk bonus (vanilla displaying) const DWORD meleeDmgDispPrtAddr[] = { 0x435C0C, // DisplayFix (ListDrvdStats_) 0x439921 // PrintFix (Save_as_ASCII_) @@ -485,6 +476,10 @@ void DamageModInit() { if (BonusHtHDmgFix) { HookCall(0x472309, DisplayBonusHtHDmg1_hook); // display_stats_ MakeJump(0x472546, DisplayBonusHtHDmg2_hack); // display_stats_ + SafeWrite32(0x472558, 0x509EDC); // fmt: '%s %d-%d' + SafeWrite8(0x472552, 0x98 + 4); + SafeWrite8(0x47255F, 0x0C + 4); + SafeWrite8(0x472568, 0x10 + 4); } dlogr(" Done", DL_INIT); } diff --git a/sfall/Interface.cpp b/sfall/Interface.cpp index a38f6f17..fb03cb83 100644 --- a/sfall/Interface.cpp +++ b/sfall/Interface.cpp @@ -359,6 +359,14 @@ static void __declspec(naked) wmInterfaceRefreshCarFuel_hack() { } } +static void __declspec(naked) main_death_scene_hook() { + __asm { + mov eax, 101; + call text_font_; + jmp debug_printf_; + } +} + static void WorldMapInterfacePatch() { if (GetConfigInt("Misc", "WorldMapFontPatch", 0)) { dlog("Applying world map font patch.", DL_INIT); @@ -520,6 +528,18 @@ void InterfaceInit() { // ScriptWindow - prevents the player from moving when clicking on the window if the 'Transparent' flag is not set HookCall(0x44B737, gmouse_bk_process_hook); // InterfaceGmouseHandleHook will be run before game initialization + + // Set the normal font for death screen subtitles + if (GetConfigInt("Misc", "DeathScreenFontPatch", 0)) { + dlog("Applying death screen font patch.", DL_INIT); + HookCall(0x4812DF, main_death_scene_hook); + dlogr(" Done", DL_INIT); + } + + // Corrects the height of the black background for death screen subtitles + if (hrpIsEnabled == false) SafeWrite32(0x48134D, -602 - (640 * 2)); // main_death_scene_ (shift y-offset 2px up, w/o HRP) + if (hrpIsEnabled == false || hrpVersionValid) SafeWrite8(0x481345, 4); // main_death_scene_ + if (hrpVersionValid) SafeWrite8(HRPAddress(0x10011738), 10); } void InterfaceExit() { diff --git a/sfall/MiscPatches.cpp b/sfall/MiscPatches.cpp index 1bcdf554..371c5160 100644 --- a/sfall/MiscPatches.cpp +++ b/sfall/MiscPatches.cpp @@ -278,14 +278,6 @@ static void __declspec(naked) map_check_state_hook() { } } -static void __declspec(naked) main_death_scene_hook() { - __asm { - mov eax, 101; - call text_font_; - jmp debug_printf_; - } -} - static void AdditionalWeaponAnimsPatch() { if (GetConfigInt("Misc", "AdditionalWeaponAnims", 0)) { dlog("Applying additional weapon animations patch.", DL_INIT); @@ -701,17 +693,6 @@ void MiscPatchesInit() { HookCall(0x48A954, obj_move_to_tile_hook); HookCall(0x483726, map_check_state_hook); - // Set the normal font for death screen subtitles - if (GetConfigInt("Misc", "DeathScreenFontPatch", 0)) { - dlog("Applying death screen font patch.", DL_INIT); - HookCall(0x4812DF, main_death_scene_hook); - dlogr(" Done", DL_INIT); - } - // Corrects the height of the black background for death screen subtitles - if (hrpIsEnabled == false) SafeWrite32(0x48134D, -602 - (640 * 2)); // main_death_scene_ (shift y-offset 2px up, w/o HRP) - if (hrpIsEnabled == false || hrpVersionValid) SafeWrite8(0x481345, 4); // main_death_scene_ - if (hrpVersionValid) SafeWrite8(HRPAddress(0x10011738), 10); - F1EngineBehaviorPatch(); DialogueFix(); AdditionalWeaponAnimsPatch();