diff --git a/engines/bladerunner/script/ai_00_mccoy.cpp b/engines/bladerunner/script/ai_00_mccoy.cpp index 2d722f1c8bce..fa37efb63e50 100644 --- a/engines/bladerunner/script/ai_00_mccoy.cpp +++ b/engines/bladerunner/script/ai_00_mccoy.cpp @@ -25,150 +25,1828 @@ namespace BladeRunner { AIScript_McCoy::AIScript_McCoy(BladeRunnerEngine *vm) - : AIScriptBase(vm) -{} + : AIScriptBase(vm) { +} -void AIScript_McCoy::Initialize() -{ +void AIScript_McCoy::Initialize() { dword_45A0D0_animation_state = 0; - dword_45A0D4 = 0; + dword_45A0D4_animation_frame = 0; dword_45A0D8 = 0; dword_45A0DC = 30; dword_45A0E0 = 1; dword_45A0E4 = 0; + off_45A0EC = 0; dword_45A0E8 = 3; + dword_45A0F0 = 3; + dword_45A0F4 = 20; + dword_45A0F8 = -1; + dword_45A0FC = 0; + off_45A100 = 0; + Actor_Set_Goal_Number(0, 0); } -void AIScript_McCoy::UpdateAnimation(int *animation, int *frame) -{ - *animation = *frame = 0; - switch (dword_45A0D0_animation_state) - { - case 0: +bool AIScript_McCoy::Update() { + if (dword_45A0F8 != -1) { + Sound_Play(dword_45A0F8, 100, 0, 0, 50); + dword_45A0F8 = -1; + } + switch (Actor_Query_Goal_Number(0)) { + case 101: + Actor_Set_Goal_Number(0, 102); + return true; + case 102: + if (Actor_Query_Inch_Distance_From_Waypoint(0, 316) < 36 && !Game_Flag_Query(375)) { + Actor_Change_Animation_Mode(0, 21); + Game_Flag_Set(375); + } + if (Actor_Query_Inch_Distance_From_Waypoint(0, 316) < 4) { + Actor_Set_Goal_Number(0, 103); + } + return true; + case 201: + Actor_Set_Goal_Number(0, 0); + if (Player_Query_Current_Set() == 55) { + Loop_Actor_Walk_To_XYZ(0, -166.0f, -70.19f, -501.0f, 0, 0, false, 0); + Actor_Face_Heading(0, 300, false); + } else { + Loop_Actor_Walk_To_XYZ(0, -461.0f, 0.0f, -373.0f, 0, 0, false, 0); + } + Player_Gains_Control(); + return true; + case 212: + if (Global_Variable_Query(47) >= 13) { + Global_Variable_Set(47, 500); + } else if (Global_Variable_Query(47) > 0) { + Global_Variable_Decrement(47, 1); + } + break; + case 221: + Actor_Set_Goal_Number(0, 0); + Actor_Set_Goal_Number(18, 212); + return true; + case 309: + sub_4053E0(); + break; + case 391: + Actor_Retired_Here(0, 12, 48, 1, -1); + Actor_Set_Goal_Number(0, 599); + break; + case 231: + sub_4053E0(); + break; + } + return false; +} + +void AIScript_McCoy::TimerExpired(int timer) { +} + +void AIScript_McCoy::CompletedMovementTrack() { +} + +void AIScript_McCoy::ReceivedClue(int clueId, int fromActorId) { + switch (clueId) { + case 8: + case 9: + Spinner_Set_Selectable_Destination_Flag(3, 1); + break; + case 44: + case 47: + Spinner_Set_Selectable_Destination_Flag(4, 1); + break; + case 53: + case 263: + if (Query_Difficulty_Level() == 0) { + Spinner_Set_Selectable_Destination_Flag(4, 1); + } + break; + case 90: + Spinner_Set_Selectable_Destination_Flag(8, 1); + break; + case 84: + case 113: + case 114: + case 115: + case 118: + Spinner_Set_Selectable_Destination_Flag(9, 1); + Spinner_Set_Selectable_Destination_Flag(8, 1); + break; + case 66: + case 80: + case 82: + case 83: + Global_Variable_Increment(49, 1); + break; + case 125: + Global_Variable_Increment(49, 5); + break; + case 124: + case 128: + Global_Variable_Increment(49, 3); + break; + case 120: + case 121: + Global_Variable_Increment(49, 2); + break; + case 147: + case 148: + case 149: + case 150: + case 151: + case 152: + Global_Variable_Increment(48, 1); + break; + } + if (Global_Variable_Query(49) > 6 && Global_Variable_Query(1) > 3 && !Actor_Clue_Query(0, 126)) { + Delay(500); + Actor_Voice_Over(3320, 99); + switch (clueId) { + case 66: + case 80: + case 82: + case 83: + case 121: + case 128: + Actor_Voice_Over(3340, 99); + Actor_Voice_Over(3350, 99); + Actor_Voice_Over(3360, 99); + Actor_Voice_Over(3370, 99); + Actor_Voice_Over(3380, 99); + break; + case 124: + Actor_Voice_Over(3330, 99); + break; + case 120: + Actor_Voice_Over(3390, 99); + Actor_Voice_Over(3400, 99); + Actor_Voice_Over(3420, 99); + break; + } + Actor_Clue_Acquire(0, 126, 1, -1); + if (clueId == 125) { + Actor_Voice_Over(2780, 99); + Actor_Voice_Over(2800, 99); + Actor_Voice_Over(2810, 99); + } else if (Actor_Clue_Query(0, 125)) { + Actor_Voice_Over(3430, 99); + Actor_Voice_Over(3440, 99); + Actor_Voice_Over(3450, 99); + Actor_Voice_Over(3460, 99); + Actor_Voice_Over(3470, 99); + Actor_Voice_Over(3480, 99); + Actor_Voice_Over(3490, 99); + Actor_Voice_Over(3500, 99); + } else { + Actor_Voice_Over(3510, 99); + Actor_Voice_Over(3520, 99); + Actor_Voice_Over(3530, 99); + Actor_Voice_Over(3540, 99); + } + } +} + +void AIScript_McCoy::ClickedByPlayer() { +} + +void AIScript_McCoy::EnteredScene(int sceneId) { +} + +void AIScript_McCoy::OtherAgentEnteredThisScene() { +} + +void AIScript_McCoy::OtherAgentExitedThisScene() { +} + +void AIScript_McCoy::OtherAgentEnteredCombatMode() { +} + +void AIScript_McCoy::ShotAtAndMissed() { +} + +void AIScript_McCoy::ShotAtAndHit() { +} + +void AIScript_McCoy::Retired(int byActorId) { + if (byActorId == 1 && Actor_Query_In_Set(1, 42)) { + if (Actor_Query_In_Set(3, 42) && Actor_Query_Goal_Number(3) != 599) { + Non_Player_Actor_Combat_Mode_On(1, 3, 1, 3, 15, 4, 7, 8, 0, 0, 100, 25, 300, 0); + } else if (Actor_Query_In_Set(6, 42) && Actor_Query_Goal_Number(6) != 599) { + Non_Player_Actor_Combat_Mode_On(1, 3, 1, 6, 15, 4, 7, 8, 0, 0, 100, 25, 300, 0); + } + } + if (Actor_Query_In_Set(0, 41) && Actor_Query_In_Set(23, 41) && Actor_Query_In_Set(3, 41) && Actor_Query_Goal_Number(3) != 599) { + Non_Player_Actor_Combat_Mode_On(23, 3, 1, 3, 4, 4, 7, 8, 0, 0, 100, 25, 300, 0); + } + if (Actor_Query_In_Set(0, 41) && Actor_Query_In_Set(24, 41) && Actor_Query_In_Set(3, 41) && Actor_Query_Goal_Number(3) != 599) { + Non_Player_Actor_Combat_Mode_On(24, 3, 1, 3, 4, 4, 7, 8, 0, 0, 100, 25, 300, 0); + } + if (Actor_Query_In_Set(0, 41) && Actor_Query_In_Set(23, 41) && Actor_Query_In_Set(6, 41) && Actor_Query_Goal_Number(6) != 599) { + Non_Player_Actor_Combat_Mode_On(23, 3, 1, 6, 4, 4, 7, 8, 0, 0, 100, 25, 300, 0); + } + if (Actor_Query_In_Set(0, 41) && Actor_Query_In_Set(24, 41) && Actor_Query_In_Set(6, 41) && Actor_Query_Goal_Number(6) != 599) { + Non_Player_Actor_Combat_Mode_On(24, 3, 1, 6, 4, 4, 7, 8, 0, 0, 100, 25, 300, 0); + } +} + +void AIScript_McCoy::GetFriendlinessModifierIfGetsClue() { +} + +bool AIScript_McCoy::GoalChanged(int currentGoalNumber, int newGoalNumber) { + unsigned int v5; + unsigned int v7; + + switch (newGoalNumber) { + case 0: + return true; + case 1: + sub_4058B0(); + return true; + case 2: + sub_405920(); + return true; + case 100: + Actor_Set_At_Waypoint(0, 315, 263); + dword_45A0D0_animation_state = 53; + dword_45A0D4_animation_frame = Slice_Animation_Query_Number_Of_Frames(18) - 1; + Actor_Set_Invisible(0, false); + return true; + case 102: + Async_Actor_Walk_To_Waypoint(0, 316, 0, 1); + return true; + case 103: + Actor_Face_Actor(0, 8, true); + return true; + case 231: + Player_Set_Combat_Mode(false); + Preload(18); + Set_Enter(59, 63); + Player_Loses_Control(); + Actor_Force_Stop_Walking(0); + Actor_Put_In_Set(0, 59); + Actor_Set_At_XYZ(0, 14.0f, 110.84f, -300.0f, 926); + Actor_Change_Animation_Mode(0, 48); + dword_45A0D0_animation_state = 27; + dword_45A0D4_animation_frame = 0; + flt_462714 = 2.84f; + flt_462710 = 110.84f; + off_45A100 = -6.0f; + return true; + case 230: + dword_45A0FC = Actor_Query_Goal_Number(1) == 215; + Actor_Change_Animation_Mode(0, 6); + return true; + case 220: + Actor_Change_Animation_Mode(0, 75); + return true; + case 212: + Global_Variable_Set(47, 0); + Player_Set_Combat_Mode_Access(false); + Player_Gains_Control(); + Scene_Exits_Disable(); + dword_45A0D0_animation_state = 68; + dword_45A0D4_animation_frame = Slice_Animation_Query_Number_Of_Frames(18) - 1; + return true; + case 211: + Actor_Face_Heading(0, 512, false); + Actor_Face_Heading(0, 768, true); + if (Random_Query(0, 1)) { + Actor_Change_Animation_Mode(0, 18); + } else { + Actor_Change_Animation_Mode(0, 16); + } + Delay(150); + Actor_Change_Animation_Mode(0, 0); + Actor_Set_Goal_Number(0, 0); + Player_Gains_Control(); + return true; + case 210: + Actor_Put_In_Set(0, 54); + Actor_Set_At_XYZ(0, -204.0, 24.0, -817.0, 256); + Actor_Set_Invisible(0, false); + if (Game_Flag_Query(627)) { + Actor_Set_Goal_Number(0, 212); + } else { + dword_45A0D0_animation_state = 53; + dword_45A0D4_animation_frame = Slice_Animation_Query_Number_Of_Frames(18) - 1; + Actor_Set_Invisible(0, false); + } + return true; + case 200: + Player_Loses_Control(); + Actor_Change_Animation_Mode(0, 0); + return true; + case 301: + dword_45A0D0_animation_state = 62; + dword_45A0D4_animation_frame = 0; + return true; + case 302: + dword_45A0D0_animation_state = 64; + dword_45A0D4_animation_frame = 0; + return true; + case 303: + dword_45A0D0_animation_state = 65; + dword_45A0D4_animation_frame = 0; + return true; + case 350: + Sound_Play(123, 50, 0, 0, 50); + Delay(1000); + Sound_Play(403, 30, 0, 0, 50); + Delay(1000); + Sound_Play(123, 50, 0, 0, 50); + Actor_Says(4, 1380, 3); + Actor_Says(0, 6610, 13); + Actor_Says(4, 1390, 3); + Actor_Says(0, 6615, 18); + Actor_Says(4, 1420, 3); + Actor_Says(0, 6625, 11); + Actor_Says(4, 1430, 3); + Actor_Says(0, 6630, 12); + Actor_Says(0, 6635, 17); + Actor_Says(0, 6640, 13); + Actor_Says(0, 6645, 19); + Actor_Says(0, 6650, 18); + Actor_Says(0, 6655, 11); + Actor_Says(4, 1440, 3); + Actor_Says(0, 6660, 17); + Actor_Says(0, 6665, 13); + Delay(1000); + Actor_Says(4, 1450, 3); + Actor_Says(0, 6670, 14); + Actor_Says(0, 6675, 11); + Actor_Says(4, 1460, 3); + Actor_Says(0, 6680, 12); + Actor_Says(4, 1470, 3); + Actor_Says(0, 6685, 13); + Delay(500); + Actor_Says(0, 6695, 16); + Actor_Says(0, 6700, 17); + Actor_Says(4, 1480, 3); + Actor_Says(0, 6705, 11); + Sound_Play(123, 50, 0, 0, 50); + return true; + case 390: + Actor_Force_Stop_Walking(0); + Player_Loses_Control(); + flt_462710 = 48.07f; + off_45A100 = -4.0f; + flt_462714 = -20.0f; + if (dword_45A0D0_animation_state != 27 && dword_45A0D0_animation_state != 50) { + dword_45A0D0_animation_state = 50; + dword_45A0D4_animation_frame = Slice_Animation_Query_Number_Of_Frames(18) - 1; + } + return true; + case 400: + Actor_Set_Health(0, 50, 50); + Game_Flag_Set(373); + v5 = Global_Variable_Query(45); + if (v5 == 1) { + Actor_Modify_Friendliness_To_Other(1, 0, 3); + } else if (v5 == 2) { + Actor_Modify_Friendliness_To_Other(1, 0, -5); + Actor_Modify_Friendliness_To_Other(5, 0, 3); + } else if (v5 == 3) { + Actor_Modify_Friendliness_To_Other(1, 0, -5); + Actor_Modify_Friendliness_To_Other(5, 0, 5); + } + if (Game_Flag_Query(666)) { + Actor_Modify_Friendliness_To_Other(1, 0, 3); + } + if (Actor_Query_Friendliness_To_Other(1, 0) < Actor_Query_Friendliness_To_Other(5, 0)) { + Game_Flag_Set(653); + } + v7 = Global_Variable_Query(45); + if (v7 == 1) { + if (Game_Flag_Query(653)) { + Global_Variable_Set(45, 0); + } + } else if (v7 == 2 || v7 == 3) { + if (!Game_Flag_Query(653)) { + Global_Variable_Set(45, 0); + } + } + if (!Game_Flag_Query(653)) { + Game_Flag_Set(461); + } + Ambient_Sounds_Remove_All_Non_Looping_Sounds(1); + Ambient_Sounds_Remove_All_Looping_Sounds(1); + Global_Variable_Set(1, 5); + Outtake_Play(10, 0, -1); + if (Game_Flag_Query(666)) { + Chapter_Enter(5, 53, 53); + } else { + Game_Flag_Set(34); + Chapter_Enter(5, 10, 49); + } + return true; + case 500: + Music_Stop(3); + Player_Set_Combat_Mode(false); + Actor_Change_Animation_Mode(0, 0); + dword_45A0D0_animation_state = 0; + dword_45A0D4_animation_frame = 0; + Game_Flag_Set(465); + Set_Enter(67, 72); + return true; + } + return false; +} + +bool AIScript_McCoy::UpdateAnimation(int *animation, int *frame) { + int v7, v18, v19, v46; + switch (dword_45A0D0_animation_state) { + case 71: + *animation = 52; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(52)) { + Actor_Change_Animation_Mode(0, 0); *animation = 19; - if (dword_45A0D8 < dword_45A0DC) - { - *frame = dword_45A0E8; - dword_45A0D4 += dword_45A0E0; - if (dword_45A0D4 > dword_45A0E8) - { - dword_45A0D4 = dword_45A0E8; - dword_45A0E0 = -1; - } - else - { - *frame = dword_45A0D4; - if (dword_45A0D4 < dword_45A0E4) - { - dword_45A0D4 = dword_45A0E4; - dword_45A0E0 = 1; - *frame = dword_45A0E4; - } - } - dword_45A0D8++; - } - else - { - dword_45A0D4 += dword_45A0E0; - dword_45A0DC = 0; - if (dword_45A0D4 == 18 && Random_Query(0, 2)) - { + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 0; + Player_Gains_Control(); + } + break; + case 70: + *animation = 51; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(51)) { + dword_45A0D4_animation_frame = 0; + } + break; + case 69: + *animation = 50; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(50)) { + Actor_Change_Animation_Mode(0, 53); + *animation = 51; + } + break; + case 68: + *animation = 18; + v7 = Slice_Animation_Query_Number_Of_Frames(*animation) - 1 - Global_Variable_Query(47); + if (dword_45A0D4_animation_frame < v7) { + dword_45A0D4_animation_frame++; + } else if (dword_45A0D4_animation_frame > v7) { + dword_45A0D4_animation_frame--; + } + if (dword_45A0D4_animation_frame <= 0) { + Actor_Change_Animation_Mode(0, 0); + *animation = 19; + dword_45A0D0_animation_state = 0; + dword_45A0D4_animation_frame = 0; + Game_Flag_Reset(627); + Scene_Exits_Enable(); + Player_Set_Combat_Mode_Access(true); + Actor_Set_Goal_Number(0, 0); + } + break; + case 67: + *animation = 53; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(53)) { + Actor_Change_Animation_Mode(0, 0); + *animation = 19; + dword_45A0D0_animation_state = 0; + dword_45A0D4_animation_frame = 0; + if (Actor_Query_Goal_Number(0) == 220) { + Actor_Change_Animation_Mode(0, 48); + } + } + break; + case 66: + *animation = 40; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(40)) { + Actor_Change_Animation_Mode(0, 0); + *animation = 19; + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 0; + } + break; + case 65: + *animation = 45; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(45)) { + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 14; + *animation = 0; + Actor_Set_Goal_Number(0, 0); + } + break; + case 64: + *animation = 44; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(44)) { + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 63; + *animation = 43; + } + break; + case 63: + *animation = 43; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(43)) { + dword_45A0D4_animation_frame = 0; + } + break; + case 62: + *animation = 42; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(42)) { + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 63; + *animation = 43; + } + break; + case 61: + *animation = 41; + dword_45A0D4_animation_frame--; + if (dword_45A0D4_animation_frame <= 0) { + *animation = 19; + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 0; + if (Actor_Query_Goal_Number(0) == 200) { + Actor_Set_Goal_Number(0, 201); + } + } + break; + case 60: + *animation = 41; + if (dword_45A0D4_animation_frame < Slice_Animation_Query_Number_Of_Frames(41) - 1) { + dword_45A0D4_animation_frame++; + } + return true; + case 59: + *animation = 48; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(48)) { + *animation = 19; + dword_45A0D4_animation_frame = 0; + dword_45A0DC = 0; + dword_45A0D0_animation_state = 0; + Player_Gains_Control(); + Item_Add_To_World(109, 982, 6, -110.0, 0.0, -192.0, 0, 48, 32, false, true, false, false); + } + break; + case 58: + *animation = 47; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame == 6) { + v18 = Random_Query(0, 2); + v19 = 0; + if (v18 == 0) { + v19 = 595; + } else if (v18 == 1) { + v19 = 594; + } else if (v18 == 2) { + v19 = 593; + } + Ambient_Sounds_Play_Sound(v19, 39, 0, 0, 99); + } + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(*animation) - 1) { //why -1? + dword_45A0D4_animation_frame = 0; + } + break; + case 57: + *animation = 46; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(46)) { + dword_45A0D4_animation_frame = 0; + } + if (!Game_Flag_Query(550)) { + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 59; + *animation = 48; + } + break; + case 56: + *animation = 49; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(49)) { + dword_45A0D4_animation_frame = 0; + if (Actor_Query_Which_Set_In(0) == 87) { + dword_45A0D0_animation_state = 27; + } else { + *animation = 19; + dword_45A0D0_animation_state = 0; + Actor_Change_Animation_Mode(0, 0); + } + } + break; + case 55: + *animation = 32; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame == 7) { + Actor_Change_Animation_Mode(66, 52); + } + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(*animation)) { + *animation = 19; + dword_45A0D0_animation_state = 0; + } + break; + case 53: + *animation = 18; + dword_45A0D4_animation_frame--; + if (dword_45A0D4_animation_frame <= 0) { + Actor_Change_Animation_Mode(0, 0); + *animation = 19; + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 0; + if (Actor_Query_Goal_Number(0) == 100) { + Actor_Set_Goal_Number(0, 101); + } + if (Actor_Query_Goal_Number(0) == 210) { + Actor_Set_Goal_Number(0, 211); + } + } + break; + case 52: + *animation = 31; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(31)) { + dword_45A0D4_animation_frame = Slice_Animation_Query_Number_Of_Frames(31) - 1; + dword_45A0D0_animation_state = 50; + } + break; + case 51: + *animation = 28; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(28)) { + Player_Set_Combat_Mode(true); + sub_405800(); + Actor_Set_Goal_Number(0, 0); + dword_45A0D4_animation_frame = 0; + Player_Gains_Control(); + } + break; + case 50: + *animation = 18; + dword_45A0D4_animation_frame = Slice_Animation_Query_Number_Of_Frames(18) - 1; + break; + case 49: + *animation = 34; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(34)) { + Actor_Set_Goal_Number(0, 0); + *animation = 19; + dword_45A0D4_animation_frame = 0; + sub_405660(); + } + break; + case 48: + *animation = 33; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(33)) { + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 49; + *animation = 34; + } + break; + case 47: + *animation = 29; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(29)) { + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 48; + *animation = 33; + } + break; + case 46: + Actor_Set_Invisible(0, false); + *animation = 36; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(36)) { + *animation = 19; + dword_45A0D4_animation_frame = 0; + Player_Gains_Control(); + sub_405660(); + Actor_Face_Heading(0, (Actor_Query_Facing_1024(0) + 512) & 1023, false); + } + break; + case 45: + *animation = 35; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(35)) { + Actor_Set_Invisible(0, true); + *animation = 19; + dword_45A0D4_animation_frame = 0; + sub_405660(); + } + break; + case 44: + *animation = 30; + if (dword_45A0D4_animation_frame++ == 127) { + Game_Flag_Set(325); + } + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(30)) { + *animation = 19; + sub_405660(); + Actor_Set_At_XYZ(0, -203.41f, -621.3f, 724.57f, 538); + Player_Gains_Control(); + } + break; + case 43: + *animation = 38; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(38) - 1) { //why -1? + dword_45A0D4_animation_frame = 0; + } + switch (dword_45A0D4_animation_frame) { + case 9: + Sound_Left_Footstep_Walk(0); + break; + case 4: + Sound_Right_Footstep_Walk(0); + break; + case 1: + Sound_Right_Footstep_Walk(0); + break; + } + break; + case 42: + *animation = 37; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(37) - 1) { //why -1? + dword_45A0D4_animation_frame = 0; + } + switch (dword_45A0D4_animation_frame) { + case 9: + Sound_Left_Footstep_Walk(0); + break; + case 4: + Sound_Right_Footstep_Walk(0); + break; + case 1: + Sound_Right_Footstep_Walk(0); + break; + } + break; + case 41: + *animation = 7; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(7)) { + dword_45A0D4_animation_frame = 0; + ++off_45A0EC; + } + if (dword_45A0D4_animation_frame == 9) { + Sound_Left_Footstep_Walk(0); + } else if (dword_45A0D4_animation_frame == 4) { + Sound_Right_Footstep_Walk(0); + } + if (Game_Flag_Query(359)) { + sub_4059D0(-0.2f); + } + break; + case 40: + *animation = 6; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(6)) { + dword_45A0D4_animation_frame = 0; + ++off_45A0EC; + } + if (dword_45A0D4_animation_frame == 8) { + Sound_Left_Footstep_Walk(0); + } else if (dword_45A0D4_animation_frame == 3) { + Sound_Right_Footstep_Walk(0); + } + if (Game_Flag_Query(358)) { + sub_405940(0.5f); + } + break; + case 39: + *animation = 16; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(16)) { + dword_45A0D4_animation_frame = 0; + ++off_45A0EC; + } + if (dword_45A0D4_animation_frame == 8) { + Sound_Left_Footstep_Walk(0); + } else if (dword_45A0D4_animation_frame == 3) { + Sound_Right_Footstep_Walk(0); + } + if (Game_Flag_Query(359)) { + sub_4059D0(-0.2f); + } + break; + case 38: + *animation = 15; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(15)) { + dword_45A0D4_animation_frame = 0; + ++off_45A0EC; + } + if (dword_45A0D4_animation_frame == 9) { + Sound_Left_Footstep_Walk(0); + } else if (dword_45A0D4_animation_frame == 4) { + Sound_Right_Footstep_Walk(0); + } + if (Game_Flag_Query(358)) { + sub_405940(0.5f); + } + break; + case 37: + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(4)) { + dword_45A0D4_animation_frame = 0; + } + *animation = 4; + if (dword_45A0D4_animation_frame == 6) { + Sound_Left_Footstep_Run(0); + } + if (dword_45A0D4_animation_frame == 0) { + Sound_Right_Footstep_Run(0); + } + break; + case 36: + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(3)) { + dword_45A0D4_animation_frame = 0; + } + *animation = 3; + if (dword_45A0D4_animation_frame == 15) { + Sound_Left_Footstep_Walk(0); + } + if (dword_45A0D4_animation_frame == 6) { + Sound_Right_Footstep_Walk(0); + } + break; + case 32: + dword_45A0D4_animation_frame = 1; + dword_45A0D0_animation_state = 30; + *animation = 13; + break; + case 31: + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(14)) { + dword_45A0D4_animation_frame = 0; + } + *animation = 14; + if (dword_45A0D4_animation_frame == 5) { + Sound_Left_Footstep_Run(0); + } else if (dword_45A0D4_animation_frame == 12) { + Sound_Right_Footstep_Run(0); + } + break; + case 30: + *animation = 13; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(13)) { + dword_45A0D4_animation_frame = 0; + } + if (dword_45A0D4_animation_frame == 2) { + Sound_Right_Footstep_Walk(0); + } else if (dword_45A0D4_animation_frame == 10) { + Sound_Left_Footstep_Walk(0); + } + break; + case 29: + v46 = dword_45A0D4_animation_frame + dword_45A0E0; + *animation = 18; + dword_45A0D4_animation_frame = v46; + if (v46 < 14) { + dword_45A0E0 = 1; + } + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(*animation)) { + Actor_Change_Animation_Mode(0, 48); + *animation = 18; + dword_45A0D0_animation_state = 27; + dword_45A0D4_animation_frame = Slice_Animation_Query_Number_Of_Frames(18) - 1; + } + break; + case 28: + *animation = 5; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(5)) { + dword_45A0D4_animation_frame = Slice_Animation_Query_Number_Of_Frames(*animation) - 1; + dword_45A0D0_animation_state = 50; + sub_4054F0(); + } + break; + case 27: + *animation = 18; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(18)) { + dword_45A0D4_animation_frame = Slice_Animation_Query_Number_Of_Frames(*animation) - 1; + dword_45A0D0_animation_state = 50; + sub_4054F0(); + if (Actor_Query_Goal_Number(0) == 220) { + Actor_Set_Goal_Number(0, 221); + } + } + break; + case 26: + *animation = 17; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(17)) { + *animation = 19; + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 0; + Actor_Change_Animation_Mode(0, 0); + } + break; + case 25: + *animation = 17; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(17)) { + *animation = 19; + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 0; + Actor_Change_Animation_Mode(0, 0); + } + break; + case 24: + *animation = 1; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(1)) { + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 14; + *animation = 0; + Actor_Change_Animation_Mode(0, 4); + } + break; + case 23: + *animation = 1; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(1)) { + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 14; + *animation = 0; + Actor_Change_Animation_Mode(0, 4); + } + break; + case 22: + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 17; + *animation = 12; + break; + case 21: + *animation = 12; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame == 1 && Actor_Query_Goal_Number(0) == 230 && dword_45A0FC == 1) { + dword_45A0F8 = 27; + } + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(12)) { + dword_45A0D0_animation_state = 17; + dword_45A0D4_animation_frame = 0; + *animation = 12; + if (Actor_Query_Goal_Number(0) == 230) { + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 21; + dword_45A0FC = 1; + *animation = 12; + } + } + break; + case 19: + *animation = 11; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= 12) { + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 14; + *animation = 0; + } + break; + case 18: + *animation = 10; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(10)) { + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 17; + *animation = 12; + } + break; + case 17: + *animation = 12; + dword_45A0D4_animation_frame = 0; + // weird, but thats in game code + if (Slice_Animation_Query_Number_Of_Frames(12) <= 0) { + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 17; + } + break; + case 16: + *animation = 9; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(9)) { + *animation = 19; + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 0; + } + break; + case 15: + *animation = 8; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(8)) { + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 14; + *animation = 0; + } + break; + case 14: + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(0)) { + dword_45A0D0_animation_state = 14; + dword_45A0D4_animation_frame = 0; + } + *animation = 0; + break; + case 13: + *animation = 19; + if (dword_45A0D4_animation_frame < Slice_Animation_Query_Number_Of_Frames(19) / 2) { + dword_45A0D4_animation_frame -= 3; + if (dword_45A0D4_animation_frame <= 0) { + dword_45A0D4_animation_frame = 0; + *animation = dword_46271C; + dword_45A0D0_animation_state = dword_462718; + } + } else { + dword_45A0D4_animation_frame += 3; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(19)) { + dword_45A0D4_animation_frame = 0; + *animation = dword_46271C; + dword_45A0D0_animation_state = dword_462718; + } + } + break; + case 12: + *animation = 27; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(27)) { + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 3; + *animation = 20; + } + break; + case 11: + *animation = 26; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(26)) { + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 3; + *animation = 20; + } + break; + case 10: + *animation = 25; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(25)) { + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 3; + *animation = 20; + } + break; + case 9: + *animation = 24; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(24)) { + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 3; + *animation = 20; + } + break; + case 8: + *animation = 23; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(23)) { + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 3; + *animation = 20; + } + break; + case 7: + *animation = 22; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(22)) { + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 3; + *animation = 20; + } + break; + case 6: + *animation = 27; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(27)) { + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 3; + *animation = 20; + } + break; + case 5: + *animation = 21; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(21)) { + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 3; + *animation = 20; + } + break; + case 3: + case 4: + if (dword_45A0D4_animation_frame == 0 && !Game_Flag_Query(236)) { + dword_45A0D4_animation_frame = 1; + dword_45A0D0_animation_state = dword_45A0F0; + *animation = dword_45A0F4; + dword_45A0F0 = 4; + dword_45A0F4 = 20; + } else if (dword_45A0D4_animation_frame <= 4 && Game_Flag_Query(236)) { + Game_Flag_Reset(236); + *animation = 19; + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 0; + } else { + *animation = 20; + dword_45A0D4_animation_frame++; + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(20)) { + dword_45A0D4_animation_frame = 0; + } + } + break; + case 0: + *animation = 19; + if (dword_45A0D8 < dword_45A0DC) { + //*frame = dword_45A0E8; + dword_45A0D4_animation_frame += dword_45A0E0; + if (dword_45A0D4_animation_frame > dword_45A0E8) { + dword_45A0D4_animation_frame = dword_45A0E8; + dword_45A0E0 = -1; + } else if (dword_45A0D4_animation_frame < dword_45A0E4) { + dword_45A0D4_animation_frame = dword_45A0E4; + dword_45A0E0 = 1; + } + dword_45A0D8++; + } else { + dword_45A0D4_animation_frame += dword_45A0E0; + dword_45A0DC = 0; + if (dword_45A0D4_animation_frame == 18 && Random_Query(0, 2)) { + dword_45A0E0 = -1; + dword_45A0D8 = 0; + dword_45A0E4 = 14; + dword_45A0E8 = 18; + dword_45A0DC = Random_Query(0, 30); + } + if (dword_45A0D4_animation_frame == 26) { + if (Random_Query(0, 2)) { dword_45A0E0 = -1; dword_45A0D8 = 0; - dword_45A0E4 = 14; - dword_45A0E8 = 18; + dword_45A0E4 = 23; + dword_45A0E8 = 26; dword_45A0DC = Random_Query(0, 30); } - if (dword_45A0D4 == 26) - { - if (Random_Query(0, 2)) - { - dword_45A0E0 = -1; - dword_45A0D8 = 0; - dword_45A0E4 = 23; - dword_45A0E8 = 26; - dword_45A0DC = Random_Query(0, 30); - } - } - if (dword_45A0D4 >= Slice_Animation_Query_Number_Of_Frames(19)) - { - dword_45A0D4 = 0; - if (Random_Query(0, 2)) - { - dword_45A0D8 = 0; - dword_45A0E4 = 0; - dword_45A0E8 = 3; - dword_45A0DC = Random_Query(0, 45); - } - } - *frame = dword_45A0D4; - if (dword_45A0D4 < 0) - { - *frame = Slice_Animation_Query_Number_Of_Frames(19) - 1; - dword_45A0D4 = *frame; + } + if (dword_45A0D4_animation_frame >= Slice_Animation_Query_Number_Of_Frames(19)) { + dword_45A0D4_animation_frame = 0; + if (Random_Query(0, 2)) { + dword_45A0D8 = 0; + dword_45A0E4 = 0; + dword_45A0E8 = 3; + dword_45A0DC = Random_Query(0, 45); } } + if (dword_45A0D4_animation_frame < 0) { + dword_45A0D4_animation_frame = Slice_Animation_Query_Number_Of_Frames(19) - 1; + } + } + break; + } + *frame = dword_45A0D4_animation_frame; + return true; +} + +bool AIScript_McCoy::ChangeAnimationMode(int mode) { + int v2; + switch (mode) { + case 85: + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 69; + return true; + case 75: + dword_45A0D0_animation_state = 67; + dword_45A0D4_animation_frame = 0; + return true; + case 68: + dword_45A0D0_animation_state = 29; + dword_45A0D4_animation_frame = Slice_Animation_Query_Number_Of_Frames(18) - 1; + dword_45A0E0 = -1; + return true; + case 65: + case 67: + dword_45A0D0_animation_state = 43; + dword_45A0D4_animation_frame = 0; + return true; + case 64: + case 66: + dword_45A0D0_animation_state = 42; + dword_45A0D4_animation_frame = 0; + return true; + case 53: + if (dword_45A0D0_animation_state != 60 && (Player_Query_Current_Set() == 55 || Player_Query_Current_Set() == 13)) { + dword_45A0D0_animation_state = 60; + dword_45A0D4_animation_frame = 0; + } else { + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 70; + } + return true; + case 52: + dword_45A0D0_animation_state = 55; + dword_45A0D4_animation_frame = 0; + return true; + case 51: + dword_45A0D0_animation_state = 27; + dword_45A0D4_animation_frame = 0; + return true; + case 49: + dword_45A0D0_animation_state = 28; + dword_45A0D4_animation_frame = 0; + return true; + case 48: + switch (dword_45A0D0_animation_state) { + case 14: + dword_45A0D0_animation_state = 28; + dword_45A0D4_animation_frame = 0; + break; + case 13: + dword_45A0D0_animation_state = 22; + dword_45A0D4_animation_frame = 0; + return true; + case 10: + dword_45A0D0_animation_state = 18; + dword_45A0D4_animation_frame = 8 * (13 - dword_45A0D4_animation_frame) / 13; + return true; + case 8: + case 9: + case 12: + return true; + case 11: + dword_45A0D0_animation_state = 18; + dword_45A0D4_animation_frame = 0; break; + case 7: + dword_45A0D0_animation_state = 14; + dword_45A0D4_animation_frame = 0; + break; + case 0: + case 1: + case 2: + case 3: + case 4: + case 5: + case 6: + dword_45A0D0_animation_state = 15; + dword_45A0D4_animation_frame = 0; + break; + default: + if (dword_45A0D0_animation_state != 50) { + dword_45A0D0_animation_state = 27; + dword_45A0D4_animation_frame = 0; + } + break; + } + return true; + case 47: + dword_45A0D0_animation_state = 41; + dword_45A0D4_animation_frame = 0; + return true; + case 46: + dword_45A0D0_animation_state = 40; + dword_45A0D4_animation_frame = 0; + return true; + case 45: + dword_45A0D0_animation_state = 39; + dword_45A0D4_animation_frame = 0; + return true; + case 44: + dword_45A0D0_animation_state = 38; + dword_45A0D4_animation_frame = 0; + return true; + case 42: + dword_45A0D0_animation_state = 46; + dword_45A0D4_animation_frame = 0; + Player_Loses_Control(); + return true; + case 41: + dword_45A0D0_animation_state = 45; + dword_45A0D4_animation_frame = 0; + return true; + case 40: + dword_45A0D0_animation_state = 44; + dword_45A0D4_animation_frame = 0; + return true; + case 39: + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 52; + if (Player_Query_Current_Set() == 27) { + dword_45A0D4_animation_frame = 23; + } + return true; + case 38: + dword_45A0D0_animation_state = 47; + dword_45A0D4_animation_frame = 0; + return true; + case 29: + Player_Loses_Control(); + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 71; + return true; + case 23: + dword_45A0D0_animation_state = 66; + dword_45A0D4_animation_frame = 0; + return true; + case 22: + if (Random_Query(0, 1)) { + dword_45A0D0_animation_state = 23; + } else { + dword_45A0D0_animation_state = 24; + } + dword_45A0D4_animation_frame = 0; + return true; + case 21: + switch (dword_45A0D0_animation_state) { + case 0: + case 2: + case 3: + case 4: + case 5: + case 6: + case 7: + dword_45A0D0_animation_state = 28; + dword_45A0D4_animation_frame = 0; + break; + case 1: + case 8: + dword_45A0D0_animation_state = 27; + dword_45A0D4_animation_frame = 0; + break; + default: - // Continue walking (follows state 32) - case 30: - *animation = 13; - if (++dword_45A0D4 >= Slice_Animation_Query_Number_Of_Frames(13)) - dword_45A0D4 = 0; - *frame = dword_45A0D4; + if (Random_Query(0, 1)) { + dword_45A0D0_animation_state = 26; + } else { + dword_45A0D0_animation_state = 25; + } + dword_45A0D4_animation_frame = 0; + break; + } + return true; + case 20: + v2 = Actor_Query_Which_Set_In(0); + if (v2 == 27) { + dword_45A0D0_animation_state = 51; + dword_45A0D4_animation_frame = 0; + Player_Loses_Control(); + Game_Flag_Set(210); + } else if (v2 == 70 || v2 == 87) { + dword_45A0D0_animation_state = 56; + dword_45A0D4_animation_frame = 0; + } + return true; + case 19: + if (dword_45A0D0_animation_state < 3 || dword_45A0D0_animation_state > 12) { + dword_45A0D0_animation_state = 13; + dword_462718 = 12; + dword_46271C = 27; + } else { + Game_Flag_Reset(236); + dword_45A0F0 = 12; + dword_45A0F4 = 27; + } + return true; + case 18: + if (dword_45A0D0_animation_state < 3 || dword_45A0D0_animation_state > 12) { + dword_45A0D0_animation_state = 13; + dword_462718 = 11; + dword_46271C = 26; + } else { + Game_Flag_Reset(236); + dword_45A0F0 = 11; + dword_45A0F4 = 26; + } + return true; + case 17: + if (dword_45A0D0_animation_state < 3 || dword_45A0D0_animation_state > 12) { + dword_45A0D0_animation_state = 13; + dword_462718 = 10; + dword_46271C = 25; + } else { + Game_Flag_Reset(236); + dword_45A0F0 = 10; + dword_45A0F4 = 25; + } + return true; + case 16: + if (dword_45A0D0_animation_state < 3 || dword_45A0D0_animation_state > 12) { + dword_45A0D0_animation_state = 13; + dword_462718 = 9; + dword_46271C = 24; + } else { + Game_Flag_Reset(236); + dword_45A0F0 = 9; + dword_45A0F4 = 24; + } + return true; + case 15: + if (dword_45A0D0_animation_state < 3 || dword_45A0D0_animation_state > 12) { + dword_45A0D0_animation_state = 13; + dword_462718 = 8; + dword_46271C = 23; + } else { + Game_Flag_Reset(236); + dword_45A0F0 = 8; + dword_45A0F4 = 23; + } + return true; + case 11: + case 14: + if (dword_45A0D0_animation_state < 3 || dword_45A0D0_animation_state > 12) { + dword_45A0D0_animation_state = 13; + dword_462718 = 7; + dword_46271C = 22; + } else { + Game_Flag_Reset(236); + dword_45A0F0 = 7; + dword_45A0F4 = 22; + } + return true; + case 10: + case 13: + if (dword_45A0D0_animation_state < 3 || dword_45A0D0_animation_state > 12) { + dword_45A0D0_animation_state = 13; + dword_462718 = 6; + dword_46271C = 27; + } else { + Game_Flag_Reset(236); + dword_45A0F0 = 6; + dword_45A0F4 = 27; + } + return true; + case 9: + case 12: + if (dword_45A0D0_animation_state < 3 || dword_45A0D0_animation_state > 12) { + dword_45A0D0_animation_state = 13; + dword_462718 = 5; + dword_46271C = 21; + } else { + Game_Flag_Reset(236); + dword_45A0F0 = 5; + dword_45A0F4 = 21; + } + return true; + case 8: + if (dword_45A0D0_animation_state != 27 && dword_45A0D0_animation_state != 50) { + dword_45A0D0_animation_state = 37; + dword_45A0D4_animation_frame = 0; + } + return true; + case 7: + if (dword_45A0D0_animation_state != 27 && dword_45A0D0_animation_state != 50) { + dword_45A0D0_animation_state = 36; + dword_45A0D4_animation_frame = 0; + } + return true; + case 6: + dword_45A0D0_animation_state = 21; + dword_45A0D4_animation_frame = 0; + return true; + case 5: + switch (dword_45A0D0_animation_state) { + case 1: + case 2: + case 5: + dword_45A0D0_animation_state = 14; + dword_45A0D4_animation_frame = 0; + break; + case 0: + case 3: + case 4: + dword_45A0D0_animation_state = 15; + dword_45A0D4_animation_frame = 0; + break; + default: + dword_45A0D0_animation_state = 18; + dword_45A0D4_animation_frame = 0; + break; + } + return true; + case 4: + switch (dword_45A0D0_animation_state) { + case 22: + dword_45A0D0_animation_state = 19; + dword_45A0D4_animation_frame = 41; + break; + case 18: + dword_45A0D0_animation_state = 19; + dword_45A0D4_animation_frame = 13 * ((8 - dword_45A0D4_animation_frame) / 8); + break; + case 17: + case 20: + dword_45A0D0_animation_state = 19; + dword_45A0D4_animation_frame = 0; + break; + case 16: + dword_45A0D0_animation_state = 15; + dword_45A0D4_animation_frame = 12 - 12 * dword_45A0D4_animation_frame / 16; + break; + case 14: + case 15: + case 19: + case 21: + case 2: + case 3: + return true; + default: + dword_45A0D0_animation_state = 15; + dword_45A0D4_animation_frame = 0; + break; + case 13: + dword_45A0D0_animation_state = 16; + dword_45A0D4_animation_frame = 0; + break; + case 0: + case 1: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 12: + dword_45A0D0_animation_state = 0; + dword_45A0D4_animation_frame = 0; + dword_45A0DC = 0; + break; + } + return true; + case 3: + if (dword_45A0D0_animation_state >= 3 && dword_45A0D0_animation_state <= 12) { + Game_Flag_Reset(236); + dword_45A0F0 = 4; + dword_45A0F4 = 20; + } else { + dword_45A0D0_animation_state = 13; + dword_462718 = 3; + dword_46271C = 20; + } + return true; + case 2: + if (dword_45A0D0_animation_state == 27 || dword_45A0D0_animation_state == 50) { + return true; + } + if (!Game_Flag_Query(550)) { + dword_45A0D0_animation_state = 31; + dword_45A0D4_animation_frame = 0; + return true; + } + dword_45A0D0_animation_state = 58; + dword_45A0D4_animation_frame = 4; + return true; + case 1: + if (dword_45A0D0_animation_state == 27 || dword_45A0D0_animation_state == 50) { + return true; + } + if (!Game_Flag_Query(550)) { + dword_45A0D0_animation_state = 32; + dword_45A0D4_animation_frame = 0; + return true; + } + dword_45A0D0_animation_state = 58; + dword_45A0D4_animation_frame = 0; + return true; + case 0: + if (Game_Flag_Query(550)) { + if (dword_45A0D4_animation_frame > 6) { + dword_45A0D0_animation_state = 57; + dword_45A0D4_animation_frame = 0; + return true; + } + int v3 = Random_Query(0, 2); + int v4 = 0; + if (v3 == 0) { + v4 = 595; + } else if (v3 == 1) { + v4 = 594; + } else if (v3 == 2) { + v4 = 593; + } + Ambient_Sounds_Play_Sound(v4, 39, 0, 0, 99); + dword_45A0D0_animation_state = 57; + dword_45A0D4_animation_frame = 0; + return true; + } + if (dword_45A0D0_animation_state == 60) { + dword_45A0D0_animation_state = 61; + return true; + } + dword_45A0D0_animation_state = 0; + dword_45A0D4_animation_frame = 0; + dword_45A0DC = 0; + return true; + } + return true; +} - if (dword_45A0D4 == 2) - ; //Sound_Right_Footstep_Walk(0); - else if (dword_45A0D4 == 10) - ; //Sound_Left_Footstep_Walk(0); +void AIScript_McCoy::QueryAnimationState(int *animationState, int *a2, int *a3, int *a4) { + *animationState = dword_45A0D0_animation_state; + *a2 = dword_45A0D4_animation_frame; + *a3 = dword_462718; + *a4 = dword_46271C; +} - break; +void AIScript_McCoy::SetAnimationState(int animationState, int a2, int a3, int a4) { + dword_45A0D0_animation_state = animationState; + dword_45A0D4_animation_frame = a2; + dword_462718 = a3; + dword_46271C = a4; +} - // Start walking - case 32: - dword_45A0D4 = 1; - dword_45A0D0_animation_state = 30; - *animation = 13; - *frame = 1; - break; +bool AIScript_McCoy::ReachedMovementTrackWaypoint() { + return true; +} - case 58: - *animation = 47; - if (dword_45A0D4++ == 5) { - int stepSound; - switch (Random_Query(0, 2)) { - case 0: - stepSound = 595; - break; - case 1: - stepSound = 594; - break; - default: - stepSound = 593; - } - (void)stepSound; - // Ambient_Sounds_Play_Sound(stepSound, 39, 0, 0, 99); +void AIScript_McCoy::sub_4053E0() { + float x, y, z; + Actor_Query_XYZ(0, &x, &y, &z); + flt_462710 = flt_462710 + off_45A100; + if (flt_462714 < flt_462710) { + off_45A100 = off_45A100 - 0.2f; + } else { + flt_462710 = flt_462714; + Actor_Set_Goal_Number(0, 0); + Actor_Retired_Here(0, 12, 48, 1, -1); + } + return Actor_Set_At_XYZ(0, x, flt_462710, z, Actor_Query_Facing_1024(0)); +} + +void AIScript_McCoy::sub_4054F0() { + if (Actor_Query_Which_Set_In(0) == 87 && Actor_Query_Goal_Number(0) != 390 && !Game_Flag_Query(682)) { + float x, y, z; + Actor_Query_XYZ(0, &x, &y, &z); + if ((z < 220.0f) && (-210.0f < x) && (-70.0f > x)) { + Game_Flag_Set(682); + Scene_Loop_Set_Default(3); + Scene_Loop_Start_Special(2, 2, 1); + Actor_Set_Goal_Number(0, 390); + Actor_Query_XYZ(64, &x, &y, &z); + if (-200.0 < x && -62.0f > x) { + Actor_Set_Goal_Number(64, 309); } - if (dword_45A0D4 > Slice_Animation_Query_Number_Of_Frames(*animation) - 2) - dword_45A0D4 = 0; - *frame = dword_45A0D4; - break; + } else { + Actor_Set_Goal_Number(0, 391); + } } } -void AIScript_McCoy::ChangeAnimationMode(int mode) -{ - switch (mode) - { - case 0: - dword_45A0D0_animation_state = 0; - dword_45A0D4 = 0; - break; +void AIScript_McCoy::sub_405660() { + if (Game_Flag_Query(550)) { + if (dword_45A0D4_animation_frame <= 6) { + int v1 = Random_Query(0, 2); + int v2 = 0; + if (v1 == 0) { + v2 = 595; + } else if (v1 == 1) { + v2 = 594; + } else if (v1 == 2) { + v2 = 593; + } + Ambient_Sounds_Play_Sound(v2, 39, 0, 0, 99); + } + dword_45A0D0_animation_state = 57; + dword_45A0D4_animation_frame = 0; + return; + } + switch (dword_45A0D0_animation_state) { + case 17: + case 20: + case 21: + case 36: + dword_45A0D0_animation_state = 16; + dword_45A0D4_animation_frame = 0; + break; + case 16: + case 25: + case 26: + break; + case 15: + dword_45A0D0_animation_state = 16; + dword_45A0D4_animation_frame = 16 - 16 * dword_45A0D4_animation_frame / 12; + break; + case 14: + dword_45A0D0_animation_state = 16; + dword_45A0D4_animation_frame = 0; + break; + case 3: + case 4: + case 5: + case 6: + case 7: + case 8: + case 9: + case 10: + case 11: + case 12: + Game_Flag_Set(236); + dword_45A0D8 = 0; + dword_45A0DC = 30; + dword_45A0E4 = 0; + dword_45A0E0 = 1; + dword_45A0E8 = 3; + break; + case 60: + dword_45A0D0_animation_state = 61; + break; + default: + dword_45A0D0_animation_state = 0; + dword_45A0D4_animation_frame = 0; + dword_45A0DC = 0; + } +} - case 1: - dword_45A0D0_animation_state = 32; - break; +void AIScript_McCoy::sub_405800() { + switch (dword_45A0D0_animation_state) { + case 36: + case 37: + case 40: + case 41: + case 51: + dword_45A0D0_animation_state = 14; + dword_45A0D4_animation_frame = 0; + break; + case 22: + dword_45A0D0_animation_state = 19; + dword_45A0D4_animation_frame = 41; + break; + case 18: + dword_45A0D0_animation_state = 19; + dword_45A0D4_animation_frame = 13 * ((8 - dword_45A0D4_animation_frame) / 8); + break; + case 17: + case 20: + dword_45A0D0_animation_state = 19; + dword_45A0D4_animation_frame = 0; + break; + case 16: + dword_45A0D4_animation_frame = 12 - 12 * dword_45A0D4_animation_frame / 16; + dword_45A0D0_animation_state = 15; + break; + case 14: + case 15: + case 19: + case 21: + break; + default: + dword_45A0D0_animation_state = 15; + dword_45A0D4_animation_frame = 0; + break; + } +} + +void AIScript_McCoy::sub_4058B0() { + int v0 = Actor_Query_Which_Set_In(0); + if (v0 == 27) { + dword_45A0D0_animation_state = 51; + dword_45A0D4_animation_frame = 0; + Player_Loses_Control(); + Game_Flag_Set(210); + } else if (v0 == 70 || v0 == 87) { + dword_45A0D0_animation_state = 56; + dword_45A0D4_animation_frame = 0; + } +} + +void AIScript_McCoy::sub_405920() { + dword_45A0D4_animation_frame = 0; + dword_45A0D0_animation_state = 47; +} + +void AIScript_McCoy::sub_405940(float a1) { + float x, y, z; + int currentAngle = Actor_Query_Facing_1024(0); + Actor_Query_XYZ(0, &x, &y, &z); + int angle = currentAngle - 12; + y = y + a1; + if (angle < 0) { + angle = currentAngle + 1012; + } + if (angle > 1023) { + angle -= 1024; + } + Actor_Set_At_XYZ(0, x, y, z, angle); +} + +void AIScript_McCoy::sub_4059D0(float a1) { + float x, y, z; + int currentAngle = Actor_Query_Facing_1024(0); + Actor_Query_XYZ(0, &x, &y, &z); + int angle = currentAngle + 15; + y = y + a1; + if (angle < 0) { + angle = currentAngle + 1039; + } + if (angle > 1023) { + angle -= 1024; } + return Actor_Set_At_XYZ(0, x, y, z, angle); } } // End of namespace BladeRunner diff --git a/engines/bladerunner/script/ai_00_mccoy.h b/engines/bladerunner/script/ai_00_mccoy.h index 11c9f1d8cb03..eedae2f99bcd 100644 --- a/engines/bladerunner/script/ai_00_mccoy.h +++ b/engines/bladerunner/script/ai_00_mccoy.h @@ -25,21 +25,58 @@ #include "bladerunner/bladerunner.h" namespace BladeRunner { - class AIScript_McCoy : public AIScriptBase { int dword_45A0D0_animation_state; - int dword_45A0D4; + int dword_45A0D4_animation_frame; int dword_45A0D8; int dword_45A0DC; int dword_45A0E0; int dword_45A0E4; + float off_45A0EC; int dword_45A0E8; + int dword_45A0F0; + int dword_45A0F4; + int dword_45A0F8; + int dword_45A0FC; + int dword_462718; + int dword_46271C; + float off_45A100; + float flt_462710; + float flt_462714; + public: AIScript_McCoy(BladeRunnerEngine *vm); void Initialize(); - void UpdateAnimation(int *animation, int *frame); - void ChangeAnimationMode(int mode); -}; + bool Update(); + void TimerExpired(int timer); + void CompletedMovementTrack(); + void ReceivedClue(int clueId, int fromActorId); + void ClickedByPlayer(); + void EnteredScene(int sceneId); + void OtherAgentEnteredThisScene(); + void OtherAgentExitedThisScene(); + void OtherAgentEnteredCombatMode(); + void ShotAtAndMissed(); + void ShotAtAndHit(); + void Retired(int byActorId); + void GetFriendlinessModifierIfGetsClue(); + bool GoalChanged(int currentGoalNumber, int newGoalNumber); + bool UpdateAnimation(int *animation, int *frame); + bool ChangeAnimationMode(int mode); + void QueryAnimationState(int *animationState, int *a2, int *a3, int *a4); + void SetAnimationState(int animationState, int a2, int a3, int a4); + bool ReachedMovementTrackWaypoint(); +private: + void sub_4053E0(); + void sub_4054F0(); + void sub_405660(); + void sub_405800(); + void sub_4058B0(); + void sub_405920(); + void sub_405940(float a1); + void sub_4059D0(float a1); + +}; } // End of namespace BladeRunner diff --git a/engines/bladerunner/script/aiscript_officer_leroy.cpp b/engines/bladerunner/script/aiscript_officer_leroy.cpp index 1acb096b0141..f388eded6bbb 100644 --- a/engines/bladerunner/script/aiscript_officer_leroy.cpp +++ b/engines/bladerunner/script/aiscript_officer_leroy.cpp @@ -40,7 +40,51 @@ void AIScript_Officer_Leroy::Initialize() // Actor_Set_Frame_Rate_FPS(23, 8); } -void AIScript_Officer_Leroy::UpdateAnimation(int *animation, int *frame) +bool AIScript_Officer_Leroy::Update() { + return false; +} + +void AIScript_Officer_Leroy::TimerExpired(int timer) { +} + +void AIScript_Officer_Leroy::CompletedMovementTrack() { +} + +void AIScript_Officer_Leroy::ReceivedClue(int clueId, int fromActorId) { +} + +void AIScript_Officer_Leroy::ClickedByPlayer() { +} + +void AIScript_Officer_Leroy::EnteredScene(int sceneId) { +} + +void AIScript_Officer_Leroy::OtherAgentEnteredThisScene() { +} + +void AIScript_Officer_Leroy::OtherAgentExitedThisScene() { +} + +void AIScript_Officer_Leroy::OtherAgentEnteredCombatMode() { +} + +void AIScript_Officer_Leroy::ShotAtAndMissed() { +} + +void AIScript_Officer_Leroy::ShotAtAndHit() { +} + +void AIScript_Officer_Leroy::Retired(int byActorId) { +} + +void AIScript_Officer_Leroy::GetFriendlinessModifierIfGetsClue() { +} + +bool AIScript_Officer_Leroy::GoalChanged(int currentGoalNumber, int newGoalNumber) { + return false; +} + +bool AIScript_Officer_Leroy::UpdateAnimation(int *animation, int *frame) { if (var_45D5B8 == 0) { *animation = 589; @@ -70,11 +114,11 @@ void AIScript_Officer_Leroy::UpdateAnimation(int *animation, int *frame) var_45D5B8 = Random_Query(0, 2); } } - *frame = var_45D5B4_frame; + return true; } -void AIScript_Officer_Leroy::ChangeAnimationMode(int mode) +bool AIScript_Officer_Leroy::ChangeAnimationMode(int mode) { switch (mode) { @@ -82,6 +126,16 @@ void AIScript_Officer_Leroy::ChangeAnimationMode(int mode) var_45D5B0_animation_state = 32; break; } + return true; +} + +void AIScript_Officer_Leroy::QueryAnimationState(int *animationState, int *a2, int *a3, int *a4) { +} + +void AIScript_Officer_Leroy::SetAnimationState(int animationState, int a2, int a3, int a4) { } +bool AIScript_Officer_Leroy::ReachedMovementTrackWaypoint() { + return false; +} } // End of namespace BladeRunner diff --git a/engines/bladerunner/script/aiscript_officer_leroy.h b/engines/bladerunner/script/aiscript_officer_leroy.h index 7d81b625e91c..152ba8346327 100644 --- a/engines/bladerunner/script/aiscript_officer_leroy.h +++ b/engines/bladerunner/script/aiscript_officer_leroy.h @@ -34,8 +34,25 @@ class AIScript_Officer_Leroy : public AIScriptBase { AIScript_Officer_Leroy(BladeRunnerEngine *vm); void Initialize(); - void UpdateAnimation(int *animation, int *frame); - void ChangeAnimationMode(int mode); + bool Update(); + void TimerExpired(int timer); + void CompletedMovementTrack(); + void ReceivedClue(int clueId, int fromActorId); + void ClickedByPlayer(); + void EnteredScene(int sceneId); + void OtherAgentEnteredThisScene(); + void OtherAgentExitedThisScene(); + void OtherAgentEnteredCombatMode(); + void ShotAtAndMissed(); + void ShotAtAndHit(); + void Retired(int byActorId); + void GetFriendlinessModifierIfGetsClue(); + bool GoalChanged(int currentGoalNumber, int newGoalNumber); + bool UpdateAnimation(int *animation, int *frame); + bool ChangeAnimationMode(int mode); + void QueryAnimationState(int *animationState, int *a2, int *a3, int *a4); + void SetAnimationState(int animationState, int a2, int a3, int a4); + bool ReachedMovementTrackWaypoint(); }; } // End of namespace BladeRunner diff --git a/engines/bladerunner/script/script.cpp b/engines/bladerunner/script/script.cpp index e9f9b602e36a..4ecec287538c 100644 --- a/engines/bladerunner/script/script.cpp +++ b/engines/bladerunner/script/script.cpp @@ -146,7 +146,9 @@ void Script::SceneFrameAdvanced(int frame) { void Script::ActorChangedGoal(int actorId, int newGoal, int oldGoal, bool currentSet) { _inScriptCounter++; - _currentScript->ActorChangedGoal(actorId, newGoal, oldGoal, currentSet); + //TODO remove this check + if(_currentScript) + _currentScript->ActorChangedGoal(actorId, newGoal, oldGoal, currentSet); _inScriptCounter--; } @@ -788,10 +790,27 @@ void ScriptBase::Sound_Play_Speech_Line(int actorId, int speechId, int a3, int a //TODO warning("Sound_Play_Speech_Line(%d, %d, %d, %d, %d)", actorId, speechId, a3, a4, a5); } -// ScriptBase::Sound_Left_Footstep_Walk -// ScriptBase::Sound_Right_Footstep_Walk -// ScriptBase::Sound_Left_Footstep_Run -// ScriptBase::Sound_Right_Footstep_Run + +void ScriptBase::Sound_Left_Footstep_Walk(int actorId) { + //TODO + warning("Sound_Left_Footstep_Walk(%d)", actorId); +} + +void ScriptBase::Sound_Right_Footstep_Walk(int actorId) { + //TODO + warning("Sound_Right_Footstep_Walk(%d)", actorId); +} + +void ScriptBase::Sound_Left_Footstep_Run(int actorId) { + //TODO + warning("Sound_Left_Footstep_Run(%d)", actorId); +} + +void ScriptBase::Sound_Right_Footstep_Run(int actorId) { + //TODO + warning("Sound_Right_Footstep_Run(%d)", actorId); +} + // ScriptBase::Sound_Walk_Shuffle_Stop void ScriptBase::Footstep_Sounds_Set(int walkboxId, int stepSound) { diff --git a/engines/bladerunner/script/script.h b/engines/bladerunner/script/script.h index 20ed8456ca63..a4c8ad00fd08 100644 --- a/engines/bladerunner/script/script.h +++ b/engines/bladerunner/script/script.h @@ -154,10 +154,10 @@ class ScriptBase { int Random_Query(int min, int max); void Sound_Play(int id, int volume, int panFrom, int panTo, int priority); void Sound_Play_Speech_Line(int actorId, int speechId, int a3, int a4, int a5); - // Sound_Left_Footstep_Walk - // Sound_Right_Footstep_Walk - // Sound_Left_Footstep_Run - // Sound_Right_Footstep_Run + void Sound_Left_Footstep_Walk(int actorId); + void Sound_Right_Footstep_Walk(int actorId); + void Sound_Left_Footstep_Run(int actorId); + void Sound_Right_Footstep_Run(int actorId); // Sound_Walk_Shuffle_Stop void Footstep_Sounds_Set(int index, int value); void Footstep_Sound_Override_On(int footstepSoundOverride); @@ -822,8 +822,25 @@ class AIScriptBase : public ScriptBase { {} virtual void Initialize() = 0; - virtual void UpdateAnimation(int *animation, int *frame) = 0; - virtual void ChangeAnimationMode(int mode) = 0; + virtual bool Update() = 0; + virtual void TimerExpired(int timer) = 0; + virtual void CompletedMovementTrack() = 0; + virtual void ReceivedClue(int clueId, int fromActorId) = 0; + virtual void ClickedByPlayer() = 0; + virtual void EnteredScene(int sceneId) = 0; + virtual void OtherAgentEnteredThisScene() = 0; + virtual void OtherAgentExitedThisScene() = 0; + virtual void OtherAgentEnteredCombatMode() = 0; + virtual void ShotAtAndMissed() = 0; + virtual void ShotAtAndHit() = 0; + virtual void Retired(int byActorId) = 0; + virtual void GetFriendlinessModifierIfGetsClue() = 0; + virtual bool GoalChanged(int currentGoalNumber, int newGoalNumber) = 0; + virtual bool UpdateAnimation(int *animation, int *frame) = 0; + virtual bool ChangeAnimationMode(int mode) = 0; + virtual void QueryAnimationState(int *animationState, int *a2, int *a3, int *a4) = 0; + virtual void SetAnimationState(int animationState, int a2, int a3, int a4) = 0; + virtual bool ReachedMovementTrackWaypoint() = 0; }; class AIScripts {