File: town7.lua

package info (click to toggle)
kq 0.99.cvs20070319-1.1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 8,344 kB
  • ctags: 2,870
  • sloc: ansic: 26,328; sh: 3,737; makefile: 203; perl: 100
file content (258 lines) | stat: -rw-r--r-- 5,546 bytes parent folder | download
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


-- town7 - "Pulcannen"

--

function autoexec()

  if ((get_progress(110) == 0) and
      (get_progress(43) > 0) and
      (get_progress(50) > 0) and
      (get_progress(69) > 0) and
      (get_progress(90) > 0)) then
    set_progress(110, 1)
  end

  if (get_progress(112) == 1) then
    set_progress(112, 0)
  end

  refresh()
end


function entity_handler(en)
  if (en == 0) then
    bubble(en, "You'll find great things here.")

  elseif (en == 1) then
    bubble(en, "Things here are rather pricey.")

  elseif (en == 2) then
    bubble(en, "It's quite peaceful here.", "I like it.")

  elseif (en == 3) then
    bubble(en, "I love the sea.")

  elseif (en == 4) then
    bubble(en, "Nothing exciting ever happens here.")

  elseif (en == 5) then
    bubble(en, "This town does not get a lot of visitors.")

  elseif (en == 6) then
    LOC_talk_oldman(en)

  end
end


function postexec()
  return
end


function refresh()
  showch("treasure1", 71)
  showch("treasure2", 72)

  LOC_setup_oldman(6)
end


-- Show the status of a treasures
function showch(which_marker, which_chest)
  -- Set tiles if chest already opened
  if (get_treasure(which_chest) == 1) then
    set_zone(which_marker, 0)
  end

  -- Only treasure1 needs to keep its obstacle setting
  if (which_marker ~= "treasure1") then
    set_obs(which_marker, 0)
  end
end


function zone_handler(zn)
  if (zn == 1) then
    change_map("main", "town7")

  elseif (zn == 2) then
    door_in("shop_1i")

  elseif (zn == 3) then
    door_in("shop_2i")

  elseif (zn == 4) then
    door_in("shop_3i")

  elseif (zn == 5) then
    door_in("room_1i")

  elseif (zn == 6) then
    door_in("room_2i")

  elseif (zn == 7) then
    door_out("shop_1o")

  elseif (zn == 8) then
    door_out("shop_2o")

  elseif (zn == 9) then
    door_out("shop_3o")

  elseif (zn == 10) then
    door_out("room_1o")

  elseif (zn == 11) then
    door_out("room_2o")

  elseif (zn == 12) then
    if (get_progress(110) > 0) then
      door_in("counter_i")
    else
      bubble(200, "Locked.")
    end

  elseif (zn == 13) then
    shop(19)

  elseif (zn == 14) then
    shop(20)

  elseif (zn == 15) then
    shop(21)

  elseif (zn == 16) then
    inn("Pulcannen Inn", 200, 1)

  elseif (zn == 17) then
    warp("dstairs1", 8)

  elseif (zn == 18) then
    warp("dstairs2", 8)

  elseif (zn == 19) then
    warp("ustairs1", 8)

  elseif (zn == 20) then
    warp("ustairs2", 8)

  elseif (zn == 21) then
    chest(71, 117, 1)

  elseif (zn == 22) then
    chest(72, 120, 1)
    refresh()

  elseif (zn == 23) then
    book_talk(party[0])

  elseif (zn == 24) then
    touch_fire(party[0])

  elseif (zn == 25) then
    door_out("counter_o")

  elseif (zn == 26) then
    entity_handler(6)

  elseif (zn == 27) then
    bubble(200, "This door appears locked.")

  elseif (zn == 28) then
    bubble(200, "This door appears locked.")

  elseif (zn == 29) then
    bubble(200, "Locked.")

  elseif (zn == 30) then
    bubble(200, "This barrel is filled with rainwater.")

  elseif (zn == 31 or zn == 32) then
    bubble(200, "The chest is locked.")

  elseif (zn == 33) then
    set_progress(112, 1)
    change_map("cave3a", "portal")

  end
end


-- Allow player to go visit the old man
function LOC_setup_oldman(en)
  if (get_progress(110) == 1) then
    set_obs("door1", 0)
  elseif (get_progress(110) > 1) then
    place_ent(en, "around_table")
    set_ent_facing(en, 0)
    local x, y = marker("counter")
    set_zone(x, y - 3, 0)
    set_zone(x, y, 0)
    if (get_progress(110) == 5) then
      --
      set_obs("hdoor1", 0)
      set_obs("hdoor2", 0)
    end
  end
end


function LOC_talk_oldman(en)
  local x, y = marker("counter")

  if (get_progress(110) == 0) then
    bubble(en, "Hey, how did you get in here? Get out!")
  elseif (get_progress(110) == 1) then
    set_ent_speed(en, 5)
    set_ent_movemode(en, 2)
    -- Move the old man to the counter closest to you
    if (get_ent_tiley(200) == 22) then
      -- Move old man to top (northern) counter
      move_entity(en, x, y - 2, 0)
      wait_for_entity(en, en)
      set_ent_facing(en, 1)
    else
      -- Move old man to bottom (southern) counter
      move_entity(en, x, y - 1, 0)
      wait_for_entity(en, en)
      set_ent_facing(en, 0)
    end
    bubble(en, "Wow! You have all the Opal items! Quick, come up here to my study and let me see them!")
    -- Unlock doors that lead behind his counters
    set_obs("hdoor1", 0)
    set_obs("hdoor2", 0)
    set_ent_speed(en, 5)

    move_entity(en, "around_table", 0)
    wait_for_entity(en, en)
    set_ent_facing(en, 0)
    set_ent_movemode(en, 0)

    set_progress(110, 2)
    refresh()
  elseif (get_progress(110) == 2) then
    bubble(en, "I see you have everything! Here, take this key.")
    sfx(5)
    msg("Rusty key procured", 63, 0)
    bubble(en, "This key will open the temple found in the Grotto around Ekla.")
    if (get_numchrs() == 1) then
      bubble(200, "The Grotto by Ekla? What will I find there?")
    else
      bubble(200, "The Grotto by Ekla? What will we find there?")
    end
    bubble(en, "It's an underwater tunnel that leads from the grotto to the island Malkaron is staying.")
    bubble(200, "Oh. Thanks!")
    set_progress(110, 3)
  elseif (get_progress(110) == 3) then
    bubble(en, "I hope the key still fits in the temple down in the Grotto by Ekla. It's a bit rusty.")
  elseif (get_progress(110) == 4) then
    bubble(en, "I see the key worked. Excellent.")
    set_progress(110, 5)
  else
    bubble(en, "Good luck on your journey.")
  end
end