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 kBB01Loops {
28 	kBB01LoopInshot            = 0, //   0 - 300
29 	kBB01LoopMainLoop          = 1, // 301 - 361
30 	kBB01LoopDoorAnim          = 3, // 362 - 421
31 	kBB01LoopOutshot           = 4, // 422 - 480
32 	kBB01LoopMainLoopNoSpinner = 5  // 481 - 540
33 };
34 
InitializeScene()35 void SceneScriptBB01::InitializeScene() {
36 	if (Game_Flag_Query(kFlagDR02toBB01)) {
37 		Setup_Scene_Information(-253.0f, 9.0f,  715.0f, 266);
38 	} else if (Game_Flag_Query(kFlagBB02toBB01)) {
39 		Setup_Scene_Information(-128.0f, 9.0f,  342.0f, 266);
40 	} else {
41 		Setup_Scene_Information(  43.0f, 0.0f, 1058.0f,   0);
42 	}
43 
44 #if BLADERUNNER_ORIGINAL_BUGS
45 	Scene_Exit_Add_2D_Exit(0,   0,   0,  72, 299, 3);
46 	Scene_Exit_Add_2D_Exit(1, 151, 218, 322, 290, 3);
47 	if (Game_Flag_Query(kFlagSpinnerAtBB01)) {
48 		Scene_Exit_Add_2D_Exit(2, 0, 311, 312, 479, 2);
49 	}
50 #else
51 	// expand the left exit downwards as much as possible, especially if Spinner is missing
52 	Scene_Exit_Add_2D_Exit(1, 151, 218, 322, 290, 3);
53 	if (Game_Flag_Query(kFlagSpinnerAtBB01)) {
54 		Scene_Exit_Add_2D_Exit(0, 0,   0,  72, 311, 3);
55 		Scene_Exit_Add_2D_Exit(2, 0, 311, 312, 479, 2);
56 	} else {
57 		Scene_Exit_Add_2D_Exit(0, 0,   0,  72, 400, 3);
58 	}
59 #endif // BLADERUNNER_ORIGINAL_BUGS
60 
61 	Ambient_Sounds_Add_Looping_Sound(kSfxCTRAIN1,  50,    0, 1);
62 	Ambient_Sounds_Add_Looping_Sound(kSfxCTRUNOFF, 25, -100, 0);
63 	Ambient_Sounds_Add_Sound(kSfxRCCARBY1, 5,  60, 40, 60, -100, 100, -101, -101, 0, 0);
64 	Ambient_Sounds_Add_Sound(kSfxRCCARBY2, 5,  60, 40, 65, -100, 100, -101, -101, 0, 0);
65 	Ambient_Sounds_Add_Sound(kSfxRCCARBY3, 5,  60, 40, 60, -100, 100, -101, -101, 0, 0);
66 	Ambient_Sounds_Add_Sound(kSfxSPIN2A,   5,  80, 20, 25, -100, 100, -101, -101, 0, 0);
67 	Ambient_Sounds_Add_Sound(kSfxSPIN1A,   5,  80, 20, 25, -100, 100, -101, -101, 0, 0);
68 	Ambient_Sounds_Add_Sound(kSfxTHNDR1,   5, 120, 25, 33, -100, 100, -101, -101, 0, 0);
69 	Ambient_Sounds_Add_Sound(kSfxTHNDR2,   5, 120, 25, 33, -100, 100, -101, -101, 0, 0);
70 	Ambient_Sounds_Add_Sound(kSfxTHNDR3,   5, 120, 25, 33, -100, 100, -101, -101, 0, 0);
71 	Ambient_Sounds_Add_Speech_Sound(kActorBlimpGuy,  0, 10, 260, 17, 24, -100, 100, -101, -101, 1, 1);
72 	Ambient_Sounds_Add_Speech_Sound(kActorBlimpGuy, 20, 10, 260, 17, 24, -100, 100, -101, -101, 1, 1);
73 	Ambient_Sounds_Add_Speech_Sound(kActorBlimpGuy, 40, 10, 260, 17, 24, -100, 100, -101, -101, 1, 1);
74 	Ambient_Sounds_Add_Speech_Sound(kActorBlimpGuy, 50, 10, 260, 17, 24, -100, 100, -101, -101, 1, 1);
75 
76 	if ( Game_Flag_Query(kFlagSpinnerAtBB01)
77 	 && !Game_Flag_Query(kFlagDR02toBB01)
78 	 && !Game_Flag_Query(kFlagBB02toBB01)
79 	) {
80 		if (!Game_Flag_Query(kFlagBB01VisitedFirstTimeWithSpinner)
81 		    || Random_Query(1, 3) == 1
82 		) {
83 			// enhancement: don't always play after first visit
84 			Scene_Loop_Start_Special(kSceneLoopModeLoseControl, kBB01LoopInshot, false);
85 		}
86 		Scene_Loop_Set_Default(kBB01LoopMainLoop);
87 	} else if (Game_Flag_Query(kFlagSpinnerAtBB01)
88 	        && Game_Flag_Query(kFlagDR02toBB01)
89 	) {
90 		Scene_Loop_Set_Default(kBB01LoopMainLoop);
91 	} else if (Game_Flag_Query(kFlagSpinnerAtBB01)
92 	        && Game_Flag_Query(kFlagBB02toBB01)
93 	) {
94 		Scene_Loop_Set_Default(kBB01LoopMainLoop);
95 	} else {
96 		Scene_Loop_Set_Default(kBB01LoopMainLoopNoSpinner);
97 	}
98 }
99 
SceneLoaded()100 void SceneScriptBB01::SceneLoaded() {
101 	Obstacle_Object("COLUME", true);
102 #if BLADERUNNER_ORIGINAL_BUGS
103 #else
104 	Unclickable_Object("OBJECT03");
105 	Unclickable_Object("OBJECT04");
106 	Unclickable_Object("OBJECT05");
107 #endif // BLADERUNNER_ORIGINAL_BUGS
108 }
109 
MouseClick(int x,int y)110 bool SceneScriptBB01::MouseClick(int x, int y) {
111 	return false;
112 }
113 
ClickedOn3DObject(const char * objectName,bool a2)114 bool SceneScriptBB01::ClickedOn3DObject(const char *objectName, bool a2) {
115 	return false;
116 }
117 
ClickedOnActor(int actorId)118 bool SceneScriptBB01::ClickedOnActor(int actorId) {
119 	return false;
120 }
121 
ClickedOnItem(int itemId,bool a2)122 bool SceneScriptBB01::ClickedOnItem(int itemId, bool a2) {
123 	return false;
124 }
125 
ClickedOnExit(int exitId)126 bool SceneScriptBB01::ClickedOnExit(int exitId) {
127 	if (exitId == 0) {
128 		Loop_Actor_Walk_To_XYZ(kActorMcCoy, -140.0f, 9.0f, 818.0f, 0, true, false, false);
129 		if (!Loop_Actor_Walk_To_XYZ(kActorMcCoy, -233.0f, 9.0f, 846.0f, 0, true, false, false)) {
130 			Game_Flag_Set(kFlagBB01toDR02);
131 			Game_Flag_Reset(kFlagMcCoyInBradburyBuilding);
132 			Game_Flag_Set(kFlagMcCoyInDNARow);
133 			Set_Enter(kSetDR01_DR02_DR04, kSceneDR02);
134 		}
135 		return true;
136 	}
137 
138 	if (exitId == 1) {
139 		if (!Loop_Actor_Walk_To_XYZ(kActorMcCoy, -125.39f, 9.0f, 372.45f, 0, true, false, false)) {
140 			Game_Flag_Set(kFlagBB01toBB02);
141 			Set_Enter(kSetBB02_BB04_BB06_BB51, kSceneBB02);
142 		}
143 		return true;
144 	}
145 
146 	if (exitId == 2) {
147 		if (!Loop_Actor_Walk_To_XYZ(kActorMcCoy, 43.0f, 0.0f, 1062.0f, 0, true, false, false)) {
148 			Game_Flag_Reset(kFlagMcCoyInChinaTown);
149 			Game_Flag_Reset(kFlagMcCoyInRunciters);
150 			Game_Flag_Reset(kFlagMcCoyInMcCoyApartment);
151 			Game_Flag_Reset(kFlagMcCoyInPoliceStation);
152 			Game_Flag_Reset(kFlagMcCoyInBradburyBuilding);
153 			int spinnerDest = Spinner_Interface_Choose_Dest(kBB01LoopDoorAnim, false);
154 			switch (spinnerDest) {
155 			case kSpinnerDestinationPoliceStation:
156 				Game_Flag_Set(kFlagMcCoyInPoliceStation);
157 				Game_Flag_Reset(kFlagSpinnerAtBB01);
158 				Game_Flag_Set(kFlagSpinnerAtPS01);
159 				Set_Enter(kSetPS01, kScenePS01);
160 				Scene_Loop_Start_Special(kSceneLoopModeChangeSet, kBB01LoopOutshot, true);
161 				break;
162 			case kSpinnerDestinationMcCoysApartment:
163 				Game_Flag_Set(kFlagMcCoyInMcCoyApartment);
164 				Game_Flag_Reset(kFlagSpinnerAtBB01);
165 				Game_Flag_Set(kFlagSpinnerAtMA01);
166 				Set_Enter(kSetMA01, kSceneMA01);
167 				Scene_Loop_Start_Special(kSceneLoopModeChangeSet, kBB01LoopOutshot, true);
168 				break;
169 			case kSpinnerDestinationRuncitersAnimals:
170 				Game_Flag_Set(kFlagMcCoyInRunciters);
171 				Game_Flag_Reset(kFlagSpinnerAtBB01);
172 				Game_Flag_Set(kFlagSpinnerAtRC01);
173 				Set_Enter(kSetRC01, kSceneRC01);
174 				Scene_Loop_Start_Special(kSceneLoopModeChangeSet, kBB01LoopOutshot, true);
175 				break;
176 			case kSpinnerDestinationChinatown:
177 				Game_Flag_Set(kFlagMcCoyInChinaTown);
178 				Game_Flag_Reset(kFlagSpinnerAtBB01);
179 				Game_Flag_Set(kFlagSpinnerAtCT01);
180 				Set_Enter(kSetCT01_CT12, kSceneCT01);
181 				Scene_Loop_Start_Special(kSceneLoopModeChangeSet, kBB01LoopOutshot, true);
182 				break;
183 			case kSpinnerDestinationAnimoidRow:
184 				Game_Flag_Set(kFlagMcCoyInAnimoidRow);
185 				Game_Flag_Reset(kFlagSpinnerAtBB01);
186 				Game_Flag_Set(kFlagSpinnerAtAR01);
187 				Set_Enter(kSetAR01_AR02, kSceneAR01);
188 				Scene_Loop_Start_Special(kSceneLoopModeChangeSet, kBB01LoopOutshot, true);
189 				break;
190 			case kSpinnerDestinationTyrellBuilding:
191 				Game_Flag_Set(kFlagMcCoyInTyrellBuilding);
192 				Game_Flag_Reset(kFlagSpinnerAtBB01);
193 				Game_Flag_Set(kFlagSpinnerAtTB02);
194 				Set_Enter(kSetTB02_TB03, kSceneTB02);
195 				Scene_Loop_Start_Special(kSceneLoopModeChangeSet, kBB01LoopOutshot, true);
196 				break;
197 			case kSpinnerDestinationDNARow:
198 				Game_Flag_Set(kFlagMcCoyInDNARow);
199 				Game_Flag_Reset(kFlagSpinnerAtBB01);
200 				Game_Flag_Set(kFlagSpinnerAtDR01);
201 				Set_Enter(kSetDR01_DR02_DR04, kSceneDR01);
202 				Scene_Loop_Start_Special(kSceneLoopModeChangeSet, kBB01LoopOutshot, true);
203 				break;
204 			case kSpinnerDestinationNightclubRow:
205 				Game_Flag_Set(kFlagMcCoyInNightclubRow);
206 				Game_Flag_Reset(kFlagSpinnerAtBB01);
207 				Game_Flag_Set(kFlagSpinnerAtNR01);
208 				Set_Enter(kSetNR01, kSceneNR01);
209 				Scene_Loop_Start_Special(kSceneLoopModeChangeSet, kBB01LoopOutshot, true);
210 				break;
211 			case kSpinnerDestinationHysteriaHall:
212 				Game_Flag_Set(kFlagMcCoyInHysteriaHall);
213 				Game_Flag_Reset(kFlagSpinnerAtBB01);
214 				Game_Flag_Set(kFlagSpinnerAtHF01);
215 				Set_Enter(kSetHF01, kSceneHF01);
216 				Scene_Loop_Start_Special(kSceneLoopModeChangeSet, kBB01LoopOutshot, true);
217 				break;
218 			default:
219 				Game_Flag_Set(kFlagMcCoyInBradburyBuilding);
220 				Scene_Loop_Start_Special(kSceneLoopModeOnce, kBB01LoopDoorAnim, true);
221 				break;
222 			}
223 		}
224 		return true;
225 	}
226 	return false;
227 }
228 
ClickedOn2DRegion(int region)229 bool SceneScriptBB01::ClickedOn2DRegion(int region) {
230 	return false;
231 }
232 
SceneFrameAdvanced(int frame)233 void SceneScriptBB01::SceneFrameAdvanced(int frame) {
234 	if (frame == 193) {
235 		Sound_Play(kSfxCARDOWN3, 40, 0, 0, 50);
236 	}
237 
238 	if (frame == 241
239 	 || frame == 363
240 	) {
241 		Sound_Play(kSfxSPINOPN4, 100, -50, -50, 50);
242 	}
243 
244 	if (frame == 286
245 	 || frame == 407
246 	) {
247 		Sound_Play(kSfxSPINCLS1, 100, -50, -50, 50);
248 	}
249 
250 	if (frame == 433) {
251 		Sound_Play(kSfxCARUP3,    40, -50, 80, 50);
252 	}
253 
254 #if BLADERUNNER_ORIGINAL_BUGS
255 #else
256 	// This is treated as a bug rather than restored content
257 	// This InShot loop otherwise seems silent for the first ~120 frames
258 	if (frame == 19) {
259 		if (Random_Query(0, 1)) {
260 			Sound_Play(kSfxSPIN3A,     90, -50, 100, 50);
261 		} else {
262 			Sound_Play(kSfxSPIN2A,     90, -50, 100, 50);
263 		}
264 	}
265 
266 	if (frame == 60 && Random_Query(0, 1)) {
267 		Sound_Play(kSfxSIREN2, 50, 20, 80, 50);
268 	}
269 
270 	if (frame == 90 && Random_Query(0, 1)) {
271 		Sound_Play(kSfxRCCARBY3, 40, 80, 100, 50);
272 	}
273 #endif // BLADERUNNER_ORIGINAL_BUGS
274 
275 #if BLADERUNNER_ORIGINAL_BUGS
276 	if (frame == 120) {
277 		Sound_Play(kSfxTRUCKBY1, Random_Query(33, 33), 100, -100, 50);
278 	}
279 #else
280 	// delay truck passing by sfx to better match the animation in the loop
281 	if (frame == 124) {
282 		Sound_Play(kSfxTRUCKBY1, Random_Query(40, 73), 100, -100, 50);
283 	}
284 #endif // BLADERUNNER_ORIGINAL_BUGS
285 }
286 
ActorChangedGoal(int actorId,int newGoal,int oldGoal,bool currentSet)287 void SceneScriptBB01::ActorChangedGoal(int actorId, int newGoal, int oldGoal, bool currentSet) {
288 }
289 
PlayerWalkedIn()290 void SceneScriptBB01::PlayerWalkedIn() {
291 	Spinner_Set_Selectable_Destination_Flag(kSpinnerDestinationBradburyBuilding, true);
292 	if (Game_Flag_Query(kFlagDR02toBB01)) {
293 		Game_Flag_Reset(kFlagDR02toBB01);
294 	} else if (Game_Flag_Query(kFlagBB02toBB01)) {
295 		Game_Flag_Reset(kFlagBB02toBB01);
296 	} else {
297 		if (!Game_Flag_Query(kFlagBB01VisitedFirstTimeWithSpinner) && Game_Flag_Query(kFlagSpinnerAtBB01)) {
298 			Game_Flag_Set(kFlagBB01VisitedFirstTimeWithSpinner);
299 		}
300 		Loop_Actor_Walk_To_XYZ(kActorMcCoy, 43.0f, 0.0f, 954.0f, 0, false, false, false);
301 	}
302 }
303 
PlayerWalkedOut()304 void SceneScriptBB01::PlayerWalkedOut() {
305 	Ambient_Sounds_Remove_All_Non_Looping_Sounds(true);
306 	Ambient_Sounds_Remove_All_Looping_Sounds(1);
307 #if BLADERUNNER_ORIGINAL_BUGS
308 #else
309 	if (!Game_Flag_Query(kFlagBB01toBB02)
310 	    && !Game_Flag_Query(kFlagBB01toDR02)) {
311 		// Acts 2, 3 - should still use a spinner fly-through transition
312 		if (!Game_Flag_Query(kFlagMcCoyInTyrellBuilding)) {
313 			Outtake_Play(kOuttakeTowards3, true, -1); // available in Acts 1, 2, 3
314 		}
315 	}
316 #endif // BLADERUNNER_ORIGINAL_BUGS
317 }
318 
DialogueQueueFlushed(int a1)319 void SceneScriptBB01::DialogueQueueFlushed(int a1) {
320 }
321 
322 } // End of namespace BladeRunner
323