Skip to content

Commit

Permalink
BLADERUNNER: Cleanup of Mutants scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
peterkohaut committed Feb 7, 2019
1 parent c99d3ea commit b3b6f6e
Show file tree
Hide file tree
Showing 8 changed files with 140 additions and 116 deletions.
4 changes: 2 additions & 2 deletions engines/bladerunner/game_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
130 changes: 67 additions & 63 deletions engines/bladerunner/script/ai/mutant1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand All @@ -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);
}

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;

Expand Down
53 changes: 32 additions & 21 deletions engines/bladerunner/script/ai/mutant2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down Expand Up @@ -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);
}
}
}
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;

Expand Down
Loading

0 comments on commit b3b6f6e

Please sign in to comment.