diff --git a/src/game/bondmove.c b/src/game/bondmove.c index 1edaa6991..999849342 100644 --- a/src/game/bondmove.c +++ b/src/game/bondmove.c @@ -4847,7 +4847,7 @@ glabel var7f1ad8e4 // g_Vars.currentplayer->gunzoomfovs[1] = fStack436; // // func00015b68(currentPlayerGetMatrix(), -// &g_Vars.currentplayer->unk025c->pos, &fStack456.pos); +// &g_Vars.currentplayer->autoeraserprop->pos, &fStack456.pos); // // func0f0b4eb8(&fStack456.pos, (struct coord *)&fStack456, fStack436, // g_Vars.currentplayer->c_perspaspect); diff --git a/src/game/game_0601b0.c b/src/game/game_0601b0.c index d099c3fa0..ae8c6f212 100644 --- a/src/game/game_0601b0.c +++ b/src/game/game_0601b0.c @@ -5493,7 +5493,7 @@ glabel func0f064ce8 /* f064d78: 24140003 */ addiu $s4,$zero,0x3 /* f064d7c: 10400009 */ beqz $v0,.L0f064da4 /* f064d80: 00000000 */ nop -/* f064d84: 0fc6829c */ jal func0f1a0a70 +/* f064d84: 0fc6829c */ jal frChooseFarsightTarget /* f064d88: 00000000 */ nop /* f064d8c: 14400007 */ bnez $v0,.L0f064dac /* f064d90: 00000000 */ nop diff --git a/src/game/training.c b/src/game/training.c index b4b31dc5a..d756e43a6 100644 --- a/src/game/training.c +++ b/src/game/training.c @@ -3797,7 +3797,7 @@ void func0f1a0924(struct prop *prop) } GLOBAL_ASM( -glabel func0f1a0a70 +glabel frChooseFarsightTarget /* f1a0a70: 27bdffa0 */ addiu $sp,$sp,-96 /* f1a0a74: f7bc0030 */ sdc1 $f28,0x30($sp) /* f1a0a78: 3c013f80 */ lui $at,0x3f80 @@ -3916,6 +3916,52 @@ glabel func0f1a0a70 /* f1a0c2c: 27bd0060 */ addiu $sp,$sp,0x60 ); +// Mismatch because f26 and f28 are swapped and the multiplication order for +// unk1c is different. f26 should be constant 0 (used in dist > 0 and value < 0 +// checks) and f28 should be bestvalue. +//bool frChooseFarsightTarget(void) +//{ +// f32 bestvalue = 1; +// f32 bestdist = -1; +// struct prop *bestprop = NULL; +// bool found = false; +// s32 i; +// +// if (getCurrentPlayerWeaponId(0) == WEAPON_FARSIGHTXR20) { +// 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 +// && g_FiringRangeData.targets[i].flags & FRTARGETFLAG_40) { +// struct prop *prop = g_FiringRangeData.targets[i].prop; +// f32 xdiff = g_Vars.currentplayer->bond2.unk10.x - prop->pos.x; +// f32 ydiff = g_Vars.currentplayer->bond2.unk10.y - prop->pos.y; +// f32 zdiff = g_Vars.currentplayer->bond2.unk10.z - prop->pos.z; +// f32 dist = sqrtf(xdiff * xdiff + ydiff * ydiff + zdiff * zdiff); +// +// if (dist > 0) { +// f32 value = ( +// g_Vars.currentplayer->bond2.unk1c.x * xdiff + +// g_Vars.currentplayer->bond2.unk1c.y * ydiff + +// g_Vars.currentplayer->bond2.unk1c.z * zdiff) / dist; +// +// if (value < 0 && value < bestvalue) { +// bestvalue = value; +// bestprop = prop; +// bestdist = dist; +// found = true; +// } +// } +// } +// } +// } +// +// g_Vars.currentplayer->autoeraserdist = bestdist; +// g_Vars.currentplayer->autoerasertarget = bestprop; +// +// return found; +//} + s32 frIsInTraining(void) { if (g_FiringRangeData.unk464 > 0 && diff --git a/src/include/constants.h b/src/include/constants.h index d302e4d26..360ffdb90 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -604,6 +604,7 @@ #define FRFAILREASON_INACCURATE 4 #define FRTARGETFLAG_20 0x20 +#define FRTARGETFLAG_40 0x40 #define FRZONE_RING3 1 #define FRZONE_RING2 2 diff --git a/src/include/game/training.h b/src/include/game/training.h index 1bd2e646d..ad85eefd7 100644 --- a/src/include/game/training.h +++ b/src/include/game/training.h @@ -57,7 +57,7 @@ struct prop *frChooseAutogunTarget(struct coord *arg0); u32 func0f19f524(void); void frTick(void); void func0f1a0924(struct prop *prop); -u32 func0f1a0a70(void); +bool frChooseFarsightTarget(void); s32 frIsInTraining(void); u32 func0f1a0cc0(void); void func0f1a0fc8(void); diff --git a/src/include/types.h b/src/include/types.h index be6cb81df..932604a4b 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -2138,7 +2138,7 @@ struct player { /*0x0250*/ u8 activemenumode; /*0x0254*/ u32 erasertime; // related to FarSight's auto tracking /*0x0258*/ f32 autoeraserdist; - /*0x025c*/ struct prop *unk025c; // eraser target? + /*0x025c*/ struct prop *autoerasertarget; /*0x0260*/ s32 aimtaptime; /*0x0264*/ struct weaponobj *slayerrocket; /*0x0268*/ bool eyesshut;