From 402d8cfb7e6bab341ab628b5468ba91ca7242508 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Fri, 17 Jan 2020 22:30:39 +1000 Subject: [PATCH] Decompile chrDetectDangerousObject --- src/game/chr/chr.c | 158 ++++++++------------------- src/game/chr/chraicommands.c | 4 +- src/game/game_00b820.c | 4 +- src/gvars/gvars.c | 13 +-- src/include/commands.h | 20 +++- src/include/constants.h | 1 + src/include/game/chr/chr.h | 2 +- src/include/game/chr/chraicommands.h | 2 +- src/include/gvars/gvars.h | 2 +- src/include/types.h | 2 +- src/setup/ailists.c | 48 ++++---- src/setup/setup_000000.c | 2 +- 12 files changed, 97 insertions(+), 161 deletions(-) diff --git a/src/game/chr/chr.c b/src/game/chr/chr.c index 319bdf31e..339c76147 100644 --- a/src/game/chr/chr.c +++ b/src/game/chr/chr.c @@ -42263,8 +42263,8 @@ glabel func0f0433e0 GLOBAL_ASM( glabel func0f043944 -/* f043944: 3c05800a */ lui $a1,%hi(var8009cc00) -/* f043948: 24a5cc00 */ addiu $a1,$a1,%lo(var8009cc00) +/* f043944: 3c05800a */ lui $a1,%hi(g_DangerousProps) +/* f043948: 24a5cc00 */ addiu $a1,$a1,%lo(g_DangerousProps) /* f04394c: 00001025 */ or $v0,$zero,$zero .L0f043950: /* f043950: 00027080 */ sll $t6,$v0,0x2 @@ -42286,10 +42286,10 @@ glabel func0f043944 GLOBAL_ASM( glabel func0f043988 -/* f043988: 3c03800a */ lui $v1,%hi(var8009cc00) +/* f043988: 3c03800a */ lui $v1,%hi(g_DangerousProps) /* f04398c: 3c02800a */ lui $v0,%hi(var8009cc30) /* f043990: 2442cc30 */ addiu $v0,$v0,%lo(var8009cc30) -/* f043994: 2463cc00 */ addiu $v1,$v1,%lo(var8009cc00) +/* f043994: 2463cc00 */ addiu $v1,$v1,%lo(g_DangerousProps) /* f043998: 8c6e0000 */ lw $t6,0x0($v1) .L0f04399c: /* f04399c: 548e0004 */ bnel $a0,$t6,.L0f0439b0 @@ -42306,10 +42306,10 @@ glabel func0f043988 GLOBAL_ASM( glabel func0f0439c0 -/* f0439c0: 3c03800a */ lui $v1,%hi(var8009cc00) +/* f0439c0: 3c03800a */ lui $v1,%hi(g_DangerousProps) /* f0439c4: 3c02800a */ lui $v0,%hi(var8009cc30) /* f0439c8: 2442cc30 */ addiu $v0,$v0,%lo(var8009cc30) -/* f0439cc: 2463cc00 */ addiu $v1,$v1,%lo(var8009cc00) +/* f0439cc: 2463cc00 */ addiu $v1,$v1,%lo(g_DangerousProps) /* f0439d0: 8c6e0000 */ lw $t6,0x0($v1) .L0f0439d4: /* f0439d4: 55c00004 */ bnezl $t6,.L0f0439e8 @@ -42586,111 +42586,47 @@ glabel func0f0439f8 /* f043da4: 00000000 */ sll $zero,$zero,0x0 ); -GLOBAL_ASM( -glabel func0f043da8 -/* f043da8: 27bdffc0 */ addiu $sp,$sp,-64 -/* f043dac: afb00020 */ sw $s0,0x20($sp) -/* f043db0: f7b40018 */ sdc1 $f20,0x18($sp) -/* f043db4: 3c0144c8 */ lui $at,0x44c8 -/* f043db8: afb60038 */ sw $s6,0x38($sp) -/* f043dbc: afb50034 */ sw $s5,0x34($sp) -/* f043dc0: afb40030 */ sw $s4,0x30($sp) -/* f043dc4: afb3002c */ sw $s3,0x2c($sp) -/* f043dc8: afb20028 */ sw $s2,0x28($sp) -/* f043dcc: afb10024 */ sw $s1,0x24($sp) -/* f043dd0: 3c10800a */ lui $s0,%hi(var8009cc00) -/* f043dd4: 4481a000 */ mtc1 $at,$f20 -/* f043dd8: 00809025 */ or $s2,$a0,$zero -/* f043ddc: 30b600ff */ andi $s6,$a1,0xff -/* f043de0: afbf003c */ sw $ra,0x3c($sp) -/* f043de4: afa50044 */ sw $a1,0x44($sp) -/* f043de8: 2610cc00 */ addiu $s0,$s0,%lo(var8009cc00) -/* f043dec: 00008825 */ or $s1,$zero,$zero -/* f043df0: 2413001e */ addiu $s3,$zero,0x1e -/* f043df4: 24140007 */ addiu $s4,$zero,0x7 -/* f043df8: 2415000c */ addiu $s5,$zero,0xc -.L0f043dfc: -/* f043dfc: 8e030000 */ lw $v1,0x0($s0) -/* f043e00: 00002025 */ or $a0,$zero,$zero -/* f043e04: 32ce0001 */ andi $t6,$s6,0x1 -/* f043e08: 5060002f */ beqzl $v1,.L0f043ec8 -/* f043e0c: 26310001 */ addiu $s1,$s1,0x1 -/* f043e10: 11c0000c */ beqz $t6,.L0f043e44 -/* f043e14: 32c50002 */ andi $a1,$s6,0x2 -/* f043e18: 8c620004 */ lw $v0,0x4($v1) -/* f043e1c: 10400009 */ beqz $v0,.L0f043e44 -/* f043e20: 00000000 */ sll $zero,$zero,0x0 -/* f043e24: 904f005c */ lbu $t7,0x5c($v0) -/* f043e28: 166f0006 */ bne $s3,$t7,.L0f043e44 -/* f043e2c: 00000000 */ sll $zero,$zero,0x0 -/* f043e30: 84580062 */ lh $t8,0x62($v0) -/* f043e34: 2b0101e0 */ slti $at,$t8,0x1e0 -/* f043e38: 10200002 */ beqz $at,.L0f043e44 -/* f043e3c: 00000000 */ sll $zero,$zero,0x0 -/* f043e40: 24040001 */ addiu $a0,$zero,0x1 -.L0f043e44: -/* f043e44: 10a00005 */ beqz $a1,.L0f043e5c -/* f043e48: 00000000 */ sll $zero,$zero,0x0 -/* f043e4c: 90790000 */ lbu $t9,0x0($v1) -/* f043e50: 16990002 */ bne $s4,$t9,.L0f043e5c -/* f043e54: 00000000 */ sll $zero,$zero,0x0 -/* f043e58: 24040001 */ addiu $a0,$zero,0x1 -.L0f043e5c: -/* f043e5c: 10800019 */ beqz $a0,.L0f043ec4 -/* f043e60: 24650008 */ addiu $a1,$v1,0x8 -/* f043e64: 0fc12555 */ jal chrGetSquaredDistanceToCoord -/* f043e68: 02402025 */ or $a0,$s2,$zero -/* f043e6c: 4614003c */ c.lt.s $f0,$f20 -/* f043e70: 00000000 */ sll $zero,$zero,0x0 -/* f043e74: 45020014 */ bc1fl .L0f043ec8 -/* f043e78: 26310001 */ addiu $s1,$s1,0x1 -/* f043e7c: 8e080000 */ lw $t0,0x0($s0) -/* f043e80: 8e4202d4 */ lw $v0,0x2d4($s2) -/* f043e84: c5040008 */ lwc1 $f4,0x8($t0) -/* f043e88: e64402c8 */ swc1 $f4,0x2c8($s2) -/* f043e8c: 8e090000 */ lw $t1,0x0($s0) -/* f043e90: c526000c */ lwc1 $f6,0xc($t1) -/* f043e94: e64602cc */ swc1 $f6,0x2cc($s2) -/* f043e98: 8e0a0000 */ lw $t2,0x0($s0) -/* f043e9c: c5480010 */ lwc1 $f8,0x10($t2) -/* f043ea0: 10400006 */ beqz $v0,.L0f043ebc -/* f043ea4: e64802d0 */ swc1 $f8,0x2d0($s2) -/* f043ea8: 944b0064 */ lhu $t3,0x64($v0) -/* f043eac: 356c0004 */ ori $t4,$t3,0x4 -/* f043eb0: a44c0064 */ sh $t4,0x64($v0) -/* f043eb4: 8e4d02d4 */ lw $t5,0x2d4($s2) -/* f043eb8: a5b1000c */ sh $s1,0xc($t5) -.L0f043ebc: -/* f043ebc: 1000000e */ beqz $zero,.L0f043ef8 -/* f043ec0: 24020001 */ addiu $v0,$zero,0x1 -.L0f043ec4: -/* f043ec4: 26310001 */ addiu $s1,$s1,0x1 -.L0f043ec8: -/* f043ec8: 1635ffcc */ bne $s1,$s5,.L0f043dfc -/* f043ecc: 26100004 */ addiu $s0,$s0,0x4 -/* f043ed0: 8e4202d4 */ lw $v0,0x2d4($s2) -/* f043ed4: 50400008 */ beqzl $v0,.L0f043ef8 -/* f043ed8: 00001025 */ or $v0,$zero,$zero -/* f043edc: 944e0064 */ lhu $t6,0x64($v0) -/* f043ee0: 2418ffff */ addiu $t8,$zero,-1 -/* f043ee4: 31cffffb */ andi $t7,$t6,0xfffb -/* f043ee8: a44f0064 */ sh $t7,0x64($v0) -/* f043eec: 8e5902d4 */ lw $t9,0x2d4($s2) -/* f043ef0: a738000c */ sh $t8,0xc($t9) -/* f043ef4: 00001025 */ or $v0,$zero,$zero -.L0f043ef8: -/* f043ef8: 8fbf003c */ lw $ra,0x3c($sp) -/* f043efc: d7b40018 */ ldc1 $f20,0x18($sp) -/* f043f00: 8fb00020 */ lw $s0,0x20($sp) -/* f043f04: 8fb10024 */ lw $s1,0x24($sp) -/* f043f08: 8fb20028 */ lw $s2,0x28($sp) -/* f043f0c: 8fb3002c */ lw $s3,0x2c($sp) -/* f043f10: 8fb40030 */ lw $s4,0x30($sp) -/* f043f14: 8fb50034 */ lw $s5,0x34($sp) -/* f043f18: 8fb60038 */ lw $s6,0x38($sp) -/* f043f1c: 03e00008 */ jr $ra -/* f043f20: 27bd0040 */ addiu $sp,$sp,0x40 -); +bool chrDetectDangerousObject(struct chrdata *chr, u8 flags) +{ + s32 i; + + for (i = 0; i != 12; i++) { + struct prop *prop = g_DangerousProps[i]; + bool pass = false; + + if (prop) { + if ((flags & 1) && prop->weapon && + prop->weapon->weapon_id == WEAPON_GRENADE && + prop->weapon->team < 480) { + pass = true; + } + + if ((flags & 2) && prop->type == PROPTYPE_7) { + pass = true; + } + + if (pass && chrGetSquaredDistanceToCoord(chr, &prop->pos) < 1600) { + chr->runfrompos.x = g_DangerousProps[i]->pos.x; + chr->runfrompos.y = g_DangerousProps[i]->pos.y; + chr->runfrompos.z = g_DangerousProps[i]->pos.z; + + if (chr->unk2d4) { + chr->unk2d4->unk064 |= 0x0004; + chr->unk2d4->unk00c = i; + } + + return true; + } + } + } + + if (chr->unk2d4) { + chr->unk2d4->unk064 &= ~0x0004; + chr->unk2d4->unk00c = -1; + } + + return false; +} void func0f043f24(s32 arg0) { diff --git a/src/game/chr/chraicommands.c b/src/game/chr/chraicommands.c index ce43b7a82..3cd4d6c04 100644 --- a/src/game/chr/chraicommands.c +++ b/src/game/chr/chraicommands.c @@ -10789,11 +10789,11 @@ bool ai013c(void) /** * @cmd 013d */ -bool ai013d(void) +bool aiIfDangerousObjectNearby(void) { u8 *cmd = g_Vars.ailist + g_Vars.aioffset; - if (func0f043da8(g_Vars.chrdata, cmd[2])) { + if (chrDetectDangerousObject(g_Vars.chrdata, cmd[2])) { g_Vars.aioffset = chraiGoToLabel(g_Vars.ailist, g_Vars.aioffset, cmd[3]); } else { g_Vars.aioffset += 4; diff --git a/src/game/game_00b820.c b/src/game/game_00b820.c index b8d06567f..0f70aa4b5 100644 --- a/src/game/game_00b820.c +++ b/src/game/game_00b820.c @@ -260,10 +260,10 @@ glabel func0f00b820 GLOBAL_ASM( glabel func0f00bb70 -/* f00bb70: 3c03800a */ lui $v1,%hi(var8009cc00) +/* f00bb70: 3c03800a */ lui $v1,%hi(g_DangerousProps) /* f00bb74: 3c02800a */ lui $v0,%hi(var8009cc30) /* f00bb78: 2442cc30 */ addiu $v0,$v0,%lo(var8009cc30) -/* f00bb7c: 2463cc00 */ addiu $v1,$v1,%lo(var8009cc00) +/* f00bb7c: 2463cc00 */ addiu $v1,$v1,%lo(g_DangerousProps) .L0f00bb80: /* f00bb80: 24630004 */ addiu $v1,$v1,0x4 /* f00bb84: 1462fffe */ bne $v1,$v0,.L0f00bb80 diff --git a/src/gvars/gvars.c b/src/gvars/gvars.c index a5a881080..6b2f02505 100644 --- a/src/gvars/gvars.c +++ b/src/gvars/gvars.c @@ -16053,18 +16053,7 @@ u32 var8009cbf0 = 0; u32 var8009cbf4 = 0; u32 var8009cbf8 = 0; u32 var8009cbfc = 0; -u32 var8009cc00 = 0; -u32 var8009cc04 = 0; -u32 var8009cc08 = 0; -u32 var8009cc0c = 0; -u32 var8009cc10 = 0; -u32 var8009cc14 = 0; -u32 var8009cc18 = 0; -u32 var8009cc1c = 0; -u32 var8009cc20 = 0; -u32 var8009cc24 = 0; -u32 var8009cc28 = 0; -u32 var8009cc2c = 0; +struct prop *g_DangerousProps[12] = {NULL}; u32 var8009cc30 = 0; u32 var8009cc34 = 0; u32 var8009cc38 = 0; diff --git a/src/include/commands.h b/src/include/commands.h index 21a7702ad..c02ff2368 100644 --- a/src/include/commands.h +++ b/src/include/commands.h @@ -2670,12 +2670,22 @@ mkshort(0x013c), \ label, -// Value is only ever 3. The function checks bits 0x01 and 0x02 to decide what -// to do, so in all cases it does both paths. -// globals.c only -#define cmd013d_if_grenade_thrown_nearby_maybe(value, label) \ +/** + * Checks if there is a live grenade or other dangerous object nearby. If so, + * the position of the object is stored in the chr's runfrompos property and the + * command passes. + * + * The flags argument is a bitfield which specifies what types of objects to + * look for. + * + * Flag 0x1 = check for grenades + * Flag 0x2 = check for prop type 7 (unsure what this is at the moment) + * + * Those are the only supported flags. + */ +#define if_dangerous_object_nearby(flags, label) \ mkshort(0x013d), \ - value, \ + flags, \ label, /** diff --git a/src/include/constants.h b/src/include/constants.h index 7ea62609b..c5ecb54b9 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -769,6 +769,7 @@ #define PROPTYPE_WEAPON 4 #define PROPTYPE_EYESPY 5 #define PROPTYPE_PLAYER 6 +#define PROPTYPE_7 7 #define RACE_HUMAN 0 #define RACE_SKEDAR 1 diff --git a/src/include/game/chr/chr.h b/src/include/game/chr/chr.h index 81374670b..03cc1368e 100644 --- a/src/include/game/chr/chr.h +++ b/src/include/game/chr/chr.h @@ -325,7 +325,7 @@ u32 func0f043944(void); u32 func0f043988(void); u32 func0f0439c0(void); u32 func0f0439f8(void); -u32 func0f043da8(struct chrdata *chr, u32 arg1); +bool chrDetectDangerousObject(struct chrdata *chr, u8 flags); void func0f043f24(s32 arg0); u32 func0f043f2c(void); u32 func0f044208(void); diff --git a/src/include/game/chr/chraicommands.h b/src/include/game/chr/chraicommands.h index 7d55435ec..b0b65c884 100644 --- a/src/include/game/chr/chraicommands.h +++ b/src/include/game/chr/chraicommands.h @@ -315,7 +315,7 @@ /*0x013a*/ bool aiSetChrPresetToUnalertedTeammate(void); /*0x013b*/ bool aiSetSquadron(void); /*0x013c*/ bool ai013c(void); -/*0x013d*/ bool ai013d(void); +/*0x013d*/ bool aiIfDangerousObjectNearby(void); /*0x013e*/ bool ai013e(void); /*0x013f*/ bool aiIfHeliWeaponsArmed(void); /*0x0140*/ bool aiIfHoverbotNextStep(void); diff --git a/src/include/gvars/gvars.h b/src/include/gvars/gvars.h index f90819fa9..9b3e3e62a 100644 --- a/src/include/gvars/gvars.h +++ b/src/include/gvars/gvars.h @@ -525,7 +525,7 @@ extern u32 var8009cadc; extern u32 var8009cae0; extern u32 var8009cb08; extern u32 var8009cbf8; -extern u32 var8009cc00; +extern struct prop *g_DangerousProps[12]; extern u32 var8009cc30; extern u32 var8009cc40; extern u32 var8009cc44; diff --git a/src/include/types.h b/src/include/types.h index a1f4d8c64..ca765edda 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -142,7 +142,7 @@ struct chr2d4 { /*0x004*/ struct mpsim *simulant; /*0x008*/ u16 unk008; /*0x008*/ s16 followingplayernum; - /*0x00c*/ u32 unk00c; + /*0x00c*/ s16 unk00c; /*0x010*/ struct prop *prop; /*0x014*/ u32 unk014; /*0x018*/ u32 unk018; diff --git a/src/setup/ailists.c b/src/setup/ailists.c index b759b1087..f904384a4 100644 --- a/src/setup/ailists.c +++ b/src/setup/ailists.c @@ -1496,7 +1496,7 @@ u8 func0007_alerted[] = { cmd0124_run_for_cover_maybe(MA_COVERWAIT) beginloop(0x55) - cmd013d_if_grenade_thrown_nearby_maybe(MA_GRENADEWAIT, /*goto*/ LABEL_FLEE_GRENADE) + if_dangerous_object_nearby(3, /*goto*/ LABEL_FLEE_GRENADE) if_chr_has_hiddenflag(CHR_TARGET, CHRHFLAG_CLOAKED, /*goto*/ LABEL_CLOAKED) if_self_flag_bankx_eq(CHRFLAG1_00001000, TRUE, BANK_1, /*goto*/ 0x13) if_self_flag_bankx_eq(CHRFLAG1_00000001, TRUE, BANK_1, /*goto*/ 0x16) @@ -1530,7 +1530,7 @@ u8 func0007_alerted[] = { try_chr_kneel_and_shoot_thing(0x0220, 0x0000, /*goto*/ 0x59) beginloop(0x59) - cmd013d_if_grenade_thrown_nearby_maybe(MA_GRENADEWAIT, /*goto*/ LABEL_FLEE_GRENADE) + if_dangerous_object_nearby(3, /*goto*/ LABEL_FLEE_GRENADE) chr_toggle_p1p2(CHR_SELF) set_target_chr(CHR_P1P2) if_within_units_of_sight(30, /*goto*/ 0x5f) @@ -1570,7 +1570,7 @@ u8 func0007_alerted[] = { try_run_to_target(/*goto*/ 0x62) beginloop(0x62) - cmd013d_if_grenade_thrown_nearby_maybe(MA_GRENADEWAIT, /*goto*/ LABEL_FLEE_GRENADE) + if_dangerous_object_nearby(3, /*goto*/ LABEL_FLEE_GRENADE) if_in_disarm_range(/*goto*/ 0x5f) if_player_using_cmp150_or_ar34(/*goto*/ 0x69) if_distance_to_target_gt(2000, /*goto*/ 0x65) @@ -1595,7 +1595,7 @@ u8 func0007_alerted[] = { label(0x16) stop_chr yield - cmd013d_if_grenade_thrown_nearby_maybe(MA_GRENADEWAIT, /*goto*/ LABEL_FLEE_GRENADE) + if_dangerous_object_nearby(3, /*goto*/ LABEL_FLEE_GRENADE) dprint 'B','A','C','K',' ','T','O',' ','C','O','V','E','R','\n',0, goto_first(0x52) @@ -1669,7 +1669,7 @@ u8 func0007_alerted[] = { try_aim_and_shoot_thing2(0x0200, 0x0000, /*goto*/ 0x60) beginloop(0x60) - cmd013d_if_grenade_thrown_nearby_maybe(MA_GRENADEWAIT, /*goto*/ LABEL_FLEE_GRENADE) + if_dangerous_object_nearby(3, /*goto*/ LABEL_FLEE_GRENADE) if_chr_stopped(/*goto*/ 0x5e) endloop(0x60) @@ -1771,7 +1771,7 @@ u8 func0007_alerted[] = { restart_timer beginloop(0x30) - cmd013d_if_grenade_thrown_nearby_maybe(MA_GRENADEWAIT, /*goto*/ LABEL_FLEE_GRENADE) + if_dangerous_object_nearby(3, /*goto*/ LABEL_FLEE_GRENADE) if_chr_has_hiddenflag(CHR_TARGET, CHRHFLAG_CLOAKED, /*goto*/ LABEL_CLOAKED) if_self_flag_bankx_eq(CHRFLAG1_00001000, TRUE, BANK_1, /*goto*/ 0x13) if_self_flag_bankx_eq(CHRFLAG1_00000001, TRUE, BANK_1, /*goto*/ 0x16) @@ -1834,7 +1834,7 @@ u8 func0007_alerted[] = { dprint 'C',' ','4','\n',0, kneel yield - cmd013d_if_grenade_thrown_nearby_maybe(MA_GRENADEWAIT, /*goto*/ LABEL_FLEE_GRENADE) + if_dangerous_object_nearby(3, /*goto*/ LABEL_FLEE_GRENADE) label(0x48) dprint 'G','R','E','N','A','D','E','P','\n',0, set_grenade_probability_out_of_255(255) @@ -1908,7 +1908,7 @@ u8 func0007_alerted[] = { try_chr_kneel_and_shoot_thing(0x0220, 0x0000, /*goto*/ 0x40) beginloop(0x40) - cmd013d_if_grenade_thrown_nearby_maybe(MA_GRENADEWAIT, /*goto*/ LABEL_FLEE_GRENADE) + if_dangerous_object_nearby(3, /*goto*/ LABEL_FLEE_GRENADE) if_self_flag_bankx_eq(CHRFLAG0_00004000, TRUE, BANK_0, /*goto*/ 0x91) if_self_flag_bankx_eq(CHRFLAG0_00002000, TRUE, BANK_0, /*goto*/ 0x16) label(0x91) @@ -1953,7 +1953,7 @@ u8 func0007_alerted[] = { try_run_to_target(/*goto*/ 0x89) beginloop(0x89) - cmd013d_if_grenade_thrown_nearby_maybe(MA_GRENADEWAIT, /*goto*/ LABEL_FLEE_GRENADE) + if_dangerous_object_nearby(3, /*goto*/ LABEL_FLEE_GRENADE) if_self_flag_bankx_eq(CHRFLAG0_00004000, TRUE, BANK_0, /*goto*/ 0x91) if_self_flag_bankx_eq(CHRFLAG0_00002000, TRUE, BANK_0, /*goto*/ 0x16) label(0x91) @@ -2019,7 +2019,7 @@ u8 func0007_alerted[] = { try_aim_and_shoot_thing2(0x0200, 0x0000, /*goto*/ 0x43) beginloop(0x43) - cmd013d_if_grenade_thrown_nearby_maybe(MA_GRENADEWAIT, /*goto*/ LABEL_FLEE_GRENADE) + if_dangerous_object_nearby(3, /*goto*/ LABEL_FLEE_GRENADE) if_chr_stopped(/*goto*/ 0x29) endloop(0x43) @@ -2079,7 +2079,7 @@ u8 func0007_alerted[] = { cmd012f beginloop(0x4f) - cmd013d_if_grenade_thrown_nearby_maybe(MA_GRENADEWAIT, /*goto*/ LABEL_FLEE_GRENADE) + if_dangerous_object_nearby(3, /*goto*/ LABEL_FLEE_GRENADE) if_timer_gt(120, /*goto*/ 0x50) if_chr_stopped(/*goto*/ 0x50) endloop(0x4f) @@ -2101,7 +2101,7 @@ u8 func0007_alerted[] = { set_ailist(CHR_SELF, GAILIST_HAND_COMBAT) label(0x13) - cmd013d_if_grenade_thrown_nearby_maybe(MA_GRENADEWAIT, /*goto*/ LABEL_FLEE_GRENADE) + if_dangerous_object_nearby(3, /*goto*/ LABEL_FLEE_GRENADE) if_chr_has_hiddenflag(CHR_TARGET, CHRHFLAG_CLOAKED, /*goto*/ LABEL_CLOAKED) goto_next(0x16) @@ -2137,7 +2137,7 @@ u8 func0007_alerted[] = { try_run_sideways(/*goto*/ 0x3e) beginloop(0x3e) - cmd013d_if_grenade_thrown_nearby_maybe(MA_GRENADEWAIT, /*goto*/ LABEL_FLEE_GRENADE) + if_dangerous_object_nearby(3, /*goto*/ LABEL_FLEE_GRENADE) if_chr_stopped(/*goto*/ 0x3f) endloop(0x3e) @@ -2161,7 +2161,7 @@ u8 func0007_alerted[] = { if_chr_has_hiddenflag(CHR_SELF, CHRHFLAG_00002000, /*goto*/ 0x13) if_chr_has_hiddenflag(CHR_TARGET, CHRHFLAG_BUDDY_PLACED, /*goto*/ 0x01) label(0x13) - cmd013d_if_grenade_thrown_nearby_maybe(MA_GRENADEWAIT, /*goto*/ LABEL_FLEE_GRENADE) + if_dangerous_object_nearby(3, /*goto*/ LABEL_FLEE_GRENADE) if_chr_has_hiddenflag(CHR_TARGET, CHRHFLAG_CLOAKED, /*goto*/ LABEL_CLOAKED) if_self_flag_bankx_eq(CHRFLAG1_00001000, TRUE, BANK_1, /*goto*/ 0x13) if_self_flag_bankx_eq(CHRFLAG1_00000001, TRUE, BANK_1, /*goto*/ 0x16) @@ -2268,7 +2268,7 @@ u8 func0007_alerted[] = { try_run_to_target(/*goto*/ 0x85) beginloop(0x85) - cmd013d_if_grenade_thrown_nearby_maybe(MA_GRENADEWAIT, /*goto*/ LABEL_FLEE_GRENADE) + if_dangerous_object_nearby(3, /*goto*/ LABEL_FLEE_GRENADE) if_chr_has_hiddenflag(CHR_TARGET, CHRHFLAG_CLOAKED, /*goto*/ LABEL_CLOAKED) if_self_flag_bankx_eq(CHRFLAG1_00001000, TRUE, BANK_1, /*goto*/ 0x13) if_self_flag_bankx_eq(CHRFLAG1_00000001, TRUE, BANK_1, /*goto*/ 0x16) @@ -2353,7 +2353,7 @@ u8 func0007_alerted[] = { try_aim_and_shoot_thing1(0x0220, 0x0000, /*goto*/ 0x28) dprint 'S','H','O','O','T','F','A','I','L','E','D','\n',0, yield - cmd013d_if_grenade_thrown_nearby_maybe(MA_GRENADEWAIT, /*goto*/ LABEL_FLEE_GRENADE) + if_dangerous_object_nearby(3, /*goto*/ LABEL_FLEE_GRENADE) goto_first(0x8b) label(0x28) @@ -2365,7 +2365,7 @@ u8 func0007_alerted[] = { say_quip(CHR_BOND, 0x01, 0x19, 0x02, 0x01, BANK_0, 0x00, 0x00) beginloop(0x45) - cmd013d_if_grenade_thrown_nearby_maybe(MA_GRENADEWAIT, /*goto*/ LABEL_FLEE_GRENADE) + if_dangerous_object_nearby(3, /*goto*/ LABEL_FLEE_GRENADE) if_chr_stopped(/*goto*/ 0x2a) endloop(0x45) @@ -2438,7 +2438,7 @@ u8 func0007_alerted[] = { set_self_flag_bankx(CHRFLAG1_00020000, BANK_1) beginloop(0x2c) - cmd013d_if_grenade_thrown_nearby_maybe(MA_GRENADEWAIT, /*goto*/ LABEL_FLEE_GRENADE) + if_dangerous_object_nearby(3, /*goto*/ LABEL_FLEE_GRENADE) if_chr_stopped(/*goto*/ 0x2e) endloop(0x2c) @@ -2479,7 +2479,7 @@ u8 func0007_alerted[] = { retreat(0x02, 0x01) beginloop(0x6c) - cmd013d_if_grenade_thrown_nearby_maybe(MA_GRENADEWAIT, /*goto*/ LABEL_FLEE_GRENADE) + if_dangerous_object_nearby(3, /*goto*/ LABEL_FLEE_GRENADE) if_distance_to_target_gt(300, /*goto*/ 0x16) if_chr_in_view(/*goto*/ 0x70) label(0x16) @@ -2490,7 +2490,7 @@ u8 func0007_alerted[] = { stop_chr beginloop(0x6e) - cmd013d_if_grenade_thrown_nearby_maybe(MA_GRENADEWAIT, /*goto*/ LABEL_FLEE_GRENADE) + if_dangerous_object_nearby(3, /*goto*/ LABEL_FLEE_GRENADE) chr_toggle_p1p2(CHR_SELF) set_target_chr(CHR_P1P2) if_distance_to_target_lt(3000, /*goto*/ 0x6f) @@ -2540,7 +2540,7 @@ u8 func0007_alerted[] = { try_run_to_chr(CHR_PRESET, /*goto*/ 0x96) beginloop(0x96) - cmd013d_if_grenade_thrown_nearby_maybe(MA_GRENADEWAIT, /*goto*/ LABEL_FLEE_GRENADE) + if_dangerous_object_nearby(3, /*goto*/ LABEL_FLEE_GRENADE) if_chr_death_animation_finished(CHR_PRESET, /*goto*/ 0x84) if_chr_unloaded(CHR_PRESET, /*goto*/ 0x84) if_detected_chr(CHR_PRESET, /*goto*/ 0x97) @@ -2568,7 +2568,7 @@ u8 func0007_alerted[] = { go_to_target_pad(SPEED_JOG) beginloop(0x9d) - cmd013d_if_grenade_thrown_nearby_maybe(MA_GRENADEWAIT, /*goto*/ LABEL_FLEE_GRENADE) + if_dangerous_object_nearby(3, /*goto*/ LABEL_FLEE_GRENADE) if_chr_stopped(/*goto*/ 0x16) endloop(0x9d) @@ -2584,7 +2584,7 @@ u8 func0007_alerted[] = { activate_alarm beginloop(0x9e) - cmd013d_if_grenade_thrown_nearby_maybe(MA_GRENADEWAIT, /*goto*/ LABEL_FLEE_GRENADE) + if_dangerous_object_nearby(3, /*goto*/ LABEL_FLEE_GRENADE) if_chr_stopped(/*goto*/ 0x16) endloop(0x9e) @@ -4125,7 +4125,7 @@ u8 func0011_flee_from_grenade[] = { beginloop(0x0c) dprint 'D','A','N','G','E','R',' ','L','O','O','P','\n',0, - cmd013d_if_grenade_thrown_nearby_maybe(MA_GRENADEWAIT, /*goto*/ 0x13) + if_dangerous_object_nearby(3, /*goto*/ 0x13) goto_next(0x16) label(0x13) diff --git a/src/setup/setup_000000.c b/src/setup/setup_000000.c index 684e9622f..ead73d77f 100644 --- a/src/setup/setup_000000.c +++ b/src/setup/setup_000000.c @@ -14451,7 +14451,7 @@ bool (*g_CommandPointers[])(void) = { /*0x013a*/ aiSetChrPresetToUnalertedTeammate, /*0x013b*/ aiSetSquadron, /*0x013c*/ ai013c, - /*0x013d*/ ai013d, + /*0x013d*/ aiIfDangerousObjectNearby, /*0x013e*/ ai013e, /*0x013f*/ aiIfHeliWeaponsArmed, /*0x0140*/ aiIfHoverbotNextStep,