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 kUG08Loops {
28 	kUG08LoopElevatorComingUp  = 0,
29 	kUG08LoopMainLoopElevator  = 1,
30 	kUG08LoopElevatorGoingDown = 3,
31 	kUG08LoopMainNoElevator    = 4
32 };
33 
InitializeScene()34 void SceneScriptUG08::InitializeScene() {
35 	if (Game_Flag_Query(kFlagUG13toUG08)) {
36 		Setup_Scene_Information(-124.0f, 93.18f,   71.0f, 745);
37 	} else {
38 		Setup_Scene_Information(-432.0f,   0.0f, -152.0f, 370);
39 	}
40 
41 	Scene_Exit_Add_2D_Exit(0, 125, 220, 157, 303, 3);
42 	Scene_Exit_Add_2D_Exit(1, 353, 145, 552, 309, 1);
43 
44 	Ambient_Sounds_Add_Looping_Sound(kSfxSTMLOOP7, 28, 0, 1);
45 	Ambient_Sounds_Add_Looping_Sound(kSfxUGBED1,   40, 0, 1);
46 	Ambient_Sounds_Add_Looping_Sound(kSfxUGBED2,   40, 0, 1);
47 	Ambient_Sounds_Add_Sound(kSfxYELL1M1,  2, 120, 11, 12, -100, 100, -100,  100, 0, 0);
48 	Ambient_Sounds_Add_Sound(kSfxYELL1M2,  2, 120, 11, 12, -100, 100, -100,  100, 0, 0);
49 	Ambient_Sounds_Add_Sound(kSfxGRUNT1M1, 2, 120, 11, 12, -100, 100, -100,  100, 0, 0);
50 	Ambient_Sounds_Add_Sound(kSfxGRUNT2M3, 2, 120, 11, 12, -100, 100, -100,  100, 0, 0);
51 	Ambient_Sounds_Add_Sound(kSfxBBDRIP1,  2,  20, 20, 25, -100, 100, -100,  100, 0, 0);
52 	Ambient_Sounds_Add_Sound(kSfxBBDRIP2,  2,  20, 20, 25, -100, 100, -100,  100, 0, 0);
53 	Ambient_Sounds_Add_Sound(kSfxBBDRIP3,  2,  20, 20, 25, -100, 100, -100,  100, 0, 0);
54 	Ambient_Sounds_Add_Sound(kSfxBBDRIP4,  2,  20, 20, 25, -100, 100, -100,  100, 0, 0);
55 	Ambient_Sounds_Add_Sound(kSfxBBDRIP5,  2,  20, 20, 25, -100, 100, -100,  100, 0, 0);
56 	Ambient_Sounds_Add_Sound(kSfxBBGRN1,   5,  50, 17, 37, -100, 100, -101, -101, 0, 0);
57 	Ambient_Sounds_Add_Sound(kSfxBBGRN2,   5,  50, 17, 37, -100, 100, -101, -101, 0, 0);
58 	Ambient_Sounds_Add_Sound(kSfxBBGRN3,   5,  50, 17, 37, -100, 100, -101, -101, 0, 0);
59 
60 	if (!Game_Flag_Query(kFlagUG08Entered)) {
61 		Game_Flag_Set(kFlagUG08ElevatorUp);
62 		Game_Flag_Set(kFlagUG08Entered);
63 	}
64 
65 #if BLADERUNNER_ORIGINAL_BUGS
66 #else
67 	// if there's no elevator here (because it's in UG13 and the player took the long way round,
68 	// McCoy is unable to call it up (there's no call button)
69 	// Additionally, since the elevator exit is added regardless, McCoy will walk up to
70 	// the elevator and then the elevator will blink in (BUG)
71 	// Solution here is to:
72 	// In easy mode: Have the elevator always be here.
73 	// In normal/hard mode: If the elevator is missing, then:
74 	//		by ~33% probability the elevator will be up again,
75 	//		and by ~66% it won't be up, so we remove the elevator exit, and force McCoy to go the long way round again (or retry the room)
76 	if (!Game_Flag_Query(kFlagUG08ElevatorUp)) {
77 		if (Query_Difficulty_Level() == kGameDifficultyEasy
78 		    || Random_Query(1, 3) == 1
79 		) {
80 			Game_Flag_Set(kFlagUG08ElevatorUp);
81 		} else {
82 			Scene_Exit_Remove(1);
83 		}
84 	}
85 #endif // BLADERUNNER_ORIGINAL_BUGS
86 
87 	if (Game_Flag_Query(kFlagUG13toUG08)) {
88 		Scene_Loop_Start_Special(kSceneLoopModeLoseControl, kUG08LoopElevatorComingUp, false);
89 		Scene_Loop_Set_Default(kUG08LoopMainLoopElevator);
90 	} else if (Game_Flag_Query(kFlagUG08ElevatorUp)) {
91 		Scene_Loop_Set_Default(kUG08LoopMainLoopElevator);
92 	} else {
93 		Scene_Loop_Set_Default(kUG08LoopMainNoElevator);
94 	}
95 }
96 
SceneLoaded()97 void SceneScriptUG08::SceneLoaded() {
98 	Obstacle_Object("ELEV LEGS", true);
99 	Unobstacle_Object("ELEV LEGS", true);
100 	Unobstacle_Object("BOX RIGHT WALL ", true);
101 #if BLADERUNNER_ORIGINAL_BUGS
102 #else
103 	Obstacle_Object("NORTHBLOCK", true);
104 #endif // BLADERUNNER_ORIGINAL_BUGS
105 }
106 
MouseClick(int x,int y)107 bool SceneScriptUG08::MouseClick(int x, int y) {
108 	return false;
109 }
110 
ClickedOn3DObject(const char * objectName,bool a2)111 bool SceneScriptUG08::ClickedOn3DObject(const char *objectName, bool a2) {
112 	return false;
113 }
114 
ClickedOnActor(int actorId)115 bool SceneScriptUG08::ClickedOnActor(int actorId) {
116 	return false;
117 }
118 
ClickedOnItem(int itemId,bool a2)119 bool SceneScriptUG08::ClickedOnItem(int itemId, bool a2) {
120 	return false;
121 }
122 
ClickedOnExit(int exitId)123 bool SceneScriptUG08::ClickedOnExit(int exitId) {
124 	if (exitId == 0) {
125 		if (!Loop_Actor_Walk_To_XYZ(kActorMcCoy, -432.0f, 0.0f, -152.0f, 0, true, false, false)) {
126 			Ambient_Sounds_Remove_All_Non_Looping_Sounds(true);
127 			Ambient_Sounds_Remove_All_Looping_Sounds(1u);
128 			Game_Flag_Set(kFlagUG08toUG07);
129 			Set_Enter(kSetUG07, kSceneUG07);
130 			return false;
131 		}
132 	}
133 
134 	if (exitId == 1) {
135 		if (!Loop_Actor_Walk_To_XYZ(kActorMcCoy, -312.0f, -2.0f, 152.0f, 0, true, false, false)) {
136 			Actor_Face_Heading(kActorMcCoy, 240, false);
137 			Footstep_Sound_Override_On(2);
138 			Loop_Actor_Travel_Stairs(kActorMcCoy, 11, true, kAnimationModeIdle);
139 			Footstep_Sound_Override_Off();
140 			Loop_Actor_Walk_To_XYZ(kActorMcCoy, -118.02f, 93.02f, 52.76f, 0, false, false, false);
141 			Player_Loses_Control();
142 			Actor_Set_Invisible(kActorMcCoy, true);
143 			Game_Flag_Set(kFlagUG08toUG13);
144 			Game_Flag_Reset(kFlagUG08ElevatorUp);
145 			Set_Enter(kSetUG13, kSceneUG13);
146 			Scene_Loop_Start_Special(kSceneLoopModeChangeSet, kUG08LoopElevatorGoingDown, false);
147 			return false;
148 		}
149 	}
150 	return false;
151 }
152 
ClickedOn2DRegion(int region)153 bool SceneScriptUG08::ClickedOn2DRegion(int region) {
154 	return false;
155 }
156 
SceneFrameAdvanced(int frame)157 void SceneScriptUG08::SceneFrameAdvanced(int frame) {
158 	if (frame == 91) {
159 		Ambient_Sounds_Play_Sound(kSfxCARGELE2, 90, 0, 0, 100);
160 	}
161 }
162 
ActorChangedGoal(int actorId,int newGoal,int oldGoal,bool currentSet)163 void SceneScriptUG08::ActorChangedGoal(int actorId, int newGoal, int oldGoal, bool currentSet) {
164 }
165 
PlayerWalkedIn()166 void SceneScriptUG08::PlayerWalkedIn() {
167 	if (Game_Flag_Query(kFlagUG13toUG08)) {
168 		Loop_Actor_Walk_To_XYZ(kActorMcCoy, -167.0f, 93.18f,  71.0f, 0, false, false, false);
169 		Loop_Actor_Walk_To_XYZ(kActorMcCoy, -180.0f, 93.18f, 134.0f, 0, false, false, false);
170 		Actor_Face_Heading(kActorMcCoy, 745, false);
171 		Footstep_Sound_Override_On(2);
172 		Loop_Actor_Travel_Stairs(kActorMcCoy, 11, false, kAnimationModeIdle);
173 		Footstep_Sound_Override_Off();
174 		Player_Gains_Control();
175 	}
176 	Game_Flag_Reset(kFlagUG07toUG08);
177 	Game_Flag_Reset(kFlagUG13toUG08);
178 }
179 
PlayerWalkedOut()180 void SceneScriptUG08::PlayerWalkedOut() {
181 }
182 
DialogueQueueFlushed(int a1)183 void SceneScriptUG08::DialogueQueueFlushed(int a1) {
184 }
185 
186 } // End of namespace BladeRunner
187