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:52:01 +08:00
parent 3b836fdf73
commit 9c6d7bfdd2
+16
View File
@@ -491,6 +491,18 @@ static __declspec(naked) void text_object_create_hack() {
}
}
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);
@@ -1023,6 +1035,10 @@ void MiscPatches::init() {
// Remove an old floating message when creating a new one if the maximum number of floating messages has been reached
HookCall(0x4B03A1, text_object_create_hack); // jge hack
// 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
SafeWriteBatch<BYTE>(100, {
0x492120, 0x49212A, // UpdateThing_