File: guild.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 (285 lines) | stat: -rw-r--r-- 7,964 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


-- guild - "Home of the Embers in Sunarin"
--
function autoexec()
  refresh()
end
function entity_handler(en)
  if (en == 2) then -- You have met Ayla
    LOC_ayla_join(en)
  end
end
function postexec()
  return
end
function refresh()
  local x, y
  x, y = marker("ustairs1")
  if (get_progress(48) == 1) then
    set_obs (x + 2, y - 1, 0)
    set_zone (x + 2, y - 1, 0)
    set_mtile(x + 2, y - 2, 0)
    set_mtile(x + 2, y - 1, 0)
    set_ftile(x + 3, y - 2, 242)
    set_ftile(x + 3, y - 1, 241)
    set_obs (x + 4, y - 1, 1)
    set_zone (x + 4, y - 1, 4)
    set_ftile(x + 4, y - 2, 242)
    set_ftile(x + 4, y - 1, 243)
  elseif (get_progress(48) == 2) then
    set_obs (x + 2, y - 1, 1)
    set_mtile(x + 2, y - 2, 242)
    set_mtile(x + 2, y - 1, 241)
    set_ftile(x + 3, y - 2, 0)
    set_ftile(x + 3, y - 1, 0)
    set_obs (x + 4, y - 1, 0)
    set_zone (x + 4, y - 1, 0)
    set_ftile(x + 4, y - 2, 0)
    set_ftile(x + 4, y - 1, 0)
  end
  if (get_progress(47) > 0) then
    set_ent_active(0, 0)
    set_ent_active(1, 0)
  end
  if (get_progress(43) > 0) then
    set_mtile("helm", 265)
    set_zone("helm", 0)
  end
  -- Should Ayla appear or not?
  if (LOC_manor_or_party(6) or get_progress(47) < 1) then
    set_ent_active(2, 0)
  else
    set_ent_active(2, 1)
    set_ent_id(2, 6)
  end
  -- I know this is supposed to check inside the individual if..thens to be
  -- proper, but figure we will call it for the remaining treasures too.
  x, y = marker("treasure")
  if (get_treasure(101) == 1) then
    set_mtile(x - 1, y - 1, 265)
  end
  if (get_treasure(102) == 1) then
    set_mtile(x, y - 1, 265)
  end
  if (get_treasure(103) == 1) then
    set_mtile(x + 1, y - 1, 265)
  end
  if (get_treasure(104) == 1) then
    set_mtile(x, y + 1, 265)
  end
  if (get_treasure(105) == 1) then
    set_mtile(x + 1, y + 1, 265)
  end
end
-- Updated 20020929 PH
-- Added test for 43 so
-- that you can re-enter the guild
-- if you do not have the helmet yet
function zone_handler(zn)
  if (zn == 1) then
    if (get_progress(43) == 1) then
      set_progress(47, 2)
    end
    change_map("town5", "guild_door")
  elseif (zn == 2) then
    warp("dstairs1", 8)
  elseif (zn == 3) then
    if (get_progress(48) == 0) then
      bubble(200, "Well I'll be...")
      bubble(200, "The book really IS called 'How to Enter the Ember's Secret Hideout'. Heh... brilliant in its simplicity, I suppose.")
      set_progress(48, 1)
      sfx(26)
      refresh()
    end
  elseif (zn == 4) then
    if (party[0] == 6) then
      bubble(200, "I'm a thief... but even I wouldn't read this garbage!")
    else
      bubble(200, "Thieves read?!")
    end
  elseif (zn == 5) then
    chest(47, 0, 500)
    refresh()
  elseif (zn == 6) then
    warp("ustairs2", 8)
  elseif (zn == 7) then
    warp("dstairs2", 8)
  elseif (zn == 8) then
    chest(50, 12, 1)
    refresh()
  elseif (zn == 9) then
    bubble(200, "These look interesting.")
  elseif (zn == 10) then
    LOC_hidden_door()
  elseif (zn == 11) then
    if (get_progress(47) == 0) then
      LOC_fight()
    end
  elseif (zn == 12) then
    LOC_get_helm()
  elseif (zn == 13) then
    warp("ustairs1", 8)
  elseif (zn == 14) then
    touch_fire(party[0])
  elseif(zn == 15) then
    -- Close the secret door
    sfx(26)
    set_progress(48, 2)
    refresh()
  elseif (zn == 16) then
    -- Open the secret door (a second time)
    sfx(26)
    set_progress(48, 1)
    refresh()
  elseif (zn >= 17 and zn <= 21) then
    -- Gold! Between 170 and 210 GP, depending on the zone number
    chest(101 + zn - 17, 0, zn * 10)
  elseif (zn == 22) then
    if (party[0] == Ayla or party[1] == Ayla) then
      local hero
      if (party[0] == Ayla) then
        hero = 200
      else
        hereo = 201
      end
      bubble(hero, "I can't seem to pick this lock.")
    else
      bubble(en, "The lock on this door looks very strange.")
    end
  elseif (zn == 23) then
    -- This will lead to a room with a TravelPoint which leads to cave1
    warp("dstairs3", 8)
  elseif (zn == 24) then
    warp("dstairs4", 8)
  elseif (zn == 25) then
    bubble(200, "This note says that there is a portal behind the fireplace.")
  elseif (zn == 26) then
    warp("fireplace2", 8)
  elseif (zn == 27) then
    warp("fireplace1", 8)
  elseif (zn == 28) then
    change_map("cave1", "dstairs1")
  end
end
function LOC_ayla_join(en)
  if (get_progress(103) == 0) then
    -- This code creates an unsolvable catch-22. Probably to prevent trapping the player in an unfinished quest.
    bubble(en, "Wha...? Oh, it's you!")
    bubble(200, "Hello... I recognise you from Nostik's manor, don't I?")
    bubble(en, "Yes, I broke into the house, but I couldn't find the secret passage.")
    bubble(200, "You must be pretty good at... uh...")
    bubble(en, "Thievery? Yea, I am.")
    bubble(200, "Well, nice meeting you.")
    bubble(en, "I would join you, but my quest isn't written yet.")
    bubble(200, "Oh. Ok. Perhaps when this game is finished?")
    bubble(en, "Yeah, probably then.")
    bubble(200, "OK.")
  else
    bubble(en, "Hey, $0. Rumor has it that the guild has a bunch of treasure hoarded somewhere.")
    bubble(200, "That's possible. Why?")
    bubble(en, "Let's just suppose that you help me find it. I wouldn't mind joining your little party and helping you out.")
    bubble(200, "Well, I can always use a little extra help. What do we have to do?")
    bubble(en, "Let's have a talk around town. I'm sure someone's bound to spill something about the guild's whereabouts.")
    bubble(200, "Well, alright then.")
    set_ent_active(en, 0)
    set_all_equip(6, 12, 40, 47, 62, 75, 0)
    id = select_team{6}
    -- Add the characters that were deselected to the manor
    add_to_manor(id)
    if (id[1]) then
      -- Need the whole "okay, meet you back at the manor" dialog here
    end
  end
end
function LOC_fight()
  local a, b
  local x, y = marker("fight")
  if (get_progress(47) ~= 0) then
    return
  end
  a = get_vx()
  b = get_vy()
  move_camera(816, 288, 2)
  bubble(200, "Ooh... a chest! But who are these clowns?")
  wait(50)
  bubble(0, "I'll follow the others to the Coliseum and you wait here for the Guildmaster to return from his visit.")
  bubble(1, "Yes sir! I'll...")
  bubble(0, "Who is that?")
  set_ent_facing(1, 3)
  drawmap()
  screen_dump()
  move_camera(a, b, 1)
  drawmap()
  screen_dump()
  bubble(0, "Guards!")
  bubble(200, "Oh oh!")
  wait(50)
  set_ftile(x, y - 1, 369)
  set_ftile(x - 1, y, 372)
  set_ftile(x + 1, y, 371)
  set_ftile(x, y + 1, 370)
  wait(50)
  bubble(200, "What the...")
  drawmap()
  screen_dump()
  set_run(0)
  combat(26)
  set_run(1)
  if (get_alldead() == 1) then
    return
  end
  set_progress(47, 1)
  set_ftile(x, y - 1, 0)
  set_ftile(x - 1, y, 0)
  set_ftile(x + 1, y, 0)
  set_ftile(x, y + 1, 0)
  refresh()
  drawmap()
  screen_dump()
  wait(50)
  bubble(200, "Those guys are gone!")
  bubble(200, "But they left the chest behind.")
end
function LOC_get_helm()
  if (get_progress(43) == 0) then
    sfx(5)
    msg("Opal Helmet procured", 255, 0)
    set_progress(43, 1)
    refresh()
    drawmap()
    screen_dump()
    wait(50)
    bubble(200, "I don't like this.",
                 "It was just too easy.")
  end
end
function LOC_hidden_door()
  if (party[0] == Ayla or party[1] == Ayla) then
    local a, b
    local x, y = marker("hidden")
    if (party[0] == Ayla) then
      a = 200
      b = 201
    else
      a = 201
      b = 200
    end
    bubble(a, "The door is just a decoy.")
    move_entity(a, x, y, 0)
    move_entity(b, x, y + 1, 0)
    set_ent_obsmode(a, 0)
    set_ent_obsmode(b, 0)
    wait_for_entity(a, b)
    set_ent_obsmode(a, 1)
    set_ent_obsmode(b, 1)
    sfx(26)
    set_ent_facing(a, 3)
    bubble(a, "There we go...")
    set_obs(x + 1, y, 0)
    set_obs(x + 2, y - 2, 0)
    set_zone(x, y - 1, 0)
  else
    bubble(200, "I can't get in this. I may need someone skilled at picking locks to get inside.")
  end
end