File: main.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 (454 lines) | stat: -rw-r--r-- 9,137 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
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
451
452
453
454


-- main - "World map of Anistal"

function autoexec()
  local x, y
  if (get_progress(8) < 2) then
    x, y = marker("bridge")
    if (get_progress(8) == 0) then
      set_mtile(x, y, 82)
    end
    set_btile(x - 1, y, 80)
    set_btile(x + 1, y, 80)
    set_obs(x, y, 1)
    set_zone(x - 1, y, 7)
    set_zone(x + 1, y, 71)
  end

  if (get_progress(32) == 1 or
      get_progress(32) == 3) then
    x, y = marker("tower")
    set_obs(x, y - 1, 0)
  end

  if (get_progress(44) > 0 and
      get_progress(106) > 0 and
      get_progress(107) > 0) then
    x, y = marker("camp")
    set_zone(x, y, 0)
  end

  if ((get_progress(43) == 1) and
      (get_progress(50) == 1) and
      (get_progress(69) == 1) and
      (get_progress(90) == 1)) then
    x, y = marker("cave6a")
    set_zone(x, y - 1, 73)
  end
end


function entity_handler(en)
  return
end


function postexec()
  return
end


function zone_handler(zn)
  local x, y

  if (zn == 1) then
    change_map("manor", "entrance")

  elseif (zn == 2) then
    if (get_progress(0) == 1) then
      if (in_forest(200)) then
        combat(27)
      else
        combat(28)
      end
    end

  elseif (zn == 3) then
    change_map("town1", "entrance")

  elseif (zn == 4) then
    change_map("town2", "entrance")

  elseif (zn == 5) then
    if (in_forest(200)) then
      combat(29)
    else
      combat(30)
    end

  elseif (zn == 6) then
    if (in_forest(200)) then
      combat(31)
    else
      combat(32)
    end

  elseif (zn == 7) then
    if (get_progress(10) == 5) then
      set_ent_facing(200, 2)
      change_map("bridge2", "entrance")
    else
      set_ent_facing(200, 2)
      change_map("bridge", "entrance")
    end

  elseif (zn == 8) then
    change_map("town3", "entrance")

  elseif (zn == 9) then
    change_map("grotto", "entrance")

  elseif (zn == 10) then
    change_map("fort", "entrance")

  elseif (zn == 11) then
    change_map("fort", "exit")

  elseif (zn == 12) then
    change_map("cave3a", "entrance")

  elseif (zn == 13) then
    change_map("cave3a", "exit")

  elseif (zn == 14) then
    if (get_progress(32) == 0) then
      if (get_progress(17) == 1) then
        set_progress(32, 1)
        set_progress(17, 2)
        bubble(200, "Hey! The pendant is glowing!")
        bubble(255, "The doors fly open and the pendant disappears in a puff of smoke.")
      elseif (get_progress(55) == 2) then
        set_progress(32, 1)
        bubble(200, "The doors open with a shower of rust.")
      else
        bubble(200, "The tower appears to be sealed. Maybe we need something to get in here?")
      end
    end

    if (get_progress(32) == 2) then
      bubble(200, "I can't get in here anymore!")
    elseif (get_progress(32) > 0) then
      change_map("tower", "entrance")
    end

  elseif (zn == 15) then
    if (in_forest(200)) then
      combat(33)
    else
      combat(34)
    end

  elseif (zn == 16) then
    if (in_forest(200)) then
      combat(35)
    else
      combat(36)
    end

  elseif (zn == 17) then
    change_map("temple1", "entrance")

  elseif (zn == 18) then
    change_map("town4", "entrance")

  elseif (zn == 19) then
    change_map("camp", "entrance")

  elseif (zn == 20) then
    change_map("estate", "entrance")

  elseif (zn == 21) then
    if (get_progress(103) == 7) then
      set_progress(103, 6)
      change_map("town5", "exit")
    else
      change_map("town5", "entrance")
    end

  elseif (zn == 22) then
    if (in_forest(200)) then
      combat(37)
    else
      combat(38)
    end

  elseif (zn == 23) then
    if (in_forest(200)) then
      combat(39)
    else
      combat(40)
    end

  elseif (zn == 24) then
    if (in_forest(200)) then
      combat(41)
    else
      combat(42)
    end

  elseif (zn == 25) then
    if (in_forest(200)) then
      combat(43)
    else
      combat(44)
    end

  elseif (zn == 26) then
    if (in_forest(200)) then
      combat(45)
    else
      combat(46)
    end

  elseif (zn == 27) then
    if (in_forest(200)) then
      combat(47)
    else
      combat(48)
    end

  elseif (zn == 28) then
    if (get_progress(49) < 2) then
      bubble(200, "The Coliseum is closed.")
      if (get_progress(49) == 0) then
        set_progress(49, 1)
      end
    else
      change_map("coliseum", "entrance")
    end

  elseif (zn == 29) then
    if (get_progress(55) == 1) then
      bubble(255, "You are not allowed in the village.")
      msg("You sneak in anyway.", 255, 0)
    end
    change_map("dville", "entrance")

  elseif (zn == 30) then
    change_map("cave4", "entrance")

  elseif (zn == 31) then
    LOC_cave4()

  elseif (zn == 32) then
    change_map("town6", "entrance")

  elseif (zn == 33) then
    warp("colis_w", 16)

  elseif (zn == 34) then
    warp("colis_e", 16)

  elseif (zn == 35) then
    change_map("pass", "entrance")

  elseif (zn == 36) then
    change_map("pass", "exit")

  elseif (zn == 37) then
    change_map("town7", "entrance")

  elseif (zn == 38) then
    LOC_giant()

  elseif (zn == 39) then
    warp("giant_e", 16)

  elseif (zn == 40) then
    change_map("cult", "entrance")

  elseif (zn == 41) then
    change_map("goblin", "entrance")

  elseif (zn == 42) then
    -- Will be fortress for Malkaron
    msg("This will be fortress for Malkaron", 255, 0)

  elseif (zn == 43) then
    change_map("town8", "entrance")

  elseif (zn == 44) then
    warp(255, 73, 16)

  elseif (zn == 45) then
    warp(61, 58, 16)

  elseif (zn == 46) then
    warp(29, 33, 16)

  elseif (zn == 47) then
    warp(26, 53, 16)

  elseif (zn == 48) then
    warp(69, 56, 16)

  elseif (zn == 49) then
    warp(37, 81, 16)

  elseif (zn == 50) then
    warp(20, 47, 16)

  elseif (zn == 51) then
    warp(37, 52, 16)

  elseif (zn == 52) then
    warp(44, 71, 16)

  elseif (zn == 53) then
    warp(70, 40, 16)

  elseif (zn == 54) then
    warp(45, 45, 16)

  elseif (zn == 55) then
    warp(20, 53, 16)

  elseif (zn == 56) then
    warp(66, 45, 16)

  elseif (zn == 57) then
    warp(12, 85, 16)

  elseif (zn == 58) then
    warp(26, 47, 16)

  elseif (zn == 59) then
    warp(31, 77, 16)

  elseif (zn == 60) then
    warp(15, 94, 16)

  elseif (zn == 61) then
    warp(33, 119, 16)

  elseif (zn == 62) then
    warp(44, 84, 16)

  elseif (zn == 63) then
    warp(108, 101, 16)

  elseif (zn == 64) then
    warp(28, 118, 16)

  elseif (zn == 65) then
    warp(85, 129, 16)

  elseif (zn == 66) then
    warp(86, 137, 16)

  elseif (zn == 67) then
    warp(18, 135, 16)

  elseif (zn == 68) then
    warp(79, 130, 16)

  elseif (zn == 69) then
    warp(41, 54, 16)

  elseif (zn == 70) then
    warp(12, 24, 16)

  elseif (zn == 71) then
    set_ent_facing(200, 2)
    change_map("bridge2", "exit")

  elseif (zn == 72) then
    LOC_cave6()

  elseif (zn == 73) then
    change_map("cave6a", "entrance")

  elseif (zn == 74) then
    change_map("cave6b", "exit")

  elseif (zn == 75) then
    bubble(200, "The underwater tunnel should go here.")
    warp("underwater_w", 16)

  elseif (zn == 76) then
    bubble(200, "The second part of the underwater tunnel should go here.")
    warp("underwater_e", 16)

  elseif (zn == 77) then
    bubble(200, "This is where the castle town of Xenar goes.")
    bubble(200, "It's not finished yet.")

  elseif (zn == 78) then
    bubble(200, "This is the cave behind the Xenar Castle. Sorry, you can't go in there yet.")

  elseif (zn == 79) then
    bubble(200, "This is as far as the dock goes.")
    warp("dock_n", 16)

  elseif (zn == 80) then
    bubble(200, "This is as far as the dock goes.")
    warp("dock_s", 16)

  elseif (zn == 81) then
    msg("This is where a short pass or cave goes.", 255, 0)
    warp("malk_pass_w", 8)

  elseif (zn == 82) then
    msg("This is where a short pass or cave goes.", 255, 0)
    warp("malk_pass_e", 8)

  elseif (zn == 83) then
    msg("This is where a new cave goes.", 255, 0)

  elseif (zn == 84) then
    msg("This is Binderak's cave.", 255, 0)

  elseif (zn == 85) then
    change_map("sunarin", "entrance")

  end
end


function LOC_cave4()
  local x, y = marker("cave4")
  if (get_progress(55) == 0) then
    bubble(200, "Hmm... there's a huge iron door blocking the entrance to this cave.")
  elseif (get_progress(55) == 1) then
    bubble(200, "This seems strange. I wonder if this has something to do with the Denorian's request.")
  else
    bubble(200, "Stones 1, 4 then 3...")
    set_btile(x, y - 1, 54)
    set_zone(x, y - 1, 30)
    set_obs(x, y - 1, 0)
    sfx(26)
    bubble(200, "Bingo.")
  end
end


function LOC_cave6()
  local x, y = marker("cave6a")
  if ((get_progress(90) == 1) and
      (get_progress(43) == 1) and
      (get_progress(50) == 1) and
      (get_progress(69) == 1)) then
    set_btile(x, y - 1, 54)
    set_zone(x, y - 1, 73)
    set_obs(x, y - 1, 0)
    sfx(26)
    bubble(200, "Ah, there we go.")
  else
    bubble(200, "I think this entrance will open once I have all the opal stuff.")
  end
end


function LOC_giant()
  if (get_progress(68) == 0) then
    combat(49)
    if (get_alldead() == 1) then
      return
    else
      set_progress(68, 1)
    end
  else
    warp("giant_w", 16)
  end
end