Moved HP/flag setting earlier in critter_kill_ engine function

(mainly for HOOK_ONDEATH, ref. fallout2-ce/fallout2-ce#384)
This commit is contained in:
NovaRain
2026-04-20 09:57:54 +08:00
parent 3dc0f42728
commit 0dd40448c2
+16
View File
@@ -521,6 +521,18 @@ static __declspec(naked) void map_check_state_hook_redraw() {
}
}
static __declspec(naked) void critter_kill_hack() {
using namespace fo;
using namespace Fields;
__asm {
mov eax, [esi + elevation]; // overwritten engine code
// lea edi, [esi + inventory]; // redundant as the original HP/flag code has been removed
mov dword ptr [esi + health], 0; // critter->critter.health = 0
or byte ptr [esi + damageFlags], DAM_DEAD; // critter->critter.damageFlags |= DAM_DEAD
retn;
}
}
static void AdditionalWeaponAnimsPatch() {
//if (IniReader::GetConfigInt("Misc", "AdditionalWeaponAnims", 1)) {
dlogr("Applying additional weapon animations patch.", DL_INIT);
@@ -1068,6 +1080,10 @@ void MiscPatches::init() {
HookCall(0x48A954, obj_move_to_tile_hook_redraw);
HookCall(0x483726, map_check_state_hook_redraw);
// Small code patch for HOOK_ONDEATH (move HP/flag setting code earlier)
MakeCall(0x42DA7E, critter_kill_hack, 1);
BlockCall(0x42DC44, 16); // original code
// Increase the maximum value of the combat speed slider from 50 to 100
const DWORD combatSpeedMaxAddr[] = {
0x492120, 0x49212A, // UpdateThing_