Fixed a bug that critters killed in combat by scripting still being able to move in their combat turn if the distance parameter in their AI packages is set to stay_close/charge, or NPCsTryToSpendExtraAP is enabled (from Mr.Stalin)

This commit is contained in:
NovaRain
2018-06-02 18:15:53 +08:00
parent 051b1c98aa
commit 1652072391
+16
View File
@@ -1109,6 +1109,18 @@ map_leave:
}
}
static void __declspec(naked) ai_move_steps_closer_hook() {
__asm {
call fo::funcoffs::combat_turn_run_;
movzx dx, word ptr [esi + 0x44]; // combat_data.results
test dx, DAM_DEAD or DAM_KNOCKED_OUT or DAM_LOSE_TURN;
jz end;
mov [esi + 0x40], 0; // pobj.curr_mp (source reset ap)
end:
retn;
}
}
void BugFixes::init()
{
@@ -1420,6 +1432,10 @@ void BugFixes::init()
// Fix for being at incorrect hex after map change when the exit hex in source map is at the same position as
// some exit hex in destination map
MakeCall(0x48A704, obj_move_to_tile_hack);
// Fix for critters killed in combat by scripting still being able to move in their combat turn if the distance parameter
// in their AI packages is set to stay_close/charge, or NPCsTryToSpendExtraAP is enabled
HookCall(0x42A1A8, ai_move_steps_closer_hook); // 0x42B24D
}
}