From cf45c85ac1527385b15245791d6932be75f840b6 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Wed, 26 Feb 2020 22:44:49 +1000 Subject: [PATCH] Decompile activemenuApply --- src/files/setup/setuppete.c | 4 +- src/game/data/ailists.c | 24 +- src/game/data/data_020df0.c | 2 +- src/game/game_0fd660.c | 382 ++++++++++------------------ src/include/commands.h | 5 +- src/include/constants.h | 6 +- src/include/game/data/data_020df0.h | 1 + src/include/game/game_0b0420.h | 4 +- src/include/game/game_0fd660.h | 6 +- src/include/game/game_197600.h | 2 +- src/include/game/game_19c990.h | 2 +- src/include/types.h | 10 +- 12 files changed, 161 insertions(+), 287 deletions(-) diff --git a/src/files/setup/setuppete.c b/src/files/setup/setuppete.c index 877e6ec2a..bcd4c668d 100644 --- a/src/files/setup/setuppete.c +++ b/src/files/setup/setuppete.c @@ -2114,7 +2114,7 @@ u8 func041e_sealer1[] = { // Crash happened label(0x03) - unset_chr_hiddenflag(CHR_SELF, CHRHFLAG_00000400) + unset_chr_hiddenflag(CHR_SELF, CHRHFLAG_PASSIVE) jog_to_pad(0x00c4) set_ailist(CHR_SEALER2, AILIST_JOG_TO_ACCIDENT) set_ailist(CHR_SEALER3, AILIST_JOG_TO_ACCIDENT) @@ -2379,7 +2379,7 @@ u8 func041f_alarm_responder[] = { }; u8 func0420_jog_to_accident[] = { - unset_chr_hiddenflag(CHR_SELF, CHRHFLAG_00000400) + unset_chr_hiddenflag(CHR_SELF, CHRHFLAG_PASSIVE) label(0x03) go_to_target_pad(SPEED_JOG) diff --git a/src/game/data/ailists.c b/src/game/data/ailists.c index aeb3bf053..a9b2ce7f1 100644 --- a/src/game/data/ailists.c +++ b/src/game/data/ailists.c @@ -4566,7 +4566,7 @@ u8 func001f_related_to_spawning[] = { * Not used? */ u8 func0012_init_coop_100[] = { - set_chr_hiddenflag(CHR_SELF, CHRHFLAG_00000400) + set_chr_hiddenflag(CHR_SELF, CHRHFLAG_PASSIVE) set_self_chrflag(CHRCFLAG_00040000) set_chr_team(CHR_SELF, TEAM_ALLY) set_self_chrflag(CHRCFLAG_01000000) @@ -4640,7 +4640,7 @@ u8 func0012_init_coop_100[] = { * Not used? */ u8 func0013_init_coop_200[] = { - set_chr_hiddenflag(CHR_SELF, CHRHFLAG_00000400) + set_chr_hiddenflag(CHR_SELF, CHRHFLAG_PASSIVE) set_chr_team(CHR_SELF, TEAM_ALLY) set_self_chrflag(CHRCFLAG_00040000) set_self_chrflag(CHRCFLAG_01000000) @@ -4746,7 +4746,7 @@ u8 func0014_coop_buddy[] = { label(0x13) set_self_flag_bankx(CHRFLAG1_00000001, BANK_1) label(0x16) - if_chr_has_hiddenflag(CHR_SELF, CHRHFLAG_00000400, /*goto*/ 0xdc) + if_chr_has_hiddenflag(CHR_SELF, CHRHFLAG_PASSIVE, /*goto*/ 0xdc) if_enemy_distance_lt_and_los(2540, /*goto*/ 0x03) label(0xdc) set_target_chr(CHR_BOND) @@ -4780,7 +4780,7 @@ u8 func0014_coop_buddy[] = { label(0x07) set_target_chr(CHR_BOND) if_chr_sees_player(/*goto*/ 0xdd) - if_chr_has_hiddenflag(CHR_SELF, CHRHFLAG_00000400, /*goto*/ 0xdc) + if_chr_has_hiddenflag(CHR_SELF, CHRHFLAG_PASSIVE, /*goto*/ 0xdc) label(0xdd) if_enemy_distance_lt_and_los(2540, /*goto*/ 0x03) label(0xdc) @@ -4814,7 +4814,7 @@ u8 func0014_coop_buddy[] = { label(0x06) set_chr_hiddenflag(CHR_SELF, CHRHFLAG_DISGUISED) label(0x07) - if_chr_has_hiddenflag(CHR_SELF, CHRHFLAG_00000400, /*goto*/ 0xdc) + if_chr_has_hiddenflag(CHR_SELF, CHRHFLAG_PASSIVE, /*goto*/ 0xdc) if_stage_is_not(STAGE_G5BUILDING, /*goto*/ 0x15) goto_next(0x13) @@ -4974,12 +4974,10 @@ u8 func0023_dodge[] = { }; /** - * This appears to be a function used to test something related to the co-op - * buddy and the intro cinema. The function expects the cutscene to finish and - * then start again several times. After this has happened, the co-op buddy is - * warped to the same pad every second. + * In co-op mode with an AI buddy, this ailist is applied to the buddy when you + * give them the Stealth command. */ -u8 func0015_test_cutscene_buddy[] = { +u8 func0015_aibuddy_stealth[] = { stop_chr set_chr_cloaked(CHR_SELF, TRUE, TRUE) @@ -5040,8 +5038,8 @@ u8 func0015_test_cutscene_buddy[] = { wait_intro(0x0b) // This will execute every second after the initial 7ish seconds and while - // cutscene is not running. The chr is being moved back to the same pad - // repeatedly, so this is surely some kind of debug function. + // cutscene is not running. The chr is being moved back to the player + // repeatedly. set_chr_hiddenflag(CHR_SELF, 0x00100200) chr_move_to_pad(CHR_SELF, CHR_BOND, 88, /*goto*/ 0x17) goto_first(0x19) @@ -5496,7 +5494,7 @@ struct ailist g_GlobalAilists[] = { { func0027_psychosised, 0x0027 }, { func002d_invincible_and_idle, 0x002d }, { func0021_stop_and_idle, 0x0021 }, - { func0015_test_cutscene_buddy, 0x0015 }, + { func0015_aibuddy_stealth, 0x0015 }, { func0028_ai_bot_dead, 0x0028 }, { func0029_ai_bot_init, 0x0029 }, { func002a_ai_bot_alive, 0x002a }, diff --git a/src/game/data/data_020df0.c b/src/game/data/data_020df0.c index 6a59ee1c0..8a6edeb1f 100644 --- a/src/game/data/data_020df0.c +++ b/src/game/data/data_020df0.c @@ -12813,7 +12813,7 @@ u32 var800887f4 = 0x007e6620; u32 var800887f8 = 0x007e9d20; u32 var800887fc = 0x00000000; u32 var80088800 = 0x00000000; -u32 var80088804 = 0x00000000; +u8 var80088804 = 0; u32 var80088808 = 0x00000000; u32 var8008880c = 0x00000000; u32 var80088810 = 0x00000000; diff --git a/src/game/game_0fd660.c b/src/game/game_0fd660.c index c47c6d510..533468a80 100644 --- a/src/game/game_0fd660.c +++ b/src/game/game_0fd660.c @@ -37,7 +37,7 @@ void func0f0fd660(void) u32 prevplayernum = g_MpPlayerNum; if (!mpIsPaused()) { - g_ActiveMenuThings[g_ActiveMenuIndex].unk33 = g_ActiveMenuThings[g_ActiveMenuIndex].unk32; + g_ActiveMenuThings[g_ActiveMenuIndex].unk33 = g_ActiveMenuThings[g_ActiveMenuIndex].allbots; g_Vars.currentplayer->activemenumode = 0; g_MpPlayerNum = g_Vars.unk000288[0].mpchrnum; func0f0f8330(&menudialog_picktarget, 8); @@ -492,7 +492,7 @@ bool menudialogMpPickTarget(u32 operation, struct menu_dialog *dialog, struct me return false; } -void func0f0fdd00(bool arg0) +void activemenuSetAiBuddyTemperament(bool aggressive) { s32 i; @@ -501,17 +501,17 @@ void func0f0fdd00(bool arg0) struct chrdata *chr = g_Vars.aibuddies[i]->chr; if (chr) { - if (arg0) { - chr->hidden &= ~CHRHFLAG_00000400; + if (aggressive) { + chr->hidden &= ~CHRHFLAG_PASSIVE; } else { - chr->hidden |= CHRHFLAG_00000400; + chr->hidden |= CHRHFLAG_PASSIVE; } } } } } -void func0f0fdd84(void) +void activemenuSetAiBuddyStealth(void) { s32 i; @@ -521,12 +521,12 @@ void func0f0fdd84(void) if (chr && chr->prop && !chrIsDead(chr) - && chr->ailist != ailistFindById(GAILIST_TEST_CUTSCENE_BUDDY) + && chr->ailist != ailistFindById(GAILIST_AIBUDDY_STEALTH) && chr->actiontype != ACT_DRUGGEDDROP && chr->actiontype != ACT_DRUGGEDKO && chr->actiontype != ACT_DRUGGEDCOMINGUP) { chrStopFiring(chr); - chr->ailist = ailistFindById(GAILIST_TEST_CUTSCENE_BUDDY); + chr->ailist = ailistFindById(GAILIST_AIBUDDY_STEALTH); chr->aioffset = 0; } } @@ -553,246 +553,113 @@ s32 activemenuGetFirstBuddyIndex(void) return -1; } -GLOBAL_ASM( -glabel activemenuApply -/* f0fdf14: 3c03800a */ lui $v1,0x800a -/* f0fdf18: 8c6321b8 */ lw $v1,0x21b8($v1) -/* f0fdf1c: 3c08800a */ lui $t0,%hi(g_ActiveMenuThings) -/* f0fdf20: 250820d0 */ addiu $t0,$t0,%lo(g_ActiveMenuThings) -/* f0fdf24: 000370c0 */ sll $t6,$v1,0x3 -/* f0fdf28: 01c37023 */ subu $t6,$t6,$v1 -/* f0fdf2c: 000e70c0 */ sll $t6,$t6,0x3 -/* f0fdf30: 010e2821 */ addu $a1,$t0,$t6 -/* f0fdf34: 80a70000 */ lb $a3,0x0($a1) -/* f0fdf38: 27bdffb8 */ addiu $sp,$sp,-72 -/* f0fdf3c: afbf001c */ sw $ra,0x1c($sp) -/* f0fdf40: afb10018 */ sw $s1,0x18($sp) -/* f0fdf44: afb00014 */ sw $s0,0x14($sp) -/* f0fdf48: 10e00006 */ beqz $a3,.L0f0fdf64 -/* f0fdf4c: 00803025 */ or $a2,$a0,$zero -/* f0fdf50: 24100001 */ addiu $s0,$zero,0x1 -/* f0fdf54: 10f0005c */ beq $a3,$s0,.L0f0fe0c8 -/* f0fdf58: 3c03800a */ lui $v1,%hi(g_Vars) -/* f0fdf5c: 1000007a */ beqz $zero,.L0f0fe148 -/* f0fdf60: 3c19800a */ lui $t9,0x800a -.L0f0fdf64: -/* f0fdf64: 28c10005 */ slti $at,$a2,0x5 -/* f0fdf68: 14200002 */ bnez $at,.L0f0fdf74 -/* f0fdf6c: 000378c0 */ sll $t7,$v1,0x3 -/* f0fdf70: 24c6ffff */ addiu $a2,$a2,-1 -.L0f0fdf74: -/* f0fdf74: 01e37823 */ subu $t7,$t7,$v1 -/* f0fdf78: 000f78c0 */ sll $t7,$t7,0x3 -/* f0fdf7c: 010fc021 */ addu $t8,$t0,$t7 -/* f0fdf80: 0306c821 */ addu $t9,$t8,$a2 -/* f0fdf84: 93290020 */ lbu $t1,0x20($t9) -/* f0fdf88: 0fc44a54 */ jal currentPlayerGetNumInvItems -/* f0fdf8c: afa90040 */ sw $t1,0x40($sp) -/* f0fdf90: 8fa40040 */ lw $a0,0x40($sp) -/* f0fdf94: 0082082a */ slt $at,$a0,$v0 -/* f0fdf98: 502000b5 */ beqzl $at,.L0f0fe270 -/* f0fdf9c: 8fbf001c */ lw $ra,0x1c($sp) -/* f0fdfa0: 0fc44b11 */ jal currentPlayerGetWeaponNumByInvIndex -/* f0fdfa4: 00000000 */ sll $zero,$zero,0x0 -/* f0fdfa8: 00408025 */ or $s0,$v0,$zero -/* f0fdfac: 10400010 */ beqz $v0,.L0f0fdff0 -/* f0fdfb0: 24110001 */ addiu $s1,$zero,0x1 -/* f0fdfb4: 0fc2c62f */ jal currentPlayerHasWeaponEquipped -/* f0fdfb8: 00402025 */ or $a0,$v0,$zero -/* f0fdfbc: 2401ffff */ addiu $at,$zero,-1 -/* f0fdfc0: 1041000b */ beq $v0,$at,.L0f0fdff0 -/* f0fdfc4: 00000000 */ sll $zero,$zero,0x0 -/* f0fdfc8: 14400006 */ bnez $v0,.L0f0fdfe4 -/* f0fdfcc: 00008825 */ or $s1,$zero,$zero -/* f0fdfd0: 02002025 */ or $a0,$s0,$zero -/* f0fdfd4: 0fc2c652 */ jal func0f0b1948 -/* f0fdfd8: 24050001 */ addiu $a1,$zero,0x1 -/* f0fdfdc: 10000004 */ beqz $zero,.L0f0fdff0 -/* f0fdfe0: 00000000 */ sll $zero,$zero,0x0 -.L0f0fdfe4: -/* f0fdfe4: 02002025 */ or $a0,$s0,$zero -/* f0fdfe8: 0fc2c652 */ jal func0f0b1948 -/* f0fdfec: 00002825 */ or $a1,$zero,$zero -.L0f0fdff0: -/* f0fdff0: 1220009e */ beqz $s1,.L0f0fe26c -/* f0fdff4: 3c0a8009 */ lui $t2,0x8009 -/* f0fdff8: 914a8804 */ lbu $t2,-0x77fc($t2) -/* f0fdffc: 24110001 */ addiu $s1,$zero,0x1 -/* f0fe000: 1140000c */ beqz $t2,.L0f0fe034 -/* f0fe004: 00000000 */ sll $zero,$zero,0x0 -/* f0fe008: 0fc67494 */ jal func0f19d250 -/* f0fe00c: 00000000 */ sll $zero,$zero,0x0 -/* f0fe010: 0fc6749a */ jal func0f19d268 -/* f0fe014: 00402025 */ or $a0,$v0,$zero -/* f0fe018: 3c03800a */ lui $v1,%hi(g_Vars) -/* f0fe01c: 24639fc0 */ addiu $v1,$v1,%lo(g_Vars) -/* f0fe020: 8c6b0284 */ lw $t3,0x284($v1) -/* f0fe024: 916c0638 */ lbu $t4,0x638($t3) -/* f0fe028: 144c0002 */ bne $v0,$t4,.L0f0fe034 -/* f0fe02c: 00000000 */ sll $zero,$zero,0x0 -/* f0fe030: 00008825 */ or $s1,$zero,$zero -.L0f0fe034: -/* f0fe034: 5220008e */ beqzl $s1,.L0f0fe270 -/* f0fe038: 8fbf001c */ lw $ra,0x1c($sp) -/* f0fe03c: 0fc44bd8 */ jal currentPlayerSetEquipCurItem -/* f0fe040: 8fa40040 */ lw $a0,0x40($sp) -/* f0fe044: 02002025 */ or $a0,$s0,$zero -/* f0fe048: 0fc4473e */ jal func0f111cf8 -/* f0fe04c: 02002825 */ or $a1,$s0,$zero -/* f0fe050: 1040000f */ beqz $v0,.L0f0fe090 -/* f0fe054: 00000000 */ sll $zero,$zero,0x0 -/* f0fe058: 0fc2866a */ jal getCurrentPlayerWeaponId -/* f0fe05c: 00002025 */ or $a0,$zero,$zero -/* f0fe060: 10500003 */ beq $v0,$s0,.L0f0fe070 -/* f0fe064: 00002025 */ or $a0,$zero,$zero -/* f0fe068: 0fc28824 */ jal currentPlayerEquipWeapon -/* f0fe06c: 02002825 */ or $a1,$s0,$zero -.L0f0fe070: -/* f0fe070: 0fc2866a */ jal getCurrentPlayerWeaponId -/* f0fe074: 24040001 */ addiu $a0,$zero,0x1 -/* f0fe078: 1050007c */ beq $v0,$s0,.L0f0fe26c -/* f0fe07c: 24040001 */ addiu $a0,$zero,0x1 -/* f0fe080: 0fc28824 */ jal currentPlayerEquipWeapon -/* f0fe084: 02002825 */ or $a1,$s0,$zero -/* f0fe088: 10000079 */ beqz $zero,.L0f0fe270 -/* f0fe08c: 8fbf001c */ lw $ra,0x1c($sp) -.L0f0fe090: -/* f0fe090: 0fc2866a */ jal getCurrentPlayerWeaponId -/* f0fe094: 00002025 */ or $a0,$zero,$zero -/* f0fe098: 10500003 */ beq $v0,$s0,.L0f0fe0a8 -/* f0fe09c: 00002025 */ or $a0,$zero,$zero -/* f0fe0a0: 0fc28824 */ jal currentPlayerEquipWeapon -/* f0fe0a4: 02002825 */ or $a1,$s0,$zero -.L0f0fe0a8: -/* f0fe0a8: 0fc2866a */ jal getCurrentPlayerWeaponId -/* f0fe0ac: 24040001 */ addiu $a0,$zero,0x1 -/* f0fe0b0: 1040006e */ beqz $v0,.L0f0fe26c -/* f0fe0b4: 24040001 */ addiu $a0,$zero,0x1 -/* f0fe0b8: 0fc28824 */ jal currentPlayerEquipWeapon -/* f0fe0bc: 00002825 */ or $a1,$zero,$zero -/* f0fe0c0: 1000006b */ beqz $zero,.L0f0fe270 -/* f0fe0c4: 8fbf001c */ lw $ra,0x1c($sp) -.L0f0fe0c8: -/* f0fe0c8: 24639fc0 */ addiu $v1,$v1,%lo(g_Vars) -/* f0fe0cc: 8c6d0284 */ lw $t5,0x284($v1) -/* f0fe0d0: 81a41580 */ lb $a0,0x1580($t5) -/* f0fe0d4: 18800018 */ blez $a0,.L0f0fe138 -/* f0fe0d8: 28810024 */ slti $at,$a0,0x24 -/* f0fe0dc: 10200016 */ beqz $at,.L0f0fe138 -/* f0fe0e0: 00000000 */ sll $zero,$zero,0x0 -/* f0fe0e4: 8c6e0288 */ lw $t6,0x288($v1) -/* f0fe0e8: 2482ffff */ addiu $v0,$a0,-1 -/* f0fe0ec: 0002c8c3 */ sra $t9,$v0,0x3 -/* f0fe0f0: 8dcf0070 */ lw $t7,0x70($t6) -/* f0fe0f4: 3c0a800b */ lui $t2,0x800b -/* f0fe0f8: 304b0007 */ andi $t3,$v0,0x7 -/* f0fe0fc: 000fc080 */ sll $t8,$t7,0x2 -/* f0fe100: 030fc021 */ addu $t8,$t8,$t7 -/* f0fe104: 0018c140 */ sll $t8,$t8,0x5 -/* f0fe108: 03194821 */ addu $t1,$t8,$t9 -/* f0fe10c: 01495021 */ addu $t2,$t2,$t1 -/* f0fe110: 914ac84f */ lbu $t2,-0x37b1($t2) -/* f0fe114: 240c0001 */ addiu $t4,$zero,0x1 -/* f0fe118: 016c6804 */ sllv $t5,$t4,$t3 -/* f0fe11c: 014d7024 */ and $t6,$t2,$t5 -/* f0fe120: 11c00005 */ beqz $t6,.L0f0fe138 -/* f0fe124: 00000000 */ sll $zero,$zero,0x0 -/* f0fe128: 14d00050 */ bne $a2,$s0,.L0f0fe26c -/* f0fe12c: 240f0001 */ addiu $t7,$zero,0x1 -/* f0fe130: 1000004e */ beqz $zero,.L0f0fe26c -/* f0fe134: a0af0030 */ sb $t7,0x30($a1) -.L0f0fe138: -/* f0fe138: 10d0004c */ beq $a2,$s0,.L0f0fe26c -/* f0fe13c: 24180001 */ addiu $t8,$zero,0x1 -/* f0fe140: 1000004a */ beqz $zero,.L0f0fe26c -/* f0fe144: a0b80030 */ sb $t8,0x30($a1) -.L0f0fe148: -/* f0fe148: 8329dfeb */ lb $t1,-0x2015($t9) -/* f0fe14c: 3c03800a */ lui $v1,%hi(g_Vars) -/* f0fe150: 24639fc0 */ addiu $v1,$v1,%lo(g_Vars) -/* f0fe154: 05230019 */ bgezl $t1,.L0f0fe1bc -/* f0fe158: 8c6c0318 */ lw $t4,0x318($v1) -/* f0fe15c: 0fc3f7a3 */ jal activemenuGetFirstBuddyIndex -/* f0fe160: afa60048 */ sw $a2,0x48($sp) -/* f0fe164: 04400041 */ bltz $v0,.L0f0fe26c -/* f0fe168: 8fa60048 */ lw $a2,0x48($sp) -/* f0fe16c: 14d00005 */ bne $a2,$s0,.L0f0fe184 -/* f0fe170: 24010007 */ addiu $at,$zero,0x7 -/* f0fe174: 0fc3f740 */ jal func0f0fdd00 -/* f0fe178: 24040001 */ addiu $a0,$zero,0x1 -/* f0fe17c: 1000003c */ beqz $zero,.L0f0fe270 -/* f0fe180: 8fbf001c */ lw $ra,0x1c($sp) -.L0f0fe184: -/* f0fe184: 54c10006 */ bnel $a2,$at,.L0f0fe1a0 -/* f0fe188: 24010003 */ addiu $at,$zero,0x3 -/* f0fe18c: 0fc3f740 */ jal func0f0fdd00 -/* f0fe190: 00002025 */ or $a0,$zero,$zero -/* f0fe194: 10000036 */ beqz $zero,.L0f0fe270 -/* f0fe198: 8fbf001c */ lw $ra,0x1c($sp) -/* f0fe19c: 24010003 */ addiu $at,$zero,0x3 -.L0f0fe1a0: -/* f0fe1a0: 54c10033 */ bnel $a2,$at,.L0f0fe270 -/* f0fe1a4: 8fbf001c */ lw $ra,0x1c($sp) -/* f0fe1a8: 0fc3f761 */ jal func0f0fdd84 -/* f0fe1ac: 00000000 */ sll $zero,$zero,0x0 -/* f0fe1b0: 1000002f */ beqz $zero,.L0f0fe270 -/* f0fe1b4: 8fbf001c */ lw $ra,0x1c($sp) -/* f0fe1b8: 8c6c0318 */ lw $t4,0x318($v1) -.L0f0fe1bc: -/* f0fe1bc: 5180002c */ beqzl $t4,.L0f0fe270 -/* f0fe1c0: 8fbf001c */ lw $ra,0x1c($sp) -/* f0fe1c4: 90ab0032 */ lbu $t3,0x32($a1) -/* f0fe1c8: 5160001e */ beqzl $t3,.L0f0fe244 -/* f0fe1cc: 8c690284 */ lw $t1,0x284($v1) -/* f0fe1d0: 8c710284 */ lw $s1,0x284($v1) -/* f0fe1d4: 3c0d800b */ lui $t5,%hi(g_ActiveMenuMpBotCommands) -/* f0fe1d8: 25adcb78 */ addiu $t5,$t5,%lo(g_ActiveMenuMpBotCommands) -/* f0fe1dc: 922a1be6 */ lbu $t2,0x1be6($s1) -/* f0fe1e0: 00cd1021 */ addu $v0,$a2,$t5 -/* f0fe1e4: 00008025 */ or $s0,$zero,$zero -/* f0fe1e8: 59400021 */ blezl $t2,.L0f0fe270 -/* f0fe1ec: 8fbf001c */ lw $ra,0x1c($sp) -/* f0fe1f0: afa20020 */ sw $v0,0x20($sp) -/* f0fe1f4: 02307021 */ addu $t6,$s1,$s0 -.L0f0fe1f8: -/* f0fe1f8: 91cf1be7 */ lbu $t7,0x1be7($t6) -/* f0fe1fc: 8fa20020 */ lw $v0,0x20($sp) -/* f0fe200: 3c04800b */ lui $a0,0x800b -/* f0fe204: 000fc080 */ sll $t8,$t7,0x2 -/* f0fe208: 00982021 */ addu $a0,$a0,$t8 -/* f0fe20c: 8c84c4d0 */ lw $a0,-0x3b30($a0) -/* f0fe210: 0fc65ebd */ jal func0f197af4 -/* f0fe214: 90450000 */ lbu $a1,0x0($v0) -/* f0fe218: 3c03800a */ lui $v1,%hi(g_Vars) -/* f0fe21c: 24639fc0 */ addiu $v1,$v1,%lo(g_Vars) -/* f0fe220: 8c710284 */ lw $s1,0x284($v1) -/* f0fe224: 26100001 */ addiu $s0,$s0,0x1 -/* f0fe228: 92391be6 */ lbu $t9,0x1be6($s1) -/* f0fe22c: 0219082a */ slt $at,$s0,$t9 -/* f0fe230: 5420fff1 */ bnezl $at,.L0f0fe1f8 -/* f0fe234: 02307021 */ addu $t6,$s1,$s0 -/* f0fe238: 1000000d */ beqz $zero,.L0f0fe270 -/* f0fe23c: 8fbf001c */ lw $ra,0x1c($sp) -/* f0fe240: 8c690284 */ lw $t1,0x284($v1) -.L0f0fe244: -/* f0fe244: 3c04800b */ lui $a0,0x800b -/* f0fe248: 3c05800b */ lui $a1,0x800b -/* f0fe24c: 01276021 */ addu $t4,$t1,$a3 -/* f0fe250: 918b1be5 */ lbu $t3,0x1be5($t4) -/* f0fe254: 00a62821 */ addu $a1,$a1,$a2 -/* f0fe258: 90a5cb78 */ lbu $a1,-0x3488($a1) -/* f0fe25c: 000b5080 */ sll $t2,$t3,0x2 -/* f0fe260: 008a2021 */ addu $a0,$a0,$t2 -/* f0fe264: 0fc65ebd */ jal func0f197af4 -/* f0fe268: 8c84c4d0 */ lw $a0,-0x3b30($a0) -.L0f0fe26c: -/* f0fe26c: 8fbf001c */ lw $ra,0x1c($sp) -.L0f0fe270: -/* f0fe270: 8fb00014 */ lw $s0,0x14($sp) -/* f0fe274: 8fb10018 */ lw $s1,0x18($sp) -/* f0fe278: 03e00008 */ jr $ra -/* f0fe27c: 27bd0048 */ addiu $sp,$sp,0x48 -); +void activemenuApply(s32 slot) +{ + s32 numinvitems; + s32 invindex; + bool pass; + s32 lVar4; + s32 uVar6; + s32 weaponnum; + s32 i; + + switch (g_ActiveMenuThings[g_ActiveMenuIndex].screenindex) { + case 0: // Weapon + if (slot > 4) { + slot--; + } + + invindex = g_ActiveMenuThings[g_ActiveMenuIndex].weaponnums[slot]; + numinvitems = currentPlayerGetNumInvItems(); + + if (invindex < numinvitems) { + weaponnum = currentPlayerGetWeaponNumByInvIndex(invindex); + pass = true; + + if (weaponnum) { + lVar4 = currentPlayerHasWeaponEquipped(weaponnum); + + if (lVar4 != -1) { + pass = false; + + if (lVar4 == 0) { + func0f0b1948(weaponnum, 1); + } else { + func0f0b1948(weaponnum, 0); + } + } + } + + if (pass) { + pass = true; + + if (var80088804 != 0) { + uVar6 = func0f19d268(func0f19d250()); + + if (uVar6 == g_Vars.currentplayer->unk0638) { + pass = false; + } + } + + if (pass) { + currentPlayerSetEquipCurItem(invindex); + + if (func0f111cf8(weaponnum, weaponnum)) { + if (getCurrentPlayerWeaponId(0) != weaponnum) { + currentPlayerEquipWeapon(0, weaponnum); + } + + if (getCurrentPlayerWeaponId(1) != weaponnum) { + currentPlayerEquipWeapon(1, weaponnum); + } + } else { + if (getCurrentPlayerWeaponId(0) != weaponnum) { + currentPlayerEquipWeapon(0, weaponnum); + } + + if (getCurrentPlayerWeaponId(1) != 0) { + currentPlayerEquipWeapon(1, 0); + } + } + } + } + } + break; + case 1: // Function - 0c8 + if (g_Vars.currentplayer->unk1580 >= WEAPON_UNARMED + && g_Vars.currentplayer->unk1580 <= WEAPON_COMBATBOOST + && g_MpPlayers[g_Vars.unk000288->mpchrnum].gunfuncs[(g_Vars.currentplayer->unk1580 - 1) >> 3] & (1 << (g_Vars.currentplayer->unk1580 - 1 & 7))) { + if (slot == 1) { + g_ActiveMenuThings[g_ActiveMenuIndex].unk30 = 1; + } + } else { + if (slot != 1) { + g_ActiveMenuThings[g_ActiveMenuIndex].unk30 = 1; + } + } + break; + default: // 148 + if (g_MissionConfig.iscoop) { + if (activemenuGetFirstBuddyIndex() > -1) { + if (slot == 1) { + activemenuSetAiBuddyTemperament(true); // aggressive + } else if (slot == 7) { + activemenuSetAiBuddyTemperament(false); // passive + } else if (slot == 3) { + activemenuSetAiBuddyStealth(); + } + } + } else if (g_Vars.normmplayerisrunning) { + if (g_ActiveMenuThings[g_ActiveMenuIndex].allbots) { + for (i = 0; i < g_Vars.currentplayer->numaibuddies; i++) { + func0f197af4(g_MpPlayerChrs[g_Vars.currentplayer->aibuddynums[i]], g_ActiveMenuMpBotCommands[slot]); + } + } else { + func0f197af4(g_MpPlayerChrs[g_Vars.currentplayer->aibuddynums[g_ActiveMenuThings[g_ActiveMenuIndex].screenindex - 2]], g_ActiveMenuMpBotCommands[slot]); + } + } + } +} void activemenuGetSlotDetails(s32 slot, u32 *flags, char *label) { @@ -1066,12 +933,21 @@ void activemenuChangeScreen(s32 step) g_ActiveMenuThings[g_ActiveMenuIndex].screenindex += step; if (g_Vars.normmplayerisrunning && (g_MpSetup.options & MPOPTION_TEAMSENABLED)) { - if (g_ActiveMenuThings[g_ActiveMenuIndex].unk32) { - // Weapon selection, second function, and ...? + if (g_ActiveMenuThings[g_ActiveMenuIndex].allbots) { + // Weapon selection, second function, and bot command menu + + // @bug: This is missing a check to see if there are any bots on + // your team. In most cases this isn't a problem because the player + // opens the screen for a single bot then uses R to switch to all + // bots. When they do this without buddy bots the else part below + // runs first, limits the max screen index to 1 and all is good. + // But if you hold R as you switch to the bot command menu then this + // part runs first and sets the screen index to an invalid value, + // causing a crash. maxscreenindex = 2; } else { - // Num sims on team + 1 for weapon selection? - maxscreenindex = g_Vars.currentplayer->unk1be6 + 1; + // Weapon selection, second function and one for each AI buddy + maxscreenindex = g_Vars.currentplayer->numaibuddies + 1; } } else { // Solo missions, or MP with no teams @@ -1307,7 +1183,7 @@ void activemenuOpen(void) g_ActiveMenuThings[g_ActiveMenuIndex].unk18 = 0.3; g_ActiveMenuThings[g_ActiveMenuIndex].unk34 = 0; g_ActiveMenuThings[g_ActiveMenuIndex].unk33 = 0; - g_ActiveMenuThings[g_ActiveMenuIndex].unk32 = 0; + g_ActiveMenuThings[g_ActiveMenuIndex].allbots = false; } } diff --git a/src/include/commands.h b/src/include/commands.h index 1896f8f88..c06cf4334 100644 --- a/src/include/commands.h +++ b/src/include/commands.h @@ -2001,9 +2001,8 @@ * This may cause them to appear out of nowhere. * * If allowonscreen is 88 then the pad number will be interpreted as a chr - * number and the chr will be moved to the other chr instead. This is likely a - * hack used for debugging purposes. When using this value, the chr will not be - * moved if the destination chr is on screen. + * number and the chr will be moved to the other chr instead. This is used to + * warp a co-op AI buddy to the player when using the stealth command. */ #define chr_move_to_pad(chr, pad, allowonscreen, label) \ mkshort(0x00e2), \ diff --git a/src/include/constants.h b/src/include/constants.h index 12f134ab8..0f69f61d1 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -328,7 +328,7 @@ #define CHRHFLAG_00000080 0x00000080 // Not used in scripts #define CHRHFLAG_00000100 0x00000100 // Not used in scripts #define CHRHFLAG_00000200 0x00000200 // Not used in scripts -#define CHRHFLAG_00000400 0x00000400 // Related to coop buddy? Also used in Chicago +#define CHRHFLAG_PASSIVE 0x00000400 #define CHRHFLAG_KEEP_CORPSE 0x00000800 #define CHRHFLAG_BUDDY_PLACED 0x00001000 #define CHRHFLAG_00002000 0x00002000 // Globals, Rescue guards once disguised @@ -502,7 +502,7 @@ #define GAILIST_INIT_COOP_100 0x0012 // unused #define GAILIST_INIT_COOP_200 0x0013 // unused #define GAILIST_COOP_BUDDY 0x0014 -#define GAILIST_TEST_CUTSCENE_BUDDY 0x0015 // unused +#define GAILIST_AIBUDDY_STEALTH 0x0015 #define GAILIST_SHOW_OBJ_FAILED_MSG 0x0016 #define GAILIST_REBUILD_GROUPS 0x0017 #define GAILIST_DO_BORED_ANIMATION 0x0018 @@ -517,7 +517,7 @@ #define GAILIST_STOP_AND_IDLE 0x0021 #define GAILIST_COMMENT_ON_PLAYER_DEAD 0x0022 // unused #define GAILIST_DODGE 0x0023 -#define GAILIST_FOLLOW_BOND 0x0024 +#define GAILIST_FOLLOW_BOND 0x0024 #define GAILIST_POINTLESS 0x0025 // unused #define GAILIST_INIT_PSYCHOSIS 0x0026 #define GAILIST_PSYCHOSISED 0x0027 diff --git a/src/include/game/data/data_020df0.h b/src/include/game/data/data_020df0.h index 0cdf9ed4b..297b28d7e 100644 --- a/src/include/game/data/data_020df0.h +++ b/src/include/game/data/data_020df0.h @@ -322,6 +322,7 @@ extern u32 var800884b4; extern struct challenge g_MpChallenges[NUM_CHALLENGES]; extern u32 var800887c4; extern u32 var80088800; +extern u8 var80088804; extern u32 var80088808; extern u32 var8008880c; extern u32 var80088810; diff --git a/src/include/game/game_0b0420.h b/src/include/game/game_0b0420.h index 3da6638b5..6b13a8bf6 100644 --- a/src/include/game/game_0b0420.h +++ b/src/include/game/game_0b0420.h @@ -33,8 +33,8 @@ u32 func0f0b16a4(void); bool weaponHasFlag(s32 itemid, u32 flag); u32 func0f0b1804(void); u32 func0f0b184c(void); -u32 currentPlayerHasWeaponEquipped(u32 arg0); -u32 func0f0b1948(void); +s32 currentPlayerHasWeaponEquipped(u32 arg0); +void func0f0b1948(s32 weaponum, s32 arg1); u32 func0f0b1a18(void); u32 func0f0b1ad0(void); u32 func0f0b1af0(void); diff --git a/src/include/game/game_0fd660.h b/src/include/game/game_0fd660.h index ef9c2f85e..2622b15f6 100644 --- a/src/include/game/game_0fd660.h +++ b/src/include/game/game_0fd660.h @@ -4,10 +4,10 @@ #include "types.h" void func0f0fd660(void); -void func0f0fdd00(bool arg0); -void func0f0fdd84(void); +void activemenuSetAiBuddyTemperament(bool aggressive); +void activemenuSetAiBuddyStealth(void); s32 activemenuGetFirstBuddyIndex(void); -void activemenuApply(s32 arg0); +void activemenuApply(s32 slot); void activemenuGetSlotDetails(s32 slot, u32 *flags, char *dst); u32 func0f0fe848(void); s16 func0f0fea14(void); diff --git a/src/include/game/game_197600.h b/src/include/game/game_197600.h index 41502c80c..e54ed1360 100644 --- a/src/include/game/game_197600.h +++ b/src/include/game/game_197600.h @@ -4,7 +4,7 @@ #include "types.h" u32 func0f197600(void); -u32 func0f197af4(void); +void func0f197af4(struct chrdata *chr, s32 aibotcommand); void func0f197c00(struct chrdata *chr); u32 func0f197c70(void); u32 func0f197cf0(void); diff --git a/src/include/game/game_19c990.h b/src/include/game/game_19c990.h index aa752f252..532341c76 100644 --- a/src/include/game/game_19c990.h +++ b/src/include/game/game_19c990.h @@ -16,7 +16,7 @@ u32 func0f19cdf0(void); u32 func0f19cf20(s32 stage_index); // firing range related u32 func0f19d250(void); u32 func0f19d25c(void); -u32 func0f19d268(void); +u32 func0f19d268(s32 arg0); u32 func0f19d2e0(void); u32 func0f19d338(void); u32 func0f19d414(void); diff --git a/src/include/types.h b/src/include/types.h index 1e991a8b2..ed8b02702 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -2753,9 +2753,8 @@ struct player { /*0x1bdc*/ u32 unk1bdc; /*0x1be0*/ u32 unk1be0; /*0x1be4*/ u16 unk1be4; - /*0x1be6*/ u8 unk1be6; - /*0x1be8*/ u32 unk1be8; - /*0x1bec*/ u32 unk1bec; + /*0x1be6*/ u8 numaibuddies; + /*0x1be7*/ u8 aibuddynums[MAX_SIMULANTS]; /*0x1bf0*/ u32 bondexploding; /*0x1bf4*/ u32 bondnextexplode; /*0x1bf8*/ u32 bondcurexplode; @@ -4852,8 +4851,9 @@ struct activemenuthing { /*0x20*/ u8 weaponnums[8]; /*0x28*/ u32 unk28; /*0x2c*/ u32 unk2c; - /*0x30*/ u16 unk30; - /*0x32*/ u8 unk32; + /*0x30*/ u8 unk30; + /*0x31*/ u8 unk31; + /*0x32*/ u8 allbots; // when player holds R on the bot command screen /*0x33*/ u8 unk33; /*0x34*/ u8 unk34; };