From 2017d4a0299f29c5310ea0963e316eb1605bb8b8 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Thu, 30 Jan 2020 18:03:06 +1000 Subject: [PATCH] Attempt to decompile chrGoToPos --- src/game/chr/chr.c | 175 ++++++++++++++++++++++++++++----- src/game/chr/chraicommands.c | 4 +- src/game/game_114240.c | 6 +- src/game/game_187770.c | 22 ++--- src/game/game_1999b0.c | 10 +- src/include/constants.h | 4 + src/include/game/chr/chr.h | 18 ++-- src/include/game/game_0601b0.h | 2 +- src/include/game/game_114240.h | 6 +- src/include/game/game_187770.h | 4 +- src/include/types.h | 87 ++++++++-------- 11 files changed, 239 insertions(+), 99 deletions(-) diff --git a/src/game/chr/chr.c b/src/game/chr/chr.c index dc7c6d8e2..782587ffd 100644 --- a/src/game/chr/chr.c +++ b/src/game/chr/chr.c @@ -28509,9 +28509,9 @@ glabel func0f036fc0 /* f037084: 00000000 */ sll $zero,$zero,0x0 ); -s32 func0f037088(s32 arg0, s32 arg1, s32 arg2) +void func0f037088(struct chrdata *chr, s32 *arg1, s32 *arg2) { - return func0f036fc0(arg0, arg1, arg2, 0); + func0f036fc0(chr, arg1, arg2, 0); } GLOBAL_ASM( @@ -28623,7 +28623,7 @@ glabel func0f037124 void chrSetField66To0(struct chrdata *chr) { - chr->unk066 = 0; + chr->act_gopos.unk066 = 0; } GLOBAL_ASM( @@ -28736,15 +28736,15 @@ glabel func0f03733c /* f03738c: 000a59c0 */ sll $t3,$t2,0x7 /* f037390: 000c68c0 */ sll $t5,$t4,0x3 /* f037394: 016d2021 */ addu $a0,$t3,$t5 -/* f037398: 0fc45090 */ jal func0f114240 +/* f037398: 0fc45090 */ jal waypointSetHashThing /* f03739c: 00802825 */ or $a1,$a0,$zero /* f0373a0: 8fa40024 */ lw $a0,0x24($sp) /* f0373a4: 8e050048 */ lw $a1,0x48($s0) /* f0373a8: 2606004c */ addiu $a2,$s0,0x4c -/* f0373ac: 0fc4547b */ jal func0f1151ec +/* f0373ac: 0fc4547b */ jal waypointFindRoute /* f0373b0: 24070006 */ addiu $a3,$zero,0x6 /* f0373b4: 00002025 */ or $a0,$zero,$zero -/* f0373b8: 0fc45090 */ jal func0f114240 +/* f0373b8: 0fc45090 */ jal waypointSetHashThing /* f0373bc: 00002825 */ or $a1,$zero,$zero .L0f0373c0: /* f0373c0: 0fc0dcba */ jal func0f0372e8 @@ -30011,14 +30011,14 @@ glabel chrGoToPos .L0f03854c: /* f03854c: 27050028 */ addiu $a1,$t8,0x28 .L0f038550: -/* f038550: 0fc45095 */ jal func0f114254 +/* f038550: 0fc45095 */ jal waypointFindClosestToPos /* f038554: afaa0030 */ sw $t2,0x30($sp) /* f038558: 8faa0030 */ lw $t2,0x30($sp) /* f03855c: afa20088 */ sw $v0,0x88($sp) .L0f038560: /* f038560: 8fa40094 */ lw $a0,0x94($sp) /* f038564: 8fa50098 */ lw $a1,0x98($sp) -/* f038568: 0fc45095 */ jal func0f114254 +/* f038568: 0fc45095 */ jal waypointFindClosestToPos /* f03856c: afaa0030 */ sw $t2,0x30($sp) /* f038570: 8fab0088 */ lw $t3,0x88($sp) /* f038574: 8faa0030 */ lw $t2,0x30($sp) @@ -30034,16 +30034,16 @@ glabel chrGoToPos /* f03859c: 000c69c0 */ sll $t5,$t4,0x7 /* f0385a0: 000e78c0 */ sll $t7,$t6,0x3 /* f0385a4: 01af2021 */ addu $a0,$t5,$t7 -/* f0385a8: 0fc45090 */ jal func0f114240 +/* f0385a8: 0fc45090 */ jal waypointSetHashThing /* f0385ac: 00802825 */ or $a1,$a0,$zero /* f0385b0: 8fa40088 */ lw $a0,0x88($sp) /* f0385b4: 8fa50084 */ lw $a1,0x84($sp) /* f0385b8: 27a6006c */ addiu $a2,$sp,0x6c -/* f0385bc: 0fc4547b */ jal func0f1151ec +/* f0385bc: 0fc4547b */ jal waypointFindRoute /* f0385c0: 24070006 */ addiu $a3,$zero,0x6 /* f0385c4: afa20034 */ sw $v0,0x34($sp) /* f0385c8: 00002025 */ or $a0,$zero,$zero -/* f0385cc: 0fc45090 */ jal func0f114240 +/* f0385cc: 0fc45090 */ jal waypointSetHashThing /* f0385d0: 00002825 */ or $a1,$zero,$zero /* f0385d4: 8faa0030 */ lw $t2,0x30($sp) .L0f0385d8: @@ -30204,6 +30204,133 @@ glabel chrGoToPos /* f038814: 00000000 */ sll $zero,$zero,0x0 ); +//u32 chrGoToPos(struct chrdata *chr, struct coord *pos, s16 *room, u32 speed) +//{ +// struct prop *prop = chr->prop; // 140 +// s32 *nextwaypoint; // 136 +// s32 *lastwaypoint; // 132 +// s32 *waypoints[MAX_CHRWAYPOINTS]; // 108 +// s32 auStack52[4]; // 92 +// s32 auStack68[3]; // 76 +// bool same2; // 72 +// struct coord prevpos; // 56 +// s32 numwaypoints; // 52 +// bool same; // 48 +// s32 i; +// +// same = (chr->actiontype == ACT_GOPOS); +// +// // 470 +// if (same) { +// same = (chr->act_gopos.unk065 & 0x3) == (speed & 0x3); +// +// // 490 +// if (same) { +// same = func0f02e064(chr) == 0; +// } +// } +// +// // 4b0 +// same2 = same; +// same = same && chr->act_gopos.unk068 == MAX_CHRWAYPOINTS; +// +// // 4c4 +// numwaypoints = 0; +// +// // 4e8 +// for (i = 0; chr->prop->rooms[i] != -1; i++) { +// chr->oldrooms[i] = chr->prop->rooms[i]; +// } +// +// // 508 +// chr->oldrooms[i] = -1; +// +// // 51c +// if (same2 && same && chr->act_gopos.waypoints[chr->act_gopos.nextwaypointindex]) { +// nextwaypoint = chr->act_gopos.waypoints[chr->act_gopos.nextwaypointindex]; +// } else { +// // 54c +// nextwaypoint = waypointFindClosestToPos(&prop->pos, &prop->rooms[0]); +// } +// +// // 560 +// lastwaypoint = waypointFindClosestToPos(pos, room); +// +// // 57c +// if (nextwaypoint && lastwaypoint) { +// // 588 +// waypointSetHashThing( +// ((g_Vars.lvframe60 >> 9) << 7) + chr->chrnum * 8, +// ((g_Vars.lvframe60 >> 9) << 7) + chr->chrnum * 8); +// numwaypoints = waypointFindRoute(nextwaypoint, lastwaypoint, &waypoints[0], MAX_CHRWAYPOINTS); +// waypointSetHashThing(0, 0); +// } +// +// // 5d8 +// if (numwaypoints > 1) { +// if (same2 && same) { +// func0f0379b0(chr, &prevpos); +// } else { +// prevpos.x = prop->pos.x; +// prevpos.y = prop->pos.y; +// prevpos.z = prop->pos.z; +// } +// +// chrStopFiring(chr); +// chr->actiontype = ACT_GOPOS; +// chr->act_gopos.pos.x = pos->x; +// chr->act_gopos.pos.y = pos->y; +// chr->act_gopos.pos.z = pos->z; +// func0f0657a4(room, &chr->act_gopos.rooms[0]); +// chr->act_gopos.nextwaypointindex = 0; +// chr->act_gopos.numwaypoints = numwaypoints; +// chr->act_gopos.unk065 = 4 | speed; +// chr->act_gopos.unk0ac = 0; +// chr->unk32c_21 = 0; +// chr->act_gopos.unk090 = random() % 100; +// chr->act_gopos.unk06b = 0; +// +// // 6c4 +// if (same2 == 0) { +// chr->act_gopos.unk0a8 = -1; +// } +// +// // 6d0 +// for (i = 0; i < MAX_CHRWAYPOINTS; i++) { +// chr->act_gopos.waypoints[i] = waypoints[i]; +// } +// +// func0f0372e8(chr); +// chr->goposforce = -1; +// chr->sleep = 0; +// chr->unk32c_00 = 0; +// chr->act_gopos.unk065 &= 0xff1f; +// func0f037088(chr, &auStack52[0], &auStack68[0]); +// +// if ((!same2 || same) && +// g_Vars.mplayerisrunning == 0 && +// (prop->flags & (PROPFLAG_80 | PROPFLAG_40 | PROPFLAG_02)) == 0 && +// func0f036c08(chr, &auStack52[0], &auStack68[0]) && +// chr->unk32c_00 >= 0) { +// func0f036ee4(chr, &chr->act_gopos.unk068, &auStack52[0], &prevpos); +// } +// +// if (chr->act_gopos.unk068 != MAX_CHRWAYPOINTS && func0001db94(chr->unk020) != 0 && !chr->unk2d4) { +// chr->hidden |= CHRHFLAG_00200000; +// return true; +// } else { +// if (!same2) { +// func0f037b70(chr); +// } +// +// chr->hidden &= ~CHRHFLAG_00200000; +// return true; +// } +// } +// +// return false; +//} + struct path *pathFindById(u32 path_id) { s32 i = 0; @@ -49376,7 +49503,7 @@ glabel func0f04a37c /* f04a39c: afb3002c */ sw $s3,0x2c($sp) /* f04a3a0: afb20028 */ sw $s2,0x28($sp) /* f04a3a4: afb10024 */ sw $s1,0x24($sp) -/* f04a3a8: 0fc45095 */ jal func0f114254 +/* f04a3a8: 0fc45095 */ jal waypointFindClosestToPos /* f04a3ac: afa70044 */ sw $a3,0x44($sp) /* f04a3b0: 10400044 */ beqz $v0,.L0f04a4c4 /* f04a3b4: 00409825 */ or $s3,$v0,$zero @@ -49492,12 +49619,12 @@ glabel func0f04a4ec /* f04a52c: 02202025 */ or $a0,$s1,$zero /* f04a530: 26040008 */ addiu $a0,$s0,0x8 /* f04a534: 26050028 */ addiu $a1,$s0,0x28 -/* f04a538: 0fc45095 */ jal func0f114254 +/* f04a538: 0fc45095 */ jal waypointFindClosestToPos /* f04a53c: afa20048 */ sw $v0,0x48($sp) /* f04a540: 8fa30048 */ lw $v1,0x48($sp) /* f04a544: 00408025 */ or $s0,$v0,$zero /* f04a548: 24640008 */ addiu $a0,$v1,0x8 -/* f04a54c: 0fc45095 */ jal func0f114254 +/* f04a54c: 0fc45095 */ jal waypointFindClosestToPos /* f04a550: 24650028 */ addiu $a1,$v1,0x28 /* f04a554: 8fa60024 */ lw $a2,0x24($sp) /* f04a558: 12000040 */ beqz $s0,.L0f04a65c @@ -49513,16 +49640,16 @@ glabel func0f04a4ec /* f04a580: 000fc1c0 */ sll $t8,$t7,0x7 /* f04a584: 001940c0 */ sll $t0,$t9,0x3 /* f04a588: 03082021 */ addu $a0,$t8,$t0 -/* f04a58c: 0fc45090 */ jal func0f114240 +/* f04a58c: 0fc45090 */ jal waypointSetHashThing /* f04a590: 00802825 */ or $a1,$a0,$zero /* f04a594: 02002025 */ or $a0,$s0,$zero /* f04a598: 8fa50040 */ lw $a1,0x40($sp) /* f04a59c: 27a60034 */ addiu $a2,$sp,0x34 -/* f04a5a0: 0fc4547b */ jal func0f1151ec +/* f04a5a0: 0fc4547b */ jal waypointFindRoute /* f04a5a4: 24070003 */ addiu $a3,$zero,0x3 /* f04a5a8: 00408025 */ or $s0,$v0,$zero /* f04a5ac: 00002025 */ or $a0,$zero,$zero -/* f04a5b0: 0fc45090 */ jal func0f114240 +/* f04a5b0: 0fc45090 */ jal waypointSetHashThing /* f04a5b4: 00002825 */ or $a1,$zero,$zero /* f04a5b8: 2a010003 */ slti $at,$s0,0x3 /* f04a5bc: 14200027 */ bnez $at,.L0f04a65c @@ -49538,14 +49665,14 @@ glabel func0f04a4ec /* f04a5e0: 000c69c0 */ sll $t5,$t4,0x7 /* f04a5e4: 000e78c0 */ sll $t7,$t6,0x3 /* f04a5e8: 01af2021 */ addu $a0,$t5,$t7 -/* f04a5ec: 0fc45090 */ jal func0f114240 +/* f04a5ec: 0fc45090 */ jal waypointSetHashThing /* f04a5f0: 00802825 */ or $a1,$a0,$zero /* f04a5f4: 02002025 */ or $a0,$s0,$zero /* f04a5f8: 0fc45578 */ jal func0f1155e0 /* f04a5fc: 8fa50040 */ lw $a1,0x40($sp) /* f04a600: 00408025 */ or $s0,$v0,$zero /* f04a604: 00002025 */ or $a0,$zero,$zero -/* f04a608: 0fc45090 */ jal func0f114240 +/* f04a608: 0fc45090 */ jal waypointSetHashThing /* f04a60c: 00002825 */ or $a1,$zero,$zero /* f04a610: 52000013 */ beqzl $s0,.L0f04a660 /* f04a614: 00001025 */ or $v0,$zero,$zero @@ -49967,12 +50094,12 @@ glabel chrIsInLoadedRoom /* f04ad80: 10000041 */ beqz $zero,.L0f04ae88 /* f04ad84: 00001025 */ or $v0,$zero,$zero .L0f04ad88: -/* f04ad88: 0fc45095 */ jal func0f114254 +/* f04ad88: 0fc45095 */ jal waypointFindClosestToPos /* f04ad8c: 02a02825 */ or $a1,$s5,$zero /* f04ad90: 26330028 */ addiu $s3,$s1,0x28 /* f04ad94: 00408025 */ or $s0,$v0,$zero /* f04ad98: 02602825 */ or $a1,$s3,$zero -/* f04ad9c: 0fc45095 */ jal func0f114254 +/* f04ad9c: 0fc45095 */ jal waypointFindClosestToPos /* f04ada0: 02c02025 */ or $a0,$s6,$zero /* f04ada4: 12000037 */ beqz $s0,.L0f04ae84 /* f04ada8: 00408825 */ or $s1,$v0,$zero @@ -49985,16 +50112,16 @@ glabel chrIsInLoadedRoom /* f04adc4: 000849c0 */ sll $t1,$t0,0x7 /* f04adc8: 000b60c0 */ sll $t4,$t3,0x3 /* f04adcc: 012c2021 */ addu $a0,$t1,$t4 -/* f04add0: 0fc45090 */ jal func0f114240 +/* f04add0: 0fc45090 */ jal waypointSetHashThing /* f04add4: 00802825 */ or $a1,$a0,$zero /* f04add8: 02202025 */ or $a0,$s1,$zero /* f04addc: 02002825 */ or $a1,$s0,$zero /* f04ade0: 27a600b4 */ addiu $a2,$sp,0xb4 -/* f04ade4: 0fc4547b */ jal func0f1151ec +/* f04ade4: 0fc4547b */ jal waypointFindRoute /* f04ade8: 24070005 */ addiu $a3,$zero,0x5 /* f04adec: 00408025 */ or $s0,$v0,$zero /* f04adf0: 00002025 */ or $a0,$zero,$zero -/* f04adf4: 0fc45090 */ jal func0f114240 +/* f04adf4: 0fc45090 */ jal waypointSetHashThing /* f04adf8: 00002825 */ or $a1,$zero,$zero /* f04adfc: 2a010003 */ slti $at,$s0,0x3 /* f04ae00: 14200020 */ bnez $at,.L0f04ae84 diff --git a/src/game/chr/chraicommands.c b/src/game/chr/chraicommands.c index f518d52fa..cb9d3d130 100644 --- a/src/game/chr/chraicommands.c +++ b/src/game/chr/chraicommands.c @@ -912,7 +912,7 @@ bool ai00f0(void) { u8 *cmd = g_Vars.ailist + g_Vars.aioffset; - if (g_Vars.chrdata->actiontype == ACT_ATTACK && !g_Vars.chrdata->unk058 && g_Vars.chrdata->act_attack.unk04c & 0x40) { + if (g_Vars.chrdata->actiontype == ACT_ATTACK && !g_Vars.chrdata->act_attack.unk058 && g_Vars.chrdata->act_attack.unk04c & 0x40) { g_Vars.aioffset = chraiGoToLabel(g_Vars.ailist, g_Vars.aioffset, cmd[2]); } else { g_Vars.aioffset += 3; @@ -1566,7 +1566,7 @@ bool aiIfPathStarted(void) { u8 *cmd = g_Vars.ailist + g_Vars.aioffset; - if (g_Vars.chrdata->actiontype == ACT_PATROL || (g_Vars.chrdata->actiontype == ACT_GOPOS && (g_Vars.chrdata->speed & 8))) { + if (g_Vars.chrdata->actiontype == ACT_PATROL || (g_Vars.chrdata->actiontype == ACT_GOPOS && g_Vars.chrdata->act_gopos.unk065 & 8)) { g_Vars.aioffset = chraiGoToLabel(g_Vars.ailist, g_Vars.aioffset, cmd[2]); } else { g_Vars.aioffset += 3; diff --git a/src/game/game_114240.c b/src/game/game_114240.c index 8a3803615..a9f78948a 100644 --- a/src/game/game_114240.c +++ b/src/game/game_114240.c @@ -16,7 +16,7 @@ const char var7f1b3a80[] = "padhalllv.c"; const u32 var7f1b3a8c[] = {0x00000000}; GLOBAL_ASM( -glabel func0f114240 +glabel waypointSetHashThing /* f114240: 3c028007 */ lui $v0,%hi(var80075ca0) /* f114244: 24425ca0 */ addiu $v0,$v0,%lo(var80075ca0) /* f114248: ac440000 */ sw $a0,0x0($v0) @@ -25,7 +25,7 @@ glabel func0f114240 ); GLOBAL_ASM( -glabel func0f114254 +glabel waypointFindClosestToPos /* f114254: 27bdfc60 */ addiu $sp,$sp,-928 /* f114258: afbf0054 */ sw $ra,0x54($sp) /* f11425c: afbe0050 */ sw $s8,0x50($sp) @@ -1161,7 +1161,7 @@ glabel func0f11505c ); GLOBAL_ASM( -glabel func0f1151ec +glabel waypointFindRoute /* f1151ec: 27bdff90 */ addiu $sp,$sp,-112 /* f1151f0: afb00018 */ sw $s0,0x18($sp) /* f1151f4: 3c10800a */ lui $s0,0x800a diff --git a/src/game/game_187770.c b/src/game/game_187770.c index 77b3969ac..df0779e75 100644 --- a/src/game/game_187770.c +++ b/src/game/game_187770.c @@ -12559,24 +12559,24 @@ void func0f1924ac(struct chrdata *chr, struct prop *prop) chr->unk2d4->unk0d8 = 1; } -void func0f1924e8(struct chrdata *chr, struct coord *pos, s32 *arg2, f32 arg3) +void func0f1924e8(struct chrdata *chr, struct coord *pos, s16 *room, f32 arg3) { chr->unk2d4->unk079 = 2; chr->unk2d4->unk08c.x = pos->x; chr->unk2d4->unk08c.y = pos->y; chr->unk2d4->unk08c.z = pos->z; - func0f0657a4(arg2, &chr->unk2d4->unk07a); + func0f0657a4(room, &chr->unk2d4->rooms[0]); chr->unk2d4->unk098 = arg3; chr->unk2d4->unk0d8 = 1; } -void func0f19257c(struct chrdata *chr, struct coord *pos, s32 *arg2, f32 arg3) +void func0f19257c(struct chrdata *chr, struct coord *pos, s16 *room, f32 arg3) { chr->unk2d4->unk079 = 3; chr->unk2d4->unk08c.x = pos->x; chr->unk2d4->unk08c.y = pos->y; chr->unk2d4->unk08c.z = pos->z; - func0f0657a4(arg2, &chr->unk2d4->unk07a); + func0f0657a4(room, &chr->unk2d4->rooms[0]); chr->unk2d4->unk098 = arg3; chr->unk2d4->unk0d8 = 1; } @@ -17309,11 +17309,11 @@ glabel func0f194b40 /* f196be8: 8e83001c */ lw $v1,0x1c($s4) /* f196bec: 00408025 */ or $s0,$v0,$zero /* f196bf0: 24640008 */ addiu $a0,$v1,0x8 -/* f196bf4: 0fc45095 */ jal func0f114254 +/* f196bf4: 0fc45095 */ jal waypointFindClosestToPos /* f196bf8: 24650028 */ addiu $a1,$v1,0x28 /* f196bfc: 00408825 */ or $s1,$v0,$zero /* f196c00: 26040008 */ addiu $a0,$s0,0x8 -/* f196c04: 0fc45095 */ jal func0f114254 +/* f196c04: 0fc45095 */ jal waypointFindClosestToPos /* f196c08: 26050028 */ addiu $a1,$s0,0x28 /* f196c0c: 12200014 */ beqz $s1,.L0f196c60 /* f196c10: 00408025 */ or $s0,$v0,$zero @@ -17325,16 +17325,16 @@ glabel func0f194b40 /* f196c28: 000b71c0 */ sll $t6,$t3,0x7 /* f196c2c: 000cc0c0 */ sll $t8,$t4,0x3 /* f196c30: 01d82021 */ addu $a0,$t6,$t8 -/* f196c34: 0fc45090 */ jal func0f114240 +/* f196c34: 0fc45090 */ jal waypointSetHashThing /* f196c38: 00802825 */ or $a1,$a0,$zero /* f196c3c: 02002025 */ or $a0,$s0,$zero /* f196c40: 02202825 */ or $a1,$s1,$zero /* f196c44: 264601e8 */ addiu $a2,$s2,0x1e8 -/* f196c48: 0fc4547b */ jal func0f1151ec +/* f196c48: 0fc4547b */ jal waypointFindRoute /* f196c4c: 24070008 */ addiu $a3,$zero,0x8 /* f196c50: ae420208 */ sw $v0,0x208($s2) /* f196c54: 00002025 */ or $a0,$zero,$zero -/* f196c58: 0fc45090 */ jal func0f114240 +/* f196c58: 0fc45090 */ jal waypointSetHashThing /* f196c5c: 00002825 */ or $a1,$zero,$zero .L0f196c60: /* f196c60: 0fc663bb */ jal func0f198eec @@ -17959,7 +17959,7 @@ void func0f197544(struct chrdata *chr) struct chr2d4 *chr2d4 = chr->unk2d4; if (chr->myaction == MA_AIBOTGETITEM) { - if (chr->act_aibotgetitem.unk4c[chr->unk064] == 0) { + if (chr->act_gopos.waypoints[chr->act_gopos.nextwaypointindex] == 0) { struct prop *prop = chr2d4->prop; if (prop && !prop->parent && prop->timetoregen == 0) { @@ -17974,6 +17974,6 @@ void func0f197544(struct chrdata *chr) } if (!pass) { - chrGoToPos(chr, &chr->act_aibotgetitem.pos, &chr->act_aibotgetitem.rooms[0], chr->speed); + chrGoToPos(chr, &chr->act_gopos.pos, &chr->act_gopos.rooms[0], chr->act_gopos.unk065); } } diff --git a/src/game/game_1999b0.c b/src/game/game_1999b0.c index 0275c7513..8a9899d6d 100644 --- a/src/game/game_1999b0.c +++ b/src/game/game_1999b0.c @@ -1056,11 +1056,11 @@ glabel func0f19a6d0 /* f19a6dc: afa50054 */ sw $a1,0x54($sp) /* f19a6e0: 00a02025 */ or $a0,$a1,$zero /* f19a6e4: afa60058 */ sw $a2,0x58($sp) -/* f19a6e8: 0fc45095 */ jal func0f114254 +/* f19a6e8: 0fc45095 */ jal waypointFindClosestToPos /* f19a6ec: 00e02825 */ or $a1,$a3,$zero /* f19a6f0: afa2004c */ sw $v0,0x4c($sp) /* f19a6f4: 8fa40058 */ lw $a0,0x58($sp) -/* f19a6f8: 0fc45095 */ jal func0f114254 +/* f19a6f8: 0fc45095 */ jal waypointFindClosestToPos /* f19a6fc: 8fa50060 */ lw $a1,0x60($sp) /* f19a700: 8fae004c */ lw $t6,0x4c($sp) /* f19a704: afa20048 */ sw $v0,0x48($sp) @@ -1075,16 +1075,16 @@ glabel func0f19a6d0 /* f19a728: 0018c9c0 */ sll $t9,$t8,0x7 /* f19a72c: 000950c0 */ sll $t2,$t1,0x3 /* f19a730: 032a2021 */ addu $a0,$t9,$t2 -/* f19a734: 0fc45090 */ jal func0f114240 +/* f19a734: 0fc45090 */ jal waypointSetHashThing /* f19a738: 00802825 */ or $a1,$a0,$zero /* f19a73c: 8fa4004c */ lw $a0,0x4c($sp) /* f19a740: 8fa50048 */ lw $a1,0x48($sp) /* f19a744: 27a60030 */ addiu $a2,$sp,0x30 -/* f19a748: 0fc4547b */ jal func0f1151ec +/* f19a748: 0fc4547b */ jal waypointFindRoute /* f19a74c: 24070006 */ addiu $a3,$zero,0x6 /* f19a750: afa2002c */ sw $v0,0x2c($sp) /* f19a754: 00002025 */ or $a0,$zero,$zero -/* f19a758: 0fc45090 */ jal func0f114240 +/* f19a758: 0fc45090 */ jal waypointSetHashThing /* f19a75c: 00002825 */ or $a1,$zero,$zero /* f19a760: 8fab002c */ lw $t3,0x2c($sp) /* f19a764: 8fac0030 */ lw $t4,0x30($sp) diff --git a/src/include/constants.h b/src/include/constants.h index 8168b6436..76ecab2ba 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -554,6 +554,7 @@ #define MA_FACING 53 #define MA_PUNCHING 54 +#define MAX_CHRWAYPOINTS 6 #define MAX_DANGEROUSPROPS 12 #define MAX_LIFTS 10 #define MAX_MPCHRS (4 + MAX_SIMULANTS) @@ -1487,7 +1488,10 @@ #define PLAYERFLAG_NOCONTROL 0x00000002 +#define PROPFLAG_02 0x02 #define PROPFLAG_HIDDEN 0x04 +#define PROPFLAG_40 0x40 +#define PROPFLAG_80 0x80 #define PROPTYPE_OBJ 1 #define PROPTYPE_DOOR 2 diff --git a/src/include/game/chr/chr.h b/src/include/game/chr/chr.h index 6300581cb..5f815a25c 100644 --- a/src/include/game/chr/chr.h +++ b/src/include/game/chr/chr.h @@ -124,7 +124,7 @@ u32 func0f02d4fc(void); u32 func0f02dbac(void); u32 func0f02ddbc(void); u32 func0f02dff0(void); -u32 func0f02e064(void); +u32 func0f02e064(struct chrdata *chr); u32 func0f02e124(void); u32 func0f02e15c(void); u32 func0f02e1cc(void); @@ -199,15 +199,15 @@ u32 func0f0369cc(void); u32 func0f036aa0(void); u32 func0f036b10(void); u32 func0f036b98(void); -u32 func0f036c08(void); -u32 func0f036ee4(void); -s32 func0f036fc0(s32 arg0, s32 arg1, s32 arg2, s32 arg3); -s32 func0f037088(s32 arg0, s32 arg1, s32 arg2); +u32 func0f036c08(struct chrdata *chr, s32 *arg1, s32 *arg2); +void func0f036ee4(struct chrdata *chr, s8 *maxwaypoints, s32 *arg2, struct coord *prevpos); +void func0f036fc0(struct chrdata *chr, s32 *arg1, s32 *arg2, s32 arg3); +void func0f037088(struct chrdata *chr, s32 *arg1, s32 *arg2); u32 func0f0370a8(void); u32 func0f037124(void); void chrSetField66To0(struct chrdata *chr); u32 func0f037224(void); -u32 func0f0372e8(void); +void func0f0372e8(struct chrdata *chr); u32 func0f03733c(void); u32 func0f0373dc(void); u32 func0f0374a0(void); @@ -216,9 +216,9 @@ s32 func0f037560(s32 arg0, s32 arg1, s32 arg2); u32 func0f037580(void); u32 func0f0375b0(void); u32 func0f0375e8(void); -u32 func0f0379b0(void); -u32 func0f037b70(void); -u32 chrGoToPos(struct chrdata *chr, struct coord *pos, s16 *room_id, u32 speed); +void func0f0379b0(struct chrdata *chr, struct coord *pos); +void func0f037b70(struct chrdata *chr); +u32 chrGoToPos(struct chrdata *chr, struct coord *pos, s16 *room, u32 speed); struct path *pathFindById(u32 path_id); u32 func0f038868(void); void func0f038b9c(struct chrdata *chr, struct path *path); diff --git a/src/include/game/game_0601b0.h b/src/include/game/game_0601b0.h index 775674dee..18827844e 100644 --- a/src/include/game/game_0601b0.h +++ b/src/include/game/game_0601b0.h @@ -39,7 +39,7 @@ u32 func0f064a24(void); u32 func0f064ce8(void); u32 func0f0654e8(void); u32 func0f06554c(void); -void func0f0657a4(s32 *arg0, s8 *arg1); +void func0f0657a4(s16 *room, s16 *rooms); u32 func0f0657d8(void); bool arrayIntersects(s16 *a, s16 *b); u32 func0f0658e8(void); diff --git a/src/include/game/game_114240.h b/src/include/game/game_114240.h index 144f4e3da..0508723ee 100644 --- a/src/include/game/game_114240.h +++ b/src/include/game/game_114240.h @@ -3,8 +3,8 @@ #include #include "types.h" -u32 func0f114240(void); -u32 func0f114254(void); +void waypointSetHashThing(s32 hash1, s32 hash2); +s32 *waypointFindClosestToPos(struct coord *pos, s16 *room); u32 func0f114810(void); u32 func0f114958(void); u32 func0f1149b0(void); @@ -17,7 +17,7 @@ u32 func0f114de0(void); u32 func0f114ee4(void); u32 func0f114f70(void); u32 func0f11505c(void); -u32 func0f1151ec(void); +s32 waypointFindRoute(s32 *from, s32 *to, s32 **dst, s32 maxwaypoints); u32 func0f115390(void); u32 func0f1153c4(void); u32 func0f1154cc(void); diff --git a/src/include/game/game_187770.h b/src/include/game/game_187770.h index 7a4c895c7..4ca92274b 100644 --- a/src/include/game/game_187770.h +++ b/src/include/game/game_187770.h @@ -142,8 +142,8 @@ char *mpGetBotCommandName(s32 command); void func0f192438(struct chrdata *chr, struct prop *prop); void func0f192474(struct chrdata *chr, struct prop *prop); void func0f1924ac(struct chrdata *chr, struct prop *prop); -void func0f1924e8(struct chrdata *chr, struct coord *pos, s32 *arg2, f32 arg3); -void func0f19257c(struct chrdata *chr, struct coord *pos, s32 *arg2, f32 arg3); +void func0f1924e8(struct chrdata *chr, struct coord *pos, s16 *room, f32 arg3); +void func0f19257c(struct chrdata *chr, struct coord *pos, s16 *room, f32 arg3); void func0f192610(struct chrdata *chr, s32 arg1); u32 func0f192628(void); u32 func0f19277c(void); diff --git a/src/include/types.h b/src/include/types.h index b8c57323b..b77da7f6a 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -199,7 +199,7 @@ struct chr2d4 { /*0x077*/ s8 unk077; /*0x078*/ u8 unk078; /*0x079*/ u8 unk079; - /*0x07a*/ s8 unk07a; + /*0x07a*/ s16 rooms[1]; /*0x07c*/ u32 unk07c; /*0x080*/ u32 unk080; /*0x084*/ u32 unk084; @@ -375,6 +375,8 @@ struct act_attack { /*0x48*/ u32 unk048; /*0x4c*/ u32 unk04c; /*0x50*/ u32 unk050; + /*0x54*/ u32 unk054; + /*0x58*/ u32 unk058; }; struct act_sidestep { @@ -392,6 +394,43 @@ struct act_runpos { /*0x40*/ f32 unk040; }; +struct act_gopos { + /*0x02c*/ struct coord pos; + /*0x038*/ s16 rooms[8]; + /*0x048*/ s32 numwaypoints; + /*0x04c*/ s32 *waypoints[MAX_CHRWAYPOINTS]; + /*0x064*/ u8 nextwaypointindex; + + // This doesn't appear to be a proper bitfield, but is used as one + // ....x... = on preset path + // ......xx = speed + /*0x065*/ u8 unk065; + + /*0x066*/ s16 unk066; + /*0x068*/ s8 unk068; + /*0x069*/ u8 unk069; + /*0x06a*/ u8 unk06a; + /*0x06b*/ u8 unk06b; + /*0x06c*/ u16 unk06c; + /*0x06e*/ u8 unk06e; + /*0x070*/ u32 unk070; + /*0x074*/ u32 unk074; + /*0x078*/ u32 unk078; + /*0x07c*/ u32 unk07c; + /*0x080*/ u32 unk080; + /*0x084*/ u32 unk084; + /*0x088*/ u32 unk088; + /*0x08c*/ u32 unk08c; + /*0x090*/ u32 unk090; + /*0x094*/ u32 unk094; + /*0x098*/ u32 unk098; + /*0x09c*/ u32 unk09c; + /*0x0a0*/ u32 unk0a0; + /*0x0a4*/ u32 unk0a4; + /*0x0a8*/ s32 unk0a8; + /*0x0ac*/ f32 unk0ac; +}; + struct act_surprised { /*0x2c*/ u32 unk02c; }; @@ -411,13 +450,6 @@ struct act_attackamount { /*0x34*/ s8 unk034; }; -struct act_aibotgetitem { - /*0x2c*/ struct coord pos; - /*0x38*/ s16 rooms[8]; - /*0x48*/ u32 unk48; - /*0x4c*/ s32 unk4c[1]; -}; - struct act_skjump { /*0x2c*/ u32 unk00; /*0x30*/ u32 unk30; @@ -475,39 +507,13 @@ struct chrdata { struct act_sidestep act_sidestep; struct act_jumpout act_jumpout; struct act_runpos act_runpos; + struct act_gopos act_gopos; struct act_surprised act_surprised; struct act_throwgrenade act_throwgrenade; struct act_attackamount act_attackamount; - struct act_aibotgetitem act_aibotgetitem; struct act_skjump act_skjump; }; - /*0x054*/ u32 unk054; - /*0x058*/ void *unk058; - /*0x05c*/ u32 unk05c; - /*0x060*/ u32 unk060; - /*0x064*/ u8 unk064; - /*0x065*/ u8 speed; - /*0x066*/ s16 unk066; - /*0x068*/ u32 unk068; - /*0x06c*/ u16 unk06c; - /*0x06e*/ u8 unk06e; - /*0x070*/ u32 unk070; - /*0x074*/ u32 unk074; - /*0x078*/ u32 unk078; - /*0x07c*/ u32 unk07c; - /*0x080*/ u32 unk080; - /*0x084*/ u32 unk084; - /*0x088*/ u32 unk088; - /*0x08c*/ u32 unk08c; - /*0x090*/ u32 unk090; - /*0x094*/ u32 unk094; - /*0x098*/ u32 unk098; - /*0x09c*/ u32 unk09c; - /*0x0a0*/ u32 unk0a0; - /*0x0a4*/ u32 unk0a4; - /*0x0a8*/ u32 unk0a8; - /*0x0ac*/ u32 unk0ac; /*0x0b0*/ u32 sumground; /*0x0b4*/ f32 manground; /*0x0b8*/ f32 ground; @@ -574,7 +580,7 @@ struct chrdata { /*0x194*/ u32 magicframe; /*0x198*/ u32 magicspeed; /*0x19c*/ u16 magicanim; - /*0x19e*/ u16 goposforce; + /*0x19e*/ s16 goposforce; /*0x1a0*/ s32 bdlist[60]; /*0x290*/ u8 bdstart; /*0x291*/ u8 goposhitcount; @@ -593,7 +599,7 @@ struct chrdata { /*0x2b1*/ u8 voicebox; /*0x2b2*/ u16 floorroom; /*0x2b4*/ u32 unk2b4; - /*0x2b8*/ u16 oldrooms[8]; + /*0x2b8*/ s16 oldrooms[8]; /*0x2c8*/ struct coord runfrompos; /*0x2d4*/ struct chr2d4 *unk2d4; /*0x2d8*/ s16 blurdrugamount; @@ -623,12 +629,15 @@ struct chrdata { u8 unk32c_08 : 1; u8 pouncebits : 3; - u8 unk32c_12 : 2; + u8 unk32c_12 : 1; + u8 unk32c_13 : 1; u8 darkroomthing : 1; u8 unk32c_15 : 1; u8 p1p2 : 2; - u8 unk32c_18 : 6; + u8 unk32c_18 : 3; + u8 unk32c_21 : 1; + u8 unk32c_22 : 2; u8 specialdie : 8;