1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #include "bladerunner/script/scene_script.h"
24 
25 namespace BladeRunner {
26 
27 enum kDR01Loops {
28 	kDR01LoopBikerInshot          = 0,
29 	kDR01LoopPanFromDR02          = 1,
30 	kDR01LoopPanFromDR04Pre       = 2,
31 	kDR01LoopPanFromDR04Post      = 3,
32 	kDR01LoopMainLoop             = 4
33 };
34 
InitializeScene()35 void SceneScriptDR01::InitializeScene() {
36 	if (Game_Flag_Query(kFlagDR02toDR01)) {
37 		Setup_Scene_Information(  -835.0f, -0.04f, -118.0f, 664);
38 	} else if (Game_Flag_Query(kFlagDR04toDR01)) {
39 		Setup_Scene_Information(  -711.0f, -0.04f,   70.0f, 307);
40 	} else if (Game_Flag_Query(kFlagCT11toDR01)) {
41 		Setup_Scene_Information(-1765.28f, -0.04f, -23.82f, 269);
42 	} else {
43 		Setup_Scene_Information(  -386.0f, -0.04f,  -82.0f, 792);
44 	}
45 
46 	Scene_Exit_Add_2D_Exit(0, 240, 60, 450, 250, 0);
47 	Scene_Exit_Add_2D_Exit(1,   0,   0, 30, 479, 3);
48 	if (Game_Flag_Query(kFlagSpinnerAtDR01)
49 	 && Global_Variable_Query(kVariableChapter) < 4
50 	) {
51 		Scene_Exit_Add_2D_Exit(2, 610, 0, 639, 479, 1);
52 	}
53 	if (Global_Variable_Query(kVariableChapter) >= 3) {
54 		Scene_Exit_Add_2D_Exit(3, 0, 45, 142, 201, 0);
55 	}
56 
57 	Ambient_Sounds_Remove_All_Non_Looping_Sounds(false);
58 	Ambient_Sounds_Add_Looping_Sound(kSfxCTRAIN1, 50,  0, 1);
59 	Ambient_Sounds_Add_Looping_Sound(kSfxHUMMER3, 12, 85, 1);
60 	Ambient_Sounds_Add_Looping_Sound(kSfxBIGFAN2, 14, 85, 1);
61 	Ambient_Sounds_Add_Speech_Sound(kActorBlimpGuy,  0, 10, 260, 17, 24, -100, 100, -101, -101, 1, 1);
62 	Ambient_Sounds_Add_Speech_Sound(kActorBlimpGuy, 20, 10, 260, 17, 24, -100, 100, -101, -101, 1, 1);
63 	Ambient_Sounds_Add_Speech_Sound(kActorBlimpGuy, 40, 10, 260, 17, 24, -100, 100, -101, -101, 1, 1);
64 	Ambient_Sounds_Add_Speech_Sound(kActorBlimpGuy, 50, 10, 260, 17, 24, -100, 100, -101, -101, 1, 1);
65 	Ambient_Sounds_Add_Sound(kSfxSPIN2A, 5, 80, 16,  25, -100, 100, -101, -101, 0, 0);
66 	Ambient_Sounds_Add_Sound(kSfxSPIN1A, 5, 80, 16,  25, -100, 100, -101, -101, 0, 0);
67 	Ambient_Sounds_Add_Sound(kSfxTHNDR1, 5, 80, 50, 100, -100, 100, -101, -101, 0, 0);
68 	Ambient_Sounds_Add_Sound(kSfxTHNDR2, 5, 80, 50, 100, -100, 100, -101, -101, 0, 0);
69 	Ambient_Sounds_Add_Sound(kSfxTHNDR3, 5, 80, 50, 100, -100, 100, -101, -101, 0, 0);
70 
71 	if (Game_Flag_Query(kFlagDR05BombExploded)
72 	 && Game_Flag_Query(kFlagDR04toDR01)
73 	) {
74 		Scene_Loop_Start_Special(kSceneLoopModeLoseControl, kDR01LoopPanFromDR04Post, false);
75 		Scene_Loop_Set_Default(kDR01LoopMainLoop);
76 	} else if (!Game_Flag_Query(kFlagDR05BombExploded)
77 	        &&  Game_Flag_Query(kFlagDR04toDR01)
78 	) {
79 		Scene_Loop_Start_Special(kSceneLoopModeLoseControl, kDR01LoopPanFromDR04Pre, false);
80 		Scene_Loop_Set_Default(kDR01LoopMainLoop);
81 	} else if (Game_Flag_Query(kFlagDR02toDR01)) {
82 		Scene_Loop_Start_Special(kSceneLoopModeLoseControl, kDR01LoopPanFromDR02, false);
83 		Scene_Loop_Set_Default(kDR01LoopMainLoop);
84 	} else if (Game_Flag_Query(kFlagCT11toDR01)) {
85 		Scene_Loop_Set_Default(kDR01LoopMainLoop);
86 	} else {
87 		if ((!Game_Flag_Query(kFlagDR01Visited) && Global_Variable_Query(kVariableChapter) == 2)
88 		     || Random_Query(1, 3) == 1)
89 		{
90 			// enhancement: don't always play after first visit
91 			// But first visit in 2nd chapter should always show it.
92 			Scene_Loop_Start_Special(kSceneLoopModeLoseControl, kDR01LoopBikerInshot, false);
93 		}
94 		Scene_Loop_Set_Default(kDR01LoopMainLoop);
95 	}
96 }
97 
SceneLoaded()98 void SceneScriptDR01::SceneLoaded() {
99 	Obstacle_Object("TRASH CAN WITH FIRE", true);
100 	Obstacle_Object("V2PYLON02", true);
101 	Obstacle_Object("V2PYLON04", true);
102 	Obstacle_Object("U2 CHEWDOOR", true);
103 	Obstacle_Object("MMTRASHCAN", true);
104 	Obstacle_Object("PARKMETR02", true);
105 	Obstacle_Object("TRANSFORMER 01", true);
106 	Obstacle_Object("TRANSFORMER 02", true);
107 	Obstacle_Object("PARKMETR01", true);
108 	Obstacle_Object("Z2TRSHCAN", true);
109 	Obstacle_Object("Z2ENTRYDR", true);
110 	Obstacle_Object("Z2DR2", true);
111 	Unobstacle_Object("V2 BUILD01", true);
112 }
113 
MouseClick(int x,int y)114 bool SceneScriptDR01::MouseClick(int x, int y) {
115 	return false;
116 }
117 
ClickedOn3DObject(const char * objectName,bool a2)118 bool SceneScriptDR01::ClickedOn3DObject(const char *objectName, bool a2) {
119 	return false;
120 }
121 
ClickedOnActor(int actorId)122 bool SceneScriptDR01::ClickedOnActor(int actorId) {
123 	return actorId == kActorShoeshineMan;
124 }
125 
ClickedOnItem(int itemId,bool a2)126 bool SceneScriptDR01::ClickedOnItem(int itemId, bool a2) {
127 	return false;
128 }
129 
ClickedOnExit(int exitId)130 bool SceneScriptDR01::ClickedOnExit(int exitId) {
131 	if (exitId == 0) {
132 		if (_vm->_cutContent) {
133 			float x, y, z;
134 			Actor_Query_XYZ(kActorMcCoy, &x, &y, &z);
135 			bool exitFlag = true;
136 			bool fromFarTop = false;
137 			if (x < -1088) {
138 				fromFarTop = true;
139 				exitFlag = Loop_Actor_Walk_To_XYZ(kActorMcCoy, -1149.80f, 0.56f, -94.45f, 0, true, false, false);
140 			} else if (-1088 < x && x < -642) {
141 				exitFlag = Loop_Actor_Walk_To_XYZ(kActorMcCoy, -1271.89f, 6.71f, -268.63f, 0, true, false, false);
142 			} else {
143 				exitFlag = Loop_Actor_Walk_To_XYZ(kActorMcCoy, -835.0f, -0.04f, -118.0f, 0, true, false, false);
144 			}
145 			if (!exitFlag) {
146 				if (fromFarTop) {
147 					Async_Actor_Walk_To_XYZ(kActorMcCoy,  -1066.51f, 0.51f, -110.60f, 0, false);
148 				} else {
149 					Async_Actor_Walk_To_XYZ(kActorMcCoy, -911.0f, -0.04f, -118.0f, 0, false);
150 				}
151 				Ambient_Sounds_Adjust_Looping_Sound(kSfxFACTAMB2, 10, -100, 1);
152 				Game_Flag_Set(kFlagDR01toDR02);
153 				Set_Enter(kSetDR01_DR02_DR04, kSceneDR02);
154 			}
155 		} else {
156 			if (!Loop_Actor_Walk_To_XYZ(kActorMcCoy, -835.0f, -0.04f, -118.0f, 0, true, false, false)) {
157 				Async_Actor_Walk_To_XYZ(kActorMcCoy, -911.0f, -0.04f, -118.0f, 0, false);
158 				Ambient_Sounds_Adjust_Looping_Sound(kSfxFACTAMB2, 10, -100, 1);
159 				Game_Flag_Set(kFlagDR01toDR02);
160 				Set_Enter(kSetDR01_DR02_DR04, kSceneDR02);
161 			}
162 		}
163 		return true;
164 	}
165 
166 	if (exitId == 1) {
167 		if (!Loop_Actor_Walk_To_XYZ(kActorMcCoy, -711.0f, -0.04f, 70.0f, 0, true, false, false)) {
168 			Async_Actor_Walk_To_XYZ(kActorMcCoy, -796.0f, -0.04f, 166.0f, 0, false);
169 			Game_Flag_Set(kFlagDR01toDR04);
170 			Set_Enter(kSetDR01_DR02_DR04, kSceneDR04);
171 		}
172 		return true;
173 	}
174 
175 	if (exitId == 2) {
176 		if (!Loop_Actor_Walk_To_XYZ(kActorMcCoy, -372.0f, -0.04f, -82.0f, 0, true, false, false)) {
177 			Game_Flag_Reset(kFlagMcCoyInChinaTown);
178 			Game_Flag_Reset(kFlagMcCoyInRunciters);
179 			Game_Flag_Reset(kFlagMcCoyInMcCoyApartment);
180 			Game_Flag_Reset(kFlagMcCoyInPoliceStation);
181 			Game_Flag_Reset(kFlagMcCoyInAnimoidRow);
182 			Game_Flag_Reset(kFlagMcCoyInTyrellBuilding);
183 			Game_Flag_Reset(kFlagMcCoyInDNARow);
184 			Game_Flag_Reset(kFlagMcCoyInBradburyBuilding);
185 			int spinnerDest = Spinner_Interface_Choose_Dest(-1, false);
186 			switch (spinnerDest) {
187 			case kSpinnerDestinationPoliceStation:
188 				Game_Flag_Set(kFlagMcCoyInPoliceStation);
189 				Game_Flag_Reset(kFlagSpinnerAtDR01);
190 				Game_Flag_Set(kFlagSpinnerAtPS01);
191 				Set_Enter(kSetPS01, kScenePS01);
192 				break;
193 			case kSpinnerDestinationMcCoysApartment:
194 				Game_Flag_Set(kFlagMcCoyInMcCoyApartment);
195 				Game_Flag_Reset(kFlagSpinnerAtDR01);
196 				Game_Flag_Set(kFlagSpinnerAtMA01);
197 				Set_Enter(kSetMA01, kSceneMA01);
198 				break;
199 			case kSpinnerDestinationRuncitersAnimals:
200 				Game_Flag_Set(kFlagMcCoyInRunciters);
201 				Game_Flag_Reset(kFlagSpinnerAtDR01);
202 				Game_Flag_Set(kFlagSpinnerAtRC01);
203 				Set_Enter(kSetRC01, kSceneRC01);
204 				break;
205 			case kSpinnerDestinationChinatown:
206 				Game_Flag_Set(kFlagMcCoyInChinaTown);
207 				Game_Flag_Reset(kFlagSpinnerAtDR01);
208 				Game_Flag_Set(kFlagSpinnerAtCT01);
209 				Set_Enter(kSetCT01_CT12, kSceneCT01);
210 				break;
211 			case kSpinnerDestinationAnimoidRow:
212 				Game_Flag_Set(kFlagMcCoyInAnimoidRow);
213 				Game_Flag_Reset(kFlagSpinnerAtDR01);
214 				Game_Flag_Set(kFlagSpinnerAtAR01);
215 				Set_Enter(kSetAR01_AR02, kSceneAR01);
216 				break;
217 			case kSpinnerDestinationTyrellBuilding:
218 				Game_Flag_Set(kFlagMcCoyInTyrellBuilding);
219 				Game_Flag_Reset(kFlagSpinnerAtDR01);
220 				Game_Flag_Set(kFlagSpinnerAtTB02);
221 				Set_Enter(kSetTB02_TB03, kSceneTB02);
222 				break;
223 			case kSpinnerDestinationBradburyBuilding:
224 				Game_Flag_Set(kFlagMcCoyInBradburyBuilding);
225 				Game_Flag_Reset(kFlagSpinnerAtDR01);
226 				Game_Flag_Set(kFlagSpinnerAtBB01);
227 				Set_Enter(kSetBB01, kSceneBB01);
228 				break;
229 			case kSpinnerDestinationNightclubRow:
230 				Game_Flag_Set(kFlagMcCoyInNightclubRow);
231 				Game_Flag_Reset(kFlagSpinnerAtDR01);
232 				Game_Flag_Set(kFlagSpinnerAtNR01);
233 				Set_Enter(kSetNR01, kSceneNR01);
234 				break;
235 			case kSpinnerDestinationHysteriaHall:
236 				Game_Flag_Set(kFlagMcCoyInHysteriaHall);
237 				Game_Flag_Reset(kFlagSpinnerAtDR01);
238 				Game_Flag_Set(kFlagSpinnerAtHF01);
239 				Set_Enter(kSetHF01, kSceneHF01);
240 				break;
241 			default:
242 				Player_Loses_Control();
243 				Game_Flag_Set(kFlagMcCoyInDNARow);
244 				Loop_Actor_Walk_To_XYZ(kActorMcCoy, -447.39f, 0.16f, -92.38f, 0, false, true, false);
245 				Player_Gains_Control();
246 				break;
247 			}
248 		}
249 		return true;
250 	}
251 
252 	if (exitId == 3) {
253 		float x, y, z;
254 		Actor_Query_XYZ(kActorMcCoy, &x, &y, &z);
255 		bool v7 = false;
256 		if (-1200 < x) {
257 			v7 = Loop_Actor_Walk_To_XYZ(kActorMcCoy, -1236.4f, -0.04f, -13.91f, 0, true, false, false);
258 		}
259 		if (!v7) {
260 			Game_Flag_Set(kFlagDR01toCT11);
261 			Game_Flag_Set(kFlagMcCoyInChinaTown);
262 			Game_Flag_Reset(kFlagMcCoyInDNARow);
263 			Set_Enter(kSetCT11, kSceneCT11);
264 		}
265 		return true;
266 	}
267 	return false;
268 }
269 
ClickedOn2DRegion(int region)270 bool SceneScriptDR01::ClickedOn2DRegion(int region) {
271 	return false;
272 }
273 
SceneFrameAdvanced(int frame)274 void SceneScriptDR01::SceneFrameAdvanced(int frame) {
275 	if (frame < 75) {
276 		Actor_Set_Invisible(kActorMcCoy, true);
277 	} else {
278 		Actor_Set_Invisible(kActorMcCoy, false);
279 	}
280 	if (frame == 2) {
281 		Ambient_Sounds_Play_Sound(kSfxBIKEMIX4, 40, -40, 100, 99);
282 	}
283 }
284 
ActorChangedGoal(int actorId,int newGoal,int oldGoal,bool currentSet)285 void SceneScriptDR01::ActorChangedGoal(int actorId, int newGoal, int oldGoal, bool currentSet) {
286 }
287 
PlayerWalkedIn()288 void SceneScriptDR01::PlayerWalkedIn() {
289 	if (Game_Flag_Query(kFlagCT11toDR01)) {
290 		Async_Actor_Walk_To_XYZ(kActorMcCoy, -757.15f, -0.04f, 24.64f, 0, false);
291 	} else if (!Game_Flag_Query(kFlagDR02toDR01)
292 	        && !Game_Flag_Query(kFlagDR04toDR01)
293 	) {
294 		Player_Loses_Control();
295 		Loop_Actor_Walk_To_XYZ(kActorMcCoy, -447.39f, 0.16f, -92.38f, 0, false, false, false);
296 		if (!Game_Flag_Query(kFlagDR01Visited)) {
297 			Game_Flag_Set(kFlagDR01Visited);
298 			// Make use of the kFlagDirectorsCut like in CT01 case
299 			// extra flags and chapter check are for compatibility / sane behavior
300 			// in imported original save games (or "exported" save games for the original)
301 			if (_vm->_cutContent) {
302 				if (
303 					Global_Variable_Query(kVariableChapter) == 2
304 					&& !Game_Flag_Query(kFlagDR03ChewTalk1)
305 					&& !Game_Flag_Query(kFlagDR05MorajiTalk)
306 					&& !Game_Flag_Query(kFlagDirectorsCut)) {
307 					Actor_Voice_Over(600, kActorVoiceOver);
308 					Actor_Voice_Over(610, kActorVoiceOver);
309 					Actor_Voice_Over(620, kActorVoiceOver);
310 					Actor_Voice_Over(630, kActorVoiceOver);
311 					Actor_Voice_Over(640, kActorVoiceOver);
312 					Actor_Voice_Over(650, kActorVoiceOver);
313 				}
314 			}
315 		}
316 		Player_Gains_Control();
317 	}
318 	Game_Flag_Reset(kFlagDR02toDR01);
319 	Game_Flag_Reset(kFlagDR04toDR01);
320 	Game_Flag_Reset(kFlagCT11toDR01);
321 }
322 
PlayerWalkedOut()323 void SceneScriptDR01::PlayerWalkedOut() {
324 	if (!Game_Flag_Query(kFlagDR01toDR04)
325 	 && !Game_Flag_Query(kFlagDR01toDR02)
326 	 && !Game_Flag_Query(kFlagDR01toCT11)
327 	) {
328 		Ambient_Sounds_Remove_All_Non_Looping_Sounds(true);
329 		Ambient_Sounds_Remove_All_Looping_Sounds(1);
330 		Outtake_Play(kOuttakeInside2, true, -1);
331 #if BLADERUNNER_ORIGINAL_BUGS
332 #else
333 		// add another transition to make it less abrupt
334 		if (!Game_Flag_Query(kFlagMcCoyInTyrellBuilding)) {
335 			// but don't play this extra outtake when going to Tyrell Building
336 			Outtake_Play(kOuttakeAway1,   true, -1);
337 		}
338 #endif // BLADERUNNER_ORIGINAL_BUGS
339 	}
340 }
341 
DialogueQueueFlushed(int a1)342 void SceneScriptDR01::DialogueQueueFlushed(int a1) {
343 }
344 
345 } // End of namespace BladeRunner
346