From 0bd58592c443fc707d79ddc361ea5a0fdb6680f7 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sun, 23 Oct 2022 22:45:06 +1000 Subject: [PATCH] Change chr AI timers to integers --- src/game/chraction.c | 4 ++-- src/game/chraicommands.c | 25 +++++++------------------ src/game/propobj.c | 4 ++-- src/include/game/chraction.h | 2 +- src/include/game/propobj.h | 2 +- 5 files changed, 13 insertions(+), 24 deletions(-) diff --git a/src/game/chraction.c b/src/game/chraction.c index dbcacde30..c5afea923 100644 --- a/src/game/chraction.c +++ b/src/game/chraction.c @@ -14419,9 +14419,9 @@ void chrRestartTimer(struct chrdata *chr) chr->hidden |= CHRHFLAG_TIMER_RUNNING; } -f32 chrGetTimer(struct chrdata *chr) +s32 chrGetTimer(struct chrdata *chr) { - return chr->timer60 * FRAMEDURATION; + return chr->timer60; } bool chrCanSeeTargetWithExtraCheck(struct chrdata *chr) diff --git a/src/game/chraicommands.c b/src/game/chraicommands.c index ab014cf54..a705fc21d 100644 --- a/src/game/chraicommands.c +++ b/src/game/chraicommands.c @@ -3669,9 +3669,7 @@ u8 *aiIfTimerStopped(u8 *cmd) */ u8 *aiIfTimerGreaterThanRandom(u8 *cmd) { - f32 timer = chrGetTimer(g_Vars.chrdata); - - if (g_Vars.chrdata->random < timer) { + if (g_Vars.chrdata->random < g_Vars.chrdata->timer60 * 60) { cmd = AILABEL(g_Vars.ailist, cmd[2], cmd[3]); } else { cmd += 4; @@ -3685,10 +3683,10 @@ u8 *aiIfTimerGreaterThanRandom(u8 *cmd) */ u8 *aiIfTimerLessThan(u8 *cmd) { - f32 value = (u32)((cmd[3] << 8) | cmd[4] | (cmd[2] << 16)) / 60.0f; + s32 value = (cmd[3] << 8) | cmd[4] | (cmd[2] << 16); - if ((g_Vars.chrdata && chrGetTimer(g_Vars.chrdata) < value) || - (g_Vars.hovercar && chopperGetTimer(g_Vars.hovercar) < value)) { + if ((g_Vars.chrdata && g_Vars.chrdata->timer60 < value) + || (g_Vars.hovercar && chopperGetTimer(g_Vars.hovercar) < value)) { cmd = AILABEL(g_Vars.ailist, cmd[5], cmd[6]); } else { cmd += 7; @@ -3702,19 +3700,10 @@ u8 *aiIfTimerLessThan(u8 *cmd) */ u8 *aiIfTimerGreaterThan(u8 *cmd) { - f32 value = (u32)((cmd[3] << 8) | cmd[4] | (cmd[2] << 16)) / 60.0f; + s32 value = (cmd[3] << 8) | cmd[4] | (cmd[2] << 16); - // These two function calls were likely used in a debug print statement - if (g_Vars.chrdata) { - chrGetTimer(g_Vars.chrdata); - } - - if (g_Vars.hovercar) { - chopperGetTimer(g_Vars.hovercar); - } - - if ((g_Vars.chrdata && chrGetTimer(g_Vars.chrdata) > value) || - (g_Vars.hovercar && chopperGetTimer(g_Vars.hovercar) > value)) { + if ((g_Vars.chrdata && g_Vars.chrdata->timer60 > value) + || (g_Vars.hovercar && chopperGetTimer(g_Vars.hovercar) > value)) { cmd = AILABEL(g_Vars.ailist, cmd[5], cmd[6]); } else { cmd += 7; diff --git a/src/game/propobj.c b/src/game/propobj.c index 1ff58804a..d23db713e 100644 --- a/src/game/propobj.c +++ b/src/game/propobj.c @@ -10374,11 +10374,11 @@ void chopperRestartTimer(struct chopperobj *obj) } } -f32 chopperGetTimer(struct chopperobj *obj) +s32 chopperGetTimer(struct chopperobj *obj) { struct chopperobj *chopper = chopperFromHovercar(obj); - return chopper->timer60 * FRAMEDURATION; + return chopper->timer60; } void chopperSetMaxDamage(struct chopperobj *chopper, u16 health) diff --git a/src/include/game/chraction.h b/src/include/game/chraction.h index 76a395d1c..74d83b1ad 100644 --- a/src/include/game/chraction.h +++ b/src/include/game/chraction.h @@ -192,7 +192,7 @@ bool chrIsLookingAtPos(struct chrdata *chr, struct coord *pos, u8 arg2); f32 chrGetSameFloorDistanceToPad(struct chrdata *chr, s32 pad_id); void chrsClearRefsToPlayer(s32 playernum); s32 chrResolveId(struct chrdata *ref, s32 id); -f32 chrGetTimer(struct chrdata *chr); +s32 chrGetTimer(struct chrdata *chr); bool chrCanSeeTargetWithExtraCheck(struct chrdata *chr); bool chrSawInjury(struct chrdata *chr, u8 arg1); bool chrSawDeath(struct chrdata *chr, u8 arg1); diff --git a/src/include/game/propobj.h b/src/include/game/propobj.h index b53064d30..5449ac929 100644 --- a/src/include/game/propobj.h +++ b/src/include/game/propobj.h @@ -180,7 +180,7 @@ bool chopperAttack(struct chopperobj *obj); bool chopperStop(struct chopperobj *obj); bool chopperSetArmed(struct chopperobj *obj, bool armed); void chopperRestartTimer(struct chopperobj *obj); -f32 chopperGetTimer(struct chopperobj *heli); +s32 chopperGetTimer(struct chopperobj *heli); void chopperSetMaxDamage(struct chopperobj *obj, u16 health); f32 func0f07b164(struct coord *pos1, struct coord *pos2, struct coord *pos3, struct coord *result); void chopperFireRocket(struct chopperobj *chopper, bool side);