File: pass.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 (168 lines) | stat: -rw-r--r-- 3,891 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
-- pass - "Karnok's pass, between Sunarin and Pulcannen"

function autoexec()
  if (get_progress(P_SAVEBREANNE) > 0) then
    -- Move guard on left side of pass
    place_ent(0, get_ent_tilex(0) - 1, get_ent_tiley(0))
    set_ent_facing(0, FACE_RIGHT)
    -- Move guard on right side of pass
    place_ent(1, get_ent_tilex(1) + 1, get_ent_tiley(1) - 1)
    set_ent_facing(1, FACE_LEFT)
  end
  refresh()
end


function entity_handler(en)
  if (en == 0 or en == 1) then
    if (get_progress(P_SAVEBREANNE) == 0) then
      bubble(en, "This pass is reserved for use by caravans only.")
    else
      bubble(en, "You are free to use the pass. Just be careful.")
    end
  elseif (en == 2) then
    -- Cabin bloke
    LOC_miner(en)
  end
end


function postexec()
  return
end


function refresh()
  if (get_progress(P_CAVEKEY) > 0) then
    -- Move Rufus into his house
    place_ent(2, 152, 12)
  end

  showch("treasure1", 73)
  showch("treasure2", 74)
  showch("treasure3", 82)
  showch("treasure4", 83)
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, 39)
    set_zone(which_marker, 0)
  end
end


function zone_handler(zn)
  local x, y
--  if (zn == 0) then
--    combat(50)

--  elseif (zn == 1) then
  if (zn == 1) then
    change_map("main", "pass_w")

  elseif (zn == 2) then
    change_map("main", "pass_e")

  elseif (zn == 3) then -- northern door
    LOC_door("door3", "cave5", "door1")

  elseif (zn == 4) then
    chest(73, I_VITSEED, 1)
    refresh()

  elseif (zn == 5) then
    chest(74, I_ERUNE, 1)
    refresh()

  -- Western door
  elseif (zn == 6) then
    LOC_door("door1", "cave5", "door2")

  elseif (zn == 7) then
    LOC_door("door2", "cave5", "entrance")

  -- Door into cabin
  elseif (zn == 8) then
    x, y = marker("cabin_in")
    -- Avoid parallax problems: remove the background temporarily
    set_background(0)
    door_in(x, y)

  -- Door out of the cabin
  elseif (zn == 9) then
    x, y = marker("cabin_out")
    -- Reset the background for correct parallax
    set_background(1)
    door_out(x, y)

  -- Treasure
  elseif (zn == 10) then
    chest(82, 0, 500)
    refresh()

  -- Treasure
  elseif (zn == 11) then
    chest(83, I_SALVE, 1)
    refresh()

  elseif (zn == 12) then
    touch_fire(party[0])
  end
end


function LOC_door(door, map, mark)
  local x, y = marker(door)

  if (get_progress(P_CAVEKEY) == 0) then
    bubble(HERO1, "Locked.")
    return
  end

  -- Open the door before going in
  set_mtile(x, y - 1, 57)
  set_mtile(x, y, 33)

  sfx(26)
  drawmap()
  screen_dump()

  change_map(map, mark)
end


function LOC_miner(en)
  if (get_progress(P_TALKRUFUS) == 0) then
    bubble(en, "Howdy!")
    bubble(HERO1, "Hello. Is this your cabin?")
    bubble(en, "It sure is! Th' name's Rufus. I work in the abandoned mines in these parts.")
    bubble(en, "But I'll warn ya now. There's something nasty hiding in them thar mines.")
    bubble(HERO1, "Like what?")
    bubble(en, "I guess I've said enough...")
    set_progress(P_TALKRUFUS, 1)
    if (get_progress(P_CAVEKEY) == 0) then
      bubble(HERO1, "Don't worry. I was just passing through, anyway.")
    end
  elseif (get_progress(P_TALKRUFUS) == 1) then
    bubble(HERO1, "Hello again.")
    bubble(en, "Don't forget what I told ya about them mines.")
    if (get_progress(P_CAVEKEY) == 0) then
      bubble(HERO1, "I won't.")
    end
  end

  if (get_progress(P_TALKRUFUS)<2) then
    bubble(HERO1, "But, I really need to get in there.")
    set_progress(P_TALKRUFUS, 2)
    bubble(en, "We-e-ell...")
    bubble(en, "I reckon that you and me might be able to do a little business here.")
  else
    bubble(en, "So, back for some more of the dynamite, are you?")
  end

  shop(23)
end