diff --git a/src/game/chr/chraction.c b/src/game/chr/chraction.c index c8b7ef8d8..d0e2f7a18 100644 --- a/src/game/chr/chraction.c +++ b/src/game/chr/chraction.c @@ -1111,7 +1111,7 @@ glabel func0f02ef40 /* f02eff8: 00000000 */ sll $zero,$zero,0x0 ); -void func0f02effc(struct chrdata *chr) +void chrStartAlarm(struct chrdata *chr) { chrStopFiring(chr); chr->actiontype = ACT_STARTALARM; @@ -13869,16 +13869,16 @@ glabel var7f1a8ed4 /* f03b5ec: 27bd02b8 */ addiu $sp,$sp,0x2b8 ); -bool func0f03b5f0(struct chrdata *chr, s32 pad_id) +bool chrTryStartAlarm(struct chrdata *chr, s32 pad_id) { if (CHRRACE(chr) == RACE_HUMAN && chrIsReadyForOrders(chr)) { pad_id = chrResolvePadId(chr, pad_id); if (pad_id >= 0) { - struct defaultobj *obj = func0f0681c0(pad_id); + struct defaultobj *obj = objFindByPadNum(pad_id); if (obj && objIsHealthy(obj)) { - func0f02effc(chr); + chrStartAlarm(chr); return true; } } diff --git a/src/game/chr/chrai.c b/src/game/chr/chrai.c index 067290079..37cb4f6cb 100644 --- a/src/game/chr/chrai.c +++ b/src/game/chr/chrai.c @@ -57,7 +57,7 @@ bool (*g_CommandPointers[])(void) = { /*0x0024*/ aiSurrender, /*0x0025*/ aiFadeOut, /*0x0026*/ aiRemoveChr, - /*0x0027*/ ai0027, + /*0x0027*/ aiTryStartAlarm, /*0x0028*/ aiActivateAlarm, /*0x0029*/ aiDeactivateAlarm, /*0x002a*/ ai002a, diff --git a/src/game/chr/chraicommands.c b/src/game/chr/chraicommands.c index 81a60a2d8..c95d5eca3 100644 --- a/src/game/chr/chraicommands.c +++ b/src/game/chr/chraicommands.c @@ -937,12 +937,12 @@ bool aiRemoveChr(void) /** * @cmd 0027 */ -bool ai0027(void) +bool aiTryStartAlarm(void) { u8 *cmd = g_Vars.ailist + g_Vars.aioffset; u16 pad_id = cmd[3] | (cmd[2] << 8); - if (func0f03b5f0(g_Vars.chrdata, pad_id)) { + if (chrTryStartAlarm(g_Vars.chrdata, pad_id)) { g_Vars.aioffset = chraiGoToLabel(g_Vars.ailist, g_Vars.aioffset, cmd[4]); } else { g_Vars.aioffset += 5; diff --git a/src/game/propobj.c b/src/game/propobj.c index 4b176ac92..fb9ca2195 100644 --- a/src/game/propobj.c +++ b/src/game/propobj.c @@ -2370,34 +2370,24 @@ glabel func0f06803c /* f0681bc: 27bd0058 */ addiu $sp,$sp,0x58 ); -GLOBAL_ASM( -glabel func0f0681c0 -/* f0681c0: 3c02800a */ lui $v0,%hi(g_Vars+0x33c) -/* f0681c4: 8c42a2fc */ lw $v0,%lo(g_Vars+0x33c)($v0) -/* f0681c8: 24050001 */ addiu $a1,$zero,0x1 -/* f0681cc: 50400010 */ beqzl $v0,.L0f068210 -/* f0681d0: 00001025 */ or $v0,$zero,$zero -/* f0681d4: 904e0000 */ lbu $t6,0x0($v0) -.L0f0681d8: -/* f0681d8: 54ae000a */ bnel $a1,$t6,.L0f068204 -/* f0681dc: 8c420020 */ lw $v0,0x20($v0) -/* f0681e0: 8c430004 */ lw $v1,0x4($v0) -/* f0681e4: 00047c00 */ sll $t7,$a0,0x10 -/* f0681e8: 000fc403 */ sra $t8,$t7,0x10 -/* f0681ec: 84790006 */ lh $t9,0x6($v1) -/* f0681f0: 57190004 */ bnel $t8,$t9,.L0f068204 -/* f0681f4: 8c420020 */ lw $v0,0x20($v0) -/* f0681f8: 03e00008 */ jr $ra -/* f0681fc: 00601025 */ or $v0,$v1,$zero -/* f068200: 8c420020 */ lw $v0,0x20($v0) -.L0f068204: -/* f068204: 5440fff4 */ bnezl $v0,.L0f0681d8 -/* f068208: 904e0000 */ lbu $t6,0x0($v0) -/* f06820c: 00001025 */ or $v0,$zero,$zero -.L0f068210: -/* f068210: 03e00008 */ jr $ra -/* f068214: 00000000 */ sll $zero,$zero,0x0 -); +struct defaultobj *objFindByPadNum(s32 padnum) +{ + struct prop *prop = g_Vars.unk00033c; + + while (prop) { + if (prop->type == PROPTYPE_OBJ) { + struct defaultobj *obj = prop->obj; + + if (obj->pad == (s16)padnum) { + return obj; + } + } + + prop = prop->next; + } + + return NULL; +} GLOBAL_ASM( glabel func0f068218 diff --git a/src/include/commands.h b/src/include/commands.h index 193f33082..12e77291b 100644 --- a/src/include/commands.h +++ b/src/include/commands.h @@ -372,7 +372,17 @@ mkshort(0x0026), \ chr, -#define cmd0027(pad, label) \ +/** + * Makes the chr try to run to an alarm switch and activate it. + * + * The pad argument should be the pad that the alarm is at. A check is done to + * make sure the object at that pad is healthy. + * + * Note that no check is done to make sure that the object at the pad is + * actually an alarm switch, and the chr will actually run to their closest + * alarm switch rather than the one at the given pad. + */ +#define try_start_alarm(pad, label) \ mkshort(0x0027), \ mkshort(pad), \ label, @@ -382,8 +392,8 @@ * start. To make guards spawn when the alarm is sounded, an AI list must wait * for the alarm then spawn them. * - * The alarm does not have a timer. You may want to use an AI list to wait for - * them alarm, then wait a certain amount of time before deactivating it. + * Alarms have a 30 second timer, with the exception of G5 Building which is + * 55 seconds. */ #define activate_alarm \ mkshort(0x0028), diff --git a/src/include/game/chr/chraction.h b/src/include/game/chr/chraction.h index 88fb9cdef..86e23f02f 100644 --- a/src/include/game/chr/chraction.h +++ b/src/include/game/chr/chraction.h @@ -210,7 +210,7 @@ void func0f02e9a0(struct chrdata *chr, f32 arg1); void func0f02ed28(struct chrdata *chr, f32 arg1); void chrStop(struct chrdata *chr); void chrKneel(struct chrdata *chr); -void func0f02effc(struct chrdata *chr); +void chrStartAlarm(struct chrdata *chr); void chrThrowGrenade(struct chrdata *chr, s32 arg1, s32 arg2); void chrDoSurprisedSurrender(struct chrdata *chr); void chrDoSurprisedLookAround(struct chrdata *chr); @@ -248,7 +248,7 @@ bool chrTrySurprisedSurrender(struct chrdata *chr); bool chrTrySurprisedLookAround(struct chrdata *chr); bool chrTryKneel(struct chrdata *chr); bool func0f03af44(struct chrdata *chr, u32 anim_id, f32 fstartframe, f32 fendframe, u8 flags, u32 transition, f32 result); -bool func0f03b5f0(struct chrdata *chr, s32 pad_id); +bool chrTryStartAlarm(struct chrdata *chr, s32 pad_id); s32 chrConsiderGrenadeThrow(struct chrdata *chr, u32 entitytype, u32 entityid); void chrTickKneel(struct chrdata *chr); void func0f03ccdc(struct chrdata *chr); diff --git a/src/include/game/chr/chraicommands.h b/src/include/game/chr/chraicommands.h index 9954416ce..8dd6ed6b9 100644 --- a/src/include/game/chr/chraicommands.h +++ b/src/include/game/chr/chraicommands.h @@ -42,7 +42,7 @@ /*0x0024*/ bool aiSurrender(void); /*0x0025*/ bool aiFadeOut(void); /*0x0026*/ bool aiRemoveChr(void); -/*0x0027*/ bool ai0027(void); +/*0x0027*/ bool aiTryStartAlarm(void); /*0x0028*/ bool aiActivateAlarm(void); /*0x0029*/ bool aiDeactivateAlarm(void); /*0x002a*/ bool ai002a(void); diff --git a/src/include/game/propobj.h b/src/include/game/propobj.h index 83612bfac..0f438b8ad 100644 --- a/src/include/game/propobj.h +++ b/src/include/game/propobj.h @@ -51,7 +51,7 @@ u32 func0f067d88(void); u32 func0f067dc4(void); void func0f068018(struct animdata *animdata, f32 *arg1, f32 *arg2, f32 *arg3, f32 *arg4); u32 func0f06803c(void); -struct defaultobj *func0f0681c0(s32 pad_id); +struct defaultobj *objFindByPadNum(s32 padnum); u32 func0f068218(void); u32 func0f0682dc(void); u32 func0f0682fc(void);