File: coliseum.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 (338 lines) | stat: -rw-r--r-- 12,355 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
-- coliseum - "Coliseum west of Sunarin"

-- /*
-- {
-- Get the 6th PM after the battle
-- Of course, we shouldn't let him/her join except if we do a side-quest.
-- }
-- */


function autoexec()
  set_ent_active(12, 0)
  if (get_progress(P_ROUNDNUM) > 0) then
    x, y = marker("after_battle")
    place_ent(6, x + 1, y + 1)
  end
end


function entity_handler(en)
  if (en == 0) then
    bubble(en, "I actually made it to the second round!")

  elseif (en == 1) then
    bubble(en, "I'm out of practice.")

  elseif (en == 2) then
    bubble(en, "I can't stand waiting like this!")

  elseif (en == 3) then
    bubble(en, "There's not enough women in these competitions.")

  elseif (en == 4) then
    bubble(en, "I came all this way and then found out that I didn't have enough money for the registration fee!")

  elseif (en == 5) then
    bubble(en, "I'm waiting for my next match.")

  elseif (en == 6) then
    local a, b

    if (get_progress(P_OPALSHIELD) == 1) then
      bubble(en, "This is where you register.")
      bubble(en, "Hey, wait a minute... you're the one who defeated Trayor. We can't let you register again... you're too good for these guys.")
      return
    end
    if (get_progress(P_ROUNDNUM) == 0) then
      bubble(en, "This is where you register.")
      if (get_progress(P_FIRSTTIME) == 0) then
        bubble(en, "Before I explain the rules, I should tell you that the registration fee is 2000 gp!")
        bubble(en, "If you lose even once, you are done... and will have to register again.")
        bubble(en, "As well, after you register you can't leave the coliseum grounds. If you leave, you will be forced to register again.")
        bubble(en, "Now, let's talk about the actual fights!")
        bubble(en, "The first three battles are more or less just preliminary fights to make sure you have what it takes.")
        bubble(en, "If you win the first three rounds, you qualify for more advanced matches.")
        bubble(en, "The more advanced matches are against more skilled opponents and will determine whether or not your skills are balanced enough.")
        bubble(en, "If you manage to defeat the advanced warriors, you will be given a chance to fight Trayor for the grand prize.")
        a = prompt(en, 2, 0, "So, are you willing to pay the",
                             "2000 gp entrance fee?",
                             "  no  ",
                             "  yes ")
        set_progress(P_FIRSTTIME, 1)
      else
        a = prompt(en, 2, 0, "The registration fee is 2000 gp.",
                             "Are you in?",
                             "  no  ",
                             "  yes ")
      end
      if (a == 0) then
        bubble(en, "Oh well. Come back when you're ready.")
      else
        if (get_gp() >= 2000) then

          set_gp(get_gp() - 2000)
          bubble(en, "Consider yourself registered. After each battle, come back and talk to me.")
          set_ent_script(en, "U2R1F2")
          wait_for_entity(en, en)
          set_progress(P_ROUNDNUM, 1)
          set_progress(P_BATTLESTATUS, 0)
        else
          bubble(en, "Umm... you don't seem to have enough. I would suggest selling some junk. In any case, you can't register at this point.")
        end
      end
    else
      a = get_progress(P_BATTLESTATUS)
      if (a == 0) then
        if (get_progress(P_ROUNDNUM) == 7) then
          bubble(en, "Wow! This is it... your next battle is with Trayor. Good luck... you'll need it!")
        else
          bubble(en, "Battle number "..get_progress(P_ROUNDNUM)..". Just head on through that door when you are ready.")
        end
      elseif (a == 1) then
        if (get_progress(P_ROUNDNUM) == 7) then
          bubble(en, "Astounding! Whoever you are, you're going to go far!")
          bubble(en, "Well, I guess this is yours.")
          sfx(5)
          msg("Opal Shield procured", 255, 0, xofs, yofs)
          set_progress(P_OPALSHIELD, 1)
          if (get_ent_tilex(HERO1) == get_ent_tilex(en)) then
            set_ent_script(HERO1, "L1")
            wait_for_entity(HERO1, HERO1)
          end

          if (get_numchrs() == 1) then
            move_entity(HERO1, "prebattle", 0)
            wait_for_entity(HERO1, HERO1)
            set_ent_facing(HERO1, FACE_UP)
          else
            move_entity(HERO1, "prebattle", 0)
            move_entity(HERO2, get_marker_tilex("prebattle"), get_marker_tiley("prebattle") + 1, 0)
            wait_for_entity(HERO1, HERO2)
            set_ent_facing(HERO1, FACE_UP)
            set_ent_facing(HERO2, FACE_UP)
            orient_heroes()
          end
          set_ent_script(en, "L1D2")
          wait_for_entity(en, en)
          bubble(en, "Good luck in your endeavours.")
	  if (get_numchrs() > 1) then -- Skip this partnering up bit.
	     return
	  end

          if (get_progress(P_OLDPARTNER) > 0) then
            set_progress(P_FINALPARTNER, get_progress(P_OLDPARTNER))
          else
            if (party[0] == Casandra) then
              if (krnd(10) < 5) then
                set_progress(P_FINALPARTNER, TEMMIN + 1)
              end
            end
            if (party[0] == Temmin) then
              if (krnd(10) < 5) then
                set_progress(P_FINALPARTNER, CASANDRA + 1)
              end
            end
            while (get_progress(P_FINALPARTNER) == 0) do
              z = krnd(8)
              if (z ~= party[0].id) then
                set_progress(P_FINALPARTNER, z + 1)
              end
            end
          end
          set_ent_id(en, get_progress(P_FINALPARTNER) - 1)
          set_ent_active(en, 1)
        else
          bubble(en, "Congratulations! You should have a rest or heal up. Come back and talk to me again after you've prepared.")
          set_progress(P_BATTLESTATUS, 0)
          set_progress(P_ROUNDNUM, get_progress(P_ROUNDNUM) + 1)
        end
      elseif (a == 2) then
        bubble(en, "Ooh... tough luck!")
        set_progress(P_BATTLESTATUS, 0)
        set_progress(P_ROUNDNUM, 0)
        set_ent_script(HERO1, "D3F1")
        wait_for_entity(0, 0)
        set_ent_script(en, "L1D2")
        wait_for_entity(en, en)
        play_map_song()
      end
    end

  elseif (en == 7) then
    bubble(en, "Losing isn't so bad.")
    bubble(en, "No wait, let me rephrase that!")
    bubble(en, "Losing sucks!")

  elseif (en == 8) then
    bubble(en, "What a waste of money.")
    bubble(HERO1, "How many matches did you fight?")
    bubble(en, "Matches? I haven't left the bar yet!")

  elseif (en == 9) then
    bubble(en, "These fights are quite interesting.")

  elseif (en == 10) then
    bubble(en, "Wine puts losing in a whole new perspective.")

  elseif (en == 11) then
    bubble(en, "The Coliseum hasn't been the same since they discontinued betting on the fights.")

  elseif (en == 12) then
    if (get_progress(P_OLDPARTNER) == 0) then
      bubble(en, "Wow! I saw you fighting. You cleaned up!")
      bubble(en, "Oh yeah! I'm here because I ran into some guy named Derig. Well, he actually came looking for me.")
      bubble(en, "Anyways, he wanted me to come and find you.")
      bubble(HERO1, "Derig! What does he want now?")
      bubble(en, "He said that he found out where all of the Opal armor is and he sent me to tell you.")
      bubble(en, "He also figured that if you didn't have a partner by now, that I should make my services available to you.")
      bubble(en, "And let me just say that after travelling all this way to find you... I won't take no for an answer!")
      bubble(HERO1, "Well, in that case, welcome to the team.")
      bubble(HERO1, "Now, I already found the Opal Helmet and the Opal Shield.")
      bubble(en, "So what about the other stuff? Do you already know where the Band and Armor are?")
      bubble(HERO1, "No... no, I don't know where the other pieces are.")
      bubble(en, "Alrighty then, down to business. The Band belongs to a merchant in Ajantara south of here.")
      bubble(en, "The Armor, however, is hidden deep in a cavern east of here.")
      bubble(HERO1, "Well, where should we go first?")
      bubble(en, "Derig said to get the Armor last and since all that leaves is the Band, then we should go for that.")
      bubble(HERO1, "Fair enough... let's roll.")
      add_chr(get_progress(P_FINALPARTNER) - 1)
      LOC_partner_up()
      set_progress(P_FINALPARTNER, 0)
      copy_ent(en, HERO2)
      set_ent_active(en, 0)
      orient_heroes()
      drawmap()
      screen_dump()
      msg("$1 joined!", 255, 0)
    else
      bubble(en, "Hey... long time no see. I saw you fighting. You were amazing!")
      bubble(en, "Oh yeah! I'm here because I ran into some guy named Derig. Well, he actually came looking for me.")
      bubble(en, "He knew that we were separated and he gave me some information to bring back.")
      bubble(HERO1, "Speaking of that... where did you go?")
      bubble(en, "Heh... when we hit the teleporter, it sent me back to Ekla.")
      bubble(en, "I was on the way back to the teleporter when I ran into Derig... and now I'm here.")
      bubble(HERO1, "So, what did Derig tell you?")
      bubble(en, "He told me where all the Opal stuff is... the Shield, the Band, the Armor, and the Helmet.")
      bubble(HERO1, "I already snagged the Helmet and the Shield... where are the other parts?")
      bubble(en, "You already found the Helmet and Shield! Wow! Well, the Band is in a town called Ajantara to the south.")
      bubble(en, "The Armor is deep in a cavern to the east. And Derig said to get the Armor last, so we should go to Ajantara first. Okay?")
      bubble(HERO1, "No problem... let's go.")
      add_chr(get_progress(P_FINALPARTNER) - 1)
      LOC_partner_up()
      set_progress(P_FINALPARTNER, 0)
      copy_ent(en, HERO2)
      set_ent_active(en, 0)
      orient_heroes()
      drawmap()
      screen_dump()
      msg("$1 joined!", 255, 0)
    end

  end
end


function postexec()
  return
end


function zone_handler(zn)
  if (zn == 1) then
    set_progress(P_ROUNDNUM, 0)
    set_progress(P_BATTLESTATUS, 0)
    change_map("main", "coliseum")

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

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

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

  elseif (zn == 5) then
    door_out("inn_o")

  elseif (zn == 6) then
    door_out("tournament_o")

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

  elseif (zn == 8) then
    inn("The Coliseum Inn", 250, 1)

  elseif (zn == 9) then
    shop(22)

  elseif (zn == 10) then
    door_out("battle")
  
  elseif (zn == 11) then
    set_save(0)

  elseif (zn == 12) then
    bubble(HERO1, "Hmm. The sun feels very warm right here.")
    set_save(1)

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

  elseif (zn == 14) then
    door_in("after_battle")
    
  elseif (zn == 15) then
    if (get_progress(P_BATTLESTATUS) > 0) then
      bubble(HERO1, "I'm not ready yet.")
      return
    end
    set_run(0)
    set_progress(P_USEITEMINCOMBAT, 1)
    combat(11 + get_progress(P_ROUNDNUM))
    set_progress(P_USEITEMINCOMBAT, 0)
    set_run(1)
    local x, y = marker("battle")
    warp(x, y - 3, 16)
    if (get_alldead() == 1) then
      set_progress(P_BATTLESTATUS, 2)
      set_party_hp(party[0], 1)
      set_alldead(0)
    else
      set_progress(P_BATTLESTATUS, 1)
    end

  end
end


function LOC_partner_up()
  local a

  a = get_party_xp(party[0]) - get_party_xp(get_pidx(1))
  if (a > 5000) then
    a = a - 5000
  end
  a = a + krnd(500)
  give_xp(get_pidx(1), a, 1)
  a = get_progress(P_FINALPARTNER) - 1
  if (a == SENSAR) then
    set_all_equip(0, I_HAMMER2, I_SHIELD3, I_CAP3, I_ARMOR5, I_BAND2, 0)
  elseif (a == SARINA) then
    set_all_equip(1, I_SPEAR2, 0, I_CAP3, I_SUIT3, I_BAND2, 0)
  elseif (a == CORIN) then
    set_all_equip(2, I_ROD3, I_SHIELD3, I_CAP2, I_ROBE3, I_BAND2, 0)
  elseif (a == AJATHAR) then
    set_all_equip(3, I_HAMMER2, I_SHIELD3, I_CAP2, I_ROBE3, I_BAND2, 0)
  elseif (a == CASANDRA) then
    set_all_equip(4, I_STAFF2, 0, I_CAP2, I_ROBE3, I_BAND2, 0)
  elseif (a == TEMMIN) then
    set_all_equip(5, I_SWORD4, I_SHIELD3, I_HELM2, I_ARMOR5, I_BAND2, 0)
  elseif (a == AYLA) then
    set_all_equip(6, I_SWORD4, I_SHIELD3, I_CAP3, I_SUIT3, I_BAND2, 0)
  elseif (a == NOSLOM) then
    set_all_equip(7, I_ROD3, I_SHIELD3, I_CAP2, I_ROBE3, I_BAND2, 0)
  end
end