File: kp03.cpp

package info (click to toggle)
scummvm 2.9.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 450,580 kB
  • sloc: cpp: 4,299,825; asm: 28,322; python: 12,901; sh: 11,302; java: 9,289; xml: 7,895; perl: 2,639; ansic: 2,465; yacc: 1,670; javascript: 1,020; makefile: 933; lex: 578; awk: 275; objc: 82; sed: 11; php: 1
file content (341 lines) | stat: -rw-r--r-- 11,726 bytes parent folder | download | duplicates (2)
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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
/* 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 3 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, see <http://www.gnu.org/licenses/>.
 *
 */

#include "bladerunner/script/scene_script.h"

namespace BladeRunner {

enum KP03Loops {
	kKP03MainLoopBombInactive  = 0,
	kKP03MainLoopBombActive    = 2,
	kKP03MainLoopBombExploding = 4,
	kKP03MainLoopBombExploded  = 5,
	kKP03MainLoopBombNoWire    = 7
};

void SceneScriptKP03::InitializeScene() {
	if (Game_Flag_Query(kFlagKP05toKP03)) {
		Setup_Scene_Information(   1.0f, -36.55f, 111.0f, 200);
	} else {
		Setup_Scene_Information(-321.0f, -36.55f,  26.0f, 350);
	}
	Scene_Exit_Add_2D_Exit(0,   0,   0,  30, 479, 3);
	Scene_Exit_Add_2D_Exit(1, 287, 104, 367, 255, 0);

	Ambient_Sounds_Add_Looping_Sound(kSfxRAIN10, 100, 1, 1);
	Ambient_Sounds_Add_Sound(kSfxSPIN2B,  60, 180, 16,  25, 0, 0, -101, -101, 0, 0);
	Ambient_Sounds_Add_Sound(kSfxSPIN3A,  60, 180, 16,  25, 0, 0, -101, -101, 0, 0);
	Ambient_Sounds_Add_Sound(kSfxTHNDER2, 60, 180, 50, 100, 0, 0, -101, -101, 0, 0);
	Ambient_Sounds_Add_Sound(kSfxTHNDER3, 50, 180, 50, 100, 0, 0, -101, -101, 0, 0);
	Ambient_Sounds_Add_Sound(kSfxTHNDER4, 50, 180, 50, 100, 0, 0, -101, -101, 0, 0);

	if (Game_Flag_Query(kFlagKP03BombExploded)) {
		Scene_Loop_Set_Default(kKP03MainLoopBombExploded);
	} else if (Game_Flag_Query(kFlagKP03BombDisarmed)) {
		Scene_Loop_Set_Default(kKP03MainLoopBombNoWire);
	} else {
		Scene_Loop_Set_Default(kKP03MainLoopBombActive);
		Game_Flag_Set(kFlagKP03BombActive);
	}

	if (( Actor_Query_Goal_Number(kActorSteele) != kGoalSteeleGone
	  && !Game_Flag_Query(kFlagKP03BombExploded)
	  && !Game_Flag_Query(kFlagKP03BombDisarmed)
	 )
	 && ((Game_Flag_Query(kFlagMcCoyIsHelpingReplicants)
	   && Game_Flag_Query(kFlagKP05toKP03)
	  )
	  || (!Game_Flag_Query(kFlagMcCoyIsHelpingReplicants)
	   &&  Game_Flag_Query(kFlagKP01toKP03)
	  )
	 )
	) {
		Actor_Put_In_Set(kActorSteele, kSetKP03);
		Actor_Set_At_XYZ(kActorSteele, -300.0f, -36.55f, 26.0f, 350);
	}
}

void SceneScriptKP03::SceneLoaded() {
	Obstacle_Object("BRACK MID", true);
	Unobstacle_Object("OBSTACLE_REMOVE", true);
	Unobstacle_Object("BOX11", true);
	Unobstacle_Object("OBSTACLE05", true);
	Clickable_Object("BRACK MID");
}

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

bool SceneScriptKP03::ClickedOn3DObject(const char *objectName, bool combatMode) {
	Actor_Face_Object(kActorSteele, "BRACK MID", true);
	if ( Object_Query_Click("BRACK MID", objectName)
	 && !Game_Flag_Query(kFlagKP03BombExploded)
	) {
		if (combatMode) {
			Scene_Loop_Set_Default(kKP03MainLoopBombExploded);
			Scene_Loop_Start_Special(kSceneLoopModeOnce, kKP03MainLoopBombExploding, true);
			Actor_Change_Animation_Mode(kActorMcCoy, 39);
			Actor_Retired_Here(kActorMcCoy, 72, 18, true, -1);
			Game_Flag_Set(kFlagKP03BombExploded);
			Game_Flag_Reset(kFlagKP03BombActive);
			return false;
		}

		if (Actor_Query_Goal_Number(kActorSteele) == kGoalSteeleKP03Walk) {
			Scene_Exits_Enable();
			saveSteele();
		} else {
			if (Game_Flag_Query(kFlagKP01toKP03)) {
				Loop_Actor_Walk_To_XYZ(kActorMcCoy, -137.0f, -36.55f, 26.0f, 0, false, true, false);
			} else if (Game_Flag_Query(kFlagKP05toKP03)) {
				Loop_Actor_Walk_To_XYZ(kActorMcCoy, -50.0f, -36.55f, 78.0f, 0, false, true, false);
			}

			if (Game_Flag_Query(kFlagKP03BombActive)) {
				Actor_Face_Object(kActorMcCoy, "BRACK MID", true);
				Game_Flag_Set(kFlagKP03BombDisarmed);
				Game_Flag_Reset(kFlagKP03BombActive);
				Scene_Loop_Set_Default(kKP03MainLoopBombNoWire);
				Scene_Loop_Start_Special(kSceneLoopModeOnce, kKP03MainLoopBombInactive, false);
				if (_vm->_cutContent) {
					Actor_Voice_Over(1100, kActorVoiceOver); // I'd been lucky this time.
				}
				Actor_Voice_Over(1110, kActorVoiceOver);
				Actor_Voice_Over(1120, kActorVoiceOver);
				if (_vm->_cutContent) {
					Actor_Voice_Over(1130, kActorVoiceOver); // One false step and...
				}
			} else {
				Actor_Face_Object(kActorMcCoy, "BRACK MID", true);
				Actor_Says(kActorMcCoy, 8580, 13);
			}
		}
		return true;
	}
	return false;
}

bool SceneScriptKP03::ClickedOnActor(int actorId) {
	if (actorId == kActorSteele
	 && Actor_Query_Goal_Number(kActorSteele) == kGoalSteeleKP03Walk
	) {
		Actor_Face_Object(kActorSteele, "BRACK MID", true);
		saveSteele();
	}
	return false;
}

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

bool SceneScriptKP03::ClickedOnExit(int exitId) {
	if (Actor_Query_Goal_Number(kActorSteele) == 410) {
		Actor_Set_Goal_Number(kActorSteele, kGoalSteeleKP03ShootMcCoy);
	} else {
		if (exitId == 0) {
			if (!Loop_Actor_Walk_To_XYZ(kActorMcCoy, 1.0f, -36.55f, 111.0f, 0, true, false, false)) {
				Ambient_Sounds_Remove_All_Non_Looping_Sounds(true);
				Ambient_Sounds_Remove_All_Looping_Sounds(1u);
				Music_Stop(2u);
				Game_Flag_Reset(kFlagKP01toKP03);
				Game_Flag_Reset(kFlagKP05toKP03);
				Game_Flag_Set(kFlagKP03toKP05);
				Set_Enter(kSetKP05_KP06, kSceneKP05);
			}
			return true;
		}

		if (exitId == 1) {
			if (!Loop_Actor_Walk_To_XYZ(kActorMcCoy, -321.0f, -36.55f, 26.0f, 0, true, false, false)) {
				Ambient_Sounds_Remove_All_Non_Looping_Sounds(true);
				Ambient_Sounds_Remove_All_Looping_Sounds(1u);
				Music_Stop(2u);
				Game_Flag_Reset(kFlagKP01toKP03);
				Game_Flag_Reset(kFlagKP05toKP03);
				Game_Flag_Set(kFlagKP03toKP01);
				Set_Enter(kSetKP01, kSceneKP01);
			}
			return true;
		}
	}
	return false;
}

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

void SceneScriptKP03::SceneFrameAdvanced(int frame) {
	if (frame == 123) {
		Ambient_Sounds_Play_Sound(kSfxCRYEXPL1, 99, -60, 100, 99);
	}

	if ( Game_Flag_Query(kFlagKP03BombActive)
	 && !Game_Flag_Query(kFlagKP03BombDisarmed)
	 && !Game_Flag_Query(kFlagKP03BombExploded)
	) {
		float x, y, z;
		int bombTriggeredByActor = -1;

		Actor_Query_XYZ(kActorMcCoy, &x, &y, &z);
		if ((Game_Flag_Query(kFlagKP01toKP03) && -130.0f < x )
		    || (Game_Flag_Query(kFlagKP05toKP03) && -130.0f > x)
		) {
			bombTriggeredByActor = kActorMcCoy;
		}

		Actor_Query_XYZ(kActorSteele, &x, &y, &z);
#if BLADERUNNER_ORIGINAL_BUGS
		if (Game_Flag_Query(kFlagMcCoyIsHelpingReplicants)
		    && Actor_Query_Which_Set_In(kActorSteele) == kSetKP03
		) {
			if ((Game_Flag_Query(kFlagKP01toKP03) && -130.0f > x)
			    || (Game_Flag_Query(kFlagKP05toKP03) && -130.0f < x)
			) {
				bombTriggeredByActor = kActorSteele;
			}
		} else if ((Game_Flag_Query(kFlagKP01toKP03) && -130.0f < x)
		            || (Game_Flag_Query(kFlagKP05toKP03) && -130.0f > x)
		) {
			bombTriggeredByActor = kActorSteele;
		}
#else
		// In both cases we're concerned about Steele's position within the current set
		// So the check for her being in KP03 should cover both cases,
		// even though, the first (when McCoy is helping Replicants) 
		// is untriggered in the vanilla game and thus Steele won't be in this set then.
		// (She would be in KP05 with exits disabled)
		// The code that gets triggered (McCoy is NOT helping Replicants) 
		// would not check for Steele's current set, and so while it did work, it was prone to errors
		// since wherever Steele is, if she's moving or if she's teleported by some piece of code
		// her x position (in the other set where she's in) could trigger the bomb.
		if (Actor_Query_Which_Set_In(kActorSteele) == kSetKP03) {
			if (Game_Flag_Query(kFlagMcCoyIsHelpingReplicants)) {
				if ((Game_Flag_Query(kFlagKP01toKP03) && -130.0f > x)
					|| (Game_Flag_Query(kFlagKP05toKP03) && -130.0f < x)
				) {
					bombTriggeredByActor = kActorSteele;
				}
			} else if ((Game_Flag_Query(kFlagKP01toKP03) && -130.0f < x)
			           || (Game_Flag_Query(kFlagKP05toKP03) && -130.0f > x)
			) {
				bombTriggeredByActor = kActorSteele;
			}
		}
#endif

		if (bombTriggeredByActor != -1) {
			Scene_Loop_Set_Default(kKP03MainLoopBombExploded);
			Scene_Loop_Start_Special(kSceneLoopModeOnce, kKP03MainLoopBombExploding, true);
			Game_Flag_Set(kFlagKP03BombExploded);
			Game_Flag_Reset(kFlagKP03BombActive);
			Unclickable_Object("BRACK MID");
			Scene_Exits_Enable();

			if (bombTriggeredByActor == kActorSteele) {
				Actor_Set_Goal_Number(kActorSteele, kGoalSteeleKP03Exploded);
				Music_Play(kMusicCrysDie1, 25, 0, 1, -1, kMusicLoopPlayOnce, 0);
				if (Actor_Query_Inch_Distance_From_Actor(kActorMcCoy, kActorSteele) <= 120) {
					bombTriggeredByActor = kActorMcCoy;
				}
			}

			if (bombTriggeredByActor == kActorSteele) {
				Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeHit);
			} else {
				Actor_Force_Stop_Walking(kActorMcCoy);
				Actor_Change_Animation_Mode(kActorMcCoy, kAnimationModeDie);
				Actor_Retired_Here(kActorMcCoy, 72, 18, true, -1);
			}
		}
	}
}

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

void SceneScriptKP03::PlayerWalkedIn() {
	if (Game_Flag_Query(kFlagKP05toKP03)) {
		Loop_Actor_Walk_To_XYZ(kActorMcCoy, 1.0f, -36.55f, 87.0f, 0, false, false, false);
	}

	if (Actor_Query_Is_In_Current_Set(kActorSteele)
	 && Actor_Query_Goal_Number(kActorSteele) != kGoalSteeleKP03Dead
	) {
		if (Game_Flag_Query(kFlagMcCoyIsHelpingReplicants)) {
			if (Game_Flag_Query(kFlagKP05toKP03)) {
				Actor_Set_Goal_Number(kActorSteele, 410);
			}
			return;
		}

		if (!Game_Flag_Query(kFlagKP03BombExploded)
		 && !Game_Flag_Query(kFlagKP03BombDisarmed)
		 &&  Game_Flag_Query(kFlagKP01toKP03)
		) {
			Scene_Exits_Disable();
			Delay(1000);
			Actor_Set_Goal_Number(kActorSteele, kGoalSteeleKP03Walk);
		}
	}
}

void SceneScriptKP03::PlayerWalkedOut() {
}

void SceneScriptKP03::DialogueQueueFlushed(int a1) {
}

void SceneScriptKP03::saveSteele() {
	Player_Loses_Control();
	Actor_Says(kActorMcCoy, 2180, 14);
	Actor_Set_Goal_Number(kActorSteele, kGoalSteeleKP03StopWalking);
	Actor_Says(kActorSteele, 480, 60);
	Actor_Face_Object(kActorMcCoy, "BRACK MID", true);
	Actor_Says(kActorMcCoy, 2185, 14);
	Loop_Actor_Walk_To_XYZ(kActorSteele, -137.0f, -36.55f, 26.0f, 0, false, false, false);
	Actor_Face_Object(kActorSteele, "BRACK MID", true);
	Actor_Says(kActorSteele, 490, 58);
	Actor_Says(kActorMcCoy, 2190, 14);
	Actor_Says(kActorSteele, 500, 58);
	Actor_Says(kActorSteele, 510, 59);
	Actor_Says(kActorSteele, 520, 60);
	Game_Flag_Set(kFlagKP03BombDisarmed);
	Game_Flag_Reset(kFlagKP03BombActive);
	Scene_Loop_Set_Default(kKP03MainLoopBombNoWire);
	Scene_Loop_Start_Special(kSceneLoopModeOnce, kKP03MainLoopBombNoWire, false);
	Actor_Set_Goal_Number(kActorSteele, kGoalSteeleKP03Leave);
	Actor_Says(kActorMcCoy, 2195, 14);
	Ambient_Sounds_Play_Sound(kSfxLABMISC6, 40, -60, -60, 0);
	Loop_Actor_Walk_To_XYZ(kActorMcCoy, 1.0f, -36.55f, 111.0f, 0, false, false, false);
	Actor_Set_Goal_Number(kActorSteele, kGoalSteeleKP05Enter);
	Ambient_Sounds_Remove_All_Non_Looping_Sounds(true);
	Ambient_Sounds_Remove_All_Looping_Sounds(1u);
	Game_Flag_Reset(kFlagKP01toKP03);
	Game_Flag_Reset(kFlagKP05toKP03);
	Game_Flag_Set(kFlagKP03toKP05);
	Set_Enter(kSetKP05_KP06, kSceneKP05);
	Player_Gains_Control();
}

} // End of namespace BladeRunner