File: cult.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 (432 lines) | stat: -rw-r--r-- 9,878 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


-- cult - "Cult of the Shadow Walker base on island west of Sunarin"

function autoexec()
  local a

  if (get_progress(67) < 2) then
    set_zone("front_door", 32)
    set_obs("front_door", 1)
  else
    set_zone("fight", 31)
    set_obs("front_door", 0)
    for a = 0, 19, 1 do
      set_ent_active(a, 0)
    end
    set_ent_active(23, 0)
  end

  set_ent_active(20, 0)
  set_ent_active(21, 0)
  set_ent_active(22, 0)
  refresh()
end


function entity_handler(en)
  if (en == 0) then
    if (get_progress(66) == 0) then
      bubble(0, "What th...")
      bubble(200, "Where's the girl?")
      bubble(0, "Do you really think that I'm going to tell you?")
      bubble(200, "That depends... do you want to live?")
      bubble(0, "Bah! Don't be deceived by the robes. I'm all muscle under here.")
      drawmap()
      screen_dump()
      set_run(0)
      combat(22)
      set_run(1)
      if (get_alldead() == 1) then
        return
      end
      drawmap()
      screen_dump()
      set_ent_active(0, 0)
      set_progress(66, 1)
      sfx(5)
      msg("Iron key procured", 255, 0)
    end

  end
end


function postexec()
  return
end


function refresh()
  showch("treasure1", 75)
  showch("treasure2", 76)
  showch("treasure3", 77)
  showch("treasure4", 78)
  showch("treasure5", 79)
end


-- Show the status of a chest
function showch(which_marker, which_chest)
  -- Set tiles if -1 passed in as 'which_chest' or if chest already opened
  if (which_chest < 0 or get_treasure(which_chest) == 1) then
    set_mtile(which_marker, 65)
    set_zone(which_marker, 0)
  end
end


function zone_handler(zn)
  local x, y
  if (zn == 0) then
    if (get_progress(67) < 2) then
-- combat(19)
    end

  elseif (zn == 1) then
    change_map("main", "cult")

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

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

  elseif (zn == 4) then
    warp("dstairs3", 8)

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

  elseif (zn == 6) then
    warp("ustairs4", 8)

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

  elseif (zn == 8) then
    warp("ustairs5", 8)

  elseif (zn == 9) then
    warp("dstairs4", 8)

  elseif (zn == 10) then
    warp("ustairs6", 8)

  elseif (zn == 11) then
    LOC_freed(20, 21, 22, 23)

  elseif (zn == 12) then
    LOC_open_door("door1")

  elseif (zn == 13) then
    LOC_open_door("door2")

  elseif (zn == 14) then
    LOC_open_door("door3")

  elseif (zn == 15) then
    LOC_open_door("door4")

  elseif (zn == 16) then
    LOC_open_door("door5")

  elseif (zn == 17) then
    LOC_open_door("door6")

  elseif (zn == 18) then
    if (get_progress(66) == 0) then
      bubble(200, "Locked tight.")
    else
      if (get_progress(66) == 1) then
        bubble(200, "Unlocked.")
        set_progress(66, 2)
      end
      LOC_open_door("door7")
    end

  elseif (zn == 19) then
    LOC_open_door("door8")

  elseif (zn == 20) then
    chest(75, 70, 1)
    refresh()

  elseif (zn == 21) then
    chest(76, 0, 900)
    refresh()

  elseif (zn == 22) then
    chest(77, 58, 1)
    refresh()

  elseif (zn == 23) then
    chest(78, 42, 1)
    refresh()

  elseif (zn == 24) then
    chest(79, 85, 1)
    refresh()

  elseif (zn == 25) then
    bubble(200, "Egad, these books are horrible!")

  elseif (zn == 26) then
    bubble(200, "These are just sick!")

  elseif (zn == 27) then
    bubble(200, "These books are just plain bad.")

  elseif (zn == 28) then
    bubble(200, "There is nothing here but common supplies.")

  elseif (zn == 29) then
    if (get_progress(67) == 0) then

      bubble(200, "Breanne... are you in here?")
      wait(50)
      bubble(23, "Huh?")
      bubble(200, "Breanne... are you in here?")
      wait(50)
      set_ent_script(23, "R2D4W50")
      wait_for_entity(23, 23)
      bubble(23, "Who are you?")
      bubble(200, "Your parents sent us to rescue you.")
      bubble(23, "You'll have to get me out later. Those creeps took some of my blood and they are going to do something evil with it.")
      bubble(23, "You've got to stop them!")
      bubble(200, "Well... I guess we should hurry then. We'll be back shortly to get you out.")
      bubble(23, "Thanks! Now hurry!")
      set_progress(67, 1)
      return
    elseif (get_progress(67) == 1) then
      bubble(23, "What are you waiting for?")
    end

  elseif (zn == 30) then
    LOC_fight(17, 18, 19)

  elseif (zn == 32) then
    bubble(200, "Hey! The door is sealed!")

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

  end
end


function LOC_avatar_abounds()
  local a, b, dx, dy
  local ax, ay, z
  local x, y

  create_df("mpcx.dat", "LFLAME_PCX")
  create_bmp(0, 24, 24)
  df2bmp(0, 0, 16, 0, 0, 24, 24)
  create_bmp(1, 64, 16)
  df2bmp(1, 0, 0, 0, 0, 64, 16)
  destroy_df()

  ax = get_vx()
  ay = get_vy()
  move_camera(1032, 576, 1)

  for a = 1, 23, 1 do
    for b = 0, 3, 3 do
      drawmap()
      for dx = 0, 6, 1 do
        for dy = 1, 5, 1 do
          maskblit(1, b * 16, 0, dx * 16 + 104, dy * 16 + 64, 16, 16)
        end
      end
      for dx = 1, 5, 1 do
        maskblit(1, b * 16, 0, dx * 16 + 104, 64, 16, 16)
        maskblit(1, b * 16, 0, dx * 16 + 104, 160, 16, 16)
      end
      maskblit(0, 0, 0, 148, 128 - a, 24, a)
      screen_dump()
      rest(40)
    end
  end
  destroy_bmp(0)
  destroy_bmp(1)

  for a = 1, 19, 1 do
    set_ent_active(a, 0)
  end

  x, y = marker("avatar")
  set_mtile(x, y - 1, 270)
  set_mtile(x - 1, y, 271)
  set_mtile(x, y, 272)
  set_mtile(x + 1, y, 273)
  set_mtile(x - 1, y + 1, 274)
  set_mtile(x, y + 1, 275)
  set_mtile(x + 1, y + 1, 276)

  move_camera(ax, ay, 1)
end


function LOC_fight(guard1, guard2, guard3)
  bubble(5, "Hey! Who is that?")
  bubble(5, "You three take care of them!")
  wait(50)
  set_ent_script(guard1, "L1D1")
  set_ent_script(guard2, "D1L1")
  set_ent_script(guard3, "D1L2")
  wait_for_entity(guard1, guard3)
  wait(50)
  set_run(0)
  combat(20)
  set_run(1)
  if (get_alldead() == 1) then
    return
  end

  x, y = marker("fight")
  set_zone(x, y, 31)
  set_zone(x, y + 1, 31)

  set_ent_active(guard1, 0)
  set_ent_active(guard2, 0)
  set_ent_active(guard3, 0)
  set_mtile("avatar", 250)
  set_autoparty(1)
  set_ent_script(200, "R4U1")
  if (get_numchrs() == 2) then
    set_ent_script(201, "R5")
    wait_for_entity(200, 201)
    set_ent_facing(201, 1)
  else
    wait_for_entity(200, 200)
  end
  set_autoparty(0)
  wait(50)
  bubble(200, "Uh oh!")

  LOC_avatar_abounds()

  drawmap()
  screen_dump()
  wait(50)
  bubble(200, "The time to attack is now!")
  drawmap()
  screen_dump()
  set_autoparty(1)
  set_ent_script(200, "U2")
  if (get_numchrs() == 2) then
    set_ent_script(201, "U2")
    wait_for_entity(200, 201)
  else
    wait_for_entity(200, 200)
  end
  set_autoparty(0)
  orient_heroes()
  set_run(0)
  combat(21)
  set_run(1)
  if (get_alldead() == 1) then
    return
  end

  x, y = marker("avatar")
  set_mtile(x, y - 1, 0)
  set_mtile(x - 1, y, 0)
  set_mtile(x, y, 0)
  set_mtile(x + 1, y, 0)
  set_mtile(x - 1, y + 1, 0)
  set_mtile(x, y + 1, 0)
  set_mtile(x + 1, y + 1, 0)
  set_progress(67, 2)
  set_obs("front_door", 0)
  set_zone("front_door", 1)
end



function LOC_freed(guard1, guard2, guard3, breanne)
  if (get_progress(67) == 2) then
    x, y = marker("rescue")

    set_ent_active(guard1, 1)
    set_ent_active(guard2, 1)
    set_ent_active(guard3, 1)
    set_ent_active(breanne, 1)

    place_ent(breanne, x, y)
    set_ent_facing(breanne, 3)
    set_btile(x, y - 2, 160)
    set_ftile(x, y - 2, 0)
    set_zone (x, y - 2, 0)
    set_obs (x, y - 2, 0)
  end

  warp("dstairs5", 8)

  if (get_progress(67) == 2) then
    set_autoparty(1)
    if (get_numchrs() == 2) then
      set_ent_script(200, "L1")
      wait_for_entity(200, 200)
      set_ent_script(200, "L6")
      set_ent_script(201, "L6")
      wait_for_entity(200, 201)
    else
      set_ent_script(200, "L7")
      wait_for_entity(200, 200)
    end
    set_autoparty(0)
    orient_heroes()
    bubble(200, "Hey, you're free!")
    bubble(breanne, "Yes, some of my father's men were waiting outside. Once the doors became unsealed they figured things were safe.")
    bubble(breanne, "It seems that you've taken care of the Cult of the Shadow.")
    bubble(200, "Yeah, that avatar wasn't very strong. It was probably weak due to just having been summoned.")
    bubble(breanne, "Don't be modest, you did a great job.")
    bubble(breanne, "By the way, these men here mentioned that you came here because you wanted my Opal Band.")
    bubble(200, "Well, that was partly the reason we came, but once we found about this Cult and the Avatar, we had to act.")
    bubble(breanne, "That's okay... I believe you. I want you to have the Band... you've earned it.")
    bubble(200, "Are you sure?")
    bubble(breanne, "Yes.")
    drawmap()
    screen_dump()
    sfx(5)
    msg("Opal Band procured", 255, 0)
    set_progress(69, 1)
    drawmap()
    screen_dump()
    bubble(200, "Thank you very much!")
    bubble(breanne, "No problem, and good luck!")
    bubble(200, "See ya!")
    set_ent_script(guard1, "L1U1")
    wait_for_entity(guard1, guard1)
    set_ent_script(guard1, "L3")
    set_ent_script(guard2, "L3")
    set_ent_script(breanne, "L3")
    wait_for_entity(guard1, guard2)
    wait_for_entity(breanne, breanne)
    set_ent_script(guard3, "D1L1")
    wait_for_entity(guard3, guard3)
    set_ent_script(guard1, "L8")
    set_ent_script(guard2, "L8")
    set_ent_script(breanne, "L8")
    set_ent_script(guard3, "L8")
    wait_for_entity(guard1, breanne)
    set_ent_active(guard1, 0)
    set_ent_active(guard2, 0)
    set_ent_active(guard3, 0)
    set_ent_active(breanne, 0)
    set_progress(67, 3)
    set_progress(64, 3)
  end
end


function LOC_open_door(which_marker)
  local x, y = marker(which_marker)
  sfx(26)
  set_btile(x, y + 1, 176)
  set_ftile(x, y, 175)
  set_zone(x, y, 0)
  set_obs(x, y, 0)
end