From 376ae2d7c7aec31fcd12da79ffd290017cc8e789 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 30 May 2020 10:55:30 +1000 Subject: [PATCH] Decompile chrIsTargetInFov and rename several AI commands relating to FOV direction checks --- src/files/setup/setupame.c | 8 +-- src/files/setup/setupcave.c | 18 +++---- src/files/setup/setupdam.c | 2 +- src/files/setup/setupdepo.c | 2 +- src/files/setup/setupdish.c | 14 ++--- src/files/setup/setupear.c | 6 +-- src/files/setup/setuplee.c | 8 +-- src/files/setup/setuplip.c | 14 ++--- src/files/setup/setuplue.c | 2 +- src/files/setup/setuppam.c | 6 +-- src/files/setup/setuppete.c | 6 +-- src/files/setup/setuprit.c | 8 +-- src/files/setup/setupsho.c | 20 ++++---- src/files/setup/setuptra.c | 2 +- src/files/setup/setupwax.c | 4 +- src/game/chr/chraction.c | 77 +++++----------------------- src/game/chr/chrai.c | 8 +-- src/game/chr/chraicommands.c | 12 ++--- src/game/data/ailists.c | 20 ++++---- src/game/game_190260.c | 8 +-- src/game/game_1999b0.c | 2 +- src/include/commands.h | 40 +++++++-------- src/include/game/chr/chraction.h | 6 +-- src/include/game/chr/chraicommands.h | 8 +-- 24 files changed, 125 insertions(+), 176 deletions(-) diff --git a/src/files/setup/setupame.c b/src/files/setup/setupame.c index 7f2239904..eeb430494 100644 --- a/src/files/setup/setupame.c +++ b/src/files/setup/setupame.c @@ -1279,7 +1279,7 @@ u8 func040f_cass[] = { try_face_entity(ENTITYTYPE_TARGET, 0, /*goto*/ 0x64) beginloop(0x64) - if_jo_ccw_direction_lt(10, /*goto*/ 0x65) + if_target_in_fov_left(10, /*goto*/ 0x65) if_timer_gt(90, /*goto*/ 0x65) endloop(0x64) @@ -1512,7 +1512,7 @@ u8 func0411_secretary[] = { try_face_entity(ENTITYTYPE_TARGET, 0, /*goto*/ 0x7f) beginloop(0x7f) - if_jo_ccw_direction_lt(10, /*goto*/ 0x81) + if_target_in_fov_left(10, /*goto*/ 0x81) if_timer_gt(120, /*goto*/ 0x81) endloop(0x7f) @@ -1703,7 +1703,7 @@ u8 func0414_programmer[] = { try_face_entity(ENTITYTYPE_TARGET, 0, /*goto*/ 0x9a) beginloop(0x9a) - if_jo_ccw_direction_lt(10, /*goto*/ 0x06) + if_target_in_fov_left(10, /*goto*/ 0x06) if_timer_gt(60, /*goto*/ 0x06) endloop(0x9a) @@ -1803,7 +1803,7 @@ u8 func0414_programmer[] = { beginloop(0x9b) if_stage_flag_eq(STAGEFLAG_TALKED_TO_PROGRAMMER, TRUE, /*goto*/ 0x06) - if_jo_ccw_direction_lt(10, /*goto*/ 0x06) + if_target_in_fov_left(10, /*goto*/ 0x06) if_timer_gt(60, /*goto*/ 0x06) endloop(0x9b) diff --git a/src/files/setup/setupcave.c b/src/files/setup/setupcave.c index 1f72d0d00..efdffda02 100644 --- a/src/files/setup/setupcave.c +++ b/src/files/setup/setupcave.c @@ -1232,7 +1232,7 @@ u8 func0407_stewardess[] = { try_face_entity(ENTITYTYPE_TARGET, 0, /*goto*/ 0x05) beginloop(0x05) - if_jo_ccw_direction_lt(10, /*goto*/ 0x02) + if_target_in_fov_left(10, /*goto*/ 0x02) if_timer_gt(60, /*goto*/ 0x02) endloop(0x05) @@ -1529,7 +1529,7 @@ u8 func0408_secretary[] = { try_face_entity(ENTITYTYPE_TARGET, 0, /*goto*/ 0x05) beginloop(0x05) - if_jo_ccw_direction_lt(10, /*goto*/ 0x02) + if_target_in_fov_left(10, /*goto*/ 0x02) if_timer_gt(60, /*goto*/ 0x02) endloop(0x05) @@ -2125,7 +2125,7 @@ u8 func0409_office1[] = { reloop(0x0b) label(0x31) - if_jo_ccw_direction_lt(10, /*goto*/ 0x02) + if_target_in_fov_left(10, /*goto*/ 0x02) if_timer_gt(60, /*goto*/ 0x02) endloop(0x0b) @@ -2148,7 +2148,7 @@ u8 func0409_office1[] = { try_face_entity(ENTITYTYPE_TARGET, 0, /*goto*/ 0x05) beginloop(0x05) - if_jo_ccw_direction_lt(10, /*goto*/ 0x02) + if_target_in_fov_left(10, /*goto*/ 0x02) if_timer_gt(60, /*goto*/ 0x02) endloop(0x05) @@ -2243,7 +2243,7 @@ u8 func040a_office2[] = { reloop(0x05) label(0x31) - if_jo_ccw_direction_lt(10, /*goto*/ 0x02) + if_target_in_fov_left(10, /*goto*/ 0x02) if_timer_gt(60, /*goto*/ 0x02) endloop(0x05) @@ -2508,8 +2508,8 @@ u8 func040f_nsa[] = { try_face_entity(ENTITYTYPE_TARGET, 0, /*goto*/ 0x09) beginloop(0x09) - if_jo_ccw_direction_lt(10, /*goto*/ 0x02) - if_jo_ccw_direction_gt(245, /*goto*/ 0x02) + if_target_in_fov_left(10, /*goto*/ 0x02) + if_target_out_of_fov_left(245, /*goto*/ 0x02) if_timer_gt(60, /*goto*/ 0x02) endloop(0x09) @@ -2746,7 +2746,7 @@ u8 func0414_officeworker[] = { try_face_entity(ENTITYTYPE_TARGET, 0, /*goto*/ 0x78) beginloop(0x78) - if_jo_ccw_direction_lt(10, /*goto*/ 0x02) + if_target_in_fov_left(10, /*goto*/ 0x02) if_timer_gt(40, /*goto*/ 0x02) endloop(0x78) @@ -3417,7 +3417,7 @@ u8 func0419_ba8c[] = { try_face_entity(ENTITYTYPE_TARGET, 0, /*goto*/ 0x08) label(0x08) yield - if_jo_ccw_direction_lt(10, /*goto*/ 0x02) + if_target_in_fov_left(10, /*goto*/ 0x02) if_timer_gt(40, /*goto*/ 0x02) goto_first(0x08) diff --git a/src/files/setup/setupdam.c b/src/files/setup/setupdam.c index d48458970..ab7b3e38f 100644 --- a/src/files/setup/setupdam.c +++ b/src/files/setup/setupdam.c @@ -1580,7 +1580,7 @@ u8 func0411_labtech_alerted[] = { try_face_entity(ENTITYTYPE_TARGET, 0, /*goto*/ 0x0c) beginloop(0x0c) - if_jo_ccw_direction_lt(10, /*goto*/ 0x04) + if_target_in_fov_left(10, /*goto*/ 0x04) if_timer_gt(60, /*goto*/ 0x04) endloop(0x0c) diff --git a/src/files/setup/setupdepo.c b/src/files/setup/setupdepo.c index 9b8642205..e37a7974f 100644 --- a/src/files/setup/setupdepo.c +++ b/src/files/setup/setupdepo.c @@ -2353,7 +2353,7 @@ u8 func0413_cloak1_guard[] = { chr_toggle_p1p2(CHR_SELF) set_target_chr(CHR_P1P2) if_distance_to_target_lt(400, /*goto*/ 0x06) - if_jo_front_direction_lt(30, /*goto*/ 0x06) + if_target_in_fov(30, /*goto*/ 0x06) if_chr_in_view(/*goto*/ 0x06) if_difficulty_lt(DIFF_SA, /*goto*/ 0x2c) if_timer_gt(180, /*goto*/ 0x06) diff --git a/src/files/setup/setupdish.c b/src/files/setup/setupdish.c index 494fba210..edb004c82 100644 --- a/src/files/setup/setupdish.c +++ b/src/files/setup/setupdish.c @@ -594,7 +594,7 @@ u8 func041e_colleague[] = { try_face_entity(ENTITYTYPE_TARGET, 0, /*goto*/ 0x09) beginloop(0x09) - if_jo_ccw_direction_lt(10, /*goto*/ 0x06) + if_target_in_fov_left(10, /*goto*/ 0x06) if_timer_gt(60, /*goto*/ 0x06) endloop(0x09) @@ -2468,7 +2468,7 @@ u8 func0429_grimshaw_disguise[] = { beginloop(0x09) if_stage_flag_eq(STAGEFLAG_DEVICE_ABORTING, TRUE, /*goto*/ 0x0d) - if_jo_ccw_direction_lt(10, /*goto*/ 0x06) + if_target_in_fov_left(10, /*goto*/ 0x06) if_timer_gt(60, /*goto*/ 0x06) endloop(0x09) @@ -2659,7 +2659,7 @@ u8 func042a_carrington_cloak[] = { try_face_entity(ENTITYTYPE_TARGET, 0, /*goto*/ 0x09) beginloop(0x09) - if_jo_ccw_direction_lt(10, /*goto*/ 0x06) + if_target_in_fov_left(10, /*goto*/ 0x06) if_timer_gt(60, /*goto*/ 0x06) endloop(0x09) @@ -5245,8 +5245,8 @@ u8 func0416_holo_guard_unarmed_alert2[] = { label(0x06) restart_timer - if_jo_ccw_direction_lt(10, /*goto*/ 0x06) - if_jo_ccw_direction_gt(246, /*goto*/ 0x06) + if_target_in_fov_left(10, /*goto*/ 0x06) + if_target_out_of_fov_left(246, /*goto*/ 0x06) stop_chr try_face_entity(ENTITYTYPE_TARGET, 0, /*goto*/ 0x09) @@ -5254,8 +5254,8 @@ u8 func0416_holo_guard_unarmed_alert2[] = { if_chr_dead(CHR_TARGET, /*goto*/ 0x57) if_chr_knockedout(CHR_TARGET, /*goto*/ 0x57) if_distance_to_target_gt(400, /*goto*/ 0x10) - if_jo_ccw_direction_lt(10, /*goto*/ 0x06) - if_jo_ccw_direction_gt(246, /*goto*/ 0x06) + if_target_in_fov_left(10, /*goto*/ 0x06) + if_target_out_of_fov_left(246, /*goto*/ 0x06) if_timer_gt(120, /*goto*/ 0x06) endloop(0x09) diff --git a/src/files/setup/setupear.c b/src/files/setup/setupear.c index 7e933f3b0..494befe4b 100644 --- a/src/files/setup/setupear.c +++ b/src/files/setup/setupear.c @@ -1027,7 +1027,7 @@ u8 func0404_scientist[] = { endloop(0x09) label(0x2f) - if_jo_ccw_direction_lt(10, /*goto*/ 0x06) + if_target_in_fov_left(10, /*goto*/ 0x06) if_timer_gt(60, /*goto*/ 0x06) goto_first(0x09) @@ -1059,7 +1059,7 @@ u8 func0404_scientist[] = { chr_do_animation(ANIM_SURRENDER_002E, 0, -1, 0x10, 0x10, CHR_SELF, 2) beginloop(0x0b) - if_jo_ccw_direction_lt(10, /*goto*/ 0x06) + if_target_in_fov_left(10, /*goto*/ 0x06) if_timer_gt(90, /*goto*/ 0x06) endloop(0x0b) @@ -1211,7 +1211,7 @@ u8 func0406_nasty_scientist[] = { reloop(0x09) label(0x2f) - if_jo_ccw_direction_lt(10, /*goto*/ 0x06) + if_target_in_fov_left(10, /*goto*/ 0x06) if_timer_gt(60, /*goto*/ 0x06) endloop(0x09) diff --git a/src/files/setup/setuplee.c b/src/files/setup/setuplee.c index f98356716..d6cd71108 100644 --- a/src/files/setup/setuplee.c +++ b/src/files/setup/setuplee.c @@ -2336,8 +2336,8 @@ u8 func041a_bridgeclone[] = { label(0x2e) restart_timer dprint 'F','A','C','E',' ','T','A','R','G','E','T','\n',0, - if_jo_ccw_direction_lt(10, /*goto*/ 0x06) - if_jo_ccw_direction_gt(246, /*goto*/ 0x06) + if_target_in_fov_left(10, /*goto*/ 0x06) + if_target_out_of_fov_left(246, /*goto*/ 0x06) stop_chr try_face_entity(ENTITYTYPE_TARGET, 1, /*goto*/ 0x0b) @@ -2346,8 +2346,8 @@ u8 func041a_bridgeclone[] = { if_chr_death_animation_finished(CHR_TARGET, /*goto*/ 0x10) if_chr_dead(CHR_TARGET, /*goto*/ 0x10) if_chr_knockedout(CHR_TARGET, /*goto*/ 0x10) - if_jo_ccw_direction_lt(10, /*goto*/ 0x06) - if_jo_ccw_direction_gt(246, /*goto*/ 0x06) + if_target_in_fov_left(10, /*goto*/ 0x06) + if_target_out_of_fov_left(246, /*goto*/ 0x06) if_timer_gt(15, /*goto*/ 0x06) endloop(0x0b) diff --git a/src/files/setup/setuplip.c b/src/files/setup/setuplip.c index 2137a2118..ea587c9ff 100644 --- a/src/files/setup/setuplip.c +++ b/src/files/setup/setuplip.c @@ -1357,7 +1357,7 @@ u8 func0410_labtech_showers_sa_pa[] = { try_face_entity(ENTITYTYPE_TARGET, 0, /*goto*/ 0x09) beginloop(0x09) - if_jo_ccw_direction_lt(10, /*goto*/ 0x06) + if_target_in_fov_left(10, /*goto*/ 0x06) if_timer_gt(60, /*goto*/ 0x06) endloop(0x09) @@ -1728,7 +1728,7 @@ u8 func0418_doorman[] = { try_face_entity(ENTITYTYPE_TARGET, 0, /*goto*/ 0x09) beginloop(0x09) - if_jo_ccw_direction_lt(10, /*goto*/ 0x06) + if_target_in_fov_left(10, /*goto*/ 0x06) if_timer_gt(60, /*goto*/ 0x06) endloop(0x09) @@ -1961,7 +1961,7 @@ u8 func041a_labtech_harrysmate[] = { try_face_entity(ENTITYTYPE_TARGET, 0, /*goto*/ 0x09) beginloop(0x09) - if_jo_ccw_direction_lt(10, /*goto*/ 0x06) + if_target_in_fov_left(10, /*goto*/ 0x06) if_timer_gt(60, /*goto*/ 0x06) endloop(0x09) @@ -2331,7 +2331,7 @@ u8 func0413_mechanic[] = { try_face_entity(ENTITYTYPE_TARGET, 0, /*goto*/ 0x09) beginloop(0x09) - if_jo_ccw_direction_lt(10, /*goto*/ 0x06) + if_target_in_fov_left(10, /*goto*/ 0x06) if_timer_gt(60, /*goto*/ 0x06) endloop(0x09) @@ -2635,7 +2635,7 @@ u8 func041f_labtech_lights[] = { try_face_entity(ENTITYTYPE_TARGET, 0, /*goto*/ 0x09) beginloop(0x09) - if_jo_ccw_direction_lt(10, /*goto*/ 0x06) + if_target_in_fov_left(10, /*goto*/ 0x06) if_timer_gt(60, /*goto*/ 0x06) endloop(0x09) @@ -2864,7 +2864,7 @@ u8 func0420_labtech_doors[] = { beginloop(0x09) if_saw_injury(0x00, /*goto*/ 0x89) if_saw_death(0x00, /*goto*/ 0x89) - if_jo_ccw_direction_lt(10, /*goto*/ 0x06) + if_target_in_fov_left(10, /*goto*/ 0x06) if_timer_gt(60, /*goto*/ 0x06) endloop(0x09) @@ -3097,7 +3097,7 @@ u8 func0422_labtech_records[] = { try_face_entity(ENTITYTYPE_TARGET, 0, /*goto*/ 0x09) label(0x09) yield - if_jo_ccw_direction_lt(10, /*goto*/ 0x06) + if_target_in_fov_left(10, /*goto*/ 0x06) if_timer_gt(60, /*goto*/ 0x06) goto_first(0x09) diff --git a/src/files/setup/setuplue.c b/src/files/setup/setuplue.c index 3383cb7b6..f8b92f56c 100644 --- a/src/files/setup/setuplue.c +++ b/src/files/setup/setuplue.c @@ -1662,7 +1662,7 @@ u8 func0416_mechanic[] = { try_face_entity(ENTITYTYPE_TARGET, 0, /*goto*/ 0x0a) beginloop(0x0a) - if_jo_ccw_direction_lt(10, /*goto*/ 0x06) + if_target_in_fov_left(10, /*goto*/ 0x06) if_timer_gt(30, /*goto*/ 0x06) endloop(0x0a) diff --git a/src/files/setup/setuppam.c b/src/files/setup/setuppam.c index c98689c36..6ff02e4a6 100644 --- a/src/files/setup/setuppam.c +++ b/src/files/setup/setuppam.c @@ -3133,7 +3133,7 @@ u8 func041b_sniper_wait_for_detection[] = { label(0x2e) if_distance_to_target_lt(400, /*goto*/ 0x06) - if_jo_front_direction_lt(30, /*goto*/ 0x06) + if_target_in_fov(30, /*goto*/ 0x06) if_chr_in_view(/*goto*/ 0x06) if_saw_death(0x00, /*goto*/ 0x06) if_alertness(100, OPERATOR_GREATER_THAN, /*goto*/ 0x06) @@ -3474,8 +3474,8 @@ u8 func040f_miniskedar[] = { reloop(0x0b) label(0x2e) - if_jo_ccw_direction_lt(10, /*goto*/ 0x06) - if_jo_ccw_direction_gt(246, /*goto*/ 0x06) + if_target_in_fov_left(10, /*goto*/ 0x06) + if_target_out_of_fov_left(246, /*goto*/ 0x06) endloop(0x0b) label(0x06) diff --git a/src/files/setup/setuppete.c b/src/files/setup/setuppete.c index 811badc11..21debea11 100644 --- a/src/files/setup/setuppete.c +++ b/src/files/setup/setuppete.c @@ -1440,7 +1440,7 @@ u8 func0412_cia[] = { try_face_entity(ENTITYTYPE_TARGET, 0, /*goto*/ 0x09) beginloop(0x09) - if_jo_ccw_direction_lt(10, /*goto*/ 0x04) + if_target_in_fov_left(10, /*goto*/ 0x04) if_timer_gt(40, /*goto*/ 0x04) endloop(0x09) @@ -1589,7 +1589,7 @@ u8 func0413_bugspotter[] = { try_face_entity(ENTITYTYPE_TARGET, 0, /*goto*/ 0x04) beginloop(0x09) - if_jo_ccw_direction_lt(10, /*goto*/ 0x04) + if_target_in_fov_left(10, /*goto*/ 0x04) if_timer_gt(40, /*goto*/ 0x04) endloop(0x09) @@ -1871,7 +1871,7 @@ u8 func041d_fbi[] = { try_face_entity(ENTITYTYPE_TARGET, 0, /*goto*/ 0x0d) beginloop(0x0d) - if_jo_ccw_direction_lt(10, /*goto*/ 0x04) + if_target_in_fov_left(10, /*goto*/ 0x04) if_timer_gt(40, /*goto*/ 0x04) endloop(0x0d) diff --git a/src/files/setup/setuprit.c b/src/files/setup/setuprit.c index 685b8b472..2a15ac044 100644 --- a/src/files/setup/setuprit.c +++ b/src/files/setup/setuprit.c @@ -1218,7 +1218,7 @@ u8 func0405_president_in_room[] = { reloop(0x09) label(0x2d) - if_jo_ccw_direction_lt(10, /*goto*/ 0x06) + if_target_in_fov_left(10, /*goto*/ 0x06) if_timer_gt(60, /*goto*/ 0x06) endloop(0x09) @@ -1249,7 +1249,7 @@ u8 func0405_president_in_room[] = { try_face_entity(ENTITYTYPE_TARGET, 0, /*goto*/ 0x78) // In this loop the president will continue to turn to face the player - // because it lacks an if_jo_ccw_direction_lt check. + // because it lacks an if_target_in_fov_left check. beginloop(0x78) if_chr_in_room(CHR_TARGET, 0x00, 0x0055, /*goto*/ 0x2d) if_chr_in_room(CHR_TARGET, 0x00, 0x0056, /*goto*/ 0x2d) @@ -3242,7 +3242,7 @@ u8 func0407_steward[] = { try_face_entity(ENTITYTYPE_TARGET, 0, /*goto*/ 0x09) beginloop(0x09) - if_jo_ccw_direction_lt(10, /*goto*/ 0x06) + if_target_in_fov_left(10, /*goto*/ 0x06) if_timer_gt(60, /*goto*/ 0x06) endloop(0x09) @@ -3298,7 +3298,7 @@ u8 func0407_stewardess[] = { try_face_entity(ENTITYTYPE_TARGET, 0, /*goto*/ 0x09) beginloop(0x09) - if_jo_ccw_direction_lt(10, /*goto*/ 0x06) + if_target_in_fov_left(10, /*goto*/ 0x06) if_timer_gt(60, /*goto*/ 0x06) endloop(0x09) diff --git a/src/files/setup/setupsho.c b/src/files/setup/setupsho.c index 7035be5e4..671205d1b 100644 --- a/src/files/setup/setupsho.c +++ b/src/files/setup/setupsho.c @@ -610,8 +610,8 @@ u8 func0402_unarmed_skedar[] = { label(0x2f) restart_timer dprint 'F','A','C','E',' ','T','A','R','G','E','T','\n',0, - if_jo_ccw_direction_lt(10, /*goto*/ 0x06) - if_jo_ccw_direction_gt(246, /*goto*/ 0x06) + if_target_in_fov_left(10, /*goto*/ 0x06) + if_target_out_of_fov_left(246, /*goto*/ 0x06) stop_chr set_action(MA_FACING, TRUE) try_face_entity(ENTITYTYPE_TARGET, 1, /*goto*/ 0x0c) @@ -623,8 +623,8 @@ u8 func0402_unarmed_skedar[] = { if_chr_death_animation_finished(CHR_TARGET, /*goto*/ 0x10) if_chr_dead(CHR_TARGET, /*goto*/ 0x10) if_chr_knockedout(CHR_TARGET, /*goto*/ 0x10) - if_jo_ccw_direction_lt(10, /*goto*/ 0x06) - if_jo_ccw_direction_gt(246, /*goto*/ 0x06) + if_target_in_fov_left(10, /*goto*/ 0x06) + if_target_out_of_fov_left(246, /*goto*/ 0x06) if_timer_gt(60, /*goto*/ 0x06) endloop(0x0c) @@ -809,8 +809,8 @@ u8 func0404_miniskedar[] = { endloop(0x0c) label(0x2d) - if_jo_ccw_direction_lt(10, /*goto*/ 0x06) - if_jo_ccw_direction_gt(246, /*goto*/ 0x06) + if_target_in_fov_left(10, /*goto*/ 0x06) + if_target_out_of_fov_left(246, /*goto*/ 0x06) goto_first(0x0c) label(0x06) @@ -2158,15 +2158,15 @@ u8 func040d_king_combat[] = { set_chr_cloaked(CHR_SELF, FALSE, TRUE) restart_timer dprint 'F','A','C','E',' ','T','A','R','G','E','T','\n',0, - if_jo_ccw_direction_lt(10, /*goto*/ 0x06) - if_jo_ccw_direction_gt(246, /*goto*/ 0x06) + if_target_in_fov_left(10, /*goto*/ 0x06) + if_target_out_of_fov_left(246, /*goto*/ 0x06) stop_chr try_face_entity(ENTITYTYPE_TARGET, 0, /*goto*/ 0x09) beginloop(0x09) if_chr_death_animation_finished(CHR_P1P2, /*goto*/ 0x0b) - if_jo_ccw_direction_lt(10, /*goto*/ 0x06) - if_jo_ccw_direction_gt(246, /*goto*/ 0x06) + if_target_in_fov_left(10, /*goto*/ 0x06) + if_target_out_of_fov_left(246, /*goto*/ 0x06) if_timer_gt(60, /*goto*/ 0x06) endloop(0x09) diff --git a/src/files/setup/setuptra.c b/src/files/setup/setuptra.c index 2bd577231..a9a55bd91 100644 --- a/src/files/setup/setuptra.c +++ b/src/files/setup/setuptra.c @@ -1339,7 +1339,7 @@ u8 func0413_jonathan_hangar[] = { try_face_entity(ENTITYTYPE_TARGET, 0, /*goto*/ 0x46) beginloop(0x46) - if_jo_ccw_direction_lt(10, /*goto*/ 0x06) + if_target_in_fov_left(10, /*goto*/ 0x06) if_timer_gt(60, /*goto*/ 0x06) endloop(0x46) diff --git a/src/files/setup/setupwax.c b/src/files/setup/setupwax.c index b75f6c6bc..61be3a265 100644 --- a/src/files/setup/setupwax.c +++ b/src/files/setup/setupwax.c @@ -1319,8 +1319,8 @@ u8 func0411_cass_in_office[] = { try_face_entity(ENTITYTYPE_TARGET, 0, /*goto*/ 0x56) beginloop(0x56) - if_jo_ccw_direction_lt(10, /*goto*/ 0x57) - if_jo_ccw_direction_gt(246, /*goto*/ 0x57) + if_target_in_fov_left(10, /*goto*/ 0x57) + if_target_out_of_fov_left(246, /*goto*/ 0x57) endloop(0x56) // Draw weapon diff --git a/src/game/chr/chraction.c b/src/game/chr/chraction.c index 5988d9ea8..1db29ecd3 100644 --- a/src/game/chr/chraction.c +++ b/src/game/chr/chraction.c @@ -14000,7 +14000,7 @@ glabel func0f03ba44 /* f03baa0: 00084fc2 */ srl $t1,$t0,0x1f /* f03baa4: a3a90043 */ sb $t1,0x43($sp) .L0f03baa8: -/* f03baa8: 0fc1241a */ jal func0f049068 +/* f03baa8: 0fc1241a */ jal chrIsTargetInFov /* f03baac: 93a60057 */ lbu $a2,0x57($sp) /* f03bab0: 5040003e */ beqzl $v0,.L0f03bbac /* f03bab4: 93a40040 */ lbu $a0,0x40($sp) @@ -19134,7 +19134,7 @@ glabel var7f1a9184 /* f040dd0: 46105482 */ mul.s $f18,$f10,$f16 /* f040dd4: 13000080 */ beqz $t8,.L0f040fd8 /* f040dd8: e7b200cc */ swc1 $f18,0xcc($sp) -/* f040ddc: 0fc1241a */ jal func0f049068 +/* f040ddc: 0fc1241a */ jal chrIsTargetInFov /* f040de0: 00003025 */ or $a2,$zero,$zero /* f040de4: 1040007c */ beqz $v0,.L0f040fd8 /* f040de8: 00000000 */ sll $zero,$zero,0x0 @@ -27340,68 +27340,17 @@ glabel var7f1a9360 /* f049064: 46007006 */ mov.s $f0,$f14 ); -GLOBAL_ASM( -glabel func0f049068 -.late_rodata -glabel var7f1a9364 -.word 0x3cc907a9 -glabel var7f1a9368 -.word 0x40490fdb -glabel var7f1a936c -.word 0x40c907a9 -glabel var7f1a9370 -.word 0x40490fdb -.text -/* f049068: 27bdffe8 */ addiu $sp,$sp,-24 -/* f04906c: afbf0014 */ sw $ra,0x14($sp) -/* f049070: afa5001c */ sw $a1,0x1c($sp) -/* f049074: afa60020 */ sw $a2,0x20($sp) -/* f049078: 0fc123f3 */ jal func0f048fcc -/* f04907c: 30c500ff */ andi $a1,$a2,0xff -/* f049080: 93af001f */ lbu $t7,0x1f($sp) -/* f049084: 3c014f80 */ lui $at,0x4f80 -/* f049088: 8fbf0014 */ lw $ra,0x14($sp) -/* f04908c: 448f2000 */ mtc1 $t7,$f4 -/* f049090: 05e10004 */ bgez $t7,.L0f0490a4 -/* f049094: 468021a0 */ cvt.s.w $f6,$f4 -/* f049098: 44814000 */ mtc1 $at,$f8 -/* f04909c: 00000000 */ sll $zero,$zero,0x0 -/* f0490a0: 46083180 */ add.s $f6,$f6,$f8 -.L0f0490a4: -/* f0490a4: 3c017f1b */ lui $at,%hi(var7f1a9364) -/* f0490a8: c42a9364 */ lwc1 $f10,%lo(var7f1a9364)($at) -/* f0490ac: 3c017f1b */ lui $at,%hi(var7f1a9368) -/* f0490b0: 460a3082 */ mul.s $f2,$f6,$f10 -/* f0490b4: 4602003c */ c.lt.s $f0,$f2 -/* f0490b8: 00000000 */ sll $zero,$zero,0x0 -/* f0490bc: 45000005 */ bc1f .L0f0490d4 -/* f0490c0: 00000000 */ sll $zero,$zero,0x0 -/* f0490c4: c4309368 */ lwc1 $f16,%lo(var7f1a9368)($at) -/* f0490c8: 4610003c */ c.lt.s $f0,$f16 -/* f0490cc: 00000000 */ sll $zero,$zero,0x0 -/* f0490d0: 4501000e */ bc1t .L0f04910c -.L0f0490d4: -/* f0490d4: 3c017f1b */ lui $at,%hi(var7f1a936c) -/* f0490d8: c432936c */ lwc1 $f18,%lo(var7f1a936c)($at) -/* f0490dc: 3c017f1b */ lui $at,%hi(var7f1a9370) -/* f0490e0: 00001025 */ or $v0,$zero,$zero -/* f0490e4: 46029101 */ sub.s $f4,$f18,$f2 -/* f0490e8: 4600203c */ c.lt.s $f4,$f0 -/* f0490ec: 00000000 */ sll $zero,$zero,0x0 -/* f0490f0: 45000008 */ bc1f .L0f049114 -/* f0490f4: 00000000 */ sll $zero,$zero,0x0 -/* f0490f8: c4289370 */ lwc1 $f8,%lo(var7f1a9370)($at) -/* f0490fc: 4600403c */ c.lt.s $f8,$f0 -/* f049100: 00000000 */ sll $zero,$zero,0x0 -/* f049104: 45000003 */ bc1f .L0f049114 -/* f049108: 00000000 */ sll $zero,$zero,0x0 -.L0f04910c: -/* f04910c: 10000001 */ beqz $zero,.L0f049114 -/* f049110: 24020001 */ addiu $v0,$zero,0x1 -.L0f049114: -/* f049114: 03e00008 */ jr $ra -/* f049118: 27bd0018 */ addiu $sp,$sp,0x18 -); +bool chrIsTargetInFov(struct chrdata *chr, u8 arg1, u8 arg2) +{ + f32 angle = func0f048fcc(chr, arg2); + + if ((angle < arg1 * 0.024539785459638f && angle < M_PI) + || (angle > M_BADTAU - arg1 * 0.024539785459638f && angle > M_PI)) { + return true; + } + + return false; +} bool func0f04911c(struct chrdata *chr, struct coord *pos, u8 arg2) { diff --git a/src/game/chr/chrai.c b/src/game/chr/chrai.c index d9f2ba90f..082767b93 100644 --- a/src/game/chr/chrai.c +++ b/src/game/chr/chrai.c @@ -95,11 +95,11 @@ bool (*g_CommandPointers[])(void) = { /*0x004a*/ ai004a, /*0x004b*/ aiIfNearMiss, /*0x004c*/ aiIfSeesSuspiciousItem, - /*0x004d*/ ai004d, + /*0x004d*/ aiIfTargetInFovLeft, /*0x004e*/ ai004e, - /*0x004f*/ ai004f, - /*0x0050*/ ai0050, - /*0x0051*/ ai0051, + /*0x004f*/ aiIfTargetOutOfFovLeft, + /*0x0050*/ aiIfTargetInFov, + /*0x0051*/ aiIfTargetOutOfFov, /*0x0052*/ aiIfDistanceToTargetLessThan, /*0x0053*/ aiIfDistanceToTargetGreaterThan, /*0x0054*/ aiIfChrDistanceToPadLessThan, diff --git a/src/game/chr/chraicommands.c b/src/game/chr/chraicommands.c index 4562a3753..c752eef7e 100644 --- a/src/game/chr/chraicommands.c +++ b/src/game/chr/chraicommands.c @@ -1653,7 +1653,7 @@ bool ai004e(void) /** * @cmd 004d */ -bool ai004d(void) +bool aiIfTargetInFovLeft(void) { u8 *cmd = g_Vars.ailist + g_Vars.aioffset; @@ -1669,7 +1669,7 @@ bool ai004d(void) /** * @cmd 004f */ -bool ai004f(void) +bool aiIfTargetOutOfFovLeft(void) { u8 *cmd = g_Vars.ailist + g_Vars.aioffset; @@ -1685,11 +1685,11 @@ bool ai004f(void) /** * @cmd 0050 */ -bool ai0050(void) +bool aiIfTargetInFov(void) { u8 *cmd = g_Vars.ailist + g_Vars.aioffset; - if (func0f049068(g_Vars.chrdata, cmd[2], 0)) { + if (chrIsTargetInFov(g_Vars.chrdata, cmd[2], 0)) { g_Vars.aioffset = chraiGoToLabel(g_Vars.ailist, g_Vars.aioffset, cmd[3]); } else { g_Vars.aioffset += 4; @@ -1701,11 +1701,11 @@ bool ai0050(void) /** * @cmd 0051 */ -bool ai0051(void) +bool aiIfTargetOutOfFov(void) { u8 *cmd = g_Vars.ailist + g_Vars.aioffset; - if (!func0f049068(g_Vars.chrdata, cmd[2], 0)) { + if (!chrIsTargetInFov(g_Vars.chrdata, cmd[2], 0)) { g_Vars.aioffset = chraiGoToLabel(g_Vars.ailist, g_Vars.aioffset, cmd[3]); } else { g_Vars.aioffset += 4; diff --git a/src/game/data/ailists.c b/src/game/data/ailists.c index ce1a3cfc3..49a03c9dd 100644 --- a/src/game/data/ailists.c +++ b/src/game/data/ailists.c @@ -1327,15 +1327,15 @@ u8 func0007_alerted[] = { if_distance_to_target_gt(2500, /*goto*/ 0x14) // Distance between 1000 and 2500 - if_jo_ccw_direction_lt(10, /*goto*/ 0x13) - if_jo_ccw_direction_gt(246, /*goto*/ 0x13) + if_target_in_fov_left(10, /*goto*/ 0x13) + if_target_out_of_fov_left(246, /*goto*/ 0x13) restart_timer stop_chr try_face_entity(ENTITYTYPE_TARGET, 0, /*goto*/ 0xec) beginloop(0xec) - if_jo_ccw_direction_lt(10, /*goto*/ 0x13) - if_jo_ccw_direction_gt(246, /*goto*/ 0x13) + if_target_in_fov_left(10, /*goto*/ 0x13) + if_target_out_of_fov_left(246, /*goto*/ 0x13) if_timer_gt(60, /*goto*/ 0x13) endloop(0xec) @@ -3877,8 +3877,8 @@ u8 func000f_hand_combat[] = { label(LABEL_FACE_TARGET) restart_timer dprint 'F','A','C','E',' ','T','A','R','G','E','T','\n',0, - if_jo_ccw_direction_lt(10, /*goto*/ LABEL_PUNCH) - if_jo_ccw_direction_gt(246, /*goto*/ LABEL_PUNCH) + if_target_in_fov_left(10, /*goto*/ LABEL_PUNCH) + if_target_out_of_fov_left(246, /*goto*/ LABEL_PUNCH) stop_chr try_face_entity(ENTITYTYPE_TARGET, 1, /*goto*/ 0x04) @@ -3888,8 +3888,8 @@ u8 func000f_hand_combat[] = { if_chr_knockedout(CHR_TARGET, /*goto*/ 0xfa) label(0x13) if_distance_to_target_gt(400, /*goto*/ 0x0b) - if_jo_ccw_direction_lt(15, /*goto*/ LABEL_PUNCH) - if_jo_ccw_direction_gt(240, /*goto*/ LABEL_PUNCH) + if_target_in_fov_left(15, /*goto*/ LABEL_PUNCH) + if_target_out_of_fov_left(240, /*goto*/ LABEL_PUNCH) if_timer_gt(60, /*goto*/ LABEL_PUNCH) endloop(0x04) @@ -3976,8 +3976,8 @@ u8 func0010_civilian_say_comment[] = { beginloop(0x04) if_saw_injury(0x01, /*goto*/ 0x83) if_saw_death(0x01, /*goto*/ 0x83) - if_jo_ccw_direction_lt(10, /*goto*/ 0x13) - if_jo_ccw_direction_gt(246, /*goto*/ 0x13) + if_target_in_fov_left(10, /*goto*/ 0x13) + if_target_out_of_fov_left(246, /*goto*/ 0x13) if_timer_gt(60, /*goto*/ 0x13) endloop(0x04) diff --git a/src/game/game_190260.c b/src/game/game_190260.c index 538001cba..af939c5ec 100644 --- a/src/game/game_190260.c +++ b/src/game/game_190260.c @@ -7378,7 +7378,7 @@ glabel var7f1b8fc8 /* f196dac: 02802025 */ or $a0,$s4,$zero /* f196db0: 2405001e */ addiu $a1,$zero,0x1e /* f196db4: 00003025 */ or $a2,$zero,$zero -/* f196db8: 0fc1241a */ jal func0f049068 +/* f196db8: 0fc1241a */ jal chrIsTargetInFov /* f196dbc: afa30054 */ sw $v1,0x54($sp) /* f196dc0: 1040000b */ beqz $v0,.L0f196df0 /* f196dc4: 8fa30054 */ lw $v1,0x54($sp) @@ -7397,7 +7397,7 @@ glabel var7f1b8fc8 /* f196df4: a460003c */ sh $zero,0x3c($v1) .L0f196df8: /* f196df8: 00003025 */ or $a2,$zero,$zero -/* f196dfc: 0fc1241a */ jal func0f049068 +/* f196dfc: 0fc1241a */ jal chrIsTargetInFov /* f196e00: afa30054 */ sw $v1,0x54($sp) /* f196e04: 10400010 */ beqz $v0,.L0f196e48 /* f196e08: 8fa30054 */ lw $v1,0x54($sp) @@ -7594,7 +7594,7 @@ glabel var7f1b8fc8 /* f1970c4: 14400006 */ bnez $v0,.L0f1970e0 /* f1970c8: 02802025 */ or $a0,$s4,$zero /* f1970cc: 2405002d */ addiu $a1,$zero,0x2d -/* f1970d0: 0fc1241a */ jal func0f049068 +/* f1970d0: 0fc1241a */ jal chrIsTargetInFov /* f1970d4: 00003025 */ or $a2,$zero,$zero /* f1970d8: 10400002 */ beqz $v0,.L0f1970e4 /* f1970dc: 00000000 */ sll $zero,$zero,0x0 @@ -7740,7 +7740,7 @@ glabel var7f1b8fc8 /* f1972e4: 14400006 */ bnez $v0,.L0f197300 /* f1972e8: 02802025 */ or $a0,$s4,$zero /* f1972ec: 2405002d */ addiu $a1,$zero,0x2d -/* f1972f0: 0fc1241a */ jal func0f049068 +/* f1972f0: 0fc1241a */ jal chrIsTargetInFov /* f1972f4: 00003025 */ or $a2,$zero,$zero /* f1972f8: 10400021 */ beqz $v0,.L0f197380 /* f1972fc: 00000000 */ sll $zero,$zero,0x0 diff --git a/src/game/game_1999b0.c b/src/game/game_1999b0.c index 2658697b5..543a19987 100644 --- a/src/game/game_1999b0.c +++ b/src/game/game_1999b0.c @@ -452,7 +452,7 @@ void func0f19a37c(struct chrdata *chr) sp72[0] = chr->aibot->weaponnum; sp72[3] = chr->aibot->gunfunc; - if (func0f049068(chr, WEAPON_GRENADE, 0)) { + if (chrIsTargetInFov(chr, WEAPON_GRENADE, 0)) { sp56.x = target->pos.x; sp56.z = target->pos.z; diff --git a/src/include/commands.h b/src/include/commands.h index a2f2bd383..35e6a0ffe 100644 --- a/src/include/commands.h +++ b/src/include/commands.h @@ -696,14 +696,14 @@ label, /** - * Checks if Jo is within a certain angle of the chr's direction. - * Value is a percentage of the circle, where 256 is a full circle. - * Only ever called with value = decimal 10, which is about 14 degrees. - * With value 10, returns true if Jo is roughly within 12-11 o'clock. + * Checks if the current chr's target is within a certain angle of the chr's + * direction. Angle is a percentage of the circle, where 256 is a full circle. + * Only ever called with angle = decimal 10, which is about 14 degrees. + * With angle 10, returns true if target is roughly within 12-11 o'clock. */ -#define if_jo_ccw_direction_lt(value, label) \ +#define if_target_in_fov_left(angle, label) \ mkshort(0x004d), \ - value, \ + angle, \ label, // Either bool1 or bool2 are set - never none or both @@ -717,32 +717,32 @@ label, /** - * Checks if Jo is outside of a certain angle of the chr's direction. - * Value is a percentage of the circle, where 256 is a full circle. - * Called with values = -10 and -11, which is about -14 degrees. - * With value -10, returns true if Jo is roughly within 12-1 o'clock. + * Checks if the current chr's target is outside of a certain angle of the chr's + * direction. Angle is a percentage of the circle, where 256 is a full circle. + * It is common to call this with angles > 240, which makes it follow the label + * if the target is roughly within 12-1 o'clock. */ -#define if_jo_ccw_direction_gt(value, label) \ +#define if_target_out_of_fov_left(angle, label) \ mkshort(0x004f), \ - value, \ + angle, \ label, /** - * Similar to 004d and 004f, but checks if Jo is within the angle of player's - * 12 o'clock (ie. either side). + * Similar to 004d and 004f, but checks if the target is within the angle of the + * current chr's 12 o'clock (ie. either side). */ -#define if_jo_front_direction_lt(value, label) \ +#define if_target_in_fov(angle, label) \ mkshort(0x0050), \ - value, \ + angle, \ label, /** - * Similar to 004d and 004f, but checks if Jo is not in front of the current chr - * by the given angle. + * Similar to 004d and 004f, but checks if the target is not in front of the + * current chr by the given angle. */ -#define if_jo_front_direction_gt(value, label) \ +#define if_target_out_of_fov(angle, label) \ mkshort(0x0051), \ - value, \ + angle, \ label, /** diff --git a/src/include/game/chr/chraction.h b/src/include/game/chr/chraction.h index 9602c4ea3..bf2e2262b 100644 --- a/src/include/game/chr/chraction.h +++ b/src/include/game/chr/chraction.h @@ -174,9 +174,9 @@ u32 func0f048b78(void); u32 func0f048cc0(void); f32 func0f048dcc(struct chrdata *chr); bool func0f048e74(struct chrdata *chr, u32 arg1); -u32 func0f048f20(struct chrdata *chr, u8 b); -u32 func0f048fcc(void); -u32 func0f049068(struct chrdata *chr, u32 arg1, u32 arg2); +u32 func0f048f20(struct chrdata *chr, u8 arg1); +f32 func0f048fcc(struct chrdata *chr, u8 arg1); +bool chrIsTargetInFov(struct chrdata *chr, u8 arg1, u8 arg2); bool func0f04911c(struct chrdata *chr, struct coord *pos, u8 arg2); f32 chrGetSameFloorDistanceToPad(struct chrdata *chr, s32 pad_id); void func0f049644(u32 playernum); diff --git a/src/include/game/chr/chraicommands.h b/src/include/game/chr/chraicommands.h index 74601281d..84e68fab3 100644 --- a/src/include/game/chr/chraicommands.h +++ b/src/include/game/chr/chraicommands.h @@ -80,11 +80,11 @@ /*0x004a*/ bool ai004a(void); /*0x004b*/ bool aiIfNearMiss(void); /*0x004c*/ bool aiIfSeesSuspiciousItem(void); -/*0x004d*/ bool ai004d(void); +/*0x004d*/ bool aiIfTargetInFovLeft(void); /*0x004e*/ bool ai004e(void); -/*0x004f*/ bool ai004f(void); -/*0x0050*/ bool ai0050(void); -/*0x0051*/ bool ai0051(void); +/*0x004f*/ bool aiIfTargetOutOfFovLeft(void); +/*0x0050*/ bool aiIfTargetInFov(void); +/*0x0051*/ bool aiIfTargetOutOfFov(void); /*0x0052*/ bool aiIfDistanceToTargetLessThan(void); /*0x0053*/ bool aiIfDistanceToTargetGreaterThan(void); /*0x0054*/ bool aiIfChrDistanceToPadLessThan(void);