15 '''Count the number of kobolds on the map for the blue zone.'''
16 map = Crossfire.WhoAmI().Map
18 for x
in range(map.Width):
19 for y
in range(map.Height):
20 below = map.ObjectAt(x, y)
22 if below.Name ==
'kobold' or below.Name ==
'Second Chance kobold':
30 '''Player triggered the lever, check if correct number of kobolds.'''
33 Crossfire.SetReturnValue(1)
34 Crossfire.WhoIsActivator().
Message(
'The level will only activate if there are exactly 4 kobolds on the map')
38 """Handle the Darcap Manor's potion being thrown. Check if walls to destroy in the treasure room."""
41 dir_x = [ 0, 0, 1, 1, 1, 0, -1, -1, -1 ]
42 dir_y = [ 0, -1, -1, 0, 1, 1, 1, 0, -1 ]
44 env = Crossfire.WhoAmI().Env
46 if env.Map.Path !=
'/darcap/darcap/manor.treasure':
49 x = env.X + dir_x[ env.Direction ]
50 y = env.Y + dir_y[ env.Direction ]
52 if y != 4
and y != 8
and y != 12:
58 left = env.Map.Check(
'cwall_mural_1_1', (4, y))
59 right = env.Map.Check(
'cwall_mural_1_2', (5, y))
61 if left ==
None or right ==
None:
68 env.Map.CreateObject(
'rubble', 4, y)
69 env.Map.CreateObject(
'rubble', 5, y)
70 env.Map.CreateObject(
'explosion2', 4, y)
71 env.Map.CreateObject(
'explosion2', 5, y)
73 Crossfire.WhoAmI().Remove()
75 env.Map.Print(
'The wall explodes!')
79 Handle Kaptel's death event. Depending on whether the player triggered the lever,
80 either prevent death or trigger the opening of the exit.
82 who = Crossfire.WhoAmI()
84 floor = who.Map.ObjectAt(24, 1)
85 while floor !=
None and floor.Above !=
None:
88 if floor.Name ==
'boulder':
89 who.Say(
'AAAAAAAAAaaaaahhhhhhhhhhhhhh!!!!!!!!!')
90 who.Map.TriggerConnected(11, 1)
93 who.Map.Print(
"%s roars and seems to regenerate!"%(Crossfire.WhoAmI().Name))
94 who.HP =
int(who.MaxHP / 2)
95 Crossfire.SetReturnValue(1)
98 '''Check if the reply to the challenge is correct.'''
100 return msg ==
'0' or msg ==
'none'
101 return count ==
int(msg)
104 below = map.ObjectAt(x, y)
106 if below.ArchName == arch:
114 Say handler for the final white challenge.
115 Player must know how many jewel piles of a certain kind were on the map, else failure.
118 msg = Crossfire.WhatIsMessage()
119 ear = Crossfire.WhoAmI()
120 status = ear.ReadKey(
'challenge')
123 ear.Say(
'You already replied!')
128 ear.WriteKey(
'challenge',
'ready', 1)
129 ear.Say(
'To get the white key, reply to the following question:')
131 archs = [
'gem',
'amethyst',
'emerald',
'ruby',
'sapphire',
'pearl' ]
132 names = [
'diamonds',
'amethysts',
'emeralds',
'rubies',
'sapphires',
'pearls' ]
133 choice = random.randint(0, 5)
135 behind_windows = { (8, 2), (10, 7), (10, 9), (28, 18) }
136 behind_grates = { (2, 23), (10, 7), (10, 9), (16, 21), (19, 26), (19, 28), (20, 26), (23, 7), (24, 1), (24, 6), (25, 7) }
138 location = random.randint(1, 3)
140 positions = behind_windows
141 where =
'behind windows'
143 positions = behind_grates
144 where =
'behind grates'
146 positions = behind_windows.union(behind_grates)
147 where =
'in this dungeon'
150 for pos
in positions:
151 count +=
check_arch(ear.Map, pos[0], pos[1], archs[choice])
153 ear.Say(
'How many piles of %s did you see %s?'%(names[choice],where))
154 ear.Say(
'Reply with a number in digits please.')
157 ear.WriteKey(
'reply',
str(count), 1)
162 ear.WriteKey(
'challenge',
'done')
164 count =
int(ear.ReadKey(
'reply'))
166 ear.Map.TriggerConnected(60, 1)
169 ear.Say(
'Sorry, that is not the correct reply. Please try again later.')
172 '''Handle the player applying the lever to get her reward.'''
174 'amethysts': [2, 15],
175 'glowing_crystal': [2, 17],
177 'townportal': [5, 18],
178 'lunar_shield': [7, 18],
179 'wizard_gloves': [10, 15],
180 'black_dragon_mail': [10, 17],
199 def swap_gate(item, delete = False):
201 x = rewards[chances[item]][0]
202 y = rewards[chances[item]][1]
203 gate = lever.Map.ObjectAt(x, y).Above.Above
206 if gate.ArchName ==
'grate_closed_1':
207 replace =
'igate_closed_1'
208 elif gate.ArchName ==
'grate_closed_2':
209 replace =
'igate_closed_2'
210 elif gate.ArchName ==
'igate_closed_1':
211 replace =
'grate_closed_1'
213 elif gate.ArchName ==
'igate_closed_2':
214 replace =
'grate_closed_2'
223 ob = lever.Map.CreateObject(replace, x, y)
228 Crossfire.SetReturnValue(1)
229 lever = Crossfire.WhoAmI()
230 event = Crossfire.WhatIsEvent()
231 status = lever.ReadKey(
'status')
232 if event.Subtype == Crossfire.EventType.APPLY:
234 lever.Map.Print(
'And now you shall get your reward!')
235 lever.WriteKey(
'status',
'start', 1)
236 lever.WriteKey(
'reward',
str(random.randint(0, len(chances))), 1)
237 lever.WriteKey(
'left',
str(random.randint(1, 3) + random.randint(1, 3) + random.randint(1, 3)), 1)
238 lever.WriteKey(
'current',
'-1', 1)
239 lever.CreateTimer(1 + random.randint(1, 3), 2)
241 elif event.Subtype == Crossfire.EventType.TIMER:
242 if lever.Map.Darkness < 5:
243 lever.Map.ChangeLight(1)
244 lever.CreateTimer(1 + random.randint(1, 3), 2)
247 left =
int(lever.ReadKey(
'left'))
248 current =
int(lever.ReadKey(
'current'))
250 lever.Map.Print(
"Yes! Congratulations!")
251 while lever.Map.Darkness > 0:
252 lever.Map.ChangeLight(-1)
253 swap_gate(current,
True)
257 lever.Map.Print(
'No!')
260 lever.WriteKey(
'current',
'-1', 1)
261 lever.CreateTimer(1 + random.randint(1, 3), 2)
265 lever.WriteKey(
'left',
str(left), 1)
267 current = random.randint(0, len(chances) - 1)
269 lever.WriteKey(
'current',
str(current), 1)
270 lever.CreateTimer(1 + random.randint(1, 2), 1)
271 lever.Map.Print(
'Will it be this reward?')
274 '''Handle Politos's dialog in the entrance.'''
275 msg = Crossfire.WhatIsMessage()
276 politos = Crossfire.WhoAmI()
277 pl = Crossfire.WhoIsActivator()
278 status = politos.ReadKey(
'opened')
281 politos.Say(
"This potion will replace any of the three keys, but you have to figure out how to use it yourself.")
282 elif msg ==
'yes' and status ==
'':
283 politos.Say(
'Ok, good luck')
284 politos.Map.TriggerConnected(1, 1)
285 politos.WriteKey(
'opened',
'yes', 1)
287 politos.Say(
'Feel free to go try get the keys now.')
290 'Welcome to Darcap Manor. Here you can attempt to find some exclusive rewards!\n'
291 'To get a treasure from upstairs, you need to find three keys: blue, white, brown.\n'
292 'You can get one from each of the corners of this room, provided you are strong or smart enough, of course.\n'
294 'So do you wish to enter?'
296 Crossfire.SetReturnValue(1)
298 params = Crossfire.ScriptParameters()
302 elif params ==
'potion':
304 elif params ==
'kaptel':
306 elif params ==
'white':
308 elif params ==
'reward':
310 elif params ==
'politos':