Change chr AI timers to integers

This commit is contained in:
Ryan Dwyer 2022-10-23 22:45:06 +10:00
parent 04ca114465
commit 0bd58592c4
5 changed files with 13 additions and 24 deletions

View File

@ -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)

View File

@ -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;

View File

@ -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)

View File

@ -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);

View File

@ -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);