summary refs log tree commit diff stats
path: root/res/scripts/hallucination_mirror.lua
blob: afacd59c5f0e2bb53984a3565d4b84e717eb62a5 (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
hallucination_mirror = {}

function hallucination_mirror.init()
  coroutine.yield()
  -- This routine makes the player's party face the mirror if they are standing
  -- in front of it for a few (5) seconds. The fact that this has to run
  -- continuously makes it a bit complicated, and is why we keep checking that
  -- we're on the same map.
  while getMap():getName() == "hallucination_mirror" do
    if IsSpriteInZone("lucas", "mirror_sight") and IsSpriteInZone("kuma", "mirror_sight") and IsSpriteInZone("duster", "mirror_sight") and IsSpriteInZone("boney", "mirror_sight") then
      timer = 5000 -- milliseconds
      while timer > 0 and getSprite(getPlayerSprite()).characterState == CharacterState.STILL and getMap():getName() == "hallucination_mirror" and not message().isMessageActive do
        timer = timer - coroutine.yield()
      end

      if timer <= 0 and getSprite(getPlayerSprite()).characterState == CharacterState.STILL and getMap():getName() == "hallucination_mirror" and not message().isMessageActive then
        SetPartyDirection(getPlayerSprite(), Direction.UP)
      end
    end

    coroutine.yield()
  end
end

function hallucination_mirror.off_left()
  ChangeMap("hallucination_interior", "fromRight")
end

function hallucination_mirror.mailbox()
  StartCutscene()
  DisplayMessage("* The mailbox lid is open...\n* Peek inside?", "", SpeakerType.NONE)
  ShowChoice("Yes", "No")
  WaitForEndOfMessage()

  if GetChoiceSelection() == 1 then
    HideCutsceneBars()
    return
  end

  DisplayMessage("* Inside the mailbox is a poem.\n* Read it?", "", SpeakerType.NONE)
  ShowChoice("Yes", "No")
  WaitForEndOfMessage()

  if GetChoiceSelection() == 1 then
    HideCutsceneBars()
    return
  end

  if not gamestate.read_mirror_message then
    animation():initSprite(getSpriteByAlias("double_lucas"), "../res/sprites/claus_anim.txt")
    animation():initSprite(getSpriteByAlias("double_kuma"), "../res/sprites/ionia_anim.txt")
    animation():initSprite(getSpriteByAlias("double_duster"), "../res/sprites/wess_anim.txt")
    --animation():initSprite(getSpriteByAlias("double_boney"), "../res/sprites/claus_anim.txt")
  end

  gamestate.read_mirror_message = true

  DisplayMessage("* <Your eyes that watch me walking by\nYour ears that listen to me cry\nYour mouth, alit with laughter strong\nYour forehead creased to say I'm wrong>\n* <They think you're dead, but here you stare\nReflected in the mirror's glare\nWith pounding fists and fevered moans\nThat shake me to my very bones>\n* <One day I know you'll fall right through\nTo haunt me in my life anew>\n\f...\n\f* You get the feeling you're being watched.", "", SpeakerType.NONE)
  WaitForEndOfMessage()
  HideCutsceneBars()
end

function hallucination_mirror.examine_mirror()
  StartCutscene()
  Halt("double_lucas")
  Halt("double_kuma")
  Halt("double_duster")
  Halt("double_boney")

  if gamestate.read_mirror_message then
    DisplayMessage("* Something seems wrong about this.", "", SpeakerType.NONE)
  else
    DisplayMessage("* Looking handsome.", "", SpeakerType.NONE)
  end

  WaitForEndOfMessage()
  HideCutsceneBars()
end