Fixed 0 dmg instadeath crits with HOOK_COMBATDAMAGE

This commit is contained in:
NovaRain
2023-12-15 09:17:19 +08:00
parent 96bfe13939
commit dcbe6c9c7e
3 changed files with 8 additions and 4 deletions
+3 -3
View File
@@ -1686,7 +1686,7 @@ end:
}
}
//zero damage insta death criticals fix (moved from compute_damage hook)
// fix for zero damage instadeath criticals (moved from compute_damage hook)
static void __fastcall InstantDeathFix(fo::ComputeAttackResult &ctd) {
if (ctd.targetDamage == 0 && (ctd.targetFlags & fo::DamageFlag::DAM_DEAD)) {
ctd.targetDamage++; // set 1 hp damage
@@ -3649,7 +3649,7 @@ void BugFixes::init() {
0x428AB3 // ai_move_away_ (potential fix)
});
// Fix instant death critical
// Fix instant death critical hits
dlogr("Applying instant death fix.", DL_FIX);
MakeJump(0x424BA2, compute_damage_hack);
@@ -3929,7 +3929,7 @@ void BugFixes::init() {
// Fix the placement of multihex critters in the player's party when entering a map or elevation
MakeCall(0x494E33, partyMemberSyncPosition_hack, 1);
// Fix for critter_add/rm_trait functions ignoring the value of the "amount" argument
// Fix for critter_add/rm_trait functions ignoring the "amount" argument
// Note: pass negative amount values to critter_rm_trait to remove all ranks of the perk (vanilla behavior)
HookCall(0x458CDB, op_critter_rm_trait_hook);
HookCall(0x458B3D, op_critter_add_trait_hook);
+4
View File
@@ -195,6 +195,10 @@ static void __fastcall ComputeDamageHook_Script(fo::ComputeAttackResult &ctd, DW
}
}
}
// prevent hook from setting zero damage for instadeath criticals (bug fix)
if (ctd.targetDamage == 0 && (ctd.targetFlags & fo::DamageFlag::DAM_DEAD)) {
ctd.targetDamage++; // set 1 hp damage
}
}
EndHook();
}
+1 -1
View File
@@ -807,7 +807,7 @@ void LoadGameHook::init() {
0x481028, // main_selfrun_record_
0x481062, // main_selfrun_record_
0x48110B, // main_selfrun_play_
0x481145 // main_selfrun_play_
0x481145 // main_selfrun_play_
});
HookCalls(game_reset_on_load_hook, {
0x47F491, // PrepLoad_ (the very first step during save game loading)