Permalink
Browse files

BLADERUNNER: Added debugging output for scripts

Also added last few missing script commands.
  • Loading branch information...
peterkohaut committed Jan 12, 2019
1 parent 2f0fb70 commit 0c7077cab93131a0902ccb3b5e1a85e2b5557908
@@ -117,6 +117,11 @@ void AmbientSounds::playSound(int sfxId, int volume, int panStart, int panEnd, i
_vm->_audioPlayer->playAud(_vm->_gameInfo->getSfxTrack(sfxId), volume * _ambientVolume / 100, panStart, panEnd, priority, kAudioPlayerOverrideVolume);
}

void AmbientSounds::playSpeech(int actorId, int sentenceId, int volume, int panStart, int panEnd, int priority) {
Common::String name = Common::String::format( "%02d-%04d%s.AUD", actorId, sentenceId, _vm->_languageCode.c_str());
_vm->_audioPlayer->playAud(name, volume * _ambientVolume / 100, panStart, panEnd, priority, kAudioPlayerOverrideVolume);
}

void AmbientSounds::addLoopingSound(int sfxId, int volume, int pan, int delay) {
const Common::String &name = _vm->_gameInfo->getSfxTrack(sfxId);
int32 hash = MIXArchive::getHash(name);
@@ -93,6 +93,7 @@ class AmbientSounds {
int panEndMin, int panEndMax,
int priority, int unk);
void playSound(int sfxId, int volume, int panStart, int panEnd, int priority);
void playSpeech(int actorId, int sentenceId, int volume, int panStart, int panEnd, int priority);

void addLoopingSound(int sfxId, int volume, int pan, int delay);
void adjustLoopingSound(int sfxId, int volume, int pan, int delay);
@@ -81,6 +81,7 @@
#include "common/events.h"
#include "common/savefile.h"
#include "common/system.h"
#include "common/debug-channels.h"

#include "engines/util.h"
#include "engines/advancedDetector.h"
@@ -93,6 +94,8 @@ BladeRunnerEngine::BladeRunnerEngine(OSystem *syst, const ADGameDescription *des
: Engine(syst),
_rnd("bladerunner") {

DebugMan.addDebugChannel(kDebugScript, "Script", "Debug the scripts");

_windowIsActive = true;
_gameIsRunning = true;

@@ -51,6 +51,10 @@ struct ADGameDescription;

namespace BladeRunner {

enum DebugLevels {
kDebugScript = 1 << 0
};

class Actor;
class ActorDialogueQueue;
class ScreenEffects;
@@ -146,6 +146,22 @@ bool DialogueMenu::addToListNeverRepeatOnceSelected(int answer, int priorityPoli
return addToList(answer, false, priorityPolite, priorityNormal, prioritySurly);
}

bool DialogueMenu::removeFromList(int answer) {
int index = getAnswerIndex(answer);
if (index != -1) {
return false;
}
if (index < _listSize - 1) {
for (int i = index; i < _listSize; ++i) {
_items[index] = _items[index + 1];
}
}
--_listSize;

calculatePosition();
return true;
}

int DialogueMenu::queryInput() {
if (!_isVisible || _listSize == 0) {
return -1;
@@ -89,6 +89,7 @@ class DialogueMenu {
bool hide();
bool addToList(int answer, bool done, int priorityPolite, int priorityNormal, int prioritySurly);
bool addToListNeverRepeatOnceSelected(int answer, int priorityPolite, int priorityNormal, int prioritySurly);
bool removeFromList(int answer);
bool clearList();
int queryInput();
int listSize() const;
@@ -505,6 +505,7 @@ enum Flags {
kFlagPS02toPS03 = 132,
kFlagPS02toPS09 = 133,
kFlagPS05toPS06 = 136,
kFlagHomelessTalkedTo = 137,
kFlagKleinInsulted = 138,
kFlagRC02LucyDeskAvailable = 141,
kFlagCT07toCT06 = 144,
@@ -516,6 +517,7 @@ enum Flags {
kFlagGuzzaTalkZubenRetired = 159,
kFlagGuzzaTalkZubenEscaped = 160,
kFlagChromeDebrisTaken = 163,
kFlagHomelessShot = 169,
kFlagRC01PoliceDone = 186,
kFlagShellCasingsTaken = 190,
kFlagBoughtHowieLeeFood = 192,
@@ -542,6 +544,7 @@ enum Flags {
kFlagGenericWalkerWaiting = 443,
kFlagMaggieIsHurt = 461,
kFlagKIAPrivacyAddon = 487,
kFlagCT04HomelessTrashFinish = 492,
kFlagCT07ZubenAttack = 516,
kFlagKIAPrivacyAddonIntro = 599,
kFlagMcCoySleeping = 647,
@@ -962,6 +965,7 @@ enum GoalMcCoy {

enum GoalTransient {
kGoalTransientDefault = 0,
kGoalTransientCT04Leave = 2,
};

enum GoalZuben {
@@ -100,11 +100,11 @@ void AIScriptHowieLee::ClickedByPlayer() {

void AIScriptHowieLee::EnteredScene(int sceneId) {
if (Actor_Query_Goal_Number(kActorHowieLee) == 4 && Actor_Query_In_Set(kActorHowieLee, kSetCT03_CT04)) {
if (Game_Flag_Query(169) && !Game_Flag_Query(170) && !Game_Flag_Query(171)) {
if (Game_Flag_Query(kFlagHomelessShot) && !Game_Flag_Query(170) && !Game_Flag_Query(171)) {
Game_Flag_Set(171);
// return false;
}
if (!Game_Flag_Query(169) && Game_Flag_Query(170) && !Game_Flag_Query(171) && Random_Query(1, 10) == 1) {
if (!Game_Flag_Query(kFlagHomelessShot) && Game_Flag_Query(170) && !Game_Flag_Query(171) && Random_Query(1, 10) == 1) {
Game_Flag_Set(171);
// return true;
}
@@ -178,7 +178,7 @@ bool AIScriptMutant1::GoalChanged(int currentGoalNumber, int newGoalNumber) {
AI_Movement_Track_Append(kActorMutant1, 39, 0);
AI_Movement_Track_Repeat(kActorMutant1);

if (Game_Flag_Query(169) == 1) {
if (Game_Flag_Query(kFlagHomelessShot)) {
Actor_Set_Combat_Aggressiveness(kActorMutant1, 70);
Actor_Set_Friendliness_To_Other(kActorMutant1, kActorMcCoy, 20);
}
@@ -352,7 +352,7 @@ bool AIScriptMutant1::GoalChanged(int currentGoalNumber, int newGoalNumber) {
Actor_Set_Intelligence(kActorMutant1, 40);
Actor_Set_Health(kActorMutant1, 10 * Query_Difficulty_Level() + 30, 10 * Query_Difficulty_Level() + 30);

if (Game_Flag_Query(169) == 1) {
if (Game_Flag_Query(kFlagHomelessShot)) {
Actor_Set_Combat_Aggressiveness(kActorMutant1, 70);
Actor_Set_Friendliness_To_Other(kActorMutant1, kActorMcCoy, 20);
} else {
@@ -162,7 +162,7 @@ bool AIScriptMutant2::GoalChanged(int currentGoalNumber, int newGoalNumber) {
AI_Movement_Track_Append(kActorMutant2, 39, 0);
AI_Movement_Track_Repeat(kActorMutant2);

if (Game_Flag_Query(169) == 1) {
if (Game_Flag_Query(kFlagHomelessShot)) {
Actor_Set_Combat_Aggressiveness(kActorMutant2, 60);
Actor_Set_Friendliness_To_Other(kActorMutant2, kActorMcCoy, 30);
}
@@ -334,7 +334,7 @@ bool AIScriptMutant2::GoalChanged(int currentGoalNumber, int newGoalNumber) {
Actor_Set_Intelligence(kActorMutant2, 20);
Actor_Set_Health(71, 10 * Query_Difficulty_Level() + 50, 10 * Query_Difficulty_Level() + 50);

if (Game_Flag_Query(169) == 1) {
if (Game_Flag_Query(kFlagHomelessShot)) {
Actor_Set_Combat_Aggressiveness(kActorMutant2, 60);
Actor_Set_Friendliness_To_Other(kActorMutant2, kActorMcCoy, 30);
} else {
@@ -175,7 +175,7 @@ bool AIScriptMutant3::GoalChanged(int currentGoalNumber, int newGoalNumber) {
AI_Movement_Track_Append(kActorMutant3, 39, 0);
AI_Movement_Track_Repeat(kActorMutant3);

if (Game_Flag_Query(169) == 1) {
if (Game_Flag_Query(kFlagHomelessShot)) {
Actor_Set_Combat_Aggressiveness(kActorMutant3, 80);
Actor_Set_Friendliness_To_Other(kActorMutant3, kActorMcCoy, 20);
}
@@ -345,7 +345,7 @@ bool AIScriptMutant3::GoalChanged(int currentGoalNumber, int newGoalNumber) {
Actor_Set_Intelligence(kActorMutant3, 40);
Actor_Set_Health(kActorMutant3, 10 * Query_Difficulty_Level() + 50, 10 * Query_Difficulty_Level() + 50);

if (Game_Flag_Query(169) == 1) {
if (Game_Flag_Query(kFlagHomelessShot)) {
Actor_Set_Combat_Aggressiveness(kActorMutant3, 80);
Actor_Set_Friendliness_To_Other(kActorMutant3, kActorMcCoy, 20);
} else {
@@ -386,7 +386,7 @@ void AIScriptSteele::EnteredScene(int sceneId) {

if (Actor_Query_Goal_Number(kActorSteele) != 5
|| !Actor_Query_In_Set(kActorSteele, kSetCT03_CT04)
|| Game_Flag_Query(169) != 1
|| !Game_Flag_Query(kFlagHomelessShot)
|| Game_Flag_Query(170)
|| Game_Flag_Query(171)) {
return; //false;
@@ -47,14 +47,14 @@ bool AIScriptTransient::Update() {
if (Global_Variable_Query(kVariableChapter) == 2 && (Actor_Query_Goal_Number(kActorTransient) == kGoalTransientDefault || Actor_Query_Goal_Number(kActorTransient) == 10)) {
Actor_Set_Goal_Number(kActorTransient, 200);
}
if (Global_Variable_Query(kVariableChapter) == 3 && Game_Flag_Query(169) && Game_Flag_Query(170) && !Game_Flag_Query(171) && !Game_Flag_Query(172)) {
if (Global_Variable_Query(kVariableChapter) == 3 && Game_Flag_Query(kFlagHomelessShot) && Game_Flag_Query(170) && !Game_Flag_Query(171) && !Game_Flag_Query(172)) {
Game_Flag_Set(172);
}
if (Global_Variable_Query(kVariableChapter) < 4 && Game_Flag_Query(171) && Actor_Query_Goal_Number(kActorTransient) != 6 && Actor_Query_Goal_Number(kActorTransient) != 599) {
Actor_Set_Goal_Number(kActorTransient, 6);
}
if (Player_Query_Current_Scene() == kSceneCT04 && !Game_Flag_Query(492)) {
Game_Flag_Set(492);
if (Player_Query_Current_Scene() == kSceneCT04 && !Game_Flag_Query(kFlagCT04HomelessTrashFinish)) {
Game_Flag_Set(kFlagCT04HomelessTrashFinish);
AI_Countdown_Timer_Reset(kActorTransient, 1);
AI_Countdown_Timer_Start(kActorTransient, 1, 12);
}
@@ -142,7 +142,7 @@ bool AIScriptTransient::ShotAtAndHit() {
Actor_Set_Goal_Number(kActorTransient, 599);
}

Game_Flag_Set(169);
Game_Flag_Set(kFlagHomelessShot);

return false;
}
@@ -161,7 +161,7 @@ int AIScriptTransient::GetFriendlinessModifierIfGetsClue(int otherActorId, int c

bool AIScriptTransient::GoalChanged(int currentGoalNumber, int newGoalNumber) {
switch (newGoalNumber) {
case 2:
case kGoalTransientCT04Leave:
AI_Movement_Track_Flush(kActorTransient);
AI_Movement_Track_Append(kActorTransient, 51, 0);
AI_Movement_Track_Append(kActorTransient, 105, 0);
@@ -312,7 +312,7 @@ bool AIScriptTransient::UpdateAnimation(int *animation, int *frame) {
Actor_Set_Goal_Number(kActorTransient, 3);
_animationState = 15;
_animationFrame = Slice_Animation_Query_Number_Of_Frames(489) - 1;
Actor_Set_Targetable(kActorTransient, 0);
Actor_Set_Targetable(kActorTransient, false);
Actor_Retired_Here(kActorTransient, 120, 24, 1, -1);
}
break;
@@ -72,12 +72,12 @@ bool SceneScriptCT04::MouseClick(int x, int y) {
}

bool SceneScriptCT04::ClickedOn3DObject(const char *objectName, bool a2) {
if (objectName) {
if (!Game_Flag_Query(137) && !Game_Flag_Query(169) && !Actor_Query_Goal_Number(kActorTransient)) {
Game_Flag_Set(137);
Actor_Set_Goal_Number(kActorTransient, 2);
if (objectName) { // this can be only "DUMPSTER"
if (!Game_Flag_Query(kFlagHomelessTalkedTo) && !Game_Flag_Query(kFlagHomelessShot) && Actor_Query_Goal_Number(kActorTransient) == kGoalTransientDefault) {
Game_Flag_Set(kFlagHomelessTalkedTo);
Actor_Set_Goal_Number(kActorTransient, kGoalTransientCT04Leave);
}
if (Game_Flag_Query(169) && !Game_Flag_Query(170) && !Game_Flag_Query(171) && !Game_Flag_Query(172) && Global_Variable_Query(kVariableChapter) == 1) {
if (Game_Flag_Query(kFlagHomelessShot) && !Game_Flag_Query(170) && !Game_Flag_Query(171) && !Game_Flag_Query(172) && Global_Variable_Query(kVariableChapter) == 1) {
if (!Loop_Actor_Walk_To_XYZ(kActorMcCoy, -147.41f, -621.3f, 724.57f, 0, 1, false, 0)) {
Player_Loses_Control();
Actor_Face_Heading(kActorMcCoy, 792, false);
@@ -143,7 +143,7 @@ void SceneScriptCT04::dialogueWithHomeless() {
Actor_Says(kActorTransient, 20, 14);
Actor_Modify_Friendliness_To_Other(kActorTransient, kActorMcCoy, 5);
if (Query_Difficulty_Level() != 0) {
Global_Variable_Decrement(2, 10);
Global_Variable_Decrement(kVariableChinyen, 10);
}
} else if (answer == 420) {
Actor_Says(kActorMcCoy, 430, 3);
@@ -154,28 +154,28 @@ void SceneScriptCT04::dialogueWithHomeless() {

bool SceneScriptCT04::ClickedOnActor(int actorId) {
if (actorId == kActorTransient) {
if (Game_Flag_Query(169)) {
if (!Loop_Actor_Walk_To_Actor(kActorMcCoy, kActorTransient, 36, 1, false)) {
if (Game_Flag_Query(kFlagHomelessShot)) {
if (!Loop_Actor_Walk_To_Actor(kActorMcCoy, kActorTransient, 36, true, false)) {
Actor_Voice_Over(290, kActorVoiceOver);
Actor_Voice_Over(300, kActorVoiceOver);
Actor_Voice_Over(310, kActorVoiceOver);
}
} else {
Actor_Set_Targetable(kActorTransient, false);
if (!Loop_Actor_Walk_To_Actor(kActorMcCoy, kActorTransient, 36, 1, false)) {
if (!Loop_Actor_Walk_To_Actor(kActorMcCoy, kActorTransient, 36, true, false)) {
Actor_Face_Actor(kActorMcCoy, kActorTransient, true);
if (!Game_Flag_Query(137)) {
if (!Game_Flag_Query(kFlagHomelessTalkedTo)) {
if (Game_Flag_Query(kFlagZubenRetired)) {
Actor_Says(kActorMcCoy, 435, 3);
Actor_Set_Goal_Number(kActorTransient, 2);
Actor_Set_Goal_Number(kActorTransient, kGoalTransientCT04Leave);
} else {
Music_Stop(3);
Actor_Says(kActorMcCoy, 425, 3);
Actor_Says(kActorTransient, 0, 13);
dialogueWithHomeless();
Actor_Set_Goal_Number(kActorTransient, 2);
Actor_Set_Goal_Number(kActorTransient, kGoalTransientCT04Leave);
}
Game_Flag_Set(137);
Game_Flag_Set(kFlagHomelessTalkedTo);
} else {
Actor_Face_Actor(kActorMcCoy, kActorTransient, true);
Actor_Says(kActorMcCoy, 435, 3);
@@ -194,10 +194,10 @@ bool SceneScriptCT04::ClickedOnItem(int itemId, bool a2) {
bool SceneScriptCT04::ClickedOnExit(int exitId) {
if (exitId == 1) {
if (!Loop_Actor_Walk_To_XYZ(kActorMcCoy, -82.86f, -621.3f, 769.03f, 0, 1, false, 0)) {
Ambient_Sounds_Remove_All_Non_Looping_Sounds(1);
Ambient_Sounds_Remove_All_Non_Looping_Sounds(true);
Ambient_Sounds_Remove_All_Looping_Sounds(1);
if (!Actor_Query_Goal_Number(kActorTransient)) {
Actor_Set_Goal_Number(kActorTransient, 2);
if (Actor_Query_Goal_Number(kActorTransient) == kGoalTransientDefault) {
Actor_Set_Goal_Number(kActorTransient, kGoalTransientCT04Leave);
}
Game_Flag_Set(kFlagCT04toCT05);
Set_Enter(kSetCT05, kSceneCT05);
@@ -206,7 +206,7 @@ bool SceneScriptCT04::ClickedOnExit(int exitId) {
}
if (exitId == 0) {
if (!Loop_Actor_Walk_To_XYZ(kActorMcCoy, -187.0f, -621.3f, 437.0f, 0, 1, false, 0)) {
Ambient_Sounds_Remove_All_Non_Looping_Sounds(1);
Ambient_Sounds_Remove_All_Non_Looping_Sounds(true);
Ambient_Sounds_Remove_All_Looping_Sounds(1);
Game_Flag_Set(kFlagCT04toCT03);
Set_Enter(kSetCT03_CT04, kSceneCT03);
@@ -145,7 +145,7 @@ void SceneScriptPS04::sub_4017E4() {
DM_Add_To_List_Never_Repeat_Once_Selected(150, 7, 6, 5);
}
}
if (Game_Flag_Query(169) == 1) {
if (Game_Flag_Query(kFlagHomelessShot)) {
DM_Add_To_List_Never_Repeat_Once_Selected(140, 3, -1, -1);
}
DM_Add_To_List(130, 1, 1, 1);
@@ -46,7 +46,7 @@ void SceneScriptUG13::InitializeScene() {
Ambient_Sounds_Add_Sound(369, 2, 120, 11, 12, -100, 100, -100, 100, 0, 0);
Ambient_Sounds_Add_Sound(397, 2, 120, 11, 12, -100, 100, -100, 100, 0, 0);
Ambient_Sounds_Add_Sound(398, 2, 120, 11, 12, -100, 100, -100, 100, 0, 0);
if (Global_Variable_Query(kVariableChapter) == 4 && !Game_Flag_Query(169)) {
if (Global_Variable_Query(kVariableChapter) == 4 && !Game_Flag_Query(kFlagHomelessShot)) {
Actor_Set_Goal_Number(kActorTransient, 390);
}
if (Actor_Query_Goal_Number(kActorTransient) == 599) {
@@ -72,7 +72,7 @@ void SceneScriptUG13::SceneLoaded() {
Clickable_Object("BASKET");
Clickable_Object("BOLLARD");
Unclickable_Object("BASKET");
if (Global_Variable_Query(kVariableChapter) >= 3 && !Actor_Clue_Query(kActorMcCoy, kClueOriginalRequisitionForm) && Game_Flag_Query(169) && (Actor_Clue_Query(kActorMcCoy, kClueShippingForm) || Actor_Clue_Query(kActorMcCoy, kClueWeaponsOrderForm))) {
if (Global_Variable_Query(kVariableChapter) >= 3 && !Actor_Clue_Query(kActorMcCoy, kClueOriginalRequisitionForm) && Game_Flag_Query(kFlagHomelessShot) && (Actor_Clue_Query(kActorMcCoy, kClueShippingForm) || Actor_Clue_Query(kActorMcCoy, kClueWeaponsOrderForm))) {
Item_Add_To_World(111, 958, 85, -209.01f, 70.76f, -351.79f, 0, 16, 12, false, true, false, true);
}
}
@@ -234,7 +234,7 @@ void SceneScriptUG13::PlayerWalkedIn() {
Game_Flag_Reset(429);
Player_Gains_Control();
}
if (Actor_Query_Goal_Number(kActorTransient) >= 390 && !Game_Flag_Query(169)) {
if (Actor_Query_Goal_Number(kActorTransient) >= 390 && !Game_Flag_Query(kFlagHomelessShot)) {
if (Game_Flag_Query(553)) {
if (Random_Query(1, 3) == 1) {
Actor_Set_Goal_Number(kActorTransient, 395);
Oops, something went wrong.

0 comments on commit 0c7077c

Please sign in to comment.