Added a fix to limit the maximum distance for knockback animation

* 20 hexes at max. This does not affect the knockback value in
Combat Damage hook, only the animation part.
This commit is contained in:
NovaRain
2020-08-18 13:07:25 +08:00
parent c657a9ef86
commit e6d30d7def
2 changed files with 16 additions and 4 deletions
+13 -1
View File
@@ -2795,7 +2795,6 @@ isDeath:
static void __declspec(naked) obj_move_to_tile_hack_ondeath() {
static const DWORD obj_move_to_tile_Ret = 0x48A759;
__asm {
test esi, esi;
jz skip;
cmp dudeIsAnimDeath, 0;
jnz skip;
@@ -2806,6 +2805,16 @@ skip:
}
}
static void __declspec(naked) action_knockback_hack() {
__asm {
mov ecx, 20; // cap knockback distance
cmp ebp, ecx;
cmovg ebp, ecx;
mov ecx, 1;
retn;
}
}
void BugFixes::init()
{
#ifndef NDEBUG
@@ -3538,6 +3547,9 @@ void BugFixes::init()
// (e.g. fire dance or knockback animation)
MakeCall(0x41094B, show_damage_to_object_hack, 1);
MakeCall(0x48A6CB, obj_move_to_tile_hack_ondeath, 1);
// Fix to limit the maximum distance for knockback animation
MakeCall(0x4104D5, action_knockback_hack);
}
}
+3 -3
View File
@@ -666,7 +666,7 @@ static DWORD HandleTimedEventScripts() {
fo::func::dev_printf("\n[TimedEventScripts] Event: %d", it->time);
}
bool eventsWereRunning = false;
bool eventWasRunning = false;
for (auto timerIt = timerEventScripts.cbegin(); timerIt != timerEventScripts.cend(); ++timerIt) {
if (timerIt->isActive == false) continue;
if (currentTime >= timerIt->time) {
@@ -684,14 +684,14 @@ static DWORD HandleTimedEventScripts() {
timedEvent = executeTimedEvents.top(); // restore a pointer to a previously running event
executeTimedEvents.pop();
}
eventsWereRunning = true;
eventWasRunning = true;
} else {
break;
}
}
executeTimedEventDepth--;
if (eventsWereRunning && executeTimedEventDepth == 0) {
if (eventWasRunning && executeTimedEventDepth == 0) {
timedEvent = nullptr;
// delete all previously executed events
for (auto it = timerEventScripts.cbegin(); it != timerEventScripts.cend();) {