From b3b6f6eaa36ef8651d3a7192f07223699b7055a9 Mon Sep 17 00:00:00 2001 From: Peter Kohaut Date: Wed, 6 Feb 2019 23:27:16 +0100 Subject: BLADERUNNER: Cleanup of Mutants scripts --- engines/bladerunner/game_constants.h | 4 +- engines/bladerunner/script/ai/mutant1.cpp | 130 +++++++++++---------- engines/bladerunner/script/ai/mutant2.cpp | 53 +++++---- engines/bladerunner/script/ai/mutant3.cpp | 51 ++++---- engines/bladerunner/script/ai/officer_grayford.cpp | 2 +- engines/bladerunner/script/ai/officer_leary.cpp | 4 +- engines/bladerunner/script/scene/ct12.cpp | 4 +- engines/bladerunner/script/scene/ug09.cpp | 8 +- 8 files changed, 140 insertions(+), 116 deletions(-) diff --git a/engines/bladerunner/game_constants.h b/engines/bladerunner/game_constants.h index 7248cca5cb..2686993a95 100644 --- a/engines/bladerunner/game_constants.h +++ b/engines/bladerunner/game_constants.h @@ -1066,8 +1066,8 @@ enum Flags { // 626 is never used kFlagNR01McCoyIsDrugged = 627, // 628 is never used - kFlagUnpaseGenWalkers = 629, - + kFlagUnpauseGenWalkers = 629, + kFlagMutantsPaused = 630, kFlagRatWalkingAround = 631, kFlagNR01DektoraFall = 632, kFlagNR11DektoraBurning = 633, diff --git a/engines/bladerunner/script/ai/mutant1.cpp b/engines/bladerunner/script/ai/mutant1.cpp index 1ae338f334..bdd2548db4 100644 --- a/engines/bladerunner/script/ai/mutant1.cpp +++ b/engines/bladerunner/script/ai/mutant1.cpp @@ -42,65 +42,63 @@ void AIScriptMutant1::Initialize() { } bool AIScriptMutant1::Update() { - if (Global_Variable_Query(kVariableChapter) == 5 && Actor_Query_Goal_Number(kActorMutant1) != 590) { - if (Actor_Query_Which_Set_In(kActorMutant1) != Player_Query_Current_Set()) { - Actor_Set_Goal_Number(kActorMutant1, 590); - } - - return false; - } + if (Global_Variable_Query(kVariableChapter) == 4) { + switch (Actor_Query_Goal_Number(kActorMutant1)) { + case 400: + if (!Game_Flag_Query(kFlagMutantsActive) + && Game_Flag_Query(kFlagUG06Chapter4Started) + ) { + Actor_Set_Goal_Number(kActorMutant1, 401); + Actor_Set_Goal_Number(kActorMutant2, 401); + Actor_Set_Goal_Number(kActorMutant3, 401); + Actor_Set_Targetable(kActorMutant1, true); + Actor_Set_Targetable(kActorMutant2, true); + Actor_Set_Targetable(kActorMutant3, true); + Game_Flag_Set(kFlagMutantsActive); + } + break; - if (Global_Variable_Query(kVariableChapter) != 4) { - return false; - } + case 401: + if (Actor_Query_Which_Set_In(kActorMutant1) == Player_Query_Current_Set() + && (Actor_Query_Friendliness_To_Other(kActorMutant1, kActorMcCoy) < 30 + || Actor_Query_Combat_Aggressiveness(kActorMutant1) >= 60 + ) + ) { + Actor_Set_Goal_Number(kActorMutant1, 410); + } + break; - switch (Actor_Query_Goal_Number(kActorMutant1)) { - case 400: - if (!Game_Flag_Query(kFlagMutantsActive) - && Game_Flag_Query(kFlagUG06Chapter4Started) - ) { - Actor_Set_Goal_Number(kActorMutant1, 401); - Actor_Set_Goal_Number(kActorMutant2, 401); - Actor_Set_Goal_Number(kActorMutant3, 401); - Actor_Set_Targetable(kActorMutant1, 1); - Actor_Set_Targetable(kActorMutant2, 1); - Actor_Set_Targetable(kActorMutant3, 1); - Game_Flag_Set(kFlagMutantsActive); - } - break; + case 404: + if (!Game_Flag_Query(kFlagMutantsPaused)) { + Actor_Set_Goal_Number(kActorMutant1, 403); + } + break; - case 401: - if (Actor_Query_Which_Set_In(kActorMutant1) == Player_Query_Current_Set() - && (Actor_Query_Friendliness_To_Other(kActorMutant1, kActorMcCoy) < 30 - || Actor_Query_Combat_Aggressiveness(kActorMutant1) >= 60 - ) - ) { - Actor_Set_Goal_Number(kActorMutant1, 410); - } - break; + case 410: + if (Actor_Query_Which_Set_In(kActorMutant1) != Player_Query_Current_Set()) { + Non_Player_Actor_Combat_Mode_Off(kActorMutant1); + Actor_Set_Goal_Number(kActorMutant1, 403); + } + break; - case 404: - if (!Game_Flag_Query(630)) { - Actor_Set_Goal_Number(kActorMutant1, 403); + case 599: + if (Actor_Query_Which_Set_In(kActorMutant1) != Player_Query_Current_Set()) { + Actor_Set_Goal_Number(kActorMutant1, 411); + } + break; } - break; - case 410: - if (Actor_Query_Which_Set_In(kActorMutant1) != Player_Query_Current_Set()) { - Non_Player_Actor_Combat_Mode_Off(kActorMutant1); - Actor_Set_Goal_Number(kActorMutant1, 403); + if (Game_Flag_Query(kFlagMutantsPaused) + && Actor_Query_Goal_Number(kActorMutant1) != 599 + ) { + Actor_Set_Goal_Number(kActorMutant1, 404); } - break; - - case 599: + } else if (Global_Variable_Query(kVariableChapter) == 5 + && Actor_Query_Goal_Number(kActorMutant1) != 590 + ) { if (Actor_Query_Which_Set_In(kActorMutant1) != Player_Query_Current_Set()) { - Actor_Set_Goal_Number(kActorMutant1, 411); + Actor_Set_Goal_Number(kActorMutant1, 590); } - break; - } - - if (Game_Flag_Query(630) == 1 && Actor_Query_Goal_Number(kActorMutant1) != 599) { - Actor_Set_Goal_Number(kActorMutant1, 404); } return false; @@ -111,8 +109,9 @@ void AIScriptMutant1::TimerExpired(int timer) { } void AIScriptMutant1::CompletedMovementTrack() { - if (Actor_Query_Goal_Number(kActorMutant1) == 401) + if (Actor_Query_Goal_Number(kActorMutant1) == 401) { Actor_Set_Goal_Number(kActorMutant1, 403); + } } void AIScriptMutant1::ReceivedClue(int clueId, int fromActorId) { @@ -136,31 +135,36 @@ void AIScriptMutant1::OtherAgentExitedThisScene(int otherActorId) { } void AIScriptMutant1::OtherAgentEnteredCombatMode(int otherActorId, int combatMode) { - if (Actor_Query_Which_Set_In(kActorMutant1) == Player_Query_Current_Set() && Actor_Query_Goal_Number(kActorMutant1) != 599) { - if (otherActorId != kActorMcCoy) { - if (otherActorId > 72 || (otherActorId != kActorFreeSlotA && otherActorId != kActorMutant2 && otherActorId != kActorMutant3)) { - Actor_Modify_Combat_Aggressiveness(70, -10); + if (Actor_Query_Which_Set_In(kActorMutant1) == Player_Query_Current_Set() + && Actor_Query_Goal_Number(kActorMutant1) != 599 + ) { + if (otherActorId == kActorMcCoy) { + if (combatMode) { + Actor_Modify_Combat_Aggressiveness(kActorMutant1, 10); } else { - Actor_Modify_Combat_Aggressiveness(70, 10); + Actor_Modify_Combat_Aggressiveness(kActorMutant1, -10); } - } else if (combatMode) { - Actor_Modify_Combat_Aggressiveness(70, 10); + } else if (otherActorId == kActorFreeSlotA + || otherActorId == kActorMutant2 + || otherActorId == kActorMutant3 + ) { + Actor_Modify_Combat_Aggressiveness(kActorMutant1, 10); } else { - Actor_Modify_Combat_Aggressiveness(70, -10); + Actor_Modify_Combat_Aggressiveness(kActorMutant1, -10); } } } void AIScriptMutant1::ShotAtAndMissed() { if (Actor_Query_Goal_Number(kActorMutant1) != 410) { - Actor_Modify_Combat_Aggressiveness(70, 10); + Actor_Modify_Combat_Aggressiveness(kActorMutant1, 10); Actor_Modify_Friendliness_To_Other(kActorMutant1, kActorMcCoy, -10); } } bool AIScriptMutant1::ShotAtAndHit() { if (Actor_Query_Goal_Number(kActorMutant1) != 410) { - Actor_Modify_Combat_Aggressiveness(70, 15); + Actor_Modify_Combat_Aggressiveness(kActorMutant1, 15); Actor_Modify_Friendliness_To_Other(kActorMutant1, kActorMcCoy, -15); } @@ -189,7 +193,7 @@ bool AIScriptMutant1::GoalChanged(int currentGoalNumber, int newGoalNumber) { return true; case 401: - Actor_Set_Targetable(kActorMutant1, 1); + Actor_Set_Targetable(kActorMutant1, true); AI_Movement_Track_Flush(kActorMutant1); AI_Movement_Track_Append(kActorMutant1, 39, 0); @@ -317,7 +321,7 @@ bool AIScriptMutant1::GoalChanged(int currentGoalNumber, int newGoalNumber) { return true; case 403: - Actor_Set_Targetable(kActorMutant1, 0); + Actor_Set_Targetable(kActorMutant1, false); Actor_Set_Goal_Number(kActorMutant1, 401); return true; diff --git a/engines/bladerunner/script/ai/mutant2.cpp b/engines/bladerunner/script/ai/mutant2.cpp index 3e837b6388..512f207a77 100644 --- a/engines/bladerunner/script/ai/mutant2.cpp +++ b/engines/bladerunner/script/ai/mutant2.cpp @@ -46,22 +46,18 @@ void AIScriptMutant2::Initialize() { bool AIScriptMutant2::Update() { if (Global_Variable_Query(kVariableChapter) == 4) { switch (Actor_Query_Goal_Number(kActorMutant2)) { - case 599: - if (Actor_Query_Which_Set_In(kActorMutant2) != Player_Query_Current_Set()) { - Actor_Set_Goal_Number(kActorMutant2, 403); - } - break; - case 401: if (Actor_Query_Which_Set_In(kActorMutant2) == Player_Query_Current_Set() - && (Actor_Query_Friendliness_To_Other(kActorMutant2, kActorMcCoy) < 20 - || Actor_Query_Combat_Aggressiveness(kActorMutant2) >= 60)) { + && (Actor_Query_Friendliness_To_Other(kActorMutant2, kActorMcCoy) < 20 + || Actor_Query_Combat_Aggressiveness(kActorMutant2) >= 60 + ) + ) { Actor_Set_Goal_Number(kActorMutant2, 410); } break; case 404: - if (!Game_Flag_Query(630)) { + if (!Game_Flag_Query(kFlagMutantsPaused)) { Actor_Set_Goal_Number(kActorMutant2, 403); } break; @@ -72,12 +68,22 @@ bool AIScriptMutant2::Update() { Actor_Set_Goal_Number(kActorMutant2, 403); } break; + + case 599: + if (Actor_Query_Which_Set_In(kActorMutant2) != Player_Query_Current_Set()) { + Actor_Set_Goal_Number(kActorMutant2, 403); + } + break; } - if (Game_Flag_Query(630) == 1 && Actor_Query_Goal_Number(kActorMutant2) != 599) { + if (Game_Flag_Query(kFlagMutantsPaused) + && Actor_Query_Goal_Number(kActorMutant2) != 599 + ) { Actor_Set_Goal_Number(kActorMutant2, 404); } - } else if (Global_Variable_Query(kVariableChapter) == 5 && Actor_Query_Goal_Number(kActorMutant2) != 590) { + } else if (Global_Variable_Query(kVariableChapter) == 5 + && Actor_Query_Goal_Number(kActorMutant2) != 590 + ) { if (Actor_Query_Which_Set_In(kActorMutant2) != Player_Query_Current_Set()) { Actor_Set_Goal_Number(kActorMutant2, 590); } @@ -116,17 +122,22 @@ void AIScriptMutant2::OtherAgentExitedThisScene(int otherActorId) { } void AIScriptMutant2::OtherAgentEnteredCombatMode(int otherActorId, int combatMode) { - if (Actor_Query_Which_Set_In(kActorMutant2) == Player_Query_Current_Set() && Actor_Query_Goal_Number(kActorMutant2) != 599) { - if (otherActorId != kActorMcCoy) { - if (otherActorId > 72 || (otherActorId != kActorFreeSlotA && otherActorId != kActorMutant1 && otherActorId != kActorMutant3)) { - Actor_Modify_Combat_Aggressiveness(kActorMutant2, -10); + if (Actor_Query_Which_Set_In(kActorMutant2) == Player_Query_Current_Set() + && Actor_Query_Goal_Number(kActorMutant2) != 599 + ) { + if (otherActorId == kActorMcCoy) { + if (combatMode) { + Actor_Modify_Combat_Aggressiveness(kActorMutant2, 10); } else { - Actor_Modify_Combat_Aggressiveness(kActorMutant2, 5); + Actor_Modify_Combat_Aggressiveness(kActorMutant2, -10); } - } else if (combatMode) { - Actor_Modify_Combat_Aggressiveness(kActorMutant2, -10); + } else if (otherActorId == kActorFreeSlotA + || otherActorId == kActorMutant1 + || otherActorId == kActorMutant3 + ) { + Actor_Modify_Combat_Aggressiveness(kActorMutant2, 5); } else { - Actor_Modify_Combat_Aggressiveness(kActorMutant2, 10); + Actor_Modify_Combat_Aggressiveness(kActorMutant2, -10); } } } @@ -169,7 +180,7 @@ bool AIScriptMutant2::GoalChanged(int currentGoalNumber, int newGoalNumber) { return true; case 401: - Actor_Set_Targetable(kActorMutant2, 1); + Actor_Set_Targetable(kActorMutant2, true); AI_Movement_Track_Flush(kActorMutant2); AI_Movement_Track_Append(kActorMutant2, 39, 0); @@ -292,7 +303,7 @@ bool AIScriptMutant2::GoalChanged(int currentGoalNumber, int newGoalNumber) { return true; case 403: - Actor_Set_Targetable(kActorMutant2, 0); + Actor_Set_Targetable(kActorMutant2, false); Actor_Set_Goal_Number(kActorMutant2, 401); return true; diff --git a/engines/bladerunner/script/ai/mutant3.cpp b/engines/bladerunner/script/ai/mutant3.cpp index 848dd6cc62..990ed8c474 100644 --- a/engines/bladerunner/script/ai/mutant3.cpp +++ b/engines/bladerunner/script/ai/mutant3.cpp @@ -46,22 +46,18 @@ void AIScriptMutant3::Initialize() { bool AIScriptMutant3::Update() { if (Global_Variable_Query(kVariableChapter) == 4) { switch (Actor_Query_Goal_Number(kActorMutant3)) { - case 599: - if (Actor_Query_Which_Set_In(kActorMutant3) != Player_Query_Current_Set()) { - Actor_Set_Goal_Number(kActorMutant3, 403); - } - break; - case 401: if (Actor_Query_Which_Set_In(kActorMutant3) == Player_Query_Current_Set() - && (Actor_Query_Friendliness_To_Other(kActorMutant3, kActorMcCoy) < 40 - || Actor_Query_Combat_Aggressiveness(kActorMutant3) >= 60)) { + && (Actor_Query_Friendliness_To_Other(kActorMutant3, kActorMcCoy) < 40 + || Actor_Query_Combat_Aggressiveness(kActorMutant3) >= 60 + ) + ) { Actor_Set_Goal_Number(kActorMutant3, 410); } break; case 404: - if (!Game_Flag_Query(630)) { + if (!Game_Flag_Query(kFlagMutantsPaused)) { Actor_Set_Goal_Number(kActorMutant3, 401); } break; @@ -72,12 +68,22 @@ bool AIScriptMutant3::Update() { Actor_Set_Goal_Number(kActorMutant3, 403); } break; + + case 599: + if (Actor_Query_Which_Set_In(kActorMutant3) != Player_Query_Current_Set()) { + Actor_Set_Goal_Number(kActorMutant3, 403); + } + break; } - if (Game_Flag_Query(630) == 1 && Actor_Query_Goal_Number(kActorMutant3) != 599) { + if (Game_Flag_Query(kFlagMutantsPaused) + && Actor_Query_Goal_Number(kActorMutant3) != 599 + ) { Actor_Set_Goal_Number(kActorMutant3, 404); } - } else if (Global_Variable_Query(kVariableChapter) == 5 && Actor_Query_Goal_Number(kActorMutant3) != 590) { + } else if (Global_Variable_Query(kVariableChapter) == 5 + && Actor_Query_Goal_Number(kActorMutant3) != 590 + ) { if (Actor_Query_Which_Set_In(kActorMutant3) != Player_Query_Current_Set()) { Actor_Set_Goal_Number(kActorMutant3, 590); } @@ -122,15 +128,20 @@ void AIScriptMutant3::OtherAgentExitedThisScene(int otherActorId) { } void AIScriptMutant3::OtherAgentEnteredCombatMode(int otherActorId, int combatMode) { - if (Actor_Query_Which_Set_In(kActorMutant3) == Player_Query_Current_Set() && Actor_Query_Goal_Number(kActorMutant3) != 599) { - if (otherActorId != kActorMcCoy) { - if (otherActorId > 72 || (otherActorId != kActorFreeSlotA && otherActorId != kActorMutant1 && otherActorId != kActorMutant2)) { - Actor_Modify_Combat_Aggressiveness(kActorMutant3, -10); + if (Actor_Query_Which_Set_In(kActorMutant3) == Player_Query_Current_Set() + && Actor_Query_Goal_Number(kActorMutant3) != 599 + ) { + if (otherActorId == kActorMcCoy) { + if (combatMode) { + Actor_Modify_Combat_Aggressiveness(kActorMutant3, 10); } else { - Actor_Modify_Combat_Aggressiveness(kActorMutant3, 5); + Actor_Modify_Combat_Aggressiveness(kActorMutant3, -10); } - } else if (combatMode) { - Actor_Modify_Combat_Aggressiveness(kActorMutant3, 10); + } else if (otherActorId == kActorFreeSlotA + || otherActorId == kActorMutant1 + || otherActorId == kActorMutant2 + ) { + Actor_Modify_Combat_Aggressiveness(kActorMutant3, 5); } else { Actor_Modify_Combat_Aggressiveness(kActorMutant3, -10); } @@ -182,7 +193,7 @@ bool AIScriptMutant3::GoalChanged(int currentGoalNumber, int newGoalNumber) { break; case 401: - Actor_Set_Targetable(kActorMutant3, 1); + Actor_Set_Targetable(kActorMutant3, true); AI_Movement_Track_Flush(kActorMutant3); AI_Movement_Track_Append(kActorMutant3, 39, 0); @@ -303,7 +314,7 @@ bool AIScriptMutant3::GoalChanged(int currentGoalNumber, int newGoalNumber) { break; case 403: - Actor_Set_Targetable(kActorMutant3, 0); + Actor_Set_Targetable(kActorMutant3, false); Actor_Set_Goal_Number(kActorMutant3, 401); break; diff --git a/engines/bladerunner/script/ai/officer_grayford.cpp b/engines/bladerunner/script/ai/officer_grayford.cpp index 1e7484cb92..cdf1b1a524 100644 --- a/engines/bladerunner/script/ai/officer_grayford.cpp +++ b/engines/bladerunner/script/ai/officer_grayford.cpp @@ -85,7 +85,7 @@ bool AIScriptOfficerGrayford::Update() { return false; } - if (Game_Flag_Query(kFlagUnpaseGenWalkers)) { + if (Game_Flag_Query(kFlagUnpauseGenWalkers)) { AI_Movement_Track_Unpause(kActorGenwalkerA); AI_Movement_Track_Unpause(kActorGenwalkerB); AI_Movement_Track_Unpause(kActorGenwalkerC); diff --git a/engines/bladerunner/script/ai/officer_leary.cpp b/engines/bladerunner/script/ai/officer_leary.cpp index ad94d2eeda..a8edf10ff2 100644 --- a/engines/bladerunner/script/ai/officer_leary.cpp +++ b/engines/bladerunner/script/ai/officer_leary.cpp @@ -86,8 +86,8 @@ bool AIScriptOfficerLeary::Update() { return false; } - if (Game_Flag_Query(kFlagUnpaseGenWalkers)) { - Game_Flag_Reset(kFlagUnpaseGenWalkers); + if (Game_Flag_Query(kFlagUnpauseGenWalkers)) { + Game_Flag_Reset(kFlagUnpauseGenWalkers); return false; } diff --git a/engines/bladerunner/script/scene/ct12.cpp b/engines/bladerunner/script/scene/ct12.cpp index e7171b96ec..8160b9a2fe 100644 --- a/engines/bladerunner/script/scene/ct12.cpp +++ b/engines/bladerunner/script/scene/ct12.cpp @@ -148,7 +148,7 @@ bool SceneScriptCT12::ClickedOnActor(int actorId) { Actor_Says(kActorOfficerGrayford, 90, kAnimationModeTalk); Actor_Says(kActorOfficerGrayford, 100, kAnimationModeTalk); Actor_Says(kActorOfficerGrayford, 110, kAnimationModeTalk); - Game_Flag_Set(kFlagUnpaseGenWalkers); + Game_Flag_Set(kFlagUnpauseGenWalkers); Game_Flag_Set(kFlagMcCoyFreedOfAccusations); Actor_Set_Goal_Number(kActorMcCoy, kGoalMcCoyStartChapter5); } @@ -202,7 +202,7 @@ bool SceneScriptCT12::ClickedOnExit(int exitId) { if (exitId == 4) { if (!Loop_Actor_Walk_To_XYZ(kActorMcCoy, -292.0f, -6.5f, 990.0f, 0, true, false, 0)) { if (Global_Variable_Query(kVariableChapter) == 4) { - Game_Flag_Set(kFlagUnpaseGenWalkers); + Game_Flag_Set(kFlagUnpauseGenWalkers); } Ambient_Sounds_Remove_All_Non_Looping_Sounds(true); Ambient_Sounds_Remove_All_Looping_Sounds(1); diff --git a/engines/bladerunner/script/scene/ug09.cpp b/engines/bladerunner/script/scene/ug09.cpp index 3348272ea3..678190d129 100644 --- a/engines/bladerunner/script/scene/ug09.cpp +++ b/engines/bladerunner/script/scene/ug09.cpp @@ -138,15 +138,13 @@ void SceneScriptUG09::PlayerWalkedIn() { if (Global_Variable_Query(kVariableChapter) == 4 && Game_Flag_Query(kFlagUG07Empty) ) { - Game_Flag_Set(630); + Game_Flag_Set(kFlagMutantsPaused); } } void SceneScriptUG09::PlayerWalkedOut() { - if (Global_Variable_Query(kVariableChapter) == 4 - && Global_Variable_Query(kVariableChapter) != 5 - ) { - Game_Flag_Reset(630); + if (Global_Variable_Query(kVariableChapter) == 4) { + Game_Flag_Reset(kFlagMutantsPaused); } if (Game_Flag_Query(kFlagUG09toCT12)) { -- cgit v1.2.3