diff --git a/src/game/chr/chr.c b/src/game/chr/chr.c index bf24b0d03..20d829f9d 100644 --- a/src/game/chr/chr.c +++ b/src/game/chr/chr.c @@ -30876,7 +30876,7 @@ glabel func0f038f40 /* f0390a4: 27a50028 */ addiu $a1,$sp,0x28 /* f0390a8: 27a60068 */ addiu $a2,$sp,0x68 /* f0390ac: 27a70058 */ addiu $a3,$sp,0x58 -/* f0390b0: 0c00b70f */ jal func0002dc3c +/* f0390b0: 0c00b70f */ jal hasLineOfSight /* f0390b4: afa80010 */ sw $t0,0x10($sp) /* f0390b8: 50400014 */ beqzl $v0,.L0f03910c /* f0390bc: 8fa40054 */ lw $a0,0x54($sp) @@ -30892,7 +30892,7 @@ glabel func0f038f40 /* f0390dc: afac0014 */ sw $t4,0x14($sp) /* f0390e0: 27a60068 */ addiu $a2,$sp,0x68 /* f0390e4: 27a70058 */ addiu $a3,$sp,0x58 -/* f0390e8: 0c00b70f */ jal func0002dc3c +/* f0390e8: 0c00b70f */ jal hasLineOfSight /* f0390ec: afab0010 */ sw $t3,0x10($sp) /* f0390f0: 50400006 */ beqzl $v0,.L0f03910c /* f0390f4: 8fa40054 */ lw $a0,0x54($sp) @@ -30931,7 +30931,7 @@ glabel func0f038f40 /* f039164: 8fa50080 */ lw $a1,0x80($sp) /* f039168: 27a60068 */ addiu $a2,$sp,0x68 /* f03916c: 27a70058 */ addiu $a3,$sp,0x58 -/* f039170: 0c00b70f */ jal func0002dc3c +/* f039170: 0c00b70f */ jal hasLineOfSight /* f039174: afb80010 */ sw $t8,0x10($sp) /* f039178: 10400003 */ beqz $v0,.L0f039188 /* f03917c: 24050001 */ addiu $a1,$zero,0x1 @@ -30951,7 +30951,7 @@ glabel func0f038f40 /* f0391ac: 8fa50080 */ lw $a1,0x80($sp) /* f0391b0: 27a60068 */ addiu $a2,$sp,0x68 /* f0391b4: 27a70058 */ addiu $a3,$sp,0x58 -/* f0391b8: 0c00b70f */ jal func0002dc3c +/* f0391b8: 0c00b70f */ jal hasLineOfSight /* f0391bc: afaa0010 */ sw $t2,0x10($sp) /* f0391c0: 10400002 */ beqz $v0,.L0f0391cc /* f0391c4: 240c0001 */ addiu $t4,$zero,0x1 @@ -31126,7 +31126,7 @@ glabel func0f0393b4 /* f039434: 27a4003c */ addiu $a0,$sp,0x3c /* f039438: 27a5002c */ addiu $a1,$sp,0x2c /* f03943c: 8fa60054 */ lw $a2,0x54($sp) -/* f039440: 0c00b70f */ jal func0002dc3c +/* f039440: 0c00b70f */ jal hasLineOfSight /* f039444: 8fa70058 */ lw $a3,0x58($sp) /* f039448: 10400003 */ beqz $v0,.L0f039458 /* f03944c: 02002025 */ or $a0,$s0,$zero @@ -49365,7 +49365,7 @@ glabel func0f049fcc /* f04a048: afb90014 */ sw $t9,0x14($sp) /* f04a04c: afb80010 */ sw $t8,0x10($sp) /* f04a050: 24460008 */ addiu $a2,$v0,0x8 -/* f04a054: 0c00b70f */ jal func0002dc3c +/* f04a054: 0c00b70f */ jal hasLineOfSight /* f04a058: 24470028 */ addiu $a3,$v0,0x28 /* f04a05c: 1040001c */ beqz $v0,.L0f04a0d0 /* f04a060: 8fa80058 */ lw $t0,0x58($sp) diff --git a/src/game/chr/chraicommands.c b/src/game/chr/chraicommands.c index df55dd991..36eb1799d 100644 --- a/src/game/chr/chraicommands.c +++ b/src/game/chr/chraicommands.c @@ -1661,7 +1661,7 @@ bool aiIfSawDeath(void) bool aiIfSeesPlayer(void) { if ((g_Vars.chrdata && func0f039368(g_Vars.chrdata)) || - (g_Vars.hovdata && func0f07ae18(g_Vars.hovdata, 0x40) && func0f07af34(g_Vars.hovdata))) { + (g_Vars.hovdata && func0f07ae18(g_Vars.hovdata, 0x40) && heliCheckTargetVisible(g_Vars.hovdata))) { u8 *cmd = g_Vars.ailist + g_Vars.aioffset; g_Vars.aioffset = chraiGoToLabel(g_Vars.ailist, g_Vars.aioffset, cmd[2]); } else { @@ -1677,7 +1677,7 @@ bool aiIfSeesPlayer(void) bool ai017a(void) { if ((g_Vars.chrdata && g_Vars.chrdata->prop && func0f0391ec(g_Vars.chrdata, &g_Vars.chrdata->prop->pos, &g_Vars.chrdata->prop->rooms[0], 1)) - || (g_Vars.hovdata && func0f07ae18(g_Vars.hovdata, 0x40) && func0f07af34(g_Vars.hovdata))) { + || (g_Vars.hovdata && func0f07ae18(g_Vars.hovdata, 0x40) && heliCheckTargetVisible(g_Vars.hovdata))) { u8 *cmd = g_Vars.ailist + g_Vars.aioffset; g_Vars.aioffset = chraiGoToLabel(g_Vars.ailist, g_Vars.aioffset, cmd[2]); } else { diff --git a/src/game/game_066310.c b/src/game/game_066310.c index 52918afad..e27eb9bca 100644 --- a/src/game/game_066310.c +++ b/src/game/game_066310.c @@ -41,6 +41,7 @@ #include "game/game_19c990.h" #include "game/game_1a3340.h" #include "library/library_12dc0.h" +#include "library/library_233c0.h" const char var7f1aa1c0[] = "propobj.c"; @@ -16580,7 +16581,7 @@ glabel func0f073478 /* f0739e8: afae0014 */ sw $t6,0x14($sp) /* f0739ec: afad0010 */ sw $t5,0x10($sp) /* f0739f0: 24460008 */ addiu $a2,$v0,0x8 -/* f0739f4: 0c00b70f */ jal func0002dc3c +/* f0739f4: 0c00b70f */ jal hasLineOfSight /* f0739f8: 24470028 */ addiu $a3,$v0,0x28 /* f0739fc: 1040000b */ beqz $v0,.L0f073a2c /* f073a00: 00000000 */ sll $zero,$zero,0x0 @@ -21818,7 +21819,7 @@ glabel func0f0782ac /* f078600: 25640008 */ addiu $a0,$t3,0x8 /* f078604: 25650028 */ addiu $a1,$t3,0x28 /* f078608: 25860008 */ addiu $a2,$t4,0x8 -/* f07860c: 0c00b70f */ jal func0002dc3c +/* f07860c: 0c00b70f */ jal hasLineOfSight /* f078610: 25870028 */ addiu $a3,$t4,0x28 /* f078614: 8fa3003c */ lw $v1,0x3c($sp) /* f078618: 8fa80020 */ lw $t0,0x20($sp) @@ -23026,7 +23027,7 @@ glabel func0f078c78 /* f079748: afa800ac */ sw $t0,0xac($sp) /* f07974c: e7b200a4 */ swc1 $f18,0xa4($sp) /* f079750: 25c60008 */ addiu $a2,$t6,0x8 -/* f079754: 0c00b70f */ jal func0002dc3c +/* f079754: 0c00b70f */ jal hasLineOfSight /* f079758: 25c70028 */ addiu $a3,$t6,0x28 /* f07975c: 3c09800a */ lui $t1,%hi(g_Vars) /* f079760: 25299fc0 */ addiu $t1,$t1,%lo(g_Vars) @@ -24672,52 +24673,24 @@ glabel func0f07ae18 /* f07af30: 00000000 */ sll $zero,$zero,0x0 ); -GLOBAL_ASM( -glabel func0f07af34 -/* f07af34: 27bdffd8 */ addiu $sp,$sp,-40 -/* f07af38: afbf001c */ sw $ra,0x1c($sp) -/* f07af3c: 0fc1eb7d */ jal heliFromObj -/* f07af40: 00000000 */ sll $zero,$zero,0x0 -/* f07af44: 1040001d */ beqz $v0,.L0f07afbc -/* f07af48: 00402025 */ or $a0,$v0,$zero -/* f07af4c: afa00020 */ sw $zero,0x20($sp) -/* f07af50: 0fc1eb6e */ jal heliGetTargetProp -/* f07af54: afa20024 */ sw $v0,0x24($sp) -/* f07af58: 904e0000 */ lbu $t6,0x0($v0) -/* f07af5c: 24010006 */ addiu $at,$zero,0x6 -/* f07af60: 8fa30020 */ lw $v1,0x20($sp) -/* f07af64: 15c10005 */ bne $t6,$at,.L0f07af7c -/* f07af68: 00404025 */ or $t0,$v0,$zero -/* f07af6c: 3c0f800a */ lui $t7,0x800a -/* f07af70: 8defa2e4 */ lw $t7,-0x5d1c($t7) -/* f07af74: 51e0000e */ beqzl $t7,.L0f07afb0 -/* f07af78: 8faa0024 */ lw $t2,0x24($sp) -.L0f07af7c: -/* f07af7c: 8fb80024 */ lw $t8,0x24($sp) -/* f07af80: 24190133 */ addiu $t9,$zero,0x133 -/* f07af84: 24090010 */ addiu $t1,$zero,0x10 -/* f07af88: 8f020014 */ lw $v0,0x14($t8) -/* f07af8c: afa90014 */ sw $t1,0x14($sp) -/* f07af90: afb90010 */ sw $t9,0x10($sp) -/* f07af94: 25040008 */ addiu $a0,$t0,0x8 -/* f07af98: 25050028 */ addiu $a1,$t0,0x28 -/* f07af9c: 24460008 */ addiu $a2,$v0,0x8 -/* f07afa0: 0c00b70f */ jal func0002dc3c -/* f07afa4: 24470028 */ addiu $a3,$v0,0x28 -/* f07afa8: 00401825 */ or $v1,$v0,$zero -/* f07afac: 8faa0024 */ lw $t2,0x24($sp) -.L0f07afb0: -/* f07afb0: 00601025 */ or $v0,$v1,$zero -/* f07afb4: 10000002 */ beqz $zero,.L0f07afc0 -/* f07afb8: ad4300bc */ sw $v1,0xbc($t2) -.L0f07afbc: -/* f07afbc: 00001025 */ or $v0,$zero,$zero -.L0f07afc0: -/* f07afc0: 8fbf001c */ lw $ra,0x1c($sp) -/* f07afc4: 27bd0028 */ addiu $sp,$sp,0x28 -/* f07afc8: 03e00008 */ jr $ra -/* f07afcc: 00000000 */ sll $zero,$zero,0x0 -); +bool heliCheckTargetVisible(struct defaultobj *obj) +{ + struct heliobj *heli = heliFromObj(obj); + + if (heli) { + bool visible = false; + struct prop *target = heliGetTargetProp(heli); + + if (target->type != PROPTYPE_PLAYER || g_Vars.unk000324) { + visible = hasLineOfSight(&target->pos, &target->rooms[0], &heli->base.prop->pos, &heli->base.prop->rooms[0], 307, 16); + } + + heli->targetvisible = visible; + return visible; + } + + return false; +} void heliSetTarget(struct defaultobj *obj, u32 chrnum) { @@ -41095,7 +41068,7 @@ glabel func0f089014 /* f08998c: afa90010 */ sw $t1,0x10($sp) /* f089990: 25040008 */ addiu $a0,$t0,0x8 /* f089994: 27260008 */ addiu $a2,$t9,0x8 -/* f089998: 0c00b70f */ jal func0002dc3c +/* f089998: 0c00b70f */ jal hasLineOfSight /* f08999c: 27270028 */ addiu $a3,$t9,0x28 /* f0899a0: 14400002 */ bnez $v0,.L0f0899ac /* f0899a4: 00000000 */ sll $zero,$zero,0x0 diff --git a/src/game/game_0c79f0.c b/src/game/game_0c79f0.c index 911c5a2b8..6714c8927 100644 --- a/src/game/game_0c79f0.c +++ b/src/game/game_0c79f0.c @@ -8568,7 +8568,7 @@ glabel func0f0ceec4 /* f0cf0ec: 24640008 */ addiu $a0,$v1,0x8 /* f0cf0f0: 24650028 */ addiu $a1,$v1,0x28 /* f0cf0f4: 24460008 */ addiu $a2,$v0,0x8 -/* f0cf0f8: 0c00b70f */ jal func0002dc3c +/* f0cf0f8: 0c00b70f */ jal hasLineOfSight /* f0cf0fc: 24470028 */ addiu $a3,$v0,0x28 /* f0cf100: 14400003 */ bnez $v0,.L0f0cf110 /* f0cf104: 00000000 */ sll $zero,$zero,0x0 diff --git a/src/game/game_0cf150.c b/src/game/game_0cf150.c index 8ece6d9f6..6839b9d74 100644 --- a/src/game/game_0cf150.c +++ b/src/game/game_0cf150.c @@ -3178,7 +3178,7 @@ glabel func0f0d0928 /* f0d1ebc: 25040008 */ addiu $a0,$t0,0x8 /* f0d1ec0: 25050028 */ addiu $a1,$t0,0x28 /* f0d1ec4: 24460008 */ addiu $a2,$v0,0x8 -/* f0d1ec8: 0c00b70f */ jal func0002dc3c +/* f0d1ec8: 0c00b70f */ jal hasLineOfSight /* f0d1ecc: 24470028 */ addiu $a3,$v0,0x28 /* f0d1ed0: 3c09800a */ lui $t1,%hi(g_Vars) /* f0d1ed4: 14400003 */ bnez $v0,.L0f0d1ee4 diff --git a/src/game/game_114240.c b/src/game/game_114240.c index 31596218a..21779e9bd 100644 --- a/src/game/game_114240.c +++ b/src/game/game_114240.c @@ -231,7 +231,7 @@ glabel func0f114254 /* f114538: 8fa503a4 */ lw $a1,0x3a4($sp) /* f11453c: 02003025 */ or $a2,$s0,$zero /* f114540: 02a03825 */ or $a3,$s5,$zero -/* f114544: 0c00b70f */ jal func0002dc3c +/* f114544: 0c00b70f */ jal hasLineOfSight /* f114548: a7af010c */ sh $t7,0x10c($sp) /* f11454c: 10400023 */ beqz $v0,.L0f1145dc /* f114550: 02537021 */ addu $t6,$s2,$s3 diff --git a/src/include/game/game_066310.h b/src/include/game/game_066310.h index 2e382a506..175d1c4eb 100644 --- a/src/include/game/game_066310.h +++ b/src/include/game/game_066310.h @@ -163,7 +163,7 @@ u32 func0f079f1c(void); u32 func0f07accc(void); struct heliobj *heliFromObj(struct defaultobj *obj); u32 func0f07ae18(struct heliobj *heli, u32 arg1); -u32 func0f07af34(struct heliobj *heli); +bool heliCheckTargetVisible(struct defaultobj *obj); void heliSetTarget(struct defaultobj *obj, u32 chrnum); bool heliAttack(struct defaultobj *obj); bool heliStop(struct defaultobj *obj); diff --git a/src/include/library/library_233c0.h b/src/include/library/library_233c0.h index 9e1948127..9afeb3d48 100644 --- a/src/include/library/library_233c0.h +++ b/src/include/library/library_233c0.h @@ -110,7 +110,7 @@ u32 func0002da50(void); u32 func0002dac8(void); u32 func0002db98(void); u32 func0002dc18(void); -u32 func0002dc3c(void); +bool hasLineOfSight(struct coord *coord, s16 *room, struct coord *coord2, s16 *room2, s32 arg4, s32 arg5); u32 func0002dcd0(void); u32 func0002dcfc(void); u32 func0002dd90(void); diff --git a/src/library/library_233c0.c b/src/library/library_233c0.c index 474e941f2..903ed52db 100644 --- a/src/library/library_233c0.c +++ b/src/library/library_233c0.c @@ -11859,7 +11859,7 @@ glabel func0002dc18 ); GLOBAL_ASM( -glabel func0002dc3c +glabel hasLineOfSight /* 2dc3c: 27bdff90 */ addiu $sp,$sp,-112 /* 2dc40: afbf002c */ sw $ra,0x2c($sp) /* 2dc44: afa7007c */ sw $a3,0x7c($sp) @@ -11907,7 +11907,7 @@ glabel func0002dcd0 /* 2dcd8: afbf001c */ sw $ra,0x1c($sp) /* 2dcdc: 240f001c */ addiu $t7,$zero,0x1c /* 2dce0: afaf0014 */ sw $t7,0x14($sp) -/* 2dce4: 0c00b70f */ jal func0002dc3c +/* 2dce4: 0c00b70f */ jal hasLineOfSight /* 2dce8: afae0010 */ sw $t6,0x10($sp) /* 2dcec: 8fbf001c */ lw $ra,0x1c($sp) /* 2dcf0: 27bd0020 */ addiu $sp,$sp,0x20