summary refs log tree commit diff stats
path: root/res/scripts/hallucination_cliff.lua
blob: 51fa4339c1472970e1237222792cbbb2a759c1be (plain) (blame)
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
hallucination_cliff = {}

function hallucination_cliff.init()
  gamestate.hinawa_can_appear = false
  if gamestate.saw_hinawa_first_scene then
    if gamestate.saw_hinawa_second_scene then
      -- the event can no longer trigger if the player leaves the map after
      -- seeing hinawa a second time.
    else
      -- as long as nothing else prevents the scene from occuring, a player
      -- who interrupted the hinawa event by leaving the map before seeing her
      -- a second time is allowed to resume the event.
      gamestate.hinawa_can_appear = true
      MoveSpriteToWarp("hinawa", "hinawa_second_position")
    end
  else
    -- the hinawa event only has a 50% chance of triggering; reloading the map
    -- rolls this again.
    if randomChance(1.0/2.0) then
      gamestate.hinawa_can_appear = true
    end
  end
  -- the hinawa event will not occur if claus ever joined the party.
  if gamestate.claus_joined then
    gamestate.hinawa_can_appear = false
  end
  -- if hinawa can't appear, remove her from the map.
  if not gamestate.hinawa_can_appear then
    DestroyNamedSprite("hinawa")
  end
end

function hallucination_cliff.off_bottom()
  ChangeMap("hallucination_interior", "fromTop")
end

function hallucination_cliff.off_left()
  ChangeMap("hallucination_hot_spring", "fromRight")
end

function hallucination_cliff.enter_door()
  CreateAnimatedSpriteAtWarpPoint("entryway", "entryway", "entryway_appear", "pink_shell", Direction.DOWN, SpriteLayer.NORMAL)
  PlaySound("door_open.wav")
  ChangeMap("pink_shell", "fromOutside")
end

function hallucination_cliff.talk_to_nana()
  if not gamestate.talked_to_nana_times then
    gamestate.talked_to_nana_times = 0
  end

  StartCutscene()

  if gamestate.talked_to_nana_times == 0 then
    SetAnimation("nana", "talk")
    DisplayMessage("* Don't talk to me.", "Nana", SpeakerType.WOMAN)
  elseif gamestate.talked_to_nana_times == 1 then
    SetAnimation("nana", "talk")
    DisplayMessage("* Go bother someone else.", "Nana", SpeakerType.WOMAN)
  elseif gamestate.talked_to_nana_times == 2 then
    SetAnimation("nana", "talk")
    DisplayMessage("* I only talked to you out of pity.", "Nana", SpeakerType.WOMAN)
  elseif gamestate.talked_to_nana_times >= 3 and gamestate.talked_to_nana_times < 6 then
    DisplayMessage("* ...", "Nana", SpeakerType.WOMAN)
  elseif gamestate.talked_to_nana_times >= 6 then
    SetAnimation("nana", "talk")
    DisplayMessage("* Shut up shut up shut up!\n\f* Can't you take a hint, you stupid boy?", "Nana", SpeakerType.WOMAN)
  end

  WaitForEndOfMessage()

  gamestate.talked_to_nana_times = gamestate.talked_to_nana_times + 1

  SetAnimation("nana", "still")
  SetDirection("nana", Direction.RIGHT)
  HideCutsceneBars()
end

function hallucination_cliff.claus_fall_event()
  -- do not trigger if we don't have claus
  if not gamestate.still_has_claus then
    return
  end

  -- do not trigger a second time
  if gamestate.claus_fall_scene then
    return
  end

  gamestate.claus_fall_scene = true

  -- have the player automatically climb most of the ladder. this is to ensure
  -- that Claus is off screen when the event triggers.
  DisablePlayerControl()
  Halt("lucas")
  DirectSpriteToLocation("lucas", "near_top_first_ladder", PathfindingOptions.CARDINAL_DIRECTIONS_ONLY)
  WaitForSpritePath("lucas")
  DisableBehaviour("lucas")

  StartCutscene(CutsceneOptions.DO_NOT_CHANGE_ANIMATION)
  DisplayMessage("* Aiee!", "Claus", SpeakerType.MAN)
  PlaySound("wobble_and_fall.wav")
  WaitForEndOfMessage()

  Delay(1000)

  PlaySound("thud.wav")
  ShakeCamera(100)
  Delay(50)

  ShowExpression("lucas", "surprise")
  Delay(50)

  ShowExpression("kuma", "surprise")
  ShowExpression("duster", "surprise")
  Delay(100)

  StopShakingCamera()
  Delay(1000)

  MoveSpriteToWarp("join_claus", "claus_fall_location")
  SetDirection("join_claus", Direction.LEFT)
  SetAnimation("join_claus", "collapsed")
  PanToSprite("join_claus", 4000)
  Delay(1000)

  RemoveExpression("lucas")
  RemoveExpression("kuma")
  RemoveExpression("duster")
  WaitForPan()

  Delay(1000)

  -- we need to break up the party to detach Claus anyway, and while we're there
  -- we should turn down the movement speed because the pathfinding algorithm
  -- doesn't take media into consideration, and if we don't change the speed
  -- before adding the other characters back, they'll bunch up as they move down
  BreakUpParty("lucas")
  SetMovementSpeed("lucas", 1)
  character():addSpriteToParty(getPlayerSprite(), getSpriteByAlias("kuma"))
  character():addSpriteToParty(getPlayerSprite(), getSpriteByAlias("duster"))
  character():addSpriteToParty(getPlayerSprite(), getSpriteByAlias("boney"))

  UnpauseSprite("lucas")
  DirectSpriteToLocation("lucas", "near_bottom_first_ladder", PathfindingOptions.CARDINAL_DIRECTIONS_ONLY)
  WaitForSpritePath("lucas")
  DisableBehaviour("lucas")
  PauseSprite("lucas")
  SetAnimation("lucas", "frozen") -- so he doesn't blink
  Delay(1000)

  DisplayMessage("* Lucas, you shouldn't have let me fall!\n\f* It's your fault I got hurt!\n\f* I can't get up...", "Claus", SpeakerType.MAN)
  WaitForEndOfMessage()

  DisplayMessage("* Help him up?", "", SpeakerType.NONE)
  ShowChoice("Yes", "No")
  WaitForEndOfMessage()

  -- TODO: rest of scene

  -- same as before but less justifiable because the only reason we're doing
  -- this is to fix the movement trails
  -- BreakUpParty("lucas")
  -- SetMovementSpeed("lucas", 2)
  -- character():addSpriteToParty(getPlayerSprite(), getSpriteByAlias("kuma"))
  -- character():addSpriteToParty(getPlayerSprite(), getSpriteByAlias("duster"))
  -- character():addSpriteToParty(getPlayerSprite(), getSpriteByAlias("boney"))
end

function hallucination_cliff.see_hinawa_first_event()
  -- for safety, check if the claus falling event is happening, since it moves
  -- the party into this event's trigger.
  if gamestate.claus_fall_scene then
    return
  end

  -- the scene only triggers under certain circumstances (see the init function)
  if not gamestate.hinawa_can_appear then
    return
  end

  -- do not trigger a second time
  if gamestate.saw_hinawa_first_scene then
    return
  end

  gamestate.saw_hinawa_first_scene = true

  StartCutscene(CutsceneOptions.DO_NOT_CHANGE_ANIMATION)
  Delay(100)

  ShowExpression("lucas", "surprise")
  ShowExpression("kuma", "surprise")
  ShowExpression("duster", "surprise")
  Delay(1000)

  PanToWarpPoint("first_hinawa_vantage", 2000)
  Delay(750)

  RemoveExpression("lucas")
  RemoveExpression("kuma")
  RemoveExpression("duster")
  WaitForPan()
  Delay(2000)

  UnpauseSprite("hinawa")
  DirectSpriteToLocation("hinawa", "hinawa_offscreen_first", PathfindingOptions.CARDINAL_DIRECTIONS_ONLY)
  WaitForSpritePath("hinawa")

  DisableBehaviour("hinawa")
  PauseSprite("hinawa")
  MoveSpriteToWarp("hinawa", "hinawa_second_position")
  Delay(2000)
  ReturnCamera(1000)
  Delay(500)

  DisplayMessage("* Lucas... Was that...?", "Kumatora", SpeakerType.WOMAN)
  WaitForEndOfMessage()

  HideCutsceneBars(CutsceneOptions.DO_NOT_CHANGE_ANIMATION)
end

function hallucination_cliff.see_hinawa_second_event()
  -- only trigger this scene if the first half of the scene has occured and the
  -- event hasn't been disabled.
  if not (gamestate.hinawa_can_appear and gamestate.saw_hinawa_first_scene) then
    return
  end

  -- do not trigger a second time.
  if gamestate.saw_hinawa_second_scene then
    return
  end

  gamestate.saw_hinawa_second_scene = true

  -- automatically move lucas forward enough that he is no longer on the ladder.
  DisablePlayerControl()
  Halt("lucas")
  DirectSpriteToLocation("lucas", "second_hinawa_vantage", PathfindingOptions.CARDINAL_DIRECTIONS_ONLY)
  WaitForSpritePath("lucas")
  DisableBehaviour("lucas")

  StartCutscene(CutsceneOptions.DO_NOT_CHANGE_ANIMATION)
  Delay(1000)

  -- we need to do this because a lot of pathfinding is going to fire off almost
  -- at the same time, and while the paths the characters take should not
  -- actually intersect, the pathfinding is done with only their starting
  -- positions in mind.
  MakeSpriteNotSolid("hinawa")
  MakeSpriteNotSolid("lucas")
  MakeSpriteNotSolid("kuma")
  MakeSpriteNotSolid("duster")
  MakeSpriteNotSolid("boney")

  -- hinawa walks to the left, then turns to look at lucas.
  UnpauseSprite("hinawa")
  DirectSpriteToLocation("hinawa", "hinawa_mid_checkpoint", PathfindingOptions.CARDINAL_DIRECTIONS_ONLY)
  WaitForSpritePath("hinawa")
  DisableBehaviour("hinawa")
  Delay(1500)

  SetDirection("hinawa", Direction.DOWN_LEFT)
  Delay(100)
  SetDirection("hinawa", Direction.DOWN)
  Delay(100)
  SetDirection("hinawa", Direction.DOWN_RIGHT)
  Delay(2000)
  SetDirection("hinawa", Direction.RIGHT)
  Delay(250)

  -- hinawa then walks off the cliff.
  DirectSpriteToLocation("hinawa", "hinawa_off_cliff", PathfindingOptions.CARDINAL_DIRECTIONS_ONLY | PathfindingOptions.MOONWALKING)
  Delay(1000)

  -- lucas walks after her, while the rest of the party gather a little behind
  -- him. because of this, we need to break apart the party, since they are all
  -- going to have independent walking patterns.
  BreakUpParty("lucas")
  UnpauseSprite("lucas")
  SetMovementSpeed("lucas", 1)
  DirectSpriteToLocation("lucas", "hinawa_mid_checkpoint")
  Delay(1000)

  UnpauseSprite("kuma")
  UnpauseSprite("duster")
  UnpauseSprite("boney")
  SetMovementSpeed("kuma", 1)
  SetMovementSpeed("duster", 1)
  SetMovementSpeed("boney", 1)
  DirectSpriteToLocation("kuma", "kuma_watch_point")
  DirectSpriteToLocation("duster", "hinawa_second_position")
  DirectSpriteToLocation("boney", "boney_watch_point")

  WaitForSpritePath("hinawa")
  DisableBehaviour("hinawa")
  SetDirection("hinawa", Direction.RIGHT)

  WaitForSpritePath("lucas")
  DisableBehaviour("lucas")
  SetDirection("lucas", Direction.LEFT)
  SetAnimation("lucas", "frozen")

  WaitForSpritePath("kuma")
  DisableBehaviour("kuma")
  SetDirection("kuma", Direction.LEFT)
  SetAnimation("kuma", "frozen")

  WaitForSpritePath("duster")
  DisableBehaviour("duster")
  SetDirection("duster", Direction.LEFT)
  SetAnimation("duster", "frozen")

  WaitForSpritePath("boney")
  DisableBehaviour("boney")
  SetDirection("boney", Direction.LEFT)
  SetAnimation("boney", "frozen")

  MakeSpriteSolid("hinawa")
  MakeSpriteSolid("lucas")
  MakeSpriteSolid("kuma")
  MakeSpriteSolid("duster")
  MakeSpriteSolid("boney")

  -- TODO: rest of scene
end