File: town1.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 (384 lines) | stat: -rw-r--r-- 13,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
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


-- town1 - "Ekla"

--
function autoexec()
  -- Remove Derig from the screen
  if (get_progress(9) < 4) or (get_progress(9) > 5) then
    set_ent_active(4, 0)
  else
    -- Move granddaughter to the chair next to the table
    local x, y = marker("by_derig")
    place_ent(2, x - 1, y - 2)
    set_ent_facing(2, 0)
    set_ent_facing(4, 0)
    if (get_progress(9) == 4) then
      set_desc(0)
      set_ent_facing(200, 1)
      set_ent_facing(201, 1)
      drawmap()
      screen_dump()
    end
  end
  -- Two people are wandering around until you use the transporter from Ajantara to Randen.
  if (get_progress(73) == 1) then
    set_ent_active(1, 0)
    set_ent_active(3, 0)
  end
  refresh()
end
function entity_handler(en)
  if (en == 0) then
    LOC_ekla_welcome(en)
  elseif (en == 1) then
    if (get_progress(2) == 0) then
      bubble(en, "There is a monster blocking the pass to Randen.")
    else
      bubble(en, "Now the monster is gone.")
    end -- 2
  elseif (en == 2) then
    LOC_talk_jen(en)
  elseif (en == 3) then
    if (get_progress(2) == 0) then
      bubble(en, "Stock up on weapons, magic, and experience.")
      bubble(en, "You'll need them against the monster blocking the entrance to Randen.")
    elseif (get_progress(2) == 1) then
      if (get_progress(38) == 0) then
        bubble(en, "The monster blocking Randen is gone, but there are still monsters underground.")
      elseif (get_progress(38) == 1) then
        bubble(en, "All the monsters are gone from the tunnel!")
      end -- 38
    end -- 2
  elseif (en == 4) then
    LOC_talk_derig(en)
  elseif (en == 5) then
    bubble(en, "I hid these works of art from Malkaron's forces. When they had come through here, they tried to destroy everything...")
  elseif (en == 6) then
    bubble(en, "Ever since monsters started appearing, my mother doesn't want me to go outdoors alone. It's so boring in here, though! I want to go out and play!")
  elseif (en == 7) then
    bubble(en, "My, my. This is beautiful work. How rare! How exquisite! How affordable!")
  end
end
function postexec()
  -- Monsters will not attack on the world map until 0 == 1
  if (get_progress(0) == 0) then
    msg("The strong-scented oils wore off.", 255, 0)
    set_progress(0, 1)
  end
  if (get_progress(9) == 4) then
    local en = 4
    bubble(en, "I'm Derig. If I'm here, then you found me in the Grotto.")
    bubble(en, "To stop the monsters in our underground tunnel, you must seal the portal.")
    bubble(en, "In order to do that, you can use a Rod of Cancellation to melt it shut.")
    bubble(en, "I brought you to town to get the Unadium Coin from my granddaughter, which will open the rune back at the Grotto.")
    bubble(en, "That will transport you to the place where the Rod of Cancellation is.")
    set_progress(9, 5)
  end
end
function refresh()
  -- Chest in magic shop
  if (get_treasure(0) == 1) then
    set_mtile("treasure1", 265)
    set_zone("treasure1", 0)
  end
  -- Cauldron next to item shop
  if (get_treasure(6) == 1) then
    set_zone("treasure2", 0)
  end
  -- Patch of flowers behind houses
  if (get_treasure(98) == 1) then
    set_zone("treasure3", 0)
    set_obs("treasure3", 0)
  end
end
function zone_handler(zn)
  if (zn == 1) then
    change_map("main", "town1")
  elseif (zn == 2) then
    inn("The Blue Boar Inn", 25, 1)
  elseif (zn == 3) then
    shop(0)
  elseif (zn == 4) then
    shop(1)
  elseif (zn == 5) then
    shop(2)
  elseif (zn == 6) then
    bubble(200, "Locked.")
  elseif (zn == 7) then
    change_map("cave1", "entrance")
  elseif (zn == 8) then
    chest(0, 161, 1)
    refresh()
  elseif (zn == 9) then
    bubble(255, "I don't have much.")
    shop(3)
  elseif (zn == 10) then
    door_in("inn_i")
  elseif (zn == 11) then
    door_out("inn_o")
  elseif (zn == 12) then
    door_in("shop_4i")
  elseif (zn == 13) then
    door_out("shop_4o")
  elseif (zn == 14) then
    door_in("shop_2i")
  elseif (zn == 15) then
    door_out("shop_2o")
  elseif (zn == 16) then
    door_in("shop_1i")
  elseif (zn == 17) then
    door_out("shop_1o")
  elseif (zn == 18) then
    door_in("shop_3i")
  elseif (zn == 19) then
    door_out("shop_3o")
  elseif (zn == 20) then
    chest(6, 104, 1)
    refresh()
  elseif (zn == 21) then
    book_talk(party[0])
  elseif (zn == 22) then
    door_in("derig_i")
  elseif (zn == 23) then
    door_out("derig_o")
  elseif (zn == 24) then
    touch_fire(party[0])
  elseif (zn == 25) then
    chest(98, 0, 155)
    refresh()
  elseif (zn == 26) then
    thought(200, "`Erupting Volcano'")
  elseif (zn == 27) then
    thought(200, "`Mountain Nightscape'")
  elseif (zn == 28) then
    thought(200, "`My Barn Chimney'")
  elseif (zn == 29) then
    thought(200, "`The Beach Front'")
  elseif (zn == 30) then
    thought(200, "`The Eye of Sardine'", "Hmm, sounds strangely familiar.")
  elseif (zn == 31) then
    thought(200, "`The Battle Is Over'")
  elseif (zn == 32) then
    thought(200, "`Forgotten Barn'")
  elseif (zn == 33) then
    thought(200, "`Fire Sunset'")
  elseif (zn == 34) then
    bubble(5, "This is my art collection. Any piece of work starting at only 300000 GP!")
  elseif (zn == 35) then
    bubble(200, "This armour has been highly polished. I can see myself in it!")
  elseif (zn == 36) then
    bubble(200, "Nothing in here but antique junk.")
  elseif (zn == 37) then
    bubble(200, "The drawers are locked.")
  elseif (zn == 38) then
    bubble(200, "This is the price list for all of these items.")
  elseif (zn == 39) then
    bubble(200, "None of these potions or herbs are useful.")
  elseif (zn == 40) then
    door_in("shop_5i")
  elseif (zn == 41) then
    door_out("shop_5o")
  end
end
function LOC_ekla_welcome(en)
  if (get_progress(73) == 0) then
    if (get_progress(12) == 0) then
      bubble(en, "Welcome to the town of Ekla.")
      bubble(en, "Yes! That makes eight. If I welcome enough newcomers to this town, I will get promoted.")
      bubble(en, "I might get a job sitting in a house all day saying the same thing over and over to anyone who talks to me.")
      bubble(en, "I should start practicing.")
      set_progress(12, 1)
    else
      bubble(en, "I like cheese.")
    end
  else -- 73
    if (get_progress(12) == 0) then
      bubble(en, "I welcome people to Ekla.")
      bubble(en, "Welcome back.")
    else
      bubble(en, "I welcomed you already. You're in Ekla.")
    end
  end -- 73
end
--
--
--
--
--
function LOC_help_jen_portal(en)
  if (get_progress(37) == 0) then
    LOC_help_town_rod(en)
  elseif (get_progress(2) == 0) then
    LOC_help_town_boss(en)
  elseif (get_progress(73) == 0) then
    LOC_help_town_warpstone(en)
  else
    LOC_help_town_none(en)
  end
end
--
--
--
function LOC_help_jen_tsorin(en)
  if (get_progress(9) == 0) then
    LOC_help_tsorin_derig(en)
  else
    LOC_help_tsorin_tsorin(en)
  end
end
--
--
--
function LOC_help_town_derig(en)
  if (get_progress(9) < 3) then
    LOC_help_derig_coin(en)
  elseif (get_progress(37) == 0) then
    LOC_help_derig_rod(en)
  else
    LOC_help_derig_portal(en)
  end
end
--
--
function LOC_help_town_rod(en)
  if (get_progress(36) < 2) then
    LOC_help_town_derig(en)
  end
end
function LOC_talk_derig(en)
  if (get_progress(108) == 0 or
      get_progress(108) > 2) then
    if (get_progress(9) == 5) then
      if (get_progress(36) == 1) then
        bubble(en, "Talk to Jen to get the Unadium coin.")
      elseif (get_progress(36) == 2) then
        if (get_progress(37) == 0) then
          bubble(en, "Go get the Rod of Cancellation out of the grotto. Use the rune.")
        elseif (get_progress(37) == 1) then
          if (get_progress(38) == 0) then
            bubble(en, "Now that you have the rod, go down and seal the portal.")
          elseif (get_progress(38) == 1) then
            bubble(en, "You've done it! The portal is gone, and you have returned the Unadium coin and Rod of Cancellation.")
            set_progress(36, 3)
            set_progress(37, 2)
            set_progress(9, 6)
            msg("Derig takes the Rod of Cancellation and Unadium Coin.", 255, 0)
            bubble(en, "I'll take these back to the grotto for safe keeping. Thank you.")
          end -- 38
        end -- 37
      end -- 36
    elseif (get_progress(9) == 6) then
      -- Although TALKDERIG==6, Derig will still be on the screen until you leave Ekla and return
      bubble(en, "I will take these back to the grotto. Thanks again.")
    end -- 9
  elseif (get_progress(108) == 1) then
    bubble(en, "Ah yes, $0, I... wait a minute! What is that note you are carrying?")
    msg("You show Derig the note.", 18, 0)
    bubble(en, "Oh, this is very important. Yes, of utmost importance.")
    bubble(en, "Forgive me, $0, but Tsorin writes that the Oracle's Statue has been stolen. This causes great reason for concern.")
    bubble(200, "What's the big emergency?")
    bubble(en, "No time for that now. Please, take this note to Tsorin. I authorize you to pass into the goblin lands.")
    msg("Derig continues to mumble worredly.", 255, 0)
    thought(200, "Boy, this is just too weird all of a sudden.")
    msg("Derig hands you a sealed envelope.", 18, 0)
    set_progress(108, 2)
  elseif (get_progress(108) == 2) then
    bubble(en, "Please hurry. Take this note to Tsorin immediately!")
  else
    --
  end -- 108
end
-- Jen will provide assistance in this order:
-- 1: Tsorin (war is top priority)
-- 2: Town (monsters in tunnel)
-- 3: Self (she wants her coin back)
-- 4: No extra assistance needed
function LOC_talk_jen (en)
  -- Jen will only help you if you are not on Official Business for Tsorin
  if (get_progress(108) == 0 or
      get_progress(108) > 2) then
    -- You have never spoken to Jen before
    if (get_progress(36) == 0) then
      if (get_progress(9) == 0) then
        -- You have never gone to the grotto.
        bubble(en, "Jen:", "I'm Derig's granddaughter. Go find Derig in the grotto north of here.")
      elseif (get_progress(9) == 1) then
        -- You entered the grotto, but did not fall in the pit.
        bubble(en, "Jen:", "I'm Derig's granddaughter. Go find Derig in the grotto north of here. You've been there once before.")
      elseif (get_progress(9) == 2) then
        -- You entered the grotto and fell in pit (you had NOT spoken to Jen first, though). Someone helped you get out.
        bubble(en, "You've already been to the grotto.")
        if (get_numchrs() > 1) then
          bubble(200, "Yes, we fell down a hole and someone pulled us out.")
        else
          bubble(200, "Yes, I fell down a hole and someone pulled me out.")
        end
        bubble(en, "That is Derig, my grandfather. Go back and look for him.")
      else
        -- This should never occur
        bubble(en, "Scripting Error:", "P_UCOIN == 0, but P_TALKDERIG != 0..2")
      end
      -- Now you have spoken to Jen
      set_progress(36, 1)
    -- You have spoken to Jen at least once
    elseif (get_progress(36) == 1) then
      if (get_progress(9) == 0) then
        bubble(en, "I said to go talk to Derig.")
      elseif (get_progress(9) == 1) then
        -- You entered the grotto, but did not fall in the pit.
        bubble(en, "You must find Derig in the grotto. He's there somewhere.")
      elseif (get_progress(9) == 2) then
        bubble(en, "Well? Go find Derig in the grotto!")
      elseif (get_progress(9) == 3) then
        bubble(en, "Okay, that was stupid. You saw him by the fire and you didn't talk to him.")
        if (get_numchrs() == 1) then
          bubble(en, "GO BACK AND TALK TO HIM! He's sitting by the fire you moron!")
        else
          bubble(en, "GO BACK AND TALK TO HIM! He's sitting by the fire you morons!")
        end
      elseif (get_progress(9) == 4) then
        -- This should never occur
        bubble(en, "Scripting Error:", "P_UCOIN == 1, but P_TALKDERIG == 4")
      elseif (get_progress(9) == 5) then
        -- Met Derig
        bubble(en, "Good. Now that you found Derig, here is the Unadium Coin.")
        set_progress(36, 2)
        msg("Unadium coin procured", 255, 0)
      end -- 9
    elseif (get_progress(36) == 2) then
      -- You now have the Unadium coin
      if (get_progress(9) == 5) then
        if (get_progress(37) == 0) then
          -- You do not have the rod
          bubble(en, "Go get the Rod of Cancellation.")
        elseif (get_progress(37) == 1) then
          -- You have the rod
          if (get_progress(38) == 0) then
            -- The portal is still there
            bubble(en, "Get rid of the portal now.")
          elseif (get_progress(38) == 1) then
            -- The portal is gone
            bubble(en, "You got rid of the portal! Give my father the coin and rod back and I'll give you a SunStone.")
          end -- 38
        end -- 37
      else
        -- This should never occur
        bubble(en, "Scripting Error:", "P_UCOIN == 2, but P_TALKDERIG != 5")
      end -- 9 == 5
    elseif (get_progress(36) == 3) then
      -- Returned Rod of Cancellation to Derig
      if (get_treasure(45) == 0) then
        bubble(en, "Thanks for returning the Rod to my grandfather. Here is a SunStone for you.")
        chest(45, 121, 1)
      else
        bubble(en, "Thanks again.")
      end
    end -- 36
  elseif (get_progress(108) == 1) then
    bubble(en, "Jen:", "You must be looking for Derig, my grandfather. Find him in the grotto north of here.")
  elseif (get_progress(108) == 2) then
    bubble(en, "You should finish Derig's assignment before I give you another.")
  end -- 108
--
end