-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtriggers.js
More file actions
450 lines (393 loc) · 15.3 KB
/
triggers.js
File metadata and controls
450 lines (393 loc) · 15.3 KB
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
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
import {Point, Rect, Size} from "./hgl/geometry.js"
import {Trigger} from "./TriggerController.js"
import {TriggerType, Duration, PlayerState} from "./Constants.js"
export const Triggers = [
//SOO1
new Trigger(TriggerType.sceneEnter, "s001",(g, d) => {
if(g.getSwitch("global-timeWarp2")) {
g.setStateForPlayer(PlayerState.idleRight);
g.setStateForPlayer(PlayerState.idleRight);
g.setStateForSceneElement("s001-window01", "");
g.clearSwitch("s001-onBin");
g.disableSceneElement("s001-window01");
g.enableSceneElement("s001-bin");
g.playerElement.point = new Point(80, 250);
g.wait(1000, (g) => {
g.clearCameraEffects();
g.enqueueMessage("Aaah!!")
g.enqueueMessage("I'm... ok?")
.openMessageBox();
});
return;
}
if (g.getSwitch("global-timeWarp1")) {
g.setStateForSceneElement("s001-window01", "");
g.clearSwitch("s001-onBin");
g.disableSceneElement("s001-window01");
g.enableSceneElement("s001-bin");
g.playerElement.point = new Point(80, 250);
g.wait(1000, (g) => {
g.clearCameraEffects();
g.enqueueMessage("What happened...?")
g.enqueueMessage("I'm back outside!")
g.enqueueMessage("...and the window is back to being unbroken!")
.openMessageBox();
});
return;
}
if (d.previousSceneId == "s002") {
g.playerElement.point = new Point(850, 40);
g.setSwitch("s001-onBin");
g.enableSceneElement("s001-window01");
g.disableSceneElement("s001-bin");
} else {
g.playerElement.point = new Point(80, 250);
if (!g.getSwitch("s001-firstTime")) {
g.enqueueMessage("OK - The orders are clear enough. I am supposed to find a way into this research facility, locate the underground research lab, and document or if possible - steal - the industry secrets they keep there.")
g.enqueueMessage("The client couldn't tell me what to look for. Only that it's something that helped this mining company increase their yields tenfold in the last year.")
g.enqueueMessage("If this is anything like the heist last year, I'm probably looking for some computer algorithm. I will have to keep my eyes open.")
g.enqueueMessage("Navigate with the A and D keyboard keys, and interact with your environment with [Enter]", "info")
.openMessageBox();
g.setSwitch("s001-firstTime");
}
}
}, true),
new Trigger(TriggerType.interact, "s001-bin",(g, d) => {
if (!g.getSwitch("s001-onBin")) {
g.playerElement.offsetY(-215);
g.setSwitch("s001-onBin");
g.enableSceneElement("s001-window01");
g.disableSceneElement("s001-bin");
}
}, true),
new Trigger(TriggerType.bring, "s001-binLeft",(g, d) => {
if (g.getSwitch("s001-onBin")) {
g.playerElement.offsetY(215);
g.clearSwitch("s001-onBin");
g.disableSceneElement("s001-window01");
g.enableSceneElement("s001-bin");
}
}, true),
new Trigger(TriggerType.bring, "s001-binRight",(g, d) => {
if (g.getSwitch("s001-onBin")) {
g.playerElement.offsetY(215);
g.clearSwitch("s001-onBin");
g.disableSceneElement("s001-window01");
g.enableSceneElement("s001-bin");
}
}, true),
new Trigger(TriggerType.interact, "s001-dumpster",(g, d) => {
if (g.getSwitch("global-timeWarp1") || g.getSwitch("global-timeWarp2")) {
g.enqueueMessage("No metal chair leg here... I have it on me!").openMessageBox();
return;
};
if (!g.getSwitch("s001-hasStone") && g.getSwitch("s001-hasInteractedWithWindow")) {
g.enqueueMessage("Perhaps...")
.enqueueMessage("Yes - I found a broken off leg of a metal chair. That should work.")
.openMessageBox();
g.setSwitch("s001-hasStone");
} else {
g.enqueueMessage("There's nothing in there I need").openMessageBox();
}
}, true),
new Trigger(TriggerType.interact, "s001-pipe",(g, d) => {
g.enqueueMessage("It leads all the five stories up to the roof of this building, but I'm going underground.")
.openMessageBox();
}, true),
new Trigger(TriggerType.interact, "s001-window01",(g, d) => {
if (g.getSwitch("global-timeWarp1") && g.getSwitch("s001-onBin")) {
g.pause();
g.enqueueMessage("I still have this metal bar...").openMessageBox((g)=> {
g.pause();
g.setStateForSceneElement("s001-window01", "broken");
g.applyCameraEffect("shake");
g.playSound("sfx_smashWindow.ogg", (g) => {
g.clearCameraEffects();
g.setSwitch("s001-windowBroken");
g.fadeToScene("s002");
g.unpause();
});
});
return;
};
if (g.getSwitch("global-timeWarp2") && g.getSwitch("s001-onBin")) {
g.enqueueMessage("This is getting old").openMessageBox((g)=> {
g.pause();
g.setStateForSceneElement("s001-window01", "broken");
g.applyCameraEffect("shake");
g.playSound("sfx_smashWindow.ogg", (g) => {
g.clearCameraEffects();
g.setSwitch("s001-windowBroken");
g.fadeToScene("s002");
g.unpause();
});
});
return;
};
if (!g.getSwitch("s001-onBin")) {
g.enqueueMessage("I can't reach it.").openMessageBox();
return;
} else if (!g.getSwitch("s001-hasStone")) {
g.enqueueMessage("I can't break it with my bare hands").openMessageBox();
g.setSwitch("s001-hasInteractedWithWindow");
} else if(!g.getSwitch("s001-hasEnteredWindowOnce")) {
g.setSwitch("s001-hasEnteredWindowOnce");
g.enqueueMessage("Here goes...").openMessageBox((g)=> {
g.pause();
g.setStateForSceneElement("s001-window01", "broken");
g.applyCameraEffect("shake");
g.playSound("sfx_smashWindow.ogg", (g) => {
g.clearCameraEffects();
g.setSwitch("s001-windowBroken");
g.clearSwitch("s001-onBin");
g.fadeToScene("s002");
g.unpause();
});
});
}
if (g.getSwitch("s001-windowBroken")) {
g.fadeToScene("s002");
}
}, true),
//SOO2
new Trigger(TriggerType.sceneEnter, "s002",(g, d) => {
if (d.previousSceneId == "s003") {
g.playerElement.point = new Point(750, 250);
} else {
g.playerElement.point = new Point(350, 250);
}
}, true),
new Trigger(TriggerType.interact, "s002-window01",(g, d) => {
if (g.getSwitch("global-timeWarp1") || g.getSwitch("global-timeWarp2")) {
g.enqueueMessage("No reason to go back.").openMessageBox();
return;
}
g.fadeToScene("s001");
}, true),
new Trigger(TriggerType.interact, "s002-door01",(g, d) => {
g.fadeToScene("s003");
}, true),
new Trigger(TriggerType.interact, "s002-cupboard",(g, d) => {
if (g.getSwitch("global-timeWarp2")) {
g.enqueueMessage("I already have the pliers on me!").openMessageBox();
return;
};
if (g.getSwitch("s003-inspectedAlarmBox")) {
if (!g.getSwitch("global-hasPliers")) {
g.enqueueMessage("These pliers might be useful.").openMessageBox();
g.setSwitch("global-hasPliers");
} else {
g.enqueueMessage("I already have the tools I need").openMessageBox();
}
} else {
g.enqueueMessage("Tools. I can't think of anything I need in there").openMessageBox();
}
}, true),
new Trigger(TriggerType.interact, "s002-valve",(g, d) => {
if (g.getSwitch("global-timeWarp1") || g.getSwitch("global-timeWarp2")) {
g.enqueueMessage("I still have no reason to turn this valve...").openMessageBox();
return;
};
g.enqueueMessage("I have no reason to turn this valve").openMessageBox();
}, true),
new Trigger(TriggerType.interact, "s002-shelf",(g, d) => {
g.enqueueMessage("Just old supplies and paint buckets").openMessageBox();
}, true),
//SOO3
new Trigger(TriggerType.sceneEnter, "s003",(g, d) => {
if (!g.getSwitch("s003-firstEnter")) {
g.disableSceneElement("s003-alarmBlock");
g.disableSceneElement("s003-alarmCaution");
g.setSwitch("s003-firstEnter");
}
if (d.previousSceneId == "s002") {
g.playerElement.point = new Point(350, 250);
} else if(d.previousSceneId == "s004") {
g.playerElement.point = new Point(2200, 250);
} else {
g.playerElement.point = new Point(350, 250);
}
}, true),
new Trigger(TriggerType.interact, "s003-door01",(g, d) => {
g.fadeToScene("s002");
}, true),
new Trigger(TriggerType.enterLocation, "s003-hallwayEast",(g, d) => {
g.enqueueMessage("Ok, this is it. Now to find the staircase to the lower floors.").openMessageBox();
}),
new Trigger(TriggerType.enterLocation, "s003-hallwayWest",(g, d) => {
g.enqueueMessage("No, this is the wrong way. The client told the me access to the lower floors is the other way.").openMessageBox();
}, true),
new Trigger(TriggerType.enterLocation, "s003-alarmCaution",(g, d) => {
if (g.getSwitch("s003-observedAlarmSensor")) {
g.enqueueMessage("I should not move further, that will set off the alarm.").openMessageBox();
}
}, true),
new Trigger(TriggerType.enterLocation, "s003-alarmTrigger",(g, d) => {
if (!g.getSwitch("s003-observedAlarmSensor")) {
//TODO Play Alarm, show red siren effect
g.pause();
g.playSound("sfx_alarm.ogg");
g.applyCameraEffect("alarmOverlay");
g.enqueueMessage("Oh no!").enqueueMessage("I must have tripped the alarm! I have to get out!").openMessageBox((g) => {
g.wait(1000, (g) => {
g.pause();
g.clearCameraEffects();
g.enableSceneElement("s003-alarmBlock");
g.enableSceneElement("s003-alarmCaution");
g.setSwitch("s003-observedAlarmSensor");
g.setSwitch("global-timeWarp1");
g.enqueueMessage("What's happening?!").openMessageBox((g) => {
g.timeWarp((g) => {
g.fadeToScene("s001");
});
});
});
});
} else {
// should not be possible
}
}),
new Trigger(TriggerType.interact, "s003-alarm",(g, d) => {
if (g.getSwitch("s003-alarmDisabled") || g.getSwitch("global-timeWarp2")) {
return;
}
if (g.getSwitch("s003-observedAlarmSensor")) {
if (g.getSwitch("s003-inspectedAlarmBox")) {
if (g.getSwitch("global-hasPliers")) {
g.enqueueMessage("Cutting the cord.").openMessageBox((g) => {
g.setStateForSceneElement("s003-alarm", "cut");
});
g.setSwitch("s003-alarmDisabled");
g.disableSceneElement("s003-alarmBlock");
g.disableSceneElement("s003-alarmCaution");
} else {
g.enqueueMessage("I need a way to disable this alarm.").openMessageBox();
}
} else {
g.enqueueMessage("This seems to be the box for the alarm. There doesn't seem to be any buttons on this box that allows me to disable it.").openMessageBox();
g.setSwitch("s003-inspectedAlarmBox")
}
} else {
g.enqueueMessage("Not sure what this box is for...")
g.enqueueMessage("I should follow the wire.")
.openMessageBox();
}
}, true),
new Trigger(TriggerType.interact, "s003-cabinet01",(g, d) => {
g.enqueueMessage("Locked.").openMessageBox();
}, true),
new Trigger(TriggerType.interact, "s003-cabinet02",(g, d) => {
g.enqueueMessage("Can't open it.").openMessageBox();
}, true),
new Trigger(TriggerType.interact, "s003-cabinet03",(g, d) => {
g.enqueueMessage("It's stuck.").openMessageBox();
}, true),
new Trigger(TriggerType.interact, "s003-door02",(g, d) => {
g.fadeToScene("s004");
}, true),
new Trigger(TriggerType.interact, "s003-staircase",(g, d) => {
if (g.getSwitch("global-timeWarp2") && !g.getSwitch("s005-knowsSecret")) {
g.enqueueMessage("No way am I going down there again without some form of protection.")
.openMessageBox();
return;
}
g.fadeToScene("s005");
}, true),
//S004
new Trigger(TriggerType.sceneEnter, "s004",(g, d) => {
g.playerElement.point = new Point(80, 250);
}, true),
new Trigger(TriggerType.interact, "s004-door01",(g, d) => {
g.fadeToScene("s003");
}, true),
new Trigger(TriggerType.interact, "s004-computer",(g, d) => {
if (g.getSwitch("global-timeWarp2")) {
g.enqueueMessage("Let's see if I can find something about that scientist.")
.enqueueMessage("Here's a recent employee update entry.")
.enqueueMessage("Employee ID #0023. Nicholas Andelberth -- Placed on leave of absence due to recent unacceptable behavioral incidents. The official conclusion is that this lapse in judgement and control was triggered by the recent unexplained dissappearance of his wife, Klara Andelberth. Another likely cause is prolonged exposure to [REDACTED].", "computer")
.enqueueMessage("Did his wife experience something similar to what I am?")
.openMessageBox((g)=>{
g.setSwitch("s005-knowsSecret")
});
} else {
g.enqueueMessage("It's not password protected. Let's see what's on here.")
.enqueueMessage("It's just personell files. I wouldn't even know what to look for.")
.openMessageBox();
}
}, true),
new Trigger(TriggerType.interact, "s004-cabinet01",(g, d) => {
g.enqueueMessage("Won't open.").openMessageBox();
}, true),
new Trigger(TriggerType.interact, "s004-plant",(g, d) => {
g.enqueueMessage("Plastic.").openMessageBox();
}, true),
//S005
new Trigger(TriggerType.sceneEnter, "s005",(g, d) => {
g.playerElement.point = new Point(80, 250);
if (!g.getSwitch("s005-knowsSecret")) {
g.wait(500, (g)=> {
g.setSwitch("s005-metScientist");
g.pause();
g.enqueueMessage("Who are you!? You are not supposed to be here!","scientist")
.enqueueMessage("I- I work here.")
.enqueueMessage("Lies!","scientist")
.openMessageBox((g)=>{
g.wait(500,(g)=> {
g.pause();
g.playSound("sfx_gunshot.ogg");
g.applyCameraEffect("shotOverlay");
g.setStateForPlayer(PlayerState.hurt);
g.enableSceneElement("s003-alarmBlock");
g.enableSceneElement("s003-alarmCaution");
g.setStateForSceneElement("s003-alarm", "");
g.clearSwitch("s003-alarmDisabled");
g.wait(2000,(g)=> {
g.clearCameraEffects();
g.setSwitch("global-timeWarp2");
g.timeWarp((g) => {
g.fadeToScene("s001");
})
})
});
});
})
} else {
g.wait(500, (g)=> {
g.pause();
g.enqueueMessage("Who are you!? You are not supposed to be here!","scientist")
.enqueueMessage("Professor Andelberth - I know about your wife! I know about Klara!")
.enqueueMessage("You... know.","scientist")
.openMessageBox((g) => {
g.setStateForSceneElement("s005-scientist", "relaxed");
});
});
}
}, true),
new Trigger(TriggerType.interact, "s005-staircase",(g, d) => {
if (g.getSwitch("s005-knowsSecret")) {
g.enqueueMessage("No point in leaving now.","scientist").openMessageBox();
}
}, true),
new Trigger(TriggerType.interact, "s005-scientist",(g, d) => {
if (!g.getSwitch("s005-talkedToScientist")) {
g.setSwitch("s005-talkedToScientist");
g.enqueueMessage("It was never supposed to turn out this way. We only wanted to use it for mining.","scientist")
.enqueueMessage("We found this... stone deep in the Raunisvaara mountain. With it, we have been able to mine the same vein of ore several times over. Corporate kept pushing for more results. We knew it was unstable. ","scientist")
.enqueueMessage("My wife Klara was the first victim, but I fear it is to blame for the recent dissappearances across town.","scientist")
.enqueueMessage("If you want to take it away. I will not hinder you. Do what you will.","scientist")
.openMessageBox();
} else {
g.enqueueMessage("Do what you will.","scientist").openMessageBox();
}
}, true),
new Trigger(TriggerType.interact, "s005-artifact",(g, d) => {
g.timeWarp((g) => {
g.fadeToScene("end");
})
}, true),
//END
new Trigger(TriggerType.sceneEnter, "end",(g, d) => {
g.enqueueMessage('To be continued...<br><br>Thanks for playing! This game was produced during 48 hours for <a href="http://ldjam.com/" target="_blank">Ludum Dare</a> for the theme of <em>Stuck in a loop</em>.<br><br>Please cosider <a href="https://ldjam.com/events/ludum-dare/47/the-trade-secret" target="_blank">rating the game and leaving a comment</a>.<br><br>Milestone Games',"game")
.openMessageBox()
}),
];