From 12ab88c974e2df0d32660f3f4969d5894dbad9c7 Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sun, 22 Dec 2019 16:12:57 +1000 Subject: [PATCH] Attempt to decompile chrSawInjury and improve documentation for related AI commands --- src/files/setup/setupame.c | 4 +-- src/files/setup/setupark.c | 14 +++++----- src/files/setup/setupcave.c | 26 +++++++++--------- src/files/setup/setupear.c | 12 ++++----- src/files/setup/setupeld.c | 8 +++--- src/files/setup/setuplee.c | 2 +- src/files/setup/setuplip.c | 12 ++++----- src/files/setup/setuppam.c | 2 +- src/files/setup/setuppete.c | 14 +++++----- src/files/setup/setuprit.c | 16 +++++------ src/files/setup/setupsho.c | 2 +- src/game/chr/chr.c | 40 +++++++++++++++++++++------- src/game/chr/chraicommands.c | 4 +-- src/include/commands.h | 34 ++++++++++++++++++++--- src/include/game/chr/chr.h | 2 +- src/include/game/chr/chraicommands.h | 2 +- src/setup/ailists.c | 18 ++++++------- src/setup/setup_000000.c | 2 +- 18 files changed, 131 insertions(+), 83 deletions(-) diff --git a/src/files/setup/setupame.c b/src/files/setup/setupame.c index fea52508a..c60e080b7 100644 --- a/src/files/setup/setupame.c +++ b/src/files/setup/setupame.c @@ -1681,7 +1681,7 @@ u8 func0414_programmer[] = { beginloop(0x93) if_target_chr_in_sight(/*goto*/ 0x96) if_near_miss(/*goto*/ 0x96) - if_shot_near_chr(0x00, /*goto*/ 0x96) + if_saw_injury(0x00, /*goto*/ 0x96) if_saw_death(0x00, /*goto*/ 0x96) if_hears_gunfire(/*goto*/ 0x96) if_stage_flag_eq(STAGEFLAG_PROGRAMMER_RAN_TO_GUARD, TRUE, /*goto*/ 0x2c) @@ -3731,7 +3731,7 @@ u8 func042f_surrendering_guard[] = { if_target_chr_in_sight(/*goto*/ 0x2c) if_enemy_distance_lt_and_los(500, /*goto*/ 0x2c) if_near_miss(/*goto*/ 0x2c) - if_shot_near_chr(0x00, /*goto*/ 0x2c) + if_saw_injury(0x00, /*goto*/ 0x2c) endloop(0xc4) // Be surprised diff --git a/src/files/setup/setupark.c b/src/files/setup/setupark.c index 666758b89..96fbee283 100644 --- a/src/files/setup/setupark.c +++ b/src/files/setup/setupark.c @@ -1657,7 +1657,7 @@ u8 func0409_tech_conversation[] = { animation(0x0204, -1, -1, 0x02, 0x14, 0x10, 2) beginloop(0x28) - if_shot_near_chr(0x00, /*goto*/ 0x33) + if_saw_injury(0x00, /*goto*/ 0x33) if_saw_death(0x00, /*goto*/ 0x33) if_timer_gt(30, /*goto*/ 0x20) endloop(0x28) @@ -1669,7 +1669,7 @@ u8 func0409_tech_conversation[] = { restart_timer beginloop(0x21) - if_shot_near_chr(0x00, /*goto*/ 0x33) + if_saw_injury(0x00, /*goto*/ 0x33) if_saw_death(0x00, /*goto*/ 0x33) chr_toggle_p1p2(CHR_SELF) set_target_chr(CHR_P1P2) @@ -1690,7 +1690,7 @@ u8 func0409_tech_conversation[] = { speak(CHR_PRESET, 0x0626, 0x8120, CHANNEL_7, COLOR_08_RED) // "Yes, it is." beginloop(0x22) - if_shot_near_chr(0x00, /*goto*/ 0x33) + if_saw_injury(0x00, /*goto*/ 0x33) if_saw_death(0x00, /*goto*/ 0x33) chr_toggle_p1p2(CHR_SELF) set_target_chr(CHR_P1P2) @@ -1711,7 +1711,7 @@ u8 func0409_tech_conversation[] = { speak(CHR_PRESET, 0x0627, 0x811e, CHANNEL_7, COLOR_06_WHITE) // "Give it to me - you're doing it wrong." beginloop(0x23) - if_shot_near_chr(0x00, /*goto*/ 0x33) + if_saw_injury(0x00, /*goto*/ 0x33) if_saw_death(0x00, /*goto*/ 0x33) chr_toggle_p1p2(CHR_SELF) set_target_chr(CHR_P1P2) @@ -1732,7 +1732,7 @@ u8 func0409_tech_conversation[] = { speak(CHR_PRESET, 0x0628, 0x8121, CHANNEL_7, COLOR_08_RED) // "Stop annoying me." beginloop(0x24) - if_shot_near_chr(0x00, /*goto*/ 0x33) + if_saw_injury(0x00, /*goto*/ 0x33) if_saw_death(0x00, /*goto*/ 0x33) chr_toggle_p1p2(CHR_SELF) set_target_chr(CHR_P1P2) @@ -1754,7 +1754,7 @@ u8 func0409_tech_conversation[] = { speak(CHR_PRESET, 0x0629, 0x8123, CHANNEL_7, COLOR_09_BLUE) // "Will you just hurry up!" beginloop(0x25) - if_shot_near_chr(0x00, /*goto*/ 0x33) + if_saw_injury(0x00, /*goto*/ 0x33) if_saw_death(0x00, /*goto*/ 0x33) chr_toggle_p1p2(CHR_SELF) set_target_chr(CHR_P1P2) @@ -1774,7 +1774,7 @@ u8 func0409_tech_conversation[] = { stop_chr beginloop(0x26) - if_shot_near_chr(0x00, /*goto*/ 0x33) + if_saw_injury(0x00, /*goto*/ 0x33) if_saw_death(0x00, /*goto*/ 0x33) chr_toggle_p1p2(CHR_SELF) set_target_chr(CHR_P1P2) diff --git a/src/files/setup/setupcave.c b/src/files/setup/setupcave.c index 40e9cd150..1537796cb 100644 --- a/src/files/setup/setupcave.c +++ b/src/files/setup/setupcave.c @@ -1513,7 +1513,7 @@ u8 func0408_secretary[] = { chr_toggle_p1p2(CHR_SELF) set_target_chr(CHR_P1P2) set_view_distance(100) - if_shot_near_chr(0x00, /*goto*/ LABEL_BECOME_ALERT1) + if_saw_injury(0x00, /*goto*/ LABEL_BECOME_ALERT1) if_saw_death(0x00, /*goto*/ LABEL_BECOME_ALERT1) set_view_distance(14) if_alertness(99, OPERATOR_GREATER_THAN, /*goto*/ LABEL_BECOME_ALERT1) @@ -1585,7 +1585,7 @@ u8 func0408_secretary[] = { set_morale(2) beginloop(0x08) - if_shot_near_chr(0x00, /*goto*/ LABEL_BECOME_ALERT2) + if_saw_injury(0x00, /*goto*/ LABEL_BECOME_ALERT2) if_alertness(99, OPERATOR_GREATER_THAN, /*goto*/ LABEL_BECOME_ALERT2) if_timer_gt(60, /*goto*/ 0x02) if_chr_sees_player(/*goto*/ 0x31) @@ -1615,7 +1615,7 @@ u8 func0408_secretary[] = { set_morale(3) beginloop(0x09) - if_shot_near_chr(0x00, /*goto*/ LABEL_BECOME_ALERT2) + if_saw_injury(0x00, /*goto*/ LABEL_BECOME_ALERT2) if_alertness(99, OPERATOR_GREATER_THAN, /*goto*/ LABEL_BECOME_ALERT2) if_timer_gt(400, /*goto*/ 0x02) if_chr_sees_player(/*goto*/ 0x31) @@ -1640,7 +1640,7 @@ u8 func0408_secretary[] = { set_morale(4) beginloop(0x0a) - if_shot_near_chr(0x00, /*goto*/ LABEL_BECOME_ALERT2) + if_saw_injury(0x00, /*goto*/ LABEL_BECOME_ALERT2) if_alertness(99, OPERATOR_GREATER_THAN, /*goto*/ LABEL_BECOME_ALERT2) if_timer_gt(400, /*goto*/ 0x0c) if_chr_sees_player(/*goto*/ 0x31) @@ -1690,7 +1690,7 @@ u8 func0408_secretary[] = { unlock_door(0x18, 0x02) beginloop(0x0e) - if_shot_near_chr(0x00, /*goto*/ LABEL_BECOME_ALERT2) + if_saw_injury(0x00, /*goto*/ LABEL_BECOME_ALERT2) if_saw_death(0x00, /*goto*/ LABEL_BECOME_ALERT2) if_alertness(99, OPERATOR_GREATER_THAN, /*goto*/ LABEL_BECOME_ALERT2) endloop(0x0e) @@ -2066,7 +2066,7 @@ u8 func0409_office1[] = { chr_toggle_p1p2(CHR_SELF) set_target_chr(CHR_P1P2) if_target_chr_in_sight(/*goto*/ 0x02) - if_shot_near_chr(0x00, /*goto*/ LABEL_RUN_TO_FOYER) + if_saw_injury(0x00, /*goto*/ LABEL_RUN_TO_FOYER) if_stage_flag_eq(STAGEFLAG_OFFICE2_DEAD, TRUE, /*goto*/ LABEL_RUN_TO_FOYER) if_object_in_good_condition(0x45, /*goto*/ 0x33) goto_next(LABEL_RUN_TO_FOYER) @@ -2094,7 +2094,7 @@ u8 func0409_office1[] = { speak(CHR_TARGET, 0x0e29, 0x1ae6, CHANNEL_4, COLOR_08_RED) // "Are you new around here?" beginloop(0x09) - if_shot_near_chr(0x00, /*goto*/ LABEL_RUN_TO_FOYER) + if_saw_injury(0x00, /*goto*/ LABEL_RUN_TO_FOYER) if_stage_flag_eq(STAGEFLAG_OFFICE2_DEAD, TRUE, /*goto*/ LABEL_RUN_TO_FOYER) if_chr_has_object(CHR_TARGET, OBJ_BRIEFCASE1, /*goto*/ 0x02) if_chr_weapon_equipped(CHR_TARGET, WEAPON_UNARMED, /*goto*/ 0x31) @@ -2201,7 +2201,7 @@ u8 func040a_office2[] = { beginloop(0x00) if_alertness(99, OPERATOR_GREATER_THAN, /*goto*/ 0x02) - if_shot_near_chr(0x00, /*goto*/ 0x72) + if_saw_injury(0x00, /*goto*/ 0x72) if_stage_flag_eq(STAGEFLAG_OFFICE1_DEAD, TRUE, /*goto*/ 0x72) if_chr_idle(/*goto*/ 0x31) goto_first(0x42) @@ -2216,7 +2216,7 @@ u8 func040a_office2[] = { chr_toggle_p1p2(CHR_SELF) set_target_chr(CHR_P1P2) if_chr_sees_player(/*goto*/ 0x02) - if_shot_near_chr(0x00, /*goto*/ 0x02) + if_saw_injury(0x00, /*goto*/ 0x02) if_stage_flag_eq(STAGEFLAG_OFFICE1_DEAD, TRUE, /*goto*/ 0x72) endloop(0x09) @@ -3296,7 +3296,7 @@ u8 func0419_ba8c[] = { beginloop(0x6b) if_saw_death(0x00, /*goto*/ 0x4f) - if_shot_near_chr(0x00, /*goto*/ 0x0f) + if_saw_injury(0x00, /*goto*/ 0x0f) dprint 'D','U','R','I','N','G','T','A','L','K','\n',0, if_timer_gt(180, /*goto*/ 0x02) endloop(0x6b) @@ -3372,7 +3372,7 @@ u8 func0419_ba8c[] = { chr_toggle_p1p2(CHR_SELF) set_target_chr(CHR_P1P2) if_saw_death(0x00, /*goto*/ 0x4f) - if_shot_near_chr(0x00, /*goto*/ 0x0f) + if_saw_injury(0x00, /*goto*/ 0x0f) if_target_chr_in_sight(/*goto*/ 0x02) if_chr_stopped(/*goto*/ 0x73) if_chr_idle(/*goto*/ 0x31) @@ -3385,7 +3385,7 @@ u8 func0419_ba8c[] = { label(0x6c) if_saw_death(0x00, /*goto*/ 0x4f) - if_shot_near_chr(0x00, /*goto*/ 0x0f) + if_saw_injury(0x00, /*goto*/ 0x0f) if_target_chr_in_sight(/*goto*/ 0x02) goto_first(0x00) @@ -3394,7 +3394,7 @@ u8 func0419_ba8c[] = { label(0x04) yield if_saw_death(0x00, /*goto*/ 0x4f) - if_shot_near_chr(0x00, /*goto*/ 0x0f) + if_saw_injury(0x00, /*goto*/ 0x0f) if_chr_weapon_equipped(CHR_TARGET, WEAPON_UNARMED, /*goto*/ 0x31) goto_next(0x02) label(0x31) diff --git a/src/files/setup/setupear.c b/src/files/setup/setupear.c index 587013ed6..54f87b288 100644 --- a/src/files/setup/setupear.c +++ b/src/files/setup/setupear.c @@ -2845,7 +2845,7 @@ u8 func0402_k7_guard[] = { if_target_chr_in_sight(/*goto*/ 0x0c) if_near_miss(/*goto*/ 0x0c) if_num_times_shot_gt(0, /*goto*/ 0x0c) - if_shot_near_chr(0x00, /*goto*/ 0x0c) + if_saw_injury(0x00, /*goto*/ 0x0c) if_alertness(99, OPERATOR_GREATER_THAN, /*goto*/ 0x0c) if_timer_gt(120, /*goto*/ 0x06) endloop(0x04) @@ -2863,7 +2863,7 @@ u8 func0402_k7_guard[] = { if_target_chr_in_sight(/*goto*/ 0x0c) if_near_miss(/*goto*/ 0x0c) if_num_times_shot_gt(0, /*goto*/ 0x0c) - if_shot_near_chr(0x00, /*goto*/ 0x0c) + if_saw_injury(0x00, /*goto*/ 0x0c) if_alertness(99, OPERATOR_GREATER_THAN, /*goto*/ 0x0c) if_chr_stopped(/*goto*/ 0x2f) goto_first(0x08) @@ -2899,7 +2899,7 @@ u8 func0402_k7_guard[] = { if_target_chr_in_sight(/*goto*/ 0x0c) if_near_miss(/*goto*/ 0x0c) if_num_times_shot_gt(0, /*goto*/ 0x0c) - if_shot_near_chr(0x00, /*goto*/ 0x0c) + if_saw_injury(0x00, /*goto*/ 0x0c) if_alertness(99, OPERATOR_GREATER_THAN, /*goto*/ 0x0c) if_timer_gt(180, /*goto*/ 0x06) endloop(0x09) @@ -2913,7 +2913,7 @@ u8 func0402_k7_guard[] = { if_target_chr_in_sight(/*goto*/ 0x0c) if_near_miss(/*goto*/ 0x0c) if_num_times_shot_gt(0, /*goto*/ 0x0c) - if_shot_near_chr(0x00, /*goto*/ 0x0c) + if_saw_injury(0x00, /*goto*/ 0x0c) if_alertness(99, OPERATOR_GREATER_THAN, /*goto*/ 0x0c) if_timer_gt(300, /*goto*/ 0x06) endloop(0x0a) @@ -2946,7 +2946,7 @@ u8 func0403_k7_scientist[] = { if_target_chr_in_sight(/*goto*/ 0x0c) if_near_miss(/*goto*/ 0x0c) if_num_times_shot_gt(0, /*goto*/ 0x0c) - if_shot_near_chr(0x00, /*goto*/ 0x0c) + if_saw_injury(0x00, /*goto*/ 0x0c) if_saw_death(0x00, /*goto*/ 0x0c) if_alertness(99, OPERATOR_GREATER_THAN, /*goto*/ 0x0c) call_rng @@ -2976,7 +2976,7 @@ u8 func0403_k7_scientist[] = { if_target_chr_in_sight(/*goto*/ 0x0c) if_near_miss(/*goto*/ 0x0c) if_num_times_shot_gt(0, /*goto*/ 0x0c) - if_shot_near_chr(0x00, /*goto*/ 0x0c) + if_saw_injury(0x00, /*goto*/ 0x0c) if_alertness(99, OPERATOR_GREATER_THAN, /*goto*/ 0x0c) if_chr_stopped(/*goto*/ 0x2f) endloop(0x0f) diff --git a/src/files/setup/setupeld.c b/src/files/setup/setupeld.c index 9efaa2b04..b6e44d8be 100644 --- a/src/files/setup/setupeld.c +++ b/src/files/setup/setupeld.c @@ -1618,7 +1618,7 @@ u8 func0402_taker[] = { animation(0x0232, 0, -1, 0x00, 0x0a, CHR_SELF, 2) beginloop(0x0e) - if_shot_near_chr(0x00, /*goto*/ 0x2e) + if_saw_injury(0x00, /*goto*/ 0x2e) if_chr_stopped(/*goto*/ 0x2d) endloop(0x0e) @@ -1630,7 +1630,7 @@ u8 func0402_taker[] = { walk_to_pad(0x004f) beginloop(0x11) - if_shot_near_chr(0x00, /*goto*/ 0x2e) + if_saw_injury(0x00, /*goto*/ 0x2e) if_chr_stopped(/*goto*/ 0x2d) endloop(0x11) @@ -1827,7 +1827,7 @@ u8 func0404_sniper[] = { set_target_chr(CHR_P1P2) if_target_chr_in_sight(/*goto*/ 0x58) if_saw_death(0x00, /*goto*/ 0x58) - if_shot_near_chr(0x00, /*goto*/ 0x58) + if_saw_injury(0x00, /*goto*/ 0x58) dprint 'F','A','C','E','\n',0, if_timer_gt(120, /*goto*/ 0x06) endloop(0x0a) @@ -1862,7 +1862,7 @@ u8 func0404_sniper[] = { set_target_chr(CHR_P1P2) if_target_chr_in_sight(/*goto*/ 0x58) if_saw_death(0x00, /*goto*/ 0x58) - if_shot_near_chr(0x00, /*goto*/ 0x58) + if_saw_injury(0x00, /*goto*/ 0x58) dprint 'R','U','N','\n',0, call_rng if_rand_gt(3, /*goto*/ 0x2d) diff --git a/src/files/setup/setuplee.c b/src/files/setup/setuplee.c index e04452a58..6024d7698 100644 --- a/src/files/setup/setuplee.c +++ b/src/files/setup/setuplee.c @@ -2992,7 +2992,7 @@ u8 func0421_bridge_skedar[] = { if_player_looking_at_something_maybe(0x00, 0x00, 0x01, /*goto*/ 0x06) if_target_chr_in_sight(/*goto*/ 0xc8) label(0x06) - if_shot_near_chr(0x00, /*goto*/ 0xc8) + if_saw_injury(0x00, /*goto*/ 0xc8) if_near_miss(/*goto*/ 0xc9) label(0x2c) set_target_chr(CHR_P1P2) diff --git a/src/files/setup/setuplip.c b/src/files/setup/setuplip.c index ed827bb48..941330928 100644 --- a/src/files/setup/setuplip.c +++ b/src/files/setup/setuplip.c @@ -1821,7 +1821,7 @@ u8 func0418_doorman[] = { beginloop(0x0f) if_alertness(99, OPERATOR_GREATER_THAN, /*goto*/ 0x06) - if_shot_near_chr(0x00, /*goto*/ 0x06) + if_saw_injury(0x00, /*goto*/ 0x06) if_chr_weapon_equipped(CHR_TARGET, WEAPON_NONE, /*goto*/ 0x2d) if_chr_weapon_equipped(CHR_TARGET, WEAPON_UNARMED, /*goto*/ 0x2d) goto_next(0x06) @@ -2704,7 +2704,7 @@ u8 func041f_labtech_lights[] = { chr_toggle_p1p2(CHR_SELF) set_target_chr(CHR_P1P2) if_target_chr_in_sight(/*goto*/ 0x2d) - if_shot_near_chr(0x00, /*goto*/ 0x0f) + if_saw_injury(0x00, /*goto*/ 0x0f) label(0x2d) if_chr_weapon_equipped(CHR_TARGET, WEAPON_NONE, /*goto*/ 0x2d) if_chr_weapon_equipped(CHR_TARGET, WEAPON_UNARMED, /*goto*/ 0x2d) @@ -2742,7 +2742,7 @@ u8 func041f_labtech_lights[] = { chr_toggle_p1p2(CHR_SELF) set_target_chr(CHR_P1P2) if_target_chr_in_sight(/*goto*/ 0x2d) - if_shot_near_chr(0x00, /*goto*/ 0x0f) + if_saw_injury(0x00, /*goto*/ 0x0f) label(0x2d) if_chr_weapon_equipped(CHR_TARGET, WEAPON_NONE, /*goto*/ 0x2d) if_chr_weapon_equipped(CHR_TARGET, WEAPON_UNARMED, /*goto*/ 0x2d) @@ -2838,7 +2838,7 @@ u8 func0420_labtech_doors[] = { if_chr_sees_player(/*goto*/ 0x03) label(0x06) if_alertness(99, OPERATOR_GREATER_THAN, /*goto*/ 0x03) - if_shot_near_chr(0x00, /*goto*/ 0x03) + if_saw_injury(0x00, /*goto*/ 0x03) if_saw_death(0x00, /*goto*/ 0x03) if_chr_idle(/*goto*/ 0x2d) goto_first(0x5e) @@ -2852,7 +2852,7 @@ u8 func0420_labtech_doors[] = { try_face_entity(0x0200, 0x0000, /*goto*/ 0x09) beginloop(0x09) - if_shot_near_chr(0x00, /*goto*/ 0x89) + if_saw_injury(0x00, /*goto*/ 0x89) if_saw_death(0x00, /*goto*/ 0x89) if_jo_ccw_direction_lt(10, /*goto*/ 0x06) if_timer_gt(60, /*goto*/ 0x06) @@ -2879,7 +2879,7 @@ u8 func0420_labtech_doors[] = { set_self_flag_bankx(CHRFLAG0_08000000, BANK_0) beginloop(0x7b) - if_shot_near_chr(0x00, /*goto*/ 0x89) + if_saw_injury(0x00, /*goto*/ 0x89) if_saw_death(0x00, /*goto*/ 0x89) dprint 'T','A','L','K',' ','5','\n',0, if_chr_propsoundcount_zero(CHR_SELF, /*goto*/ 0x2d) diff --git a/src/files/setup/setuppam.c b/src/files/setup/setuppam.c index 4c3f3bccd..127ecf1c4 100644 --- a/src/files/setup/setuppam.c +++ b/src/files/setup/setuppam.c @@ -3263,7 +3263,7 @@ u8 func040c_blonde[] = { set_onshot_function(GFUNC_ALERTED) beginloop(0x08) - if_shot_near_chr(0x00, /*goto*/ 0x06) + if_saw_injury(0x00, /*goto*/ 0x06) if_saw_death(0x00, /*goto*/ 0x06) if_chr_sees_player(/*goto*/ 0x06) endloop(0x08) diff --git a/src/files/setup/setuppete.c b/src/files/setup/setuppete.c index 64d2e764d..a409b5834 100644 --- a/src/files/setup/setuppete.c +++ b/src/files/setup/setuppete.c @@ -1315,7 +1315,7 @@ u8 func0412_cia[] = { // Chr is idle beginloop(0x43) if_saw_death(0x00, /*goto*/ 0x1d) - if_shot_near_chr(0x00, /*goto*/ 0x1e) + if_saw_injury(0x00, /*goto*/ 0x1e) dprint 'D','U','R','I','N','G','T','A','L','K','\n',0, if_timer_gt(180, /*goto*/ 0x04) endloop(0x43) @@ -1398,7 +1398,7 @@ u8 func0412_cia[] = { chr_toggle_p1p2(CHR_SELF) set_target_chr(CHR_P1P2) if_saw_death(0x00, /*goto*/ 0x1d) - if_shot_near_chr(0x00, /*goto*/ 0x1e) + if_saw_injury(0x00, /*goto*/ 0x1e) if_target_chr_in_sight(/*goto*/ 0x04) if_chr_stopped(/*goto*/ 0x35) endloop(0x36) @@ -1408,7 +1408,7 @@ u8 func0412_cia[] = { label(0x37) if_saw_death(0x00, /*goto*/ 0x1d) - if_shot_near_chr(0x00, /*goto*/ 0x1e) + if_saw_injury(0x00, /*goto*/ 0x1e) if_target_chr_in_sight(/*goto*/ 0x04) goto_first(0x10) @@ -1417,7 +1417,7 @@ u8 func0412_cia[] = { label(0x05) yield if_saw_death(0x00, /*goto*/ 0x1d) - if_shot_near_chr(0x00, /*goto*/ 0x1e) + if_saw_injury(0x00, /*goto*/ 0x1e) if_chr_weapon_equipped(CHR_P1P2, WEAPON_UNARMED, /*goto*/ 0x03) goto_next(0x04) @@ -1832,7 +1832,7 @@ u8 func041d_fbi[] = { if_near_miss(/*goto*/ 0x18) if_num_times_shot_gt(0, /*goto*/ 0x18) if_hears_gunfire(/*goto*/ 0x16) - if_shot_near_chr(0x00, /*goto*/ 0x16) + if_saw_injury(0x00, /*goto*/ 0x16) if_saw_death(0x00, /*goto*/ 0x16) if_dying(/*goto*/ 0x16) endloop(0x19) @@ -2107,7 +2107,7 @@ u8 func041e_sealer1[] = { if_near_miss(/*goto*/ LABEL_ALERTED) if_num_times_shot_gt(0, /*goto*/ LABEL_ALERTED) if_hears_gunfire(/*goto*/ LABEL_ALERTED) - if_shot_near_chr(0x00, /*goto*/ LABEL_ALERTED) + if_saw_injury(0x00, /*goto*/ LABEL_ALERTED) if_saw_death(0x00, /*goto*/ LABEL_ALERTED) if_dying(/*goto*/ LABEL_ALERTED) endloop(0x19) @@ -2192,7 +2192,7 @@ u8 func041e_sealer1[] = { beginloop(0x0b) if_alertness(99, OPERATOR_GREATER_THAN, /*goto*/ 0x04) - if_shot_near_chr(0x00, /*goto*/ 0x04) + if_saw_injury(0x00, /*goto*/ 0x04) if_sound_finished(CHANNEL_6, /*goto*/ 0x04) endloop(0x0b) diff --git a/src/files/setup/setuprit.c b/src/files/setup/setuprit.c index 55a10fb3d..a5166e5b5 100644 --- a/src/files/setup/setuprit.c +++ b/src/files/setup/setuprit.c @@ -1226,7 +1226,7 @@ u8 func0405_president_in_room[] = { goto_next(0x86) label(0x2d) - if_shot_near_chr(0x00, /*goto*/ 0x86) + if_saw_injury(0x00, /*goto*/ 0x86) if_hears_gunfire(/*goto*/ 0x86) if_timer_lt(120, /*goto*/ 0x2d) if_chr_in_view(/*goto*/ 0x06) @@ -1249,7 +1249,7 @@ u8 func0405_president_in_room[] = { goto_next(0x86) label(0x2d) - if_shot_near_chr(0x00, /*goto*/ 0x86) + if_saw_injury(0x00, /*goto*/ 0x86) if_hears_gunfire(/*goto*/ 0x86) if_timer_lt(240, /*goto*/ 0x2d) if_chr_in_view(/*goto*/ 0x06) @@ -1269,7 +1269,7 @@ u8 func0405_president_in_room[] = { goto_next(0x86) label(0x2d) - if_shot_near_chr(0x00, /*goto*/ 0x86) + if_saw_injury(0x00, /*goto*/ 0x86) if_hears_gunfire(/*goto*/ 0x86) if_timer_lt(400, /*goto*/ 0x2d) goto_next(0x84) @@ -1342,7 +1342,7 @@ u8 func0405_president_in_room[] = { goto_next(0x86) label(0x2d) - if_shot_near_chr(0x00, /*goto*/ 0x86) + if_saw_injury(0x00, /*goto*/ 0x86) if_hears_gunfire(/*goto*/ 0x86) if_sound_finished(CHANNEL_6, /*goto*/ 0x06) goto_first(0x0b) @@ -1360,7 +1360,7 @@ u8 func0405_president_in_room[] = { goto_next(0x86) label(0x2d) - if_shot_near_chr(0x00, /*goto*/ 0x86) + if_saw_injury(0x00, /*goto*/ 0x86) if_hears_gunfire(/*goto*/ 0x86) if_timer_gt(400, /*goto*/ 0x06) endloop(0x7a) @@ -3206,7 +3206,7 @@ u8 func0407_steward[] = { chr_toggle_p1p2(CHR_SELF) set_target_chr(CHR_P1P2) if_target_chr_in_sight(/*goto*/ 0x89) - if_shot_near_chr(0x00, /*goto*/ 0x89) + if_saw_injury(0x00, /*goto*/ 0x89) if_chr_stopped(/*goto*/ 0x06) endloop(0x87) @@ -3223,7 +3223,7 @@ u8 func0407_steward[] = { animation(ANIM_OPERATE_0204, 0, -1, 0x10, 0x10, CHR_SELF, 2) label(0x2d) if_target_chr_in_sight(/*goto*/ 0x89) - if_shot_near_chr(0x00, /*goto*/ 0x89) + if_saw_injury(0x00, /*goto*/ 0x89) endloop(0x03) // Detected player @@ -3278,7 +3278,7 @@ u8 func0407_stewardess[] = { animation(ANIM_OPERATE_0204, 0, -1, 0x10, 0x10, CHR_SELF, 2) label(0x2d) if_alertness(99, OPERATOR_GREATER_THAN, /*goto*/ 0x2d) - if_shot_near_chr(0x00, /*goto*/ 0x2d) + if_saw_injury(0x00, /*goto*/ 0x2d) if_chr_dying(CHR_STEWARD, /*goto*/ 0x2d) if_chr_death_animation_finished(CHR_STEWARD, /*goto*/ 0x2d) if_chr_unloaded(CHR_STEWARD, /*goto*/ 0x2d) diff --git a/src/files/setup/setupsho.c b/src/files/setup/setupsho.c index 5ca98f672..dd84bcf2d 100644 --- a/src/files/setup/setupsho.c +++ b/src/files/setup/setupsho.c @@ -1699,7 +1699,7 @@ u8 func0409_reaper_slayer_skedar[] = { label(0x06) if_just_injured(CHR_SELF, /*goto*/ 0x58) label(0x2d) - if_shot_near_chr(0x00, /*goto*/ 0x60) + if_saw_injury(0x00, /*goto*/ 0x60) if_near_miss(/*goto*/ 0x61) label(0x2d) set_target_chr(CHR_P1P2) diff --git a/src/game/chr/chr.c b/src/game/chr/chr.c index b3dba46dd..1ff36caf6 100644 --- a/src/game/chr/chr.c +++ b/src/game/chr/chr.c @@ -50224,7 +50224,7 @@ s32 chrGetNumCloseArghs(struct chrdata *chr) } GLOBAL_ASM( -glabel func0f04a110 +glabel chrSawInjury /* f04a110: 27bdffe0 */ addiu $sp,$sp,-32 /* f04a114: afbf0014 */ sw $ra,0x14($sp) /* f04a118: afa50024 */ sw $a1,0x24($sp) @@ -50269,6 +50269,26 @@ glabel func0f04a110 /* f04a1a8: 00000000 */ sll $zero,$zero,0x0 ); +// Mismatch because it uses the wrong register for chr->chrseeshot +//bool chrSawInjury(struct chrdata *chr, u8 arg1) +//{ +// bool saw_injury = chr->chrseeshot >= 0; +// +// if (saw_injury && arg1 == 0) { +// chr->chrseeshot = -1; +// } else if (saw_injury && arg1 == 1) { +// struct chrdata *victim = chrFindById(chr, chr->chrseeshot); +// +// if (victim && !chrCompareTeams(chr, victim, 1)) { +// saw_injury = false; +// } +// } else { +// chr->chrseeshot = -1; +// } +// +// return saw_injury; +//} + GLOBAL_ASM( glabel chrSawDeath /* f04a1ac: 27bdffe0 */ addiu $sp,$sp,-32 @@ -50323,17 +50343,19 @@ glabel chrSawDeath //{ // bool saw_death = chr->chrseedie >= 0; // -// if (!saw_death || arg1) { -// if (saw_death && arg1 == 1) { -// struct chrdata *victim = chrFindById(chr, chr->chrseedie); +// // The commented line below was likely originally there but removed before +// // the final version. Compare with chrSawInjury above. +// if (saw_death && arg1 == 0) { +// //chr->chrseedie = -1; +// } else if (saw_death && arg1 == 1) { +// struct chrdata *victim = chrFindById(chr, chr->chrseedie); // -// if (victim && !chrCompareTeams(chr, victim, 1)) { -// saw_death = false; -// chr->chrseedie = -1; -// } -// } else { +// if (victim && !chrCompareTeams(chr, victim, 1)) { +// saw_death = false; // chr->chrseedie = -1; // } +// } else { +// chr->chrseedie = -1; // } // // return saw_death; diff --git a/src/game/chr/chraicommands.c b/src/game/chr/chraicommands.c index afce8a449..d9a744bf6 100644 --- a/src/game/chr/chraicommands.c +++ b/src/game/chr/chraicommands.c @@ -1626,11 +1626,11 @@ bool ai003c(void) /** * @cmd 003d */ -bool ai003d(void) +bool aiIfSawInjury(void) { u8 *cmd = g_Vars.ailist + g_Vars.aioffset; - if (func0f04a110(g_Vars.chrdata, cmd[2])) { + if (chrSawInjury(g_Vars.chrdata, cmd[2])) { g_Vars.aioffset = chraiGoToLabel(g_Vars.ailist, g_Vars.aioffset, cmd[3]); } else { g_Vars.aioffset += 4; diff --git a/src/include/commands.h b/src/include/commands.h index 95eb39554..5453bac06 100644 --- a/src/include/commands.h +++ b/src/include/commands.h @@ -234,14 +234,40 @@ mkshort(0x003c), \ label, -#define if_shot_near_chr(u1, label) \ +/** + * Go to label if the chr has witnessed another chr being injured. + * + * The behaviour of the checktype argument is: + * + * |-----------|-------|-------------------------| + * | Checktype | Teams | Reset "Saw injury" flag | + * |-----------|-------|-------------------------| + * | 0 | Any | Yes | + * | 1 | Same | No | + * | 2+ | Any | Yes | + * |-----------|-------|-------------------------| + */ +#define if_saw_injury(checktype, label) \ mkshort(0x003d), \ - u1, \ + checktype, \ label, -#define if_saw_death(u1, label) \ +/** + * Go to label if the chr has witnessed another chr dying. + * + * The behaviour of the checktype argument is: + * + * |-----------|-------|------------------------| + * | Checktype | Teams | Reset "Saw death" flag | + * |-----------|-------|------------------------| + * | 0 | Any | No | + * | 1 | Same | Yes | + * | 2+ | Any | Yes | + * |-----------|-------|------------------------| + */ +#define if_saw_death(checktype, label) \ mkshort(0x003e), \ - u1, \ + checktype, \ label, #define if_chr_sees_player(label) \ diff --git a/src/include/game/chr/chr.h b/src/include/game/chr/chr.h index 249f455ef..37c631eb6 100644 --- a/src/include/game/chr/chr.h +++ b/src/include/game/chr/chr.h @@ -367,7 +367,7 @@ u32 func0f049fcc(struct chrdata *chr); u32 func0f04a0e4(struct chrdata *chr); s32 chrGetNumArghs(struct chrdata *chr); s32 chrGetNumCloseArghs(struct chrdata *chr); -u32 func0f04a110(struct chrdata *chr, u32 arg1); +bool chrSawInjury(struct chrdata *chr, u8 arg1); bool chrSawDeath(struct chrdata *chr, u8 arg1); bool func0f04a2b4(struct chrdata *chr); u32 func0f04a2d4(void); diff --git a/src/include/game/chr/chraicommands.h b/src/include/game/chr/chraicommands.h index 9eb8df46a..e49fc16a5 100644 --- a/src/include/game/chr/chraicommands.h +++ b/src/include/game/chr/chraicommands.h @@ -64,7 +64,7 @@ /*0x003a*/ bool aiIfAlarmActive(void); /*0x003b*/ bool aiIfAlarmInactive(void); /*0x003c*/ bool ai003c(void); -/*0x003d*/ bool ai003d(void); +/*0x003d*/ bool aiIfSawInjury(void); /*0x003e*/ bool aiIfSawDeath(void); /*0x003f*/ bool aiIfSeesPlayer(void); /*0x0040*/ bool ai0040(void); diff --git a/src/setup/ailists.c b/src/setup/ailists.c index 3b95dd56f..284f3eef7 100644 --- a/src/setup/ailists.c +++ b/src/setup/ailists.c @@ -156,7 +156,7 @@ u8 func0006_unalerted[] = { label(0x16) if_self_flag_bankx_eq(CHRFLAG1_WARNED, TRUE, BANK_1, /*goto*/ 0x13) if_saw_death(0x01, /*goto*/ LABEL_SEEFRIENDDIE) - if_shot_near_chr(0x01, /*goto*/ LABEL_NEAR_MISS) + if_saw_injury(0x01, /*goto*/ LABEL_NEAR_MISS) // Warned label(0x13) @@ -539,7 +539,7 @@ u8 func0006_unalerted[] = { beginloop(0x7e) dprint 'S','9',0, dprint 'W','A','L','K','I','N','G','\n',0, - if_shot_near_chr(0x00, /*goto*/ 0x16) + if_saw_injury(0x00, /*goto*/ 0x16) chr_toggle_p1p2(CHR_SELF) set_target_chr(CHR_P1P2) if_player_looking_at_something_maybe(0x00, 0x00, 0x01, /*goto*/ 0x13) @@ -560,7 +560,7 @@ u8 func0006_unalerted[] = { beginloop(0x7c) dprint 'T','1',0, dprint 'E','X','A','M',' ','B','O','D','Y','\n',0, - if_shot_near_chr(0x00, /*goto*/ 0x16) + if_saw_injury(0x00, /*goto*/ 0x16) set_hear_distance(10000) chr_toggle_p1p2(CHR_SELF) set_target_chr(CHR_P1P2) @@ -1268,7 +1268,7 @@ u8 func0007_alerted[] = { chr_toggle_p1p2(CHR_SELF) set_target_chr(CHR_P1P2) if_near_miss(/*goto*/ 0x13) - if_shot_near_chr(0x00, /*goto*/ 0x13) + if_saw_injury(0x00, /*goto*/ 0x13) if_saw_death(0x00, /*goto*/ 0x13) if_in_disarm_range(/*goto*/ 0x13) endloop(0xa9) @@ -2782,7 +2782,7 @@ u8 func000b_choose_target_chr[] = { // Scan failed label(0x04) - if_shot_near_chr(0x00, /*goto*/ 0x13) + if_saw_injury(0x00, /*goto*/ 0x13) if_alertness(99, OPERATOR_GREATER_THAN, /*goto*/ 0x13) goto_first(0xd3) @@ -3973,7 +3973,7 @@ u8 func0010_civilian_say_comment[] = { // Wait until facing target, or a second has passed, or something else // happens such as hearing gunfire or seeing someone die. beginloop(0x04) - if_shot_near_chr(0x01, /*goto*/ 0x83) + 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) @@ -4024,7 +4024,7 @@ u8 func0010_civilian_say_comment[] = { restart_timer beginloop(0x08) - if_shot_near_chr(0x01, /*goto*/ 0x83) + if_saw_injury(0x01, /*goto*/ 0x83) if_saw_death(0x01, /*goto*/ 0x83) if_timer_gt(180, /*goto*/ 0x16) endloop(0x08) @@ -4046,7 +4046,7 @@ u8 func0010_civilian_say_comment[] = { // Wait 3 seconds, or for see/hear gunfire beginloop(0x09) - if_shot_near_chr(0x01, /*goto*/ 0x83) + if_saw_injury(0x01, /*goto*/ 0x83) if_saw_death(0x01, /*goto*/ 0x83) if_timer_gt(180, /*goto*/ 0x16) endloop(0x09) @@ -4478,7 +4478,7 @@ u8 func001f_related_to_spawning[] = { // Not alert label(0x16) if_saw_death(0x01, /*goto*/ 0x1e) - if_shot_near_chr(0x01, /*goto*/ 0x1e) + if_saw_injury(0x01, /*goto*/ 0x1e) if_player_looking_at_something_maybe(0x00, 0x00, 0x01, /*goto*/ 0x16) if_target_chr_in_sight(/*goto*/ 0x1e) label(0x16) diff --git a/src/setup/setup_000000.c b/src/setup/setup_000000.c index 2118dcc9d..d15360e11 100644 --- a/src/setup/setup_000000.c +++ b/src/setup/setup_000000.c @@ -14193,7 +14193,7 @@ bool (*g_CommandPointers[])(void) = { /*0x003a*/ aiIfAlarmActive, /*0x003b*/ aiIfAlarmInactive, /*0x003c*/ ai003c, - /*0x003d*/ ai003d, + /*0x003d*/ aiIfSawInjury, /*0x003e*/ aiIfSawDeath, /*0x003f*/ aiIfSeesPlayer, /*0x0040*/ ai0040,