1-- Set the arena subvault tier. This must be called by main gauntlet encompass
2-- map before the subvault statement.
3--
4-- @param n The tier, currently either 1 or 2.
5function gauntlet_arena_set_tier(n)
6    gauntlet_arena_tier = n
7end
8
9-- Set a custom nsubst pattern to customize what extra items are placed in an
10-- arena. Here extra item refers to the three possible items placed after the
11-- first.
12--
13-- @param nsubst A string containing nsubst replacement terms for the
14--               three extra item 'd' glyphs. This string should only be the
15--               replacement terms of the nsubst, hence it does not begin with
16--               "d = ".
17--
18-- Example nsubst parameter:
19--
20-- "fg|*|*...... / ." : Replace one 'd' with 50% chance of nothing and 50%
21--                      chance for 'f' or 'g' (1/3 chance), or '|' or '*' (2/3
22--                      chance). The remaining 'd' become floor.
23--
24-- See the comments for gauntlet_arena_item_setup() for details on the
25-- available item slot glyphs.
26function gauntlet_arena_custom_extra_items(nsubst)
27    gauntlet_arena_extra_items_nsubst = nsubst
28end
29
30-- Set the extra item placement in arenas to the default behaviour. See
31-- gauntlet_arena_item_setup() for details on this default.
32function gauntlet_arena_default_extra_items()
33    gauntlet_arena_extra_items_nsubst = nil
34end
35
36-- Set a random monster list based on the monsters in tier1_gauntlet_arenas.
37-- Use only these so that the potential summons won't get too crazy. This isn't
38-- a great system since custom weights in the "mons" entries could throw this
39-- off.
40function gauntlet_random_mons_setup(e)
41    local mon_list = ""
42    for _, entry in ipairs(tier1_gauntlet_arenas) do
43        for _, key in ipairs({"first", "second", "third"}) do
44            if entry[key] ~= nil then
45                if mon_list == "" then
46                    mon_list = entry[key]["mons"]
47                else
48                    mon_list = mon_list .. " / " .. entry[key]["mons"]
49                end
50            end
51        end
52    end
53
54   e.set_random_mon_list(mon_list)
55end
56
57-- Main setup function for gauntlet encompass maps. See comments in the main
58-- maps section of gauntlet.des for details.
59--
60-- @param e            Lua environment.
61-- @param entry_glyphs A string of glyphs for entry transporter glyphs in order
62--                     of subvault placement.
63-- @param exit_glyphs  A string of glyphs for exit transporter landing site
64--                     glyphs in order of subvault placement.
65function gauntlet_setup(e, entry_glyphs, exit_glyphs)
66    for i = 1, entry_glyphs:len() do
67        e.lua_marker(entry_glyphs:sub(i,i),
68                     transp_loc("gauntlet_arena_entry_" ..  tostring(i)))
69        e.lua_marker(exit_glyphs:sub(i,i),
70                     transp_dest_loc("gauntlet_arena_exit_" ..  tostring(i)))
71    end
72
73    gauntlet_arena_set_tier(1)
74    gauntlet_arena_num = nil
75    gauntlet_arena_default_extra_items()
76
77    gauntlet_random_mons_setup(e)
78end
79
80-- Set up transporter features on glyphs 'P' and 'Q' based on the current
81-- subvault number.
82-- @param e Lua environment.
83function gauntlet_arena_transporter_setup(e)
84    if gauntlet_arena_num == nil then
85        gauntlet_arena_num = 1
86    else
87        gauntlet_arena_num = gauntlet_arena_num + 1
88    end
89
90    e.lua_marker("P", transp_dest_loc("gauntlet_arena_entry_" ..
91                                      tostring(gauntlet_arena_num)))
92    e.lua_marker("Q", transp_loc("gauntlet_arena_exit_" ..
93                                 tostring(gauntlet_arena_num)))
94end
95
96-- Get a random arena entry for an arena subvault based on the arena's tier.
97-- @param e Lua environment.
98function gauntlet_arena_get_monster_entry(e)
99    local gauntlet_arenas
100    if gauntlet_arena_tier == 1 then
101        gauntlet_arenas = tier1_gauntlet_arenas
102    else
103        gauntlet_arenas = tier2_gauntlet_arenas
104    end
105
106    return util.random_weighted_from("weight", gauntlet_arenas)
107end
108
109-- Make a KMONS statement based on a given monster entry and glyph. Roll the
110-- number of monsters to place and place them on that glyph.
111-- @param e     Lua environment.
112-- @param entry A table with keys 'mons', 'min', and 'max' See the comments
113--              above the variable tier1_gauntlet_arenas.
114-- @param glyph The glyph on which to place the entry. If entry is nil, this
115--              glyph will be replaced with floor.
116function gauntlet_arena_mons_setup(e, entry, glyph)
117    if entry == nil then
118        e.subst(glyph .. " = .")
119        return
120    end
121
122    e.kmons(glyph .. " = " .. entry["mons"])
123
124    local n = entry["min"] + crawl.random2(entry["max"] - entry["min"] + 1)
125    if n < 1 then
126        e.subst(glyph .. " = .")
127    else
128        e.nsubst(glyph .. " = " .. tostring(n) .. "=" .. glyph .. " / .")
129    end
130end
131
132-- Item setup for arena subvaults.
133--
134-- Defines item slots 'd', 'e', 'f', and 'g'. Slot 'd' will be any custom loot
135-- item defined by the arena, otherwise it's defined as "nothing". Slot 'e' is
136-- 50% chance each of dgn.loot_scrolls or dgn.loot_potions. Slot 'f' is
137-- good_item aux armour, and slot 'g' is good_item jewellery. Both 'f' and 'g'
138-- have a chance to be upgraded to randart for tier 2 arenas.
139--
140-- All arenas place one 'd' glyph that remains as 'd' if a custom definition is
141-- given in the other_loot parameter. Otherwise this first 'd' glyph is
142-- replaced with either 'e' or '*' with 1/2 chance each.
143--
144-- For the remaining three 'd' glyphs, they are replaced according to the
145-- custom nsubst pattern defined via gauntlet_arena_custom_extra_items(). If
146-- this function has not been called or if gauntlet_arena_default_extra_items()
147-- has just been called, the default extra item placement depends on the arena
148-- tier.
149--
150-- For default placement, tier 1 arenas have a 1/3 chance to replace one 'd'
151-- glyph with either 'f' or 'g' and a 2/3 chance to place either '|' or
152-- '*'instead. The two remaining 'd' become floor. For tier 2 arenas, one 'd'
153-- becomes either 'f' or 'g', and one additional 'd' becomes either '|' or '*',
154-- and the final 'd' becomes floor.
155--
156-- @param e           Lua environment.
157-- @param custom_loot If non-nil, place this as a guaranteed loot item.
158function gauntlet_arena_item_setup(e, custom_loot)
159    -- Replace all 'd' after the first with the unused 'X' glyph so we can more
160    -- easilly apply any custom replacement for those extra items.
161    e.nsubst("d = d / X")
162
163    -- Redefine these item class glyphs to use no_pickup
164    e.kitem("* = star_item no_pickup")
165    e.kitem("| = superb_item no_pickup")
166    e.kitem("% = any no_pickup")
167    e.kitem("$ = gold no_pickup")
168
169    -- Define item slot 'd' and first subst.
170    local first_subst = "e*"
171    if custom_loot then
172        e.item(custom_loot .. " no_pickup")
173        first_subst = "d"
174    else
175        e.item("nothing")
176    end
177
178    -- Define item slot 'e'
179    local scrolls = dgn.loot_scrolls:gsub("scroll of", "no_pickup scroll of")
180    local potions = dgn.loot_potions:gsub("potion of", "no_pickup potion of")
181    e.item(scrolls .. " / " .. potions)
182    -- Set exactly one loot item.
183    e.subst("d = " .. first_subst)
184
185    local extra_nsubst
186    if gauntlet_arena_extra_items_nsubst ~= nil then
187        extra_nsubst = gauntlet_arena_extra_items_nsubst
188    end
189
190    local good_aux = dgn.good_aux_armour:gsub("/", "no_pickup /")
191                           .. " no_pickup"
192    local randart_aux = dgn.randart_aux_armour:gsub("/", "no_pickup /")
193                           .. " no_pickup"
194    if gauntlet_arena_tier == 1 then
195        -- Item slots 'f' and 'g' for tier 1.
196        e.item(good_aux)
197        e.item("any jewellery good_item no_pickup")
198
199        if extra_nsubst == nil then
200            extra_nsubst = "fg|*|* / ."
201        end
202    else
203        -- Item slots 'f' and 'g' for tier 2.
204        if crawl.one_chance_in(3) then
205            e.item(randart_aux)
206        else
207            e.item(good_aux)
208        end
209        e.item("any jewellery good_item w:20 no_pickup " ..
210               "/ any jewellery randart no_pickup")
211
212        if extra_nsubst == nil then
213            extra_nsubst = "fg / |* / ."
214        end
215    end
216    -- Set remaining loot items.
217    e.nsubst("X = " .. extra_nsubst)
218end
219
220-- Arena subvault terrain setup. Handles randomization of rock, liquids, trap
221-- placement, and plants.
222-- subvault.
223-- @param e              Lua environment.
224-- @param rock_unchanged If true, don't randomize 'x' glyphs to other wall
225--                       types. Defaults to false.
226-- @param liquid         Either nil or one of the strings "lava" or "water". If
227--                       nil, 'l' is unchanged and 'w' has a chance to become
228--                       lava. If "lava", all 'w' glyphs becomes lava. If
229--                       "water", all 'l' glyphs become deep water.
230-- @param plant          Either nil or one of the strings "demonic" or
231--                       "withered". If nil, 'p' becomes a mix of mostly
232--                       plants with some fungus. If "withered" or "demonic",
233--                       'p' becomes withered or demonic plants, respectively.
234function gauntlet_arena_terrain_setup(e, rock_unchanged, liquid, plant)
235    if not rock_unchanged then
236        local glyphs = "xxc"
237        if gauntlet_arena_tier == 2 then
238            glyphs = "cccvvb"
239        end
240        e.subst("x : " .. glyphs)
241    end
242
243    if not liquid then liquid = "default" end
244    if liquid == "lava" then
245        e.subst("w = l")
246    elseif liquid == "water" then
247        e.subst("l = w")
248    elseif liquid == "default" then
249        e.subst("w : wwwl")
250    else
251        error("Unknown liquid type: " .. liquid)
252    end
253
254    -- A 1/6 chance to use traps for tier 1, 1/4 chance for tier 2.
255    if gauntlet_arena_tier == 1 then
256        e.subst("^ : ^.....")
257    else
258        e.subst("^ : ^...")
259    end
260    e.kfeat("^ = dispersal trap / net trap")
261
262    if not plant then plant = "default" end
263    if plant == "demonic" then
264        e.kmons("p = demonic plant")
265    elseif plant == "withered" then
266        e.kmons("p = withered plant")
267    elseif plant == "default" then
268        e.kmons("p = plant w:30 / fungus")
269    else
270        error("Unknown plant type: " .. plant)
271    end
272end
273
274-- Arena subvault main setup. See the comments in the arena subvault section of
275-- gauntlet.des for details.
276-- @param e              Lua environment.
277-- @param rock_unchanged If true, don't randomize 'x' glyphs to other wall
278--                       types. Defaults to false.
279function gauntlet_arena_setup(e, rock_unchanged)
280    gauntlet_arena_transporter_setup(e)
281
282    local entry = gauntlet_arena_get_monster_entry(e)
283
284    gauntlet_arena_item_setup(e, entry["loot"])
285
286    gauntlet_arena_mons_setup(e, entry["first"], "1")
287    gauntlet_arena_mons_setup(e, entry["second"], "2")
288    gauntlet_arena_mons_setup(e, entry["third"], "3")
289
290    gauntlet_arena_terrain_setup(e, rock_unchanged, entry["liquid"],
291                                 entry["plant"])
292end
293
294-- Arena monster sets used for the first vault choice. The monster entries are
295-- in the keys 'first', 'second', and 'third' giving the monsters to place on
296-- the glyphs '1', '2', and '3', respectively. See the comments in arena
297-- subvault section of gauntlet.des for more details.
298--
299-- Each monster entry must contain a "mons" key with the definition, and "min"
300-- and "max" keys. The number of monsters that place for that glyph will then
301-- be random uniform on [min, max].
302--
303-- Other supported keys:
304-- "weight" : Choice weight for the arena set, defaults to 10.
305-- "liquid" : Either "lava" or "water" will force the arena vault to use
306--            only that liquid wherever it would place 'w' or 'l'.
307-- "plant"  : Either "demonic" or "withered" will have the arena use that type
308--            of plant whenever it would place a plant.
309-- "loot"   : Should contain a valid item definition for a custom loot item.
310--            Exactly one of this item will always place in the arena.
311tier1_gauntlet_arenas = {
312  {
313    first  = {mons = "cane toad simulacrum / wyvern simulacrum " ..
314                      "/ hornet simulacrum", min = 1, max = 1},
315    second = {mons = "simulacrum place:D:12", min = 2, max = 4},
316    liquid = "water",
317    plant  = "withered",
318  },
319  {
320    second = {mons = "raiju", min = 1, max = 1},
321    third  = {mons = "steam dragon", min = 1, max = 2},
322    liquid = "water",
323  },
324  {
325    second = {mons = "slime creature", min = 2, max = 4},
326    third  = {mons = "jelly", min = 1, max = 3},
327    liquid = "water",
328    plant  = "demonic",
329  },
330  {
331    first  = {mons = "sixfirhy", min = 1, max = 1},
332    second = {mons = "ufetubus", min = 2, max = 4},
333    liquid = "water",
334    plant  = "demonic",
335  },
336  {
337    first  = {mons = "ice devil", min = 1, max = 1},
338    second = {mons = "white imp", min = 2, max = 4},
339    liquid = "water",
340    plant  = "demonic",
341  },
342  {
343    first  = {mons = "soul eater", min = 1, max = 1},
344    second = {mons = "shadow imp", min = 2, max = 4},
345    liquid = "water",
346    plant  = "withered",
347  },
348  {
349    first  = {mons = "ynoxinul", min = 1, max = 1},
350    second = {mons = "rust devil", min = 0, max = 1},
351    third  = {mons = "iron imp", min = 2, max = 4},
352    plant  = "demonic",
353  },
354  {
355    first  = {mons = "smoke demon", min = 1, max = 1},
356    second = {mons = "red devil", min = 0, max = 1},
357    third  = {mons = "crimson imp", min = 2, max = 4},
358    liquid = "lava",
359    plant  = "demonic",
360  },
361  {
362    first  = {mons = "neqoxec", min = 1, max = 1},
363    second = {mons = "chaos spawn", min = 1, max = 3},
364    plant  = "demonic",
365  },
366  {
367    second = {mons = "shadow", min = 2, max = 4},
368    liquid = "water",
369    plant  = "withered",
370  },
371  {
372    first  = {mons = "catoblepas", min = 1, max = 1},
373    second = {mons = "gargoyle", min = 1, max = 2},
374  },
375  {
376    first  = {mons = "torpor snail", min = 1, max = 1},
377    second = {mons = "yak band / wolf band / elephant band", min = 1,
378               max = 1},
379  },
380  {
381    first  = {mons = "fire crab", min = 1, max = 1},
382    second = {mons = "fire bat", min = 2, max = 4},
383    liquid = "lava",
384  },
385  {
386    second = {mons = "shapeshifter", min = 1, max = 3},
387  },
388  {
389    first  = {mons = "flying skull band", min = 1, max = 1},
390    plant  = "withered",
391  },
392  {
393    second = {mons = "hornet", min = 2, max = 3},
394  },
395  {
396    first  = {mons = "queen bee", min = 1, max = 1},
397    second = {mons = "killer bee band", min = 1, max = 1},
398  },
399  {
400    first  = {mons = "moth of wrath", min = 1, max = 1},
401    second = {mons = "wolf band", min = 1, max = 1},
402  },
403  {
404    first  = {mons = "worldbinder", min = 1, max = 1},
405    second = {mons = "boggart", min = 1, max = 3},
406    plant  = "demonic",
407  },
408  {
409    first  = {mons = "death scarab", min = 1, max = 1},
410    second = {mons = "spectre place:Lair:6", min = 1, max = 1},
411    liquid = "water",
412    plant  = "withered",
413  },
414  {
415    first  = {mons = "shining eye", min = 1, max = 1},
416    second = {mons = "floating eye / golden eye", min = 1, max = 2},
417    loot   = "potion of mutation ident:type",
418    plant  = "demonic",
419    weight = 5,
420  },
421  {
422    first  = {mons = "eye of devastation", min = 1, max = 1},
423    second = {mons = "floating eye / golden eye", min = 1, max = 2},
424    weight = 5,
425  },
426  {
427    first  = {mons = "tengu warrior", min = 1, max = 1},
428    second = {mons = "tengu conjurer", min = 1, max = 2},
429  },
430  {
431    first  = {mons = "wizard", min = 1, max = 1},
432    second = {mons = "white imp / shadow imp", min = 1, max = 3},
433  },
434  {
435    second = {mons = "large abomination", min = 0, max = 2},
436    third  = {mons = "small abomination", min = 3, max = 6},
437    plant  = "demonic",
438  },
439  {
440    first  = {mons = "ice statue", min = 1, max = 1},
441    second = {mons = "rime drake", min = 1, max = 2},
442    liquid = "water",
443  },
444  {
445    first  = {mons = "oklob plant", min = 1, max = 1},
446    second = {mons = "acid dragon", min = 1, max = 2},
447  },
448  {
449    first  = {mons = "necromancer", min = 1, max = 1},
450    second = {mons = "wolf band", min = 1, max = 1},
451    plant  = "withered",
452  },
453  {
454    second = {mons = "swamp worm", min = 2, max = 3},
455  },
456}
457
458-- Monster sets used for the first vault choice, same structure as for
459-- tier1_gauntlet_arenas.
460tier2_gauntlet_arenas = {
461  {
462    first  = {mons = "hydra simulacrum / harpy simulacrum " ..
463                      "/ ice dragon simulacrum", min = 1, max = 1},
464    second = {mons = "simulacrum place:D:15", min = 2, max = 4},
465    liquid = "water",
466    plant  = "withered",
467  },
468  {
469    first  = {mons = "dire elephant", min = 1, max = 1},
470    second = {mons = "elephant", min = 1, max = 3},
471  },
472  {
473    first  = {mons = "catoblepas", min = 1, max = 1},
474    second = {mons = "molten gargoyle", min = 1, max = 2},
475    third  = {mons = "gargoyle", min = 1, max = 2},
476    liquid = "lava",
477  },
478  {
479    second = {mons = "shadow", min = 3, max = 6},
480    liquid = "water",
481    plant  = "withered",
482  },
483  {
484    first  = {mons = "fire crab", min = 1, max = 1},
485    second = {mons = "hell hound", min = 1, max = 3},
486    third  = {mons = "fire bat", min = 3, max = 6},
487    liquid = "lava",
488  },
489  {
490    first  = {mons = "efreet", min = 1, max = 1},
491    second = {mons = "hell hound", min = 1, max = 3},
492    third  = {mons = "fire elemental", min = 1, max = 3},
493    liquid = "lava",
494    plant  = "demonic",
495  },
496  {
497    first  = {mons = "hell hog", min = 1, max = 1},
498    second = {mons = "hell hound", min = 1, max = 3},
499    third  = {mons = "fire bat", min = 2, max = 4},
500    liquid = "lava",
501    plant  = "demonic",
502  },
503  {
504    first = {mons = "quicksilver ooze", min = 1, max = 1},
505    liquid = "water",
506  },
507  {
508    second = {mons = "sixfirhy", min = 2, max = 4},
509    liquid = "water",
510    plant  = "demonic",
511  },
512  {
513    first  = {mons = "hell beast", min = 1, max = 1},
514    second = {mons = "hell hound", min = 0, max = 2},
515    liquid = "lava",
516    plant  = "demonic",
517  },
518  {
519    first  = {mons = "green death", min = 1, max = 1},
520    second = {mons = "orange demon", min = 0, max = 2},
521    plant  = "demonic",
522  },
523  {
524    first  = {mons = "hellion", min = 1, max = 1},
525    second = {mons = "sun demon / smoke demon / red devil", min = 0, max = 1},
526    third  = {mons = "hell hound", min = 0, max = 2},
527    liquid = "lava",
528    plant  = "demonic",
529    weight = 5
530  },
531  {
532    first  = {mons = "balrug", min = 1, max = 1},
533    third  = {mons = "sun demon", min = 0, max = 1},
534    third  = {mons = "hell hound", min = 0, max = 2},
535    liquid = "lava",
536    plant  = "demonic",
537    weight = 5
538  },
539  {
540    first  = {mons = "cacodemon", min = 1, max = 1},
541    second = {mons = "neqoxec", min = 0, max = 3},
542    loot   = "potion of mutation ident:type",
543    plant  = "demonic",
544    weight = 5
545  },
546  {
547    first  = {mons = "blizzard demon", min = 1, max = 1},
548    second = {mons = "white imp / ice devil", min = 0, max = 3},
549    liquid = "water",
550  },
551  {
552    first  = {mons = "reaper", min = 1, max = 1},
553    second = {mons = "hellwing / shadow imp", min = 1, max = 3},
554    liquid = "water",
555    plant  = "withered",
556  },
557  {
558    first  = {mons = "glowing shapeshifter", min = 1, max = 1},
559    second = {mons = "shapeshifter", min = 2, max = 3},
560  },
561  {
562    first  = {mons = "apocalypse crab", min = 1, max = 1},
563    plant  = "demonic",
564  },
565  {
566    second = {mons = "flying skull band", min = 2, max = 3},
567    plant  = "withered",
568  },
569  {
570    first  = {mons = "death drake", min = 1, max = 1},
571    second = {mons = "zombie place:D:15 / spectre place:D:15", min = 2,
572              max = 4},
573    liquid = "water",
574    plant  = "withered"
575  },
576  {
577    first  = {mons = "ghost crab", min = 1, max = 1},
578    liquid = "water",
579    plant  = "withered",
580  },
581  {
582    first  = {mons = "meliai band", min = 1, max = 1},
583  },
584  {
585    first  = {mons = "torpor snail", min = 1, max = 1},
586    second = {mons = "death yak band / hydra", min = 1, max = 1},
587  },
588  {
589    first  = {mons = "entropy weaver", min = 1, max = 1},
590    second = {mons = "wolf spider", min = 0, max = 1},
591    third  = {mons = "redback / jumping spider", min = 1, max = 2},
592    liquid = "water",
593  },
594  {
595    first  = {mons = "moth of wrath", min = 1, max = 1},
596    second = {mons = "wolf spider / nothing", min = 0, max = 1},
597    third  = {mons = "redback", min = 2, max = 4},
598    liquid = "water",
599  },
600  {
601    second = {mons = "thrashing horror", min = 1, max = 2},
602    third  = {mons = "small abomination", min = 2, max = 4},
603    plant  = "demonic",
604  },
605  {
606    first  = {mons = "great orb of eyes", min = 1, max = 1},
607    second = {mons = "ugly thing", min = 1, max = 2},
608    plant  = "demonic",
609  },
610  {
611    second = {mons = "glowing orange brain", min = 1, max = 2},
612    third  = {mons = "ugly thing", min = 1, max = 2},
613    plant  = "demonic",
614  },
615  {
616    second = {mons = "large abomination", min = 2, max = 3},
617    third  = {mons = "small abomination", min = 3, max = 6},
618    plant  = "demonic",
619  },
620  {
621    first  = {mons = "wretched star", min = 1, max = 1},
622    second = {mons = "neqoxec / small abomination", min = 1, max = 3},
623    loot   = "potion of mutation ident:type",
624    plant  = "demonic",
625  },
626  {
627    second = {mons = "wizard", min = 2, max = 2},
628    third  = {mons = "white imp / shadow imp", min = 3, max = 6},
629  },
630  {
631    first  = {mons = "necromancer", min = 1, max = 1},
632    second = {mons = "death yak band", min = 1, max = 1},
633    liquid = "water",
634    plant  = "withered",
635  },
636  {
637    second = {mons = "death scarab", min = 2, max = 2},
638    third  = {mons = "spectre place:Lair:6", min = 2, max = 4},
639    liquid = "water",
640    plant  = "withered",
641  },
642  {
643    first  = {mons = "orange crystal statue", min = 1, max = 1},
644  },
645  {
646    first  = {mons = "obsidian statue", min = 1, max = 1},
647    liquid = "water",
648    plant  = "withered",
649  },
650  {
651    -- Guarantee that one places in the central location.
652    first  = {mons = "lightning spire", min = 1, max = 1},
653    second = {mons = "lightning spire", min = 0, max = 1},
654    third  = {mons = "raiju", min = 1, max = 2},
655  },
656  {
657    first  = {mons = "tyrant leech", min = 1, max = 1},
658    second = {mons = "swamp worm", min = 2, max = 4},
659  },
660}
661
662function gauntlet_exit_loot(e)
663    local gauntlet_loot = "superb_item w:49 / any armour w:7 " ..
664                          "/ any wand w:14 / any scroll"
665
666    local num_items = 7 + crawl.random2avg(10, 2)
667    local item_def = ""
668    for i = 1, num_items do
669        if i > 1 then
670            item_def = item_def .. ", "
671        end
672
673        item_def = item_def ..
674                   (crawl.one_chance_in(3) and "star_item" or gauntlet_loot)
675    end
676
677    e.kitem("< = " .. item_def)
678end
679