aboutsummaryrefslogtreecommitdiff
path: root/engines/bladerunner/script/scene/ma02.cpp
blob: 5b3d9b0fe44d26e65faa489cb1e8d9901c910e72 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 */

#include "bladerunner/script/scene_script.h"

namespace BladeRunner {

enum kMA02Exits {
	kMA02ExitMA06 = 0,
	kMA02ExitMA04 = 1
};

void SceneScriptMA02::InitializeScene() {
	if (Game_Flag_Query(kFlagMA04ToMA02)) {
		Setup_Scene_Information(-172.0f, -144.13f,   6.27f, 500);
	} else { // From MA06
		Setup_Scene_Information( 23.19f, -144.12f, 378.27f, 750);
		if (Global_Variable_Query(kVariableChapter) == 4) {
			Actor_Set_Goal_Number(kActorRajif, 300);
		}
		Game_Flag_Reset(kFlagMA04WatchedTV);
	}
	Scene_Exit_Add_2D_Exit(kMA02ExitMA06, 538, 84, 639, 327, 1);
	Scene_Exit_Add_2D_Exit(kMA02ExitMA04,  56, 98, 150, 260, 0);

	if (Global_Variable_Query(kVariableChapter) >= 4
	 && Global_Variable_Query(kVariableChapter) == 5
	 && Game_Flag_Query(kFlagMcCoyIsHelpingReplicants)
	) {
		Actor_Set_Goal_Number(kActorMaggie, kGoalMaggieDead);
		Actor_Change_Animation_Mode(kActorMaggie, 88);
		Actor_Put_In_Set(kActorMaggie, kSetMA02_MA04);
		Actor_Set_At_XYZ(kActorMaggie, -35.51f, -144.12f, 428.0f, 0);
		Actor_Retired_Here(kActorMaggie, 24, 24, 1, -1);
	}

	Ambient_Sounds_Add_Looping_Sound(104, 12, 0, 1);
	Ambient_Sounds_Add_Looping_Sound(71, 25, 0, 1);
	Ambient_Sounds_Add_Sound( 72,  5,  30,  5,  5, -100, 100, -101, -101, 0, 0);
	Ambient_Sounds_Add_Sound( 73,  5,  30,  5,  5, -100, 100, -101, -101, 0, 0);
	Ambient_Sounds_Add_Sound( 74,  5,  30,  5,  5, -100, 100, -101, -101, 0, 0);
	Ambient_Sounds_Add_Sound(375, 10,  60, 20, 20,    0,   0, -101, -101, 0, 0);
	Ambient_Sounds_Add_Sound(376, 10,  60, 20, 20,    0,   0, -101, -101, 0, 0);
	Ambient_Sounds_Add_Sound( 87, 10,  60, 12, 12, -100, 100, -101, -101, 0, 0);
	Ambient_Sounds_Add_Sound( 68, 60, 180, 14, 14,    0,   0, -101, -101, 0, 0);
	Ambient_Sounds_Add_Sound( 69, 60, 180, 14, 14,    0,   0, -101, -101, 0, 0);
	if (isPhoneRinging()) {
		Ambient_Sounds_Add_Sound(403, 3, 3, 27, 27, -100, -100, -100, -100, 99, 0);
	}

	if ( Global_Variable_Query(kVariableChapter) == 5
	 &&  Game_Flag_Query(kFlagMcCoyIsHelpingReplicants)
	 && !Actor_Clue_Query(kActorMcCoy, kClueCrystalsCigarette)
	) {
		Overlay_Play("MA02OVER", 0, 1, 0, 0);
	}
}

void SceneScriptMA02::SceneLoaded() {
	Obstacle_Object("COUCH1", true);
	Unobstacle_Object("COUCH1", true);
	Clickable_Object("BAR-MAIN");
	Clickable_Object("E-ESPER");
}

bool SceneScriptMA02::MouseClick(int x, int y) {
	return false;
}

bool SceneScriptMA02::ClickedOn3DObject(const char *objectName, bool a2) {
	if (Object_Query_Click("E-ESPER", objectName)) {
		Actor_Face_Object(kActorMcCoy, "E-ESPER", true);
		Delay(1000);
		ESPER_Flag_To_Activate();
		return true;
	}

	if (Object_Query_Click("BAR-MAIN", objectName)) {
		if (!Loop_Actor_Walk_To_XYZ(kActorMcCoy, -29.0f, -140.4f, 298.0f, 36, true, false, 0)) {
			Actor_Face_Object(kActorMcCoy, "BAR-MAIN", true);
			if (Global_Variable_Query(kVariableChapter) < 4) {
				Actor_Set_Goal_Number(kActorMaggie, kGoalMaggieMA02GetFed);
			} else if ( Global_Variable_Query(kVariableChapter) == 5
			        &&  Game_Flag_Query(kFlagMcCoyIsHelpingReplicants)
			        && !Actor_Clue_Query(kActorMcCoy, kClueCrystalsCigarette)
			) {
				Overlay_Remove("MA02OVER");
				Item_Pickup_Spin_Effect(985, 480, 240);
				Actor_Voice_Over(1150, kActorVoiceOver);
				Actor_Voice_Over(1160, kActorVoiceOver);
				Actor_Voice_Over(1170, kActorVoiceOver);
				Actor_Voice_Over(1180, kActorVoiceOver);
				Actor_Voice_Over(1190, kActorVoiceOver);
				Actor_Voice_Over(1200, kActorVoiceOver);
				Actor_Clue_Acquire(kActorMcCoy, kClueCrystalsCigarette, true, -1);
			} else {
				Actor_Says(kActorMcCoy, 8526, 0);
			}
			return true;
		}
	}
	return false;
}

bool SceneScriptMA02::ClickedOnActor(int actorId) {
	if (actorId == kActorMaggie
	 && Actor_Query_Goal_Number(kActorMaggie) == kGoalMaggieDead
	) {
		if (!Loop_Actor_Walk_To_Actor(kActorMcCoy, kActorMaggie, 30, true, false)) {
			Actor_Face_Actor(kActorMcCoy, kActorMaggie, true);
			Actor_Voice_Over(1140, kActorVoiceOver);
		}
	}
	return false;
}

bool SceneScriptMA02::ClickedOnItem(int itemId, bool a2) {
	return false;
}

bool SceneScriptMA02::ClickedOnExit(int exitId) {
	if (exitId == kMA02ExitMA06) {
		if (!Loop_Actor_Walk_To_XYZ(kActorMcCoy, 23.19f, -144.12f, 378.27f, 0, true, false, 0)) {
			Music_Stop(10);
			Game_Flag_Set(kFlagMA02toMA06);
			Set_Enter(kSetMA06, kSceneMA06);
		}
		return true;
	}

	if (exitId == kMA02ExitMA04) {
		if (!Loop_Actor_Walk_To_XYZ(kActorMcCoy, -168.0f, -144.13f, 10.27f, 0, true, false, 0)) {
			Game_Flag_Set(kFlagMA02ToMA04);
			Set_Enter(kSetMA04, kSceneMA04);
		}
		return true;
	}
	return false;
}

bool SceneScriptMA02::ClickedOn2DRegion(int region) {
	return false;
}

void SceneScriptMA02::SceneFrameAdvanced(int frame) {
}

void SceneScriptMA02::ActorChangedGoal(int actorId, int newGoal, int oldGoal, bool currentSet) {
}

void SceneScriptMA02::PlayerWalkedIn() {
	if (Game_Flag_Query(kFlagMA06ToMA02)) {
		selectNextTvNews();
	}

	if (Game_Flag_Query(kFlagMA04ToMA02)) {
		Loop_Actor_Walk_To_XYZ(kActorMcCoy, -148.12f, -144.13f, 34.27f, 0, true, false, 0);
	}

	if ( Global_Variable_Query(kVariableChapter) == 4
	 && !Game_Flag_Query(kFlagMA02RajifTalk)
	) {
		Game_Flag_Set(kFlagUG07Empty);
		Game_Flag_Set(kFlagMA02RajifTalk);
		talkWithRajif();
		Loop_Actor_Walk_To_XYZ(kActorMcCoy, 23.19f, -144.12f, 378.27f, 0, false, false, 0);
		Game_Flag_Set(kFlagMA02toMA06);
		Set_Enter(kSetMA06, kSceneMA06);
		//	return true;
		return;
	}

	if ( Global_Variable_Query(kVariableChapter) == 5
	 && !Game_Flag_Query(kFlagMA02Chapter5Started)
	) {
		if (Game_Flag_Query(kFlagMcCoyIsHelpingReplicants)) {
			Actor_Says(kActorMcCoy, 2390, kAnimationModeIdle);
			Music_Play(2, 25, 0, 3, -1, 0, 0);
		} else {
			Actor_Says(kActorMcCoy, 2385,  kAnimationModeTalk);
		}
		Game_Flag_Set(kFlagMA02Chapter5Started);
		Autosave_Game(3);
	}

	if ( Global_Variable_Query(kVariableChapter) < 4
	 && !Game_Flag_Query(kFlagMA04ToMA02)
	 &&  Actor_Query_Goal_Number(kActorMaggie) != 2
	) {
		Actor_Set_Goal_Number(kActorMaggie, kGoalMaggieMA02WalkToEntrance);

		if (!Game_Flag_Query(kFlagMA02MaggieIntroduced)) {
			Game_Flag_Set(kFlagMA02MaggieIntroduced);
			Actor_Face_Actor(kActorMcCoy, kActorMaggie, true);
			Actor_Voice_Over(1210, kActorVoiceOver);
			if (!Game_Flag_Query(kFlagDirectorsCut)) {
				Actor_Voice_Over(1220, kActorVoiceOver);
			}
			Actor_Voice_Over(1230, kActorVoiceOver);
			if (!Game_Flag_Query(kFlagDirectorsCut)) {
				Actor_Voice_Over(1240, kActorVoiceOver);
				Actor_Voice_Over(1250, kActorVoiceOver);
			}
		}
	}

	Game_Flag_Reset(kFlagMA04ToMA02);
	Game_Flag_Reset(kFlagMA06ToMA02);
	//return false;
	return;
}

void SceneScriptMA02::PlayerWalkedOut() {
	Ambient_Sounds_Remove_All_Non_Looping_Sounds(true);
	Ambient_Sounds_Remove_All_Looping_Sounds(1);
}

void SceneScriptMA02::DialogueQueueFlushed(int a1) {
}

void SceneScriptMA02::talkWithRajif() {
	Actor_Says(kActorMcCoy, 2365, 13);
	Actor_Says(kActorRajif, 0, 13);
	Actor_Says(kActorMcCoy, 2370, 13);
	Actor_Says(kActorRajif, 10, 13);
	Actor_Says(kActorMcCoy, 2375, 13);
	Actor_Says(kActorRajif, 20, 13);
	Actor_Says(kActorMcCoy, 2380, 13);
	Sound_Play(492, 100, 0, 100, 50);
	Actor_Says(kActorRajif, 40, 13);
	Delay(3000);
}

bool SceneScriptMA02::isPhoneRinging() {
	return  Global_Variable_Query(kVariableChapter) == 5
		&& !Actor_Clue_Query(kActorMcCoy, kCluePhoneCallClovis)
		&& !Actor_Clue_Query(kActorMcCoy, kCluePhoneCallCrystal)
		&& !Actor_Clue_Query(kActorMcCoy, kCluePhoneCallDektora1)
		&& !Actor_Clue_Query(kActorMcCoy, kCluePhoneCallDektora2)
		&& !Actor_Clue_Query(kActorMcCoy, kCluePhoneCallLucy1)
		&& !Actor_Clue_Query(kActorMcCoy, kCluePhoneCallLucy2);
}

void SceneScriptMA02::selectNextTvNews() {
	int i = 0;
	int arr[7];
	if (Global_Variable_Query(kVariableChapter) < 4 && Game_Flag_Query(kFlagGordoIsReplicant)) {
		arr[i++] = 0;
	}
	arr[i++] = 1;
	if (Global_Variable_Query(kVariableChapter) >= 3) {
		arr[i++] = 2;
	}
	if (Global_Variable_Query(kVariableChapter) >= 2
	 && Global_Variable_Query(kVariableChapter) <= 4
	) {
		arr[i++] = 3;
	}
	if (Game_Flag_Query(kFlagCT04HomelessBodyFound)
	 && Game_Flag_Query(kFlagCT04HomelessBodyInDumpster)
	) {
		arr[i++] = 4;
	}
	Global_Variable_Set(kVariableNextTvNews, arr[Random_Query(0, i - 1)]);
}

} // End of namespace BladeRunner