diff --git a/src/game/propobj.c b/src/game/propobj.c index 4b2b1e302..9b5de104b 100644 --- a/src/game/propobj.c +++ b/src/game/propobj.c @@ -21987,7 +21987,7 @@ glabel var7f1aa580 /* f079038: 8fa800ac */ lw $t0,0xac($sp) /* f07903c: 8fa400b0 */ lw $a0,0xb0($sp) /* f079040: afa800ac */ sw $t0,0xac($sp) -/* f079044: 0fc67ce7 */ jal func0f19f39c +/* f079044: 0fc67ce7 */ jal frChooseAutogunTarget /* f079048: 24840008 */ addiu $a0,$a0,0x8 /* f07904c: 3c09800a */ lui $t1,%hi(g_Vars) /* f079050: 8fa800ac */ lw $t0,0xac($sp) diff --git a/src/game/training.c b/src/game/training.c index feb0ef607..b4b31dc5a 100644 --- a/src/game/training.c +++ b/src/game/training.c @@ -2160,7 +2160,7 @@ bool func0f19f2ec(struct prop *prop, struct coord *pos) return false; } - angle = func0f19f294(&prop->pos, g_FiringRangeData.targets[i].unk28, pos); + angle = func0f19f294(&prop->pos, g_FiringRangeData.targets[i].angle, pos); //if (angle > DEG2RAD(90) && angle < DEG2RAD(270)) { if (angle > 1.5707963705063f && angle < 4.7116389274597f) { @@ -2175,7 +2175,7 @@ bool func0f19f2ec(struct prop *prop, struct coord *pos) } GLOBAL_ASM( -glabel func0f19f39c +glabel frChooseAutogunTarget .late_rodata glabel var7f1b94b8 .word 0x4096c5bf @@ -2289,6 +2289,47 @@ glabel var7f1b94bc /* f19f520: 27bd00d0 */ addiu $sp,$sp,0xd0 ); +// Regalloc: s3 and s4 are swapped. +// s3 should be autogunpos and s4 should be facingtargets. +//struct prop *frChooseAutogunTarget(struct coord *autogunpos) +//{ +// f32 closestdist = 0x20000000; +// s32 facingtargets[ARRAYCOUNT(g_FiringRangeData.targets)]; +// s32 len = 0; +// struct prop *closesttarget = NULL; +// s32 i; +// +// // Make list of targets which are facing the laptop gun +// for (i = 0; i < ARRAYCOUNT(g_FiringRangeData.targets); i++) { +// if (g_FiringRangeData.targets[i].unk00_01 +// && g_FiringRangeData.targets[i].unk00_03 == 0 +// && g_FiringRangeData.targets[i].unk00_02) { +// f32 angle = func0f19f294(&g_FiringRangeData.targets[i].prop->pos, g_FiringRangeData.targets[i].angle, autogunpos); +// +// //if (!(angle > BADDEG2RAD(90) && angle < BADDEG2RAD(270))) { +// if (!(angle > 1.5707963705063f && angle < 4.7116389274597f)) { +// facingtargets[len++] = i; +// } +// } +// } +// +// // Determine which of the facing targets is closest +// for (i = 0; i < len; i++) { +// struct prop *prop = g_FiringRangeData.targets[facingtargets[i]].prop; +// f32 xdiff = prop->pos.x - autogunpos->x; +// f32 ydiff = prop->pos.y - autogunpos->y; +// f32 zdiff = prop->pos.z - autogunpos->z; +// f32 dist = xdiff * xdiff + ydiff * ydiff + zdiff * zdiff; +// +// if (dist < closestdist) { +// closestdist = dist; +// closesttarget = prop; +// } +// } +// +// return closesttarget; +//} + GLOBAL_ASM( glabel func0f19f524 /* f19f524: 27bdfd40 */ addiu $sp,$sp,-704 diff --git a/src/include/game/training.h b/src/include/game/training.h index 9d5f00edf..1bd2e646d 100644 --- a/src/include/game/training.h +++ b/src/include/game/training.h @@ -53,7 +53,7 @@ void func0f19f18c(void); bool func0f19f220(struct prop *prop); f32 func0f19f294(struct coord *a, f32 angle, struct coord *b); bool func0f19f2ec(struct prop *prop, struct coord *pos); -u32 func0f19f39c(void); +struct prop *frChooseAutogunTarget(struct coord *arg0); u32 func0f19f524(void); void frTick(void); void func0f1a0924(struct prop *prop); diff --git a/src/include/types.h b/src/include/types.h index 34822f24a..be6cb81df 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -5306,7 +5306,7 @@ struct frtarget { /*0x20*/ u8 unk20; /*0x21*/ u8 unk21; /*0x24*/ f32 unk24; - /*0x28*/ f32 unk28; + /*0x28*/ f32 angle; /*0x2c*/ f32 unk2c; /*0x30*/ u8 flags; /*0x31*/ u8 unk31;