###############################################################################
# vaults.des: Entries to the Vaults branch, and Vaults:$ set-up.
#
# Vaults are scattered according to purpose across the rest of dat/des.
###############################################################################

: crawl_require('dlua/vault.lua')

{{
-- Vaults:$ common loot substitutions and wall setting.
function vaults_end_loot(e)
  if (dgn.persist.vaults_end_crystal) then
    e.subst("x = b")
  else
    e.subst("x = v")
  end
  e.subst("? = | * .:43")
  e.subst("| = | *:2")
  e.subst("* = * |:2")
  e.nsubst("*| = 1:$")
end

-- Vaults:$ cross-vault rune substitution. Turn 'O' into a rune (if it doesn't
-- exist yet) or a good item. Note that this assumes that only one "prize"
-- subvault is ever picked, and that it is the first subvault of the four.
function vaults_end_rune(e)
  if dgn.map_by_tag("vaults_end_rune") and
     (e.has_tag("vaults_end_quadrant_prize") and crawl.one_chance_in(4) or
      e.has_tag("vaults_end_quadrant")) then
        e.subvault("k : vaults_end_gem")
        e.subvault("O : vaults_end_rune")
  else
        e.subvault("O : vaults_end_norune")
        e.subst("k = *")
  end
end
}}

###############################################################################
# Vaults entries
###############################################################################

############################################################
# Generic Vaults entry
#
NAME:    david_vaults_1
TAGS:    vaults_entry transparent
MONS:    troll / two-headed ogre / orc knight w:5
MONS:    draugr w:4 / arcanist / \
         deep elf pyromancer w:4 / deep elf zephyrmancer w:4
SHUFFLE: !-
SUBST:   ! = x, - = +, c : cxv
NSUBST:  1 = 2:1 / * = 111.., 2 = 1:2 / * = 222..
KFEAT:   O = enter_vaults
MAP
xxxxxx.@.ccccc
x....+...c..2c
x....x...c...c
x!x--x.1.c..1c
@.x..x12.+.O1c
x.x..x.1.c..1c
x.x..x...c...c
x.+..x...c..2c
xxxxxx.@.ccccc
ENDMAP

############################################################
# Vault monsters near stair
#
NAME: david_vaults_2
TAGS: vaults_entry transparent
MONS: yaktaur captain, yaktaur, ogre mage, two-headed ogre
MONS: glowing shapeshifter, shapeshifter
SHUFFLE: 12 / 34 / 56
KFEAT:   O = enter_vaults
MAP
vvvvv.@....
v1.........
v..........
v.....2v.v.
@....2Ov..@
.....vvv.v.
...........
.....v.v.v.
......@....
ENDMAP

############################################################
# Vaults patterns 0: vanguard
#
NAME:    david_vaults_3
TAGS:    vaults_entry transparent no_trap_gen
MONS:    human
KMONS:   2 = orc knight w:20 / Urug, orc knight
KMONS:   3 = centaur warrior w:30 / Nessos, centaur warrior
KMONS:   4 = two-headed ogre w:30 / Rupert / Lodul, two-headed ogre
SHUFFLE: 2349
KFEAT:   O = enter_vaults
MAP
@..........@
.$..1131..$.
...1....1...
..1......1..
..2..O{..1..
..1..()..4..
..1......1..
...1....1...
.$..1911..$.
@..........@
ENDMAP

############################################################
# Vaults patterns I
#
NAME:    david_vaults_4
TAGS:    vaults_entry transparent
MONS:    fire dragon / ice dragon / hydra / lindwurm
MONS:    freezing wraith / shadow wraith / phantasmal warrior
MONS:    deep troll / troll
MONS:    two-headed ogre / cyclops / ettin
MONS:    glowing shapeshifter / vault guard w:15 / arcanist w:15
MONS:    shapeshifter
NSUBST:  1 = 1:1 / 1:2 / 1:3. / 1 : 4 .:30 / 1:5 .:70
SHUFFLE: 12345
SUBST:   * = *.%, c : cvv, 6 = 6...
KFEAT:   O = enter_vaults
MAP
@..........@
.cccccccccc.
.c.11111..c.
.c.ccccc..c.
.c.c***c..c.
.c.+**Oc..c.
.ccccccc..c.
...666....c.
.cc...ccccc.
@..........@
ENDMAP

############################################################
# Vaults patterns II
#
NAME:   david_vaults_5
TAGS:   vaults_entry
KMONS:  O = vault guard
KFEAT:  O = enter_vaults
SUBST:  ! : !', ? : ?'
SUBST:  ?! = ':30 0:10 9:5 %:10 *:5
NSUBST: ' = 2:0 / 1:$ / *:.
MAP
xxxxxxxxxxxxxx
xOx!x!x?x!x?xx
xx!x?x!x!x?x!x
x!x!x!x?x!x?xx
xx?x!x?x?x?x!x
x!x?x.x.x.x.xx
xx?x?x.x.x.x.x
x?x?x!x?x.x.xx
xx!x!x!x?x.x.x
xxxxxxxxxxxxx@
ENDMAP

############################################################
# The Guard of Blades
#
NAME:   erik_vaults_1
TAGS:   vaults_entry transparent
MONS:   dancing weapon ; long sword good_item
MONS:   vault guard ; long sword good_item . chain mail
SUBST:  v : vcxxx, 2 = 221
KFEAT:  O = enter_vaults
MAP
.............
.............
.....v%v.....
....vvvvv....
.....1O2.....
....vvvvv....
.....v%v.....
.............
.............
ENDMAP

############################################################
# Above As Below
#
NAME:    erik_vaults_2
TAGS:    vaults_entry transparent
MONS:    vault guard
SUBST:   v : vxx, b : bcc
KFEAT:   O = enter_vaults
MAP
vvvvvv.vvvvvv
vvvvvv.vvvvvv
vvvvbb.bbvvvv
vvvvb111bvvvv
.....1O1.....
vvvvb111bvvvv
vvvvbb.bbvvvv
vvvvvv.vvvvvv
vvvvvv.vvvvvv
ENDMAP

############################################################
# Bands entry
#
NAME:    hangedman_vaults_entry_quadrant_bands
TAGS:    vaults_entry no_monster_gen no_item_gen patrolling transparent
MONS:    centaur warrior, centaur / nothing w:5
MONS:    ogre mage, two-headed ogre / ogre w:15
MONS:    orc knight, orc priest / orc warrior / orc wizard
KMONS:   7 = yaktaur
KMONS:   8 = yaktaur / nothing
KMONS:   9 = deep elf knight / deep elf archer
KMONS:   0 = deep elf pyromancer / deep elf zephyrmancer w:5 / nothing
KMONS:   A = boggart / kobold demonologist
KMONS:   B = kobold brigand / kobold w:2
KMONS:   C = skeletal warrior
KMONS:   D = yaktaur draugr
KMASK:   @` = !no_item_gen
KFEAT:   O = enter_vaults
SHUFFLE: 12 / 34 / 56 / 78 / 90 / AB / CD, O%*|
SUBST:   $ = $$., * = **%, | = **|., ` = .
MAP
vvvvvvv@@vvvvvvv
vO2...v``v...4*v
v2$v2vv``vv4v$4v
v.v1v.v``v.v3v.v
v.2vv.v``v.vv4.v
v.v....``....v.v
vvvvv.v``v.vvvvv
@``````````````@
@``````````````@
vvvvv.v``v.vvvvv
v.v....``....v.v
v.6vv.v``v.vv8.v
v.v5v.v``v.v7v.v
v6$v6vv``vv8v$8v
v%6...v``v...8|v
vvvvvvv@@vvvvvvv
ENDMAP

############################################################
# Tiered entry
#
NAME:   grunt_vaults_entry_tiered
TAGS:   vaults_entry no_monster_gen transparent
MONS:   human w:29 / orc warrior w:1
MONS:   draugr w:2 / arcanist / yaktaur w:4
MONS:   vault guard w:58 / deep elf knight w:1 / deep elf archer w:1
SUBST:  x : xcv
NSUBST: 2 = 2:2 / * = 12, 3 = 2:3 / * = 113, % = 2:. / *:%
KFEAT:  O = enter_vaults
MAP
...............
.xxxxxxxxxxxxx.
.x%%...x...%%x.
.x%212.+.323%x.
.x.1T1.+..O2.x.
.x.1.1.+.323%x.
.x.....x...%%x.
.xx+++xxxxxxxx.
.x.....x...%%x.
.x.111.+....%x.
.x.2T..+.1T1.x.
.x%111.+.1.1.x.
.x%%...x.....x.
.xxxxxxxx+++xx.
.........@@@...
ENDMAP

############################################################
# A fortification!
#
NAME:   grunt_vaults_entry_fortified
TAGS:   vaults_entry no_pool_fixup no_monster_gen patrolling transparent
MONS:   human ; arbalest . short sword | dagger . \
                leather armour w:5 | ring mail | scale mail / \
        orc warrior ; orcbow . short sword | dagger . \
                      leather armour w:5 | ring mail | scale mail / \
        deep elf knight w:5 / deep elf archer w:5 / gargoyle / yaktaur
MONS:   vault guard / orc knight w:2
MONS:   arcanist / tengu conjurer / orc sorcerer / ogre mage
NSUBST: T = 1:U / *:T
KFEAT: O = enter_vaults
MAP
xxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxx
xxxxxxxvvvvvxxxxxxx
xxxxxxxvT.Tvxxxxxxx
xxxxxxxv2O2vxxxxxxx
xxxxxxxvT.Tvxxxxxxx
xvvvvvvvv+vvvvvvvvx
xv*...3.....3...*vx
xv.......2.......vx
xv...............vx
xvv+vvvv.v.vvvv+vvx
xv...vxv...vxv...vx
xv...vxv.1.vxv...vx
xv2..vxv.1.vxv..2vx
xvv11vvv+++vvv11vvx
.wwwwwwW...Wwwwwww.
.WwwwwwW...WwwwwwW.
 .WwwwWW...WwwwwW.
  .WWWW.....WWWW.
   ......@......
ENDMAP

############################################################

NAME: lightli_vaults_fourway_checkpoint
TAGS: vaults_entry transparent
MONS: vault guard
KFEAT: O = enter_vaults
NSUBST: 0 = 1:. / 1:0. / *:0
MAP
.................
...vv.......vv...
..vvvv.....vvvv..
.vvvvvv...vvvvvv.
.vvvvvvv+vvvvvvv.
..vvvv.....vvvv..
...vv.v0.0v.vv...
....v.0%1.0.v....
....+..1O1..+....
....v.0.1%0.v....
...vv.v0.0v.vv...
..vvvv.....vvvv..
.vvvvvvv+vvvvvvv.
.vvvvvv...vvvvvv.
..vvvv.....vvvv..
...vv.......vv...
.................
ENDMAP

NAME:     skrybe_vaults_entry_preservation
TAGS:     vaults_entry transparent
SHUFFLE:  AI , BJ , CK , DL
SUBST:    A = v , B = v , C = v , D = v
SUBST:    I = + , J = + , K = + , L = +
SUBST:    E = vvm , F = vvm, G = vvm, H = vvm
SHUFFLE:  vc
KFEAT:    O = enter_vaults
KMONS:    O = ironbound preserver
NSUBST:   $ = 1:O / *=.$%
MAP
        @@
 vvvvvvv..vvvvvvv
 v$....v..v....$v
 v.....E..F.....v
 v..0..v..v..0..v
 v...0.A..B.0...v
 v.....A..B.....v
 vvEvIIv..vJJvFvv
@................@
@................@
 vvGvKKv..vLLvHvv
 v.....C..D.....v
 v...0.C..D.0...v
 v..0..v..v..0..v
 v.....G..H.....v
 v$....v..v....$v
 vvvvvvv..vvvvvvv
        @@
ENDMAP

NAME:   ximxim_vaults_locker_room
TAGS:   vaults_entry no_monster_gen no_item_gen no_trap_gen
MONS:   human, vault guard
ITEM:   plate armour w:30 / broad axe w:7 / glaive / kite shield / \
        tower shield w:5 / arbalest w:3 / great sword / great mace
KFEAT:  O = enter_vaults
KFEAT:  Z = shallow_water
NSUBST: 1 = 2:2 / 2 = 12 / * = 1112
: single_cloud(_G, "Z", "rain", true)
MAP
vvvvvvvvvvvvv
vZ1.ZZ.1..ZZv
v+n+n+n+n+n+v
+.1.1..1.1..v
+.1..1..1.1Ov
+..1.....1..v
v+v+v+v+v+v+v
vdvdvdvdvdvdv
vvvvvvvvvvvvv
ENDMAP

NAME:   hellmonk_vaults_keyhole
TAGS:   vaults_entry no_monster_gen
MONS:   human, vault guard, ironbound thunderhulk / ironbound frostheart
KFEAT:  O = enter_vaults
SUBST:  v : v:90 b
NSUBST: 2 = 1:3 / *=2., - = 8=10.. / *:.
MAP
xxxxxvvv     vvvv
xxxxvv2vv  vvv--v
xxxvv...vvvv----+@
xxxv2.O.2-------+@
xxxvv...vvvv----+@
xxxxvv2vv  vvv--v
xxxxxvvv     vvvv
ENDMAP

NAME:    hellmonk_vaults_order_and_chaos
TAGS:    vaults_entry transparent no_monster_gen
MONS:    entropy weaver / glowing orange brain / great orb of eyes w:1
MONS:    ironbound preserver / vault guard / peacekeeper w:1
KFEAT:   AO = enter_vaults
KITEM:   B = any armour good_item / gold good_item w:50
KITEM:   C = any weapon good_item ego:chaos / any wand w:50
SHUFFLE: AB / CO, gG / "' / "' / "'
NSUBST:  -" = 1:1 / *:-, .' = 1:2 / *:.
FTILE:   .BO2g = floor_hall
FTILE:   -AC1G = floor_nerves
: vault_granite_statue_setup(_G, "G", "scintillating statue")
: vault_metal_statue_setup(_G, "g", "silver statue")
MAP
    vvv
   vv.vv
  vv..gvv
 @v..B..v
 @-....vv
 @--...v
 v---..@
vv----.@
v--A--v@
vvG--vv
 vv-vv
  vvv
ENDMAP

# something nasty has slaughtered the usual guards, but can't get in (no rune)
NAME:   hellmonk_vaults_attempted_burglary
TAGS:   vaults_entry transparent no_monster_gen
NSUBST: 8 = 1:89 / *:.
SUBST:  1 = 1., .= .:80 ', v = v:80 y
KFEAT:  O = enter_vaults
KFEAT:  y = metal_wall
KPROP:  'y = bloody
: dgn.delayed_decay(_G, '1', 'human corpse')
MAP
vvvv vvvv
vv8vvv8vv
v1..8..1v
vv..1..vv
 v.1O1.v
vv..1..vv
v1..G..1v
vv.....vv
vvv+++vvv
ENDMAP

###############################################################################
# Vaults:$ last level of the vaults -- dungeon.cc will change all these 'x's
###############################################################################
#
# Vaults:$ extensively uses subvaults. To provide another Vaults:$ quadrant
# variation, create a map tagged vaults_end_quadrant that is 27x23. It should
# have three blank cells on one corner (see any existing quadrant for an
# example), which will be used to orient that corner towards the middle of
# the map. Each quadrant must be capable of generating a rune, which
# should be done by placing an 'O' glyph and calling vaults_end_rune(_G).
#
# There is a lot of variance among the possible quadrants but we do ensure
# that (exactly) one quadrant with rich loot is generated. Those are tagged
# vaults_end_quadrant_prize and come in their own section below.

#############################################################
# The main vault for Vaults:$.
#
NAME:     vaults_vault
PLACE:    Vaults:$
ORIENT:   encompass
TAGS:     no_rotate no_dump
MONS:     vault guard
SHUFFLE:  ABCD
: if not dgn.persist.vaults_end_crystal then
:   dgn.persist.vaults_end_crystal = false
: end
: if crawl.one_chance_in(10) then
:   dgn.persist.vaults_end_crystal = true
SUBST:      x = b
LFLOORTILE: floor_crystal
: else
:   dgn.persist.vaults_end_crystal = false
SUBST:      x = v
LFLOORTILE: floor_metal_silver
: end
: if crawl.one_chance_in(36) then
SUBVAULT: A : vaults_end_quadrant_prize_mall
SUBVAULT: B : vaults_end_quadrant_mall
SUBVAULT: C : vaults_end_quadrant_mall
SUBVAULT: D : vaults_end_quadrant_mall
: else
SUBVAULT: A : vaults_end_quadrant_prize
SUBVAULT: B : vaults_end_quadrant
SUBVAULT: C : vaults_end_quadrant
SUBVAULT: D : vaults_end_quadrant
:end
SUBST:    ABCD = .
FTILE:    .([{<109 = floor_vault
{{
  set_feature_name("metal_wall", "heavily etched metal wall")
  set_feature_name("crystal_wall", "heavily etched crystal wall")
  set_feature_name("stone_stairs_up_i", "metal staircase leading up")
  set_feature_name("stone_stairs_up_ii", "metal staircase leading up")
  set_feature_name("stone_stairs_up_iii", "metal staircase leading up")
}}
MAP
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xx9..............................0.............................9xx
xx..............................................................xx
xx....AAAAAAAAAAAAAAAAAAAAAAA........BBBBBBBBBBBBBBBBBBBBBBB....xx
xx...AAAAAAAAAAAAAAAAAAAAAAAAA......BBBBBBBBBBBBBBBBBBBBBBBBB...xx
xx..AAAAAAAAAAAAAAAAAAAAAAAAAAA....BBBBBBBBBBBBBBBBBBBBBBBBBBB..xx
xx..AAAAAAAAAAAAAAAAAAAAAAAAAAA....BBBBBBBBBBBBBBBBBBBBBBBBBBB..xx
xx..AAAAAAAAAAAAAAAAAAAAAAAAAAA....BBBBBBBBBBBBBBBBBBBBBBBBBBB..xx
xx..AAAAAAAAAAAAAAAAAAAAAAAAAAA....BBBBBBBBBBBBBBBBBBBBBBBBBBB..xx
xx..AAAAAAAAAAAAAAAAAAAAAAAAAAA....BBBBBBBBBBBBBBBBBBBBBBBBBBB..xx
xx..AAAAAAAAAAAAAAAAAAAAAAAAAAA....BBBBBBBBBBBBBBBBBBBBBBBBBBB..xx
xx..AAAAAAAAAAAAAAAAAAAAAAAAAAA....BBBBBBBBBBBBBBBBBBBBBBBBBBB..xx
xx..AAAAAAAAAAAAAAAAAAAAAAAAAAA....BBBBBBBBBBBBBBBBBBBBBBBBBBB..xx
xx..AAAAAAAAAAAAAAAAAAAAAAAAAAA....BBBBBBBBBBBBBBBBBBBBBBBBBBB..xx
xx..AAAAAAAAAAAAAAAAAAAAAAAAAAA....BBBBBBBBBBBBBBBBBBBBBBBBBBB..xx
xx..AAAAAAAAAAAAAAAAAAAAAAAAAAA....BBBBBBBBBBBBBBBBBBBBBBBBBBB..xx
xx..AAAAAAAAAAAAAAAAAAAAAAAAAAA....BBBBBBBBBBBBBBBBBBBBBBBBBBB..xx
xx..AAAAAAAAAAAAAAAAAAAAAAAAAAA....BBBBBBBBBBBBBBBBBBBBBBBBBBB..xx
xx..AAAAAAAAAAAAAAAAAAAAAAAAAAA....BBBBBBBBBBBBBBBBBBBBBBBBBBB..xx
xx..AAAAAAAAAAAAAAAAAAAAAAAAAAA....BBBBBBBBBBBBBBBBBBBBBBBBBBB..xx
xx..AAAAAAAAAAAAAAAAAAAAAAAAAAA....BBBBBBBBBBBBBBBBBBBBBBBBBBB..xx
xx..AAAAAAAAAAAAAAAAAAAAAAAAAAA....BBBBBBBBBBBBBBBBBBBBBBBBBBB..xx
xx..AAAAAAAAAAAAAAAAAAAAAAAAAAA....BBBBBBBBBBBBBBBBBBBBBBBBBBB..xx
xx..AAAAAAAAAAAAAAAAAAAAAAAAAAA.11.BBBBBBBBBBBBBBBBBBBBBBBBBBB..xx
xx...AAAAAAAAAAAAAAAAAAAAAAAA..1111..BBBBBBBBBBBBBBBBBBBBBBBB...xx
xx....AAAAAAAAAAAAAAAAAAAAAAA.1....1.BBBBBBBBBBBBBBBBBBBBBBB....xx
xx...........................1..(<..1...........................xx
xx0.........................11.[..{.11..........................xx
xx...........................1..<<..1..........................0xx
xx............................1....1............................xx
xx....CCCCCCCCCCCCCCCCCCCCCCC..1111..DDDDDDDDDDDDDDDDDDDDDDD....xx
xx...CCCCCCCCCCCCCCCCCCCCCCCC...11...DDDDDDDDDDDDDDDDDDDDDDDD...xx
xx..CCCCCCCCCCCCCCCCCCCCCCCCCCC....DDDDDDDDDDDDDDDDDDDDDDDDDDD..xx
xx..CCCCCCCCCCCCCCCCCCCCCCCCCCC....DDDDDDDDDDDDDDDDDDDDDDDDDDD..xx
xx..CCCCCCCCCCCCCCCCCCCCCCCCCCC....DDDDDDDDDDDDDDDDDDDDDDDDDDD..xx
xx..CCCCCCCCCCCCCCCCCCCCCCCCCCC....DDDDDDDDDDDDDDDDDDDDDDDDDDD..xx
xx..CCCCCCCCCCCCCCCCCCCCCCCCCCC....DDDDDDDDDDDDDDDDDDDDDDDDDDD..xx
xx..CCCCCCCCCCCCCCCCCCCCCCCCCCC....DDDDDDDDDDDDDDDDDDDDDDDDDDD..xx
xx..CCCCCCCCCCCCCCCCCCCCCCCCCCC....DDDDDDDDDDDDDDDDDDDDDDDDDDD..xx
xx..CCCCCCCCCCCCCCCCCCCCCCCCCCC....DDDDDDDDDDDDDDDDDDDDDDDDDDD..xx
xx..CCCCCCCCCCCCCCCCCCCCCCCCCCC....DDDDDDDDDDDDDDDDDDDDDDDDDDD..xx
xx..CCCCCCCCCCCCCCCCCCCCCCCCCCC....DDDDDDDDDDDDDDDDDDDDDDDDDDD..xx
xx..CCCCCCCCCCCCCCCCCCCCCCCCCCC....DDDDDDDDDDDDDDDDDDDDDDDDDDD..xx
xx..CCCCCCCCCCCCCCCCCCCCCCCCCCC....DDDDDDDDDDDDDDDDDDDDDDDDDDD..xx
xx..CCCCCCCCCCCCCCCCCCCCCCCCCCC....DDDDDDDDDDDDDDDDDDDDDDDDDDD..xx
xx..CCCCCCCCCCCCCCCCCCCCCCCCCCC....DDDDDDDDDDDDDDDDDDDDDDDDDDD..xx
xx..CCCCCCCCCCCCCCCCCCCCCCCCCCC....DDDDDDDDDDDDDDDDDDDDDDDDDDD..xx
xx..CCCCCCCCCCCCCCCCCCCCCCCCCCC....DDDDDDDDDDDDDDDDDDDDDDDDDDD..xx
xx..CCCCCCCCCCCCCCCCCCCCCCCCCCC....DDDDDDDDDDDDDDDDDDDDDDDDDDD..xx
xx..CCCCCCCCCCCCCCCCCCCCCCCCCCC....DDDDDDDDDDDDDDDDDDDDDDDDDDD..xx
xx..CCCCCCCCCCCCCCCCCCCCCCCCCCC....DDDDDDDDDDDDDDDDDDDDDDDDDDD..xx
xx...CCCCCCCCCCCCCCCCCCCCCCCCC......DDDDDDDDDDDDDDDDDDDDDDDDD...xx
xx....CCCCCCCCCCCCCCCCCCCCCCC........DDDDDDDDDDDDDDDDDDDDDDD....xx
xx..............................................................xx
xx9.............................0..............................9xx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# Vaults:$ - the subvault used to place the rune.
#
# Used by the 'vaults_end_rune()' function in the prelude.
#
NAME:  vaults_end_rune
TAGS:  vaults_end_rune
KMONS: O = 8 / 9
KITEM: O = silver rune of Zot
MAP
O
ENDMAP

############################################################
# Vaults:$ - the subvault used to place the gem.
#
# Used by the 'vaults_end_rune()' function in the prelude.
#
NAME:  vaults_end_gem
TAGS:  vaults_end_gem
KMONS: k = 8 / 9
KITEM: k = shining gem
MAP
k
ENDMAP

############################################################
# Vaults:$ - the subvault used for potential rune locations that do not
# contain the real rune.
#
# Used by the 'vaults_end_rune()' function in the prelude.
#
NAME:  vaults_end_norune
TAGS:  vaults_end_norune allow_dup unrand
KMONS: o = 8 / 9
: if crawl.random2(13) == 12 then
KFEAT:   o = any shop
: else
KITEM:   o = any good_item
: end
MAP
o
ENDMAP

############################################################
# Vaults:$ - the subvault used for potential rune locations that do not
# contain the rune, but rather a mimic of it!
#
# Used by the 'vaults_end_rune()' function in the prelude.
# TODO: make gem mimics appear with these rune mimics.
#
NAME:    vaults_end_rune_mimic
TAGS:    vaults_end_norune unrand
WEIGHT:  1
KITEM:   o = silver rune of Zot mimic
MAP
o
ENDMAP

###############################################################################
# Vaults:$ quadrants
#
# Each of these quadrants, after randomization transformations, should have a
# single O and a single k to place the rune and the gem, respectively.
#
# TODO: Recount and consistently count *s / |s / monsters for each subvault,
# acknowledge the gem subvault chance of lowering the * count (but not always).
###############################################################################

############################################################
# about 2 |
NAME: vaults_end_classical_cross
TAGS: vaults_end_quadrant unrand
NSUBST:  U = 1:. / *:xxxx.
NSUBST:  V = 1:. / *:xxxx.
SUBST:   - = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  ..xxxxxxxxxxxxxxxxxxx..
 ...xxxxxxxxxxxxxxxxxxx..
....xx...............xx....
xxx.......-.....-.......xxx
xxx...-.............-...xxx
xx.......................xx
xx.-....xxxxxxxxxxx....-.xx
xx......x.........x......xx
xx....xxU.........Uxx....xx
xx..-.x....xxxxx....x....xx
xx....x.-.Vx$$$xx...x.-..xx
xx....x..xx$**k$xx..x....xx
xx.-..x..x$$*O*$$x-.x....xx
xx....x..xx$***$xx..x....xx
xx....x...Vx$$$xV...x..-.xx
xx..-.xxx-.xxxxx..Uxx....xx
xx......x.........x......xx
xx......xxxxxxxxxxx.-....xx
xxx...-.................xxx
xxx........-....-.......xxx
....xx...............xx....
 ...xxxxxxxxxxxxxxxxxxx...
  ..xxxxxxxxxxxxxxxxxxx..
ENDMAP

############################################################
# about 4 |
NAME:    vaults_end_classical_diamond
TAGS:    vaults_end_quadrant unrand
SHUFFLE: !_
SUBST:   ! = | * .:20
SUBST:   _ = 8 9 .:20
SUBST:   a : x .
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  a.xxxxxxxxxxxxxxxxxxx.a
 a!x.x.x!x.x.x.x.x.x.x.x.
a.x.x.x.x.x.x.x!x.x.x_x.x.a
.x.x!x.x.x.x.x.x.x.x!x.x.x.
x.x.x.x.x_x.x.x_x.x.x.x.x.x
xx.x.x.x.x.x.x.x.x.x.x.x_xx
x.x.x!x.x.x.x.x.x.x!x.x.x.x
xx.x_x.x.x!x.x.x.x.x.x.x.xx
x.x.x.x.x_x.x.x.x.x.x.x.x.x
xx.x.x.x.x.x$x.x.x.x.x.x!xx
x_x.x!x.x.xkx.x.x!x.x_x.x.x
xx.x.x.x.x.x.O.x.x.x.x.x.xx
x.x.x_x.x.x.x.x.x.x.x.x_x.x
xx.x.x.x.x.x.x_x.x.x.x.x.xx
x!x.x.x.x!x.x.x.x.x.x.x.x.x
xx.x.x.x.x.x.x!x.x.x.x.x.xx
x.x.x.x.x.x.x.x.x.x_x.x.x.x
xx.x_x.x.x.x.x.x.x.x.x.x_xx
x.x!x.x.x.x.x.x.x!x.x.x.x.x
.x.x.x.x.x.x.x_x.x.x.x.x.x.
a.x.x.x.x.x_x.x.x.x.x.x.x.a
 a.x.x_x.x.x!x.x.x.x.x!x_a
  a.xxxxxxxxxxxxxxxxxxx.a
ENDMAP

############################################################
# about 5 |
NAME:    vaults_end_classical_stripes
TAGS:    vaults_end_quadrant unrand
NSUBST:  Y = 4 = 9:30 8 / 8 = 9:30 8 .:40 / *:.
NSUBST:  Z = 5 = 8:30 9 / 7 = 8:30 9 .:40 / *:.
SUBST:   a : x ., b : x ., c : x .
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  axaxxaaxaxxxxxxxxxxxxbx
  .......x................
a.......x.................x
x..Z..Yx.Y..Y..Yx.Yx.Y....b
a...Z.xY..Y..Y..Yx.Zx.Y...x
x....x..Y..Y..Y..Y..Yx.Y..x
x..Yx.Y..Y..Y..Y..Y..Zx.Y.x
a..xY..Y..Y..Zx.Y..Y..Yx..x
a.x..Y..Y..Y.?Zx.Y..Y..Zx.x
xx.Y..Y..Y??Y??Zx.Y..Y..Y.x
a...Y..Z??Y??Y??Zx.Y..Yx..x
x....Y.xZ??YOkY??Zx.Y..Yx.x
x..Y..Y.xZ??Y??Y??Z..Y..Y.x
x..xY..Y.xZ??Y?.Y..Y..Z...x
x...xY..Y.xZ?.Y..Y..Y..Y..x
x..Y..Y..Y.xZ..Y..Y..Yx.Y.c
x..xY..Y..Y..Y..Y..Y..Zx..c
x...xZ..Y..Y..Y..Y..Z..Y..x
x..Y.xZ..Y..Y..Y..Y..Z..Y.x
b...Z.xY.xY..Y..Z.xZ..Z...c
x....Y.xY.xY..Y..Y.xY..Y..x
 .........................
  xbxxxxxxxxxxxxxxxccxxcx
ENDMAP

############################################################
# about 4 |
NAME:    vaults_end_mu_clover
TAGS:    vaults_end_quadrant unrand
SUBST:   9 = 8 9 .:20
SHUFFLE: Aa / Bb / Cc / Dd
SUBST:   A = O, a = k, bcdBCD = *
NSUBST:  " = 1:. / *:x
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 ........................
x.........................x
x..xxxxxxxxx999xxxxxxxxx..x
x..xA**....x...x....**Bx..x
x..x*a..9..x...x..9..b*x..x
x..x*..9...x...x...9..*x..x
x..x..9....xx"xx....9..x..x
x..x...................x..x
x..xxxxxxxx.....xxxxxxxx..x
x..9......x.....x......9..x
x..9......"....."......9..x
x..9......x.....x......9..x
x..xxxxxxxx.....xxxxxxxx..x
x..x...................x..x
x..x..9....xx"xx....9..x..x
x..x*..9...x...x...9..*x..x
x..x*c..9..x...x..9..d*x..x
x..xC**....x...x....**Dx..x
x..xxxxxxxxx999xxxxxxxxx..x
x.........................x
 .........................
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# about 8 |
NAME:   vaults_end_mu_not_diamond
TAGS:   vaults_end_quadrant unrand
SUBST:  9 = 8 9 *:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 ..x9x.x.x.x.x.x.x.x.x.x.
x.x.x.x.x.x.x.x.x.x.x.x9x.x
xx.x.x.x.x9x.x.x9x.x.x.x.xx
x.x.xxxxxxxxx.xxxxxxxxx.x.x
xx9xxxxxxxxx.x.xxxxxxxxx.xx
x.x.xxxxxxxx...xxxxxxxx.x.x
xx.xxxxxxx...9...xxxxxxx9xx
x.x.xxxxx.........xxxxx.x.x
xx.xxxxx...|$|$|...xxxxx.xx
x9x.x.x....$k**$....x.x.x.x
xx.x.x.x.9.|*O*|.9.x.x.x.xx
x.x.x.x....$***$....x.x.x9x
xx.xxxxx...|$|$|...xxxxx.xx
x.x.xxxxx.........xxxxx.x.x
xx.xxxxxxx...9...xxxxxxx.xx
x.x.xxxxxxxx...xxxxxxxx.x.x
xx9xxxxxxxxx.x.xxxxxxxxx9xx
x.x.xxxxxxxxx.xxxxxxxxx.x.x
xx.x.x.x.x9x.x.x9x.x.x.x.xx
x.x.x.x.x.x.x.x.x.x.x.x.x.x
 ..x9x.x.x.x.x.x.x.x.x9x..
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# about 11 |
NAME:    vaults_end_mu_boxes
TAGS:    vaults_end_quadrant unrand
NSUBST:  a = 1:+ / *:x
NSUBST:  b = 1:+ / *:x
NSUBST:  c = 1:+ / *:x
NSUBST:  d = 1:+ / *:x
NSUBST:  e = 1:+ / *:x
NSUBST:  f = 1:+ / *:x
NSUBST:  g = 1:+ / *:x
SHUFFLE: ABCDEFG
SUBST:   ABC = 9
SUBST:   D = |*$9
SUBST:   E = |
SUBST:   F = *
NSUBST:  G = 1:O / 1:k / *:9
SUBST:   9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 ........................
x..........xxbxx..........x
x..........xBBBx..........x
x..xxaxx...bBBBb...xxcxx..x
x..xAAAx...xBBBx...xCCCx..x
x..aAAAa...xxbxx...cCCCc..x
x..xAAAx...........xCCCx..x
x..xxaxx...........xxcxx..x
x..........xxdxx..........x
x..........xDDDx..........x
x....9.....dDDDd.....9....x
x..........xDDDx..........x
x..........xxdxx..........x
x..xxfxx...........xxgxx..x
x..xFFFx...........xGGGx..x
x..fFFFf...xxexx...gGGGg..x
x..xFFFx...xEEEx...xGGGx..x
x..xxfxx...eEEEe...xxgxx..x
x..........xEEEx..........x
x..........xxexx..........x
 .........................
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# about 8 |
NAME:    vaults_end_mu_long
TAGS:    vaults_end_quadrant unrand
SHUFFLE: Oo / Pp / Qq / Rr / Ss
SUBST:   9 = 8 9 .:10
SUBST:   o = k, pqrsPQRS = $
SUBST:   $ = |**$
SUBST:   a = x.
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  axxxxxxxxxxxxxxxxxxxxxa
 ........................
a.........................a
x.........................x
x..xxxxxxxxxxxxxxxxxxxxx..x
x....999............$o$x..x
x....999............$$Ox..x
x..xxxxxxxxxxxxxxxxxxxxx..x
x..x$p$............999....x
x..xP$$............999....x
x..xxxxxxxxxxxxxxxxxxxxx..x
x....999............$q$x..x
x....999............$$Qx..x
x..xxxxxxxxxxxxxxxxxxxxx..x
x..x$r$............999....x
x..xR$$............999....x
x..xxxxxxxxxxxxxxxxxxxxx..x
x....999............$s$x..x
x....999............$$Sx..x
x..xxxxxxxxxxxxxxxxxxxxx..x
a.........................a
 .........................
  axxxxxxxxxxxxxxxxxxxxxa
ENDMAP

############################################################
# 19 *, 14 monsters
NAME:    vaults_end_minmay_circular_pillars
TAGS:    vaults_end_quadrant unrand
SHUFFLE: Oo / Pp / Qq / Rr
NSUBST:  o = 1:k / *:*
SUBST:   pqrPQR = *
NSUBST:  a = 1:+ / *:x, b = 1:+ / *:x, c = 1:+ / *:x, d = 1:+ / *:x
SUBST:   9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 ..9..9xxxx9...9xxxx9....
x.......xx.......xx.......x
x9..xx......xbx......xx...x
x..xxxx....xxoxx....xxxx..x
x..xxxx....boOob....xxxx..x
x9..xx9....xxoxx....9xx..9x
xx..........xbx..........xx
xxx.....................xxx
xxx..xax...9...9...xcx..xxx
xx..xxpxx.........xxqxx..xx
x9..apPpa.........cqQqc..9x
xx..xxpxx.........xxqxx..xx
xxx..xax...9...9...xcx..xxx
xxx.....................xxx
xx..........xdx..........xx
x9..xx9....xxrxx....9xx..9x
x..xxxx....drRrd....xxxx..x
x..xxxx....xxrxx....xxxx..x
x9..xx......xdx......xx..9x
x.......xx.......xx.......x
 ..9..9xxxx9...9xxxx9..9..
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 20 *, 12 monsters
NAME:   vaults_end_minmay_hexagonal
TAGS:   vaults_end_quadrant unrand
SUBST:  9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 ....xx9...........9xx...
x.........................x
x..xx...xxxxx.xxxxx.......x
x..x...xx9.......9xx......x
x..x..xx...........xx.....x
xx....x...xxx.xxx...x....xx
xx...xx..xx9...9xx..xx...xx
xx..xx...x.......x...xx..xx
x9..x9..xx..***..xx..9x..9x
x..xx..xx9.*****.9xx..xx..x
x..........**O**..........x
x..xx..xx9.*k***.9xx..xx..x
x9..x9..xx..***..xx..9x..9x
xx..xx...x.......x...xx..xx
xx...xx..xx9...9xx..xx...xx
xx....x...xxx.xxx...x....xx
x..x..xx...........xx..x..x
x..x...xx9.......9xx...x..x
x..xx...xxxxx.xxxxx...xx..x
x.........................x
 ....xx9...........9xx....
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 16 *, 10 monsters
NAME:   vaults_end_minmay_subdivision
TAGS:   vaults_end_quadrant unrand
SUBST:  9 = 8 9 .:20
NSUBST: k = 1:k / *:*
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 .....x....*xxx*....x....
x.....x.....xxx.....x.....x
x.....x.....xxx.....x.....x
x....9x9....xxx....9x9....x
xxxxxx.xxxxx...xxxxx.xxxxxx
x....9x9....xxx....9x9....x
x.....x.....xxx.....x.....x
x.....x.....xxx.....x.....x
x*....x....kxxxk....x....*x
xxxxxx.xxxxx9*9xxxxx.xxxxxx
xxxxxx.xxxxx*O*xxxxx.xxxxxx
xxxxxx.xxxxx9*9xxxxx.xxxxxx
x*....x....kxxxk....x....*x
x.....x.....xxx.....x.....x
x.....x.....xxx.....x.....x
x....9x9....xxx....9x9....x
xxxxxx.xxxxx...xxxxx.xxxxxx
x....9x9....xxx....9x9....x
x.....x.....xxx.....x.....x
x.....x.....xxx.....x.....x
 .....x....*xxx*....x.....
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 14 *, 8 monsters
NAME:    vaults_end_minmay_triangle_fans
TAGS:    vaults_end_quadrant unrand
SHUFFLE: Oo / Pp
SUBST:   o = k, P = *, p = .
SUBST:   9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  ...xxxxxxxxxxxxxxxxxxxx
 xxxx.....9xxxx.....9xxxx
.xxx..x....xxx..x....xxx..x
.xx...xx...xx...xx...xx...x
.x....xxx..x....xxx..x....x
x....9xxxx.....9xxxx......x
x.xxxx9.....xxxx9.....xxxxx
x..xxx...*x.*xxx...*x..xxxx
x...xx...xx..Oxx...xx...xxx
x....x.*xxx.o.*x.*xxx....xx
x......xxxx9.....xxxx9....x
x.........................x
xxxxx.....9xxxx.....9xxxx.x
xxxx..x*...xxx*.x*...xxx..x
xxx...xx...xxP..xx...xx...x
xx....xxx*.x*.p.xxx*.x....x
x....9xxxx.....9xxxx......x
x.xxxx9.....xxxx9.....xxxxx
x..xxx....x..xxx....x..xxxx
x...xx...xx...xx...xx...xxx
x....x..xxx....x..xxx....xx
 ......xxxx9.....xxxx9....
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 8 |, 11 monsters
NAME:   vaults_end_minmay_pillar_box
TAGS:   vaults_end_quadrant unrand
SUBST:  9 = 8 9 .:20
NSUBST: k = 1:k / *:.
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 ........................
x.x.x.x.x.x.x.x.x.x.x.x.x.x
x.........................x
x.x.xx9xx..xx9xx..xx9xx.x.x
x...xx.xx..xx.xx..xx.xx...x
x.x.9.|....9.|.9....|.9.x.x
x...xx.xx..xx.xx..xx.xx...x
x.x.xx.xx..xxkxx..xx.xx.x.x
x...9...9..xx.xx..9...9...x
x.x.xx.xx..x...x..xx.xx.x.x
x...xx|xx..x.O.x..xx|xx...x
x.x.xx.xx..x...x..xx.xx.x.x
x...9...9..xx.xx..9...9...x
x.x.xx.xx..xxkxx..xx.xx.x.x
x...xx.xx..xx.xx..xx.xx...x
x.x.9.|....9.|.9....|.9.x.x
x...xx.xx..xx.xx..xx.xx...x
x.x.xx9xx..xx9xx..xx9xx.x.x
x.........................x
x.x.x.x.x.x.x.x.x.x.x.x.x.x
 .........................
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 20 *, 15 monsters
NAME:   vaults_end_minmay_partial_spiral
TAGS:   vaults_end_quadrant unrand
SUBST:  9 = 8 9 .:20
NSUBST: k = 1:k / *:*
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 .........................
x.........................x
x..x99xxxxxxxxxxxxxxxxxx..x
x..x................9..9..x
x..x................9..9..x
x..x99x99xxxxxxxxxxxx..x..x
x..x..x..........9..9..x..x
x..x..x..........9..9..x..x
x..x..x99xxxxxxxxx..x..x..x
x..x..x..x**k*k**x..x..x..x
x..x..x..+***O***x..x..x..x
x..x..x..x**k*k**x..x..x..x
x..x..xxxxxxxxxxxx99x..x..x
x..9..9.............x..x..x
x..9..9.............x..x..x
x..xxxxxxxxxxxxxxx99x99x..x
x..9...................x..x
x..9...................x..x
x..xxxxxxxxxxxxxxxxxx99x..x
x.........................x
 ........................
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 2 |, 19 *, 16 monsters
NAME:   vaults_end_minmay_grid2
TAGS:   vaults_end_quadrant unrand
SUBST:  9 = 8 9 .:20
NSUBST: k = 1:k / *:., O = 1:O / 1:* / *:|
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  .xxxxxxxxxxxxxxxxxxxxxx
 ..xx**xx**xx**xx**xx**xx.
xxx..xx..xx..xx..xx..xx..xx
xxx.9xx9.xx..xx..xx.9xx9.xx
x..xx..xx..xx..xx..xx..xx*x
x..xx..xx..xx..xx..xx..xx*x
xxx.9xx9.xx..xx..xx.9xx9.xx
xxx..xx.9xx9.xx.9xx9.xx..xx
x..xx..xx..xx..xx..xx..xx*x
x..xx..xx..xxkkxx..xx..xx*x
xxx..xx.9xx9OxxO9xx9.xx..xx
xxx..xx.9xx9OxxO9xx9.xx..xx
x..xx..xx..xxkkxx..xx..xx*x
x..xx..xx..xx..xx..xx..xx*x
xxx..xx.9xx9.xx.9xx9.xx..xx
xxx.9xx9.xx..xx..xx.9xx9.xx
x..xx..xx..xx..xx..xx..xx*x
x..xx..xx..xx..xx..xx..xx*x
xxx.9xx9.xx..xx..xx.9xx9.xx
xxx..xx..xx..xx..xx..xx..xx
x..xx..xx..xx..xx..xx..xx..
  .xx..xx..xx..xx..xx..xx.
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 2 |, 15 *, 14 monsters
NAME:    vaults_end_minmay_pluses
TAGS:    vaults_end_quadrant unrand
SHUFFLE: Oo / Pp / Qq
SUBST:   o = k, pq = *, PQ = |
SUBST:   9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 .....x......x......x....
x.........................x
x.........................x
x.....x......x......x.....x
xx...xxx9999xxx9999xxx...xx
x.....x......x......x.....x
x.....9......x......9.....x
x.....9.....*x......9.....x
x.....9....o*x......9.....x
x.....x...**Ox......x.....x
xx...xxxxxxxxxxxxxxxxx...xx
x.....x...**PxQ**...x.....x
x.....9....p*x*q....9.....x
x.....9.....*x*.....9.....x
x.....9......x......9.....x
x.....x......x......x.....x
xx...xxx9999xxx9999xxx...xx
x.....x......x......x.....x
x.........................x
x.........................x
 .....x......x......x.....
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 14 *, 9 monsters
NAME:    vaults_end_minmay_broken_diamonds
TAGS:    vaults_end_quadrant unrand
SHUFFLE: Oo / Pp / Qq / Rr
SUBST:   o = k, pqrPQR = *
SUBST:   9 = 8 9 .:20
NSUBST:  * = 14:* / *:.
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 ..xx....9xx...xx9....xx.
x........xx.....xx........x
xx......xx...x...xx......xx
xxx....xx....xx...xx....xxx
x9xx...x......xx...x...xx9x
x..xx.......o**xx.....xx..x
x...xx...xx.*O*9xx........x
x.........xx**9xx...x....xx
x......x...xx9xx...xxx...xx
xx....xxx...xxx...xx9xx...x
xx...xx9xx...x...xx9P*xx..x
x...xx**9xx.......xx*p....x
x..xx.*Q*9xx...x...xx....xx
x9....q**xx....xx...x...xxx
xx......xx....r*xx.....xx9x
xxx....xx...xx*R9xx...xx..x
x.xx...x.....xx9xx........x
x..xx.....x...xxx...x....xx
x...xx...xx....x....xx...xx
x.......xx...........xx...x
 ......xx9..xx...xx..9xx..
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 17 *, 10 monsters
NAME:   vaults_end_minmay_smooth_crossroads
TAGS:   vaults_end_quadrant unrand
SUBST:  9 = 8 9 .:20
NSUBST: O = 1:O / *:.
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 9.....x9.....9x9........
x......x.......x...x....9.x
x.....xx...x...x...xx.....x
x.....x....x...x....x.....x
x....xx....x...x....xx....x
x..xxx....xx...xx....xxx..x
x.xx......x*...*x......xxxx
x........xx*...*xx.......9x
x9.....xxxO.....Oxxx......x
xxxxxxxx**...9...**xxxx...x
x9..........9x9..........9x
x...xxxx**..k9...**xxxxxxxx
x......xxxO.....Oxxx.....9x
x9.......xx*...*xx........x
xxxx......x*...*x......xx.x
x..xxx....xx...xx....xxx..x
x....xx....x...x....xx....x
x.....x....x...x....x.....x
x.....xx...x...x...xx.....x
x......x...x.......x......x
 9........9x9.....9x.....9
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 14 *, 10 monsters
NAME:   vaults_end_minmay_diagonal_split
TAGS:   vaults_end_quadrant unrand
NSUBST: k = 1:k / *:*
SUBST:  9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 9xxx9.......x9..........
x..xxx...xx...x...........x
x...xxx..9xx...x..........x
x....xxx...xx...x9........x
x.x9..xxx...xx...x........x
x.xx...xxx..*xx...x.......x
x..xx...xxx..*xx...x......x
x...xx...xxx..*xx...x.....x
xx...xx...xxx..kxx...x9...x
x9x...xx*..xxx9.*xx...x...x
x..x...xx*..9O9..*xx...x..x
x...x...xx*.9xxx..*xx...x9x
x...9x...xxk..xxx...xx...xx
x.....x...xx*..xxx...xx...x
x......x...xx*..xxx...xx..x
x.......x...xx*..xxx...xx.x
x........x...xx...xxx..9x.x
x........9x...xx...xxx....x
x..........x...xx9..xxx...x
x...........x...xx...xxx..x
 ...........9x.......9xxx9
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 82 $, 16 monsters
NAME:    vaults_end_minmay_loops
TAGS:    vaults_end_quadrant vaults_end_quadrant_mall unrand
SHUFFLE: ae / bf / cg / dh
SUBST:   a = +, e = k, bcdfgh = x
SUBST:   9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 ..xxxxxx$$$$$$$$$xxxxx..
x......xxx$$$$$$$xxx......x
xx.9xx9.xxx$$$$$xxx.9xx9.xx
xx.xxxx.xxxx$$$xxxx.xxxx.xx
xx.xxxx.xxxxx$xxxxx.xxxx.xx
xx.9xx9..xxxx+xxxx..9xx9.xx
xxx......9xx9.9xx9......xxx
x$xxxx9.............9xxxx$x
x$$xxxx....9xax9....xxxx$$x
x$$$xxx....xxexx....xxx$$$x
x$$$$+.....dhOfb.....+$$$$x
x$$$xxx....xxgxx....xxx$$$x
x$$xxxx....9xcx9....xxxx$$x
x$xxxx9.............9xxxx$x
xxx......9xx9.9xx9......xxx
xx.9xx9..xxxx+xxxx..9xx9.xx
xx.xxxx.xxxxx$xxxxx.xxxx.xx
xx.xxxx.xxxx$$$xxxx.xxxx.xx
xx.9xx9.xxx$$$$$xxx.9xx9.xx
x......xxx$$$$$$$xxx......x
 ..xxxxxx$$$$$$$$$xxxxxx..
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# One shop, 16 monsters
NAME:    vaults_end_dpeg_shops1
TAGS:    vaults_end_quadrant vaults_end_quadrant_mall unrand
KFEAT:   S = any shop
: if crawl.one_chance_in(4) then
SUBST:   A = +, a = ., CD = x
: else
SHUFFLE: CD
SUBST:   C = ., DAa = x
: end
SUBST:   9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 ..xxxxxxxxxx.....xxxx...
x...xxxxx.................x
xx........................x
xxx......................xx
xxxx.....................xx
xxxx.....................xx
xxx......9xxxxxxx........xx
xx......9xxxxxxxxx.......xx
xx......xxx$999$xxx.......x
xx......xC.9$$$9$xx.......x
x.......CC.9$Sk9Oxx.......x
x.......xC.9$$$9$xx......xx
x.......xAa$999$xxx......xx
xx.......xAxDDDxxx9......xx
xx........xxxDxxx9......xxx
xx.....................xxxx
xx.....................xxxx
xx......................xxx
x........................xx
x.................xxxxx...x
 ....xxxx.....xxxxxxxxxx..
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# Consumable shops (scrolls, potions).
# Monsters in rooms.
NAME:    vaults_end_dpeg_shops2
TAGS:    vaults_end_quadrant vaults_end_quadrant_mall unrand
SHUFFLE: Ll / Mm / Nn / Oo / Pp / Qq / Rr / Ss / Tt
SUBST:   o = k, lmnpqrst = ', LMNPQ = S99, RT = S
NSUBST:  A = 1:+ / *:x+, B = 1:+ / *:x+, C = 1:+ / *:x+
KFEAT:   S = scroll shop / distillery shop / abandoned_shop
NSUBST:  ' = 20:9 / *:.
NSUBST:  . = 5:9 / *:.
SUBST:   9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 ........................
x.........................x
x...xxxxx..xxxxx..xxxxx...x
x...x'L'x..x'M'x..x'N'x...x
x...x'l'x..x'm'x..x'n'x...x
x...xx+xx..xx+xx..xx+xx...x
x.........................x
x.........................x
x...xxAxx..xxBxx..xxCxx...x
x...x'''x..x'''x..x'''x...x
x...x'O'x..x'P'x..x'Q'x...x
x...xo''x..xp''x..xq''x...x
x...xxAxx..xxBxx..xxCxx...x
x.........................x
x.........................x
x...xx+xx..xx+xx..xx+xx...x
x...x'r'x..x's'x..x't'x...x
x...x'R'x..x'S'x..x'T'x...x
x...xxxxx..xxxxx..xxxxx...x
x.........................x
 .........................
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 20 *, 20 monsters
NAME:    vaults_end_minmay_plus_grid
TAGS:    vaults_end_quadrant unrand
SHUFFLE: Oo / Pp / Qq / Rr
SUBST:   o = k, pqr = ., PQR = *
SUBST:   * = 9 8 *:20 .
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 xxx.x.*.x.xxx.x.*.x.xxx.
x.x.*.x.xxx.x.*.x.xxx.x...x
.*.x.xxx.x.*.x.xxx.x.*.x.xx
x.xxx.x.*.x.xxx.x.*.x.xxx.x
xx.x.*.x.xxx.x.*.x.xxx.x.*x
x.*.x.xxx.x.*.x.xxx.x.*.x.x
xx.xxx.x.*.x.xxx.x.*.x.xxxx
xxx.x.*.x.xxx.x.*.x.xxx.x.x
xx.Oox.xxx.x.*.x.xxx.xqQ.xx
x.x.xxx.x.*.x.xxx.x.*.x.xxx
xxxx.x.*.x.xxx.x.*.x.xxx.xx
x.x.*.x.xxx.x.*.x.xxx.xrR.x
xPpx.xxx.x.*.x.xxx.x.*.x.xx
x.xxx.x.*.x.xxx.x.*.x.xxx.x
xx.x.*.x.xxx.x.*.x.xxx.x.*x
x.*.x.xxx.x.*.x.xxx.x.*.x.x
xx.xxx.x.*.x.xxx.x.*.x.xxxx
xxx.x.*.x.xxx.x.*.x.xxx.x.x
xx.*.x.xxx.x.*.x.xxx.x.*.xx
..x.xxx.x.*.x.xxx.x.*.x.xxx
 xxx.x.*.x.xxx.x.*.x.xxx.x
  xxxxxxxxxxxxxxxxxxxxx..
ENDMAP

############################################################
# 14 *, 12 monsters
NAME:    vaults_end_minmay_curved1
TAGS:    vaults_end_quadrant unrand
SHUFFLE: Oo / Pp
SUBST:   o = k, Pp = *
SUBST:   9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  x.x.xxxxxxxxxxxxxxxxxxx
 .................xxxxxx.
x.xxxx....xxxx.......xx...x
....9xxx....9xxx.........xx
x.....9xx.....9xx.......xxx
x......9x......9x.......xxx
x.......xx......xx.......xx
x.......9x......9x.......xx
x........x.......x9......xx
x.xxxx...xxxxx***xx.......x
x...9xxx.*xxxxxxP*x9......x
x.....9xxoxxxxxxxpxx9.....x
x......9x*Oxxxxxx*.xxx9...x
x.......xx***xxxxx...xxxx.x
xx......9x.......x........x
xx.......x9......x9.......x
xx.......xx......xx.......x
xxx.......x9......x9......x
xxx.......xx9.....xx9.....x
xx.........xxx9....xxx9....
x...xx.......xxxx....xxxx.x
 ..xxxxxx.................
  xxxxxxxxxxxxxxxxxxx.x.x
ENDMAP

############################################################
# 18 *, 20 monsters
NAME:   vaults_end_minmay_broken_lines
TAGS:   vaults_end_quadrant unrand
NSUBST: k = 1:k / *:*
SUBST:  9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 .9.x.x.x.x.x.x.x.9.x.x..
x.x.x.x.x.x.x*x.x.x.x.x...x
x.x.x.x.9.x.9*x.x.x.9.x.x.x
x.x.9.x.x.x.x*x.x.x.x.x.x.x
x.x.x.x.x.9.x*x.9.x.x.9.x.x
x.x.x.9.x.x.x*x.x.x.x.x.x.x
x.x.x.x.x.x.x*9.x.x.x.9.x.x
x.x.x.x.9.x.x*x.x.9.9.x.x.x
x.x.x.x.x.x.9kx.x.x.x.x.x.x
x.x.x.x.x.x.x*x.x.x.x.x.9.x
x.x.x.x.x.x.xO9.x.x.x.x.x.x
x.x.9.x.x.9.x*x.x.9.x.x.x.x
x.x.x.x.x.x.xkx.x.x.x.9.x.x
x.x.x.x.9.x.x*9.x.x.x.x.x.x
x.x.x.x.x.x.x*x.x.x.x.x.9.x
x.x.x.9.x.9.x*x.9.x.9.x.x.x
x.x.9.x.x.x.9*x.x.x.x.9.x.x
x.x.x.x.x.x.x*9.x.x.x.x.x.x
x.x.x.9.x.x.x*x.x.x.x.x.x.x
x.x.x.x.x.x.x*x.x.9.x.x.9.x
 .9.x.x.x.9.9.x.x.x.9.x...
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 16 *, 12 monsters
NAME:    vaults_end_minmay_surrounding_squares
TAGS:    vaults_end_quadrant unrand
SHUFFLE: AB
SUBST:   9 = 8 9 .:20
SUBST:   A = ., B = x
NSUBST:  k = 1:k / *:*
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 9......................9
x.9xx.xxx.xxx.xxx.xxx.xx.9x
x.xxx.xxx.xxx.xxx.xxx.xxx.x
x.xxx.xxx.xxx.xxx.xxx.xxx.x
x.........................x
x.xxx.9xxxxxxAxxxxxx9.xxx.x
x.xxx.xx...........xx.xxx.x
x.xxx.x.9xxxxBxxxx9.x.xxx.x
x.....x.xx9.....9xx.x.....x
x.xxx.x.x9.*k***.9x.x.xxx.x
x.xxx.B.A.***O***.A.B.xxx.x
x.xxx.x.x9.***k*.9x.x.xxx.x
x.....x.xx9.....9xx.x.....x
x.xxx.x.9xxxxBxxxx9.x.xxx.x
x.xxx.xx...........xx.xxx.x
x.xxx.9xxxxxxAxxxxxx9.xxx.x
x.........................x
x.xxx.xxx.xxx.xxx.xxx.xxx.x
x.xxx.xxx.xxx.xxx.xxx.xxx.x
x.9xx.xxx.xxx.xxx.xxx.xx9.x
 9.......................9
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 4 |, 15 *, 18 monsters
NAME:   vaults_end_minmay_split_center
TAGS:   vaults_end_quadrant unrand
SUBST:  9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
  .......................
x.........................x
x..xxxx999xxxxxxx999xxxx..x
x..9..xxx..xxOxx..xxx..9..x
x..9....xx..x*x..xx....9..x
x..xxxx..xx.xkx.xx..xxxx..x
x..9..xx..x|x*x|x..xx..9..x
x..xx..xx.xxx*xxx.xx..xx..x
x..9xx..x..xx*xx..x..xx9..x
x..9....xx.xx*xx.xx....9..x
x..xxxx....xx*xx....xxxx..x
x..9..xxx...x*x...xxx..9..x
x..9....xx...*...xx....9..x
x..xxxx..xx.x*x.xx..xxxx..x
x..9..xx..x|x*x|x..xx..9..x
x..xx..xx.xxx*xxx.xx..xx..x
x..9xx..x..xx*xx..x..xx9..x
x..9.xx.x..xx*xx..x.xx.9..x
x..x99x9x99xxxxx99x9x99x..x
x.........................x
 .........................
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 16 *, 12 monsters
NAME:   vaults_end_minmay_sharp_edges
TAGS:   vaults_end_quadrant unrand
SUBST:  9 = 8 9 .:20
NSUBST: O = 1:O / *:*
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 ..x9xxx9xxx9xxx9xxx9xxx.
x.....x...x...x...x...x...x
xx.......................xx
x9....x.................xxx
xx...xxx.................xx
xxx.xxxxx..x......x......9x
xx...xxx..xxx....xxx.....xx
x9....x..xxOxx..xxxxx...xxx
xx......xxO**xx..xxx.....xx
xxx......xx***xx..x......9x
xx........x9*k*xx........xx
x9......x..99***xx......xxx
xx.....xxx..99**Oxx......xx
xxx...xxxxx..xxOxx..x....9x
xx.....xxx....xxx..xxx...xx
x9......x......x..xxxxx.xxx
xx.................xxx...xx
xxx.................x....9x
xx.9.....................xx
x...x...x...x...x...x.....x
 ..xxx9xxx9xxx9xxx9xxx9x..
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 20 *, 14 monsters
NAME:   vaults_end_minmay_outlined_triangles
TAGS:   vaults_end_quadrant unrand
SUBST:  9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 ........................
x...x.x.x..x.x.x..x.x.x...x
x....9.9....9.9....9.9....x
x...x.x.....x.x.....x.x...x
x....9.......9.......9....x
x...x........x........x...x
x.........................x
x.........xxx9xxx.........x
x...x.....xx***xx.....x...x
x....9x...x*****x...x9....x
x...x..9x.9**O**9.x9..x...x
x....9x...x*k***x...x9....x
x...x.....xx***xx.....x...x
x.........xxx9xxx.........x
x.........................x
x...x........x........x...x
x....9.......9.......9....x
x...x.x.....x.x.....x.x...x
x....9.9....9.9....9.9....x
x...x.x.x..x.x.x..x.x.x...x
 .........................
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 12 *, 11 monsters
NAME:   vaults_end_minmay_oval
TAGS:   vaults_end_quadrant unrand
SUBST:  9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 ........................
x.........................x
x..xxxxxxxxxx......xxxxx..x
x..xxxxxxx9..........xxx..x
x..xxxxx9.............xx..x
x..xxxx9...............x..x
x..xxx9..........***...x..x
x..xx9..........9xx*......x
x..xx.........9xxxx*......x
x..x9......9xxxxxx9....x..x
x..x.....9xxxxxxx9.....x..x
x..x....9xxxxxx9......9x..x
x......*xxxx9.*.......xx..x
x......*xx9..........9xx..x
x..x...O**..........9xxx..x
x..x...............9xxxx..x
x..xxk............9xxxxx..x
x..xxx..........9xxxxxxx..x
x..xxxxx......xxxxxxxxxx..x
x.........................x
 .........................
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 12 *, 12 monsters
NAME:   vaults_end_minmay_fences
TAGS:   vaults_end_quadrant unrand
NSUBST: A = 1:+ / *:x, B = 1:+ / *:x
SUBST:  9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 ........................
x.........................x
x..xxx..x.x.x9x.x.x..xxx..x
x..x9.................9x..x
x..x...................x..x
x.......x.x.x9x.x.x.......x
x......9x.........x9......x
x..x..xxx...*.*...xxx..x..x
x..........xxAxx..........x
x..x..x...*x*9*x*...x..x..x
x..9..9...*A9O9A....9..9..x
x..x..x....xk9*x*...x..x..x
x..........xxAxx..........x
x..x..xxx...*.*...xxx..x..x
x......9x.........x9......x
x99.....x.x.x9x.x.x.......x
xBBx...................x..x
x..B9.................9x..x
x..xBx..x.x.x9x.x.x..xxx..x
x....B9...................x
 ....B9...................
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 17 *, 2 |, 14 monsters
NAME:    vaults_end_minmay_wings
TAGS:    vaults_end_quadrant unrand
SHUFFLE: Oo / Pp
SUBST:   o = k, p = *, P = |
SUBST:   9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 ............9...........
x............9............x
xxxxx9999xx.....xx9999xxxxx
x**xx....xx.....xx....xx**x
x**.xx....xx...xx....xx.**x
x...xx....xx...xx....xx...x
x....xx....xx.xx....xx....x
x....xx....xx.xx....xx....x
x.....xx....x.x....xx.....x
x|....xx....x.x....xx....px
xO....99....9*9....99....Px
xo....xx....xxx....xx....|x
x.....xx....xxx....xx.....x
x....xx....xx.xx....xx....x
x....xx....xx.xx....xx....x
x...xx....xx...xx....xx...x
x*..xx....xx...xx....xx..*x
x**xx....xx.....xx....xx**x
xxxxx9999xx.....xx9999xxxxx
x........9.......9........x
 ........9.......9........
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 16 *, 1 |, 13 monsters
NAME:    vaults_end_minmay_cones
TAGS:    vaults_end_quadrant unrand
SHUFFLE: Oo / Pp
SUBST:   o = k, p = *, P = |
SUBST:   9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 ........................
x.xx........xx.......xx...x
x......xx...9....xx...9...x
x..xx..9.....xx.....xx.9x.x
x........xx..9...xx.9.x.x.x
x....xx.......xx.....9x...x
xxx...9....xx.9..xx.......x
x.......xx.....xx9.x.x.x..x
x....xx.9...xxx...9x.x.x..x
x.xx......xxx9....x.......x
x.......xxx...xx..x.x.....x
x*****xxx9...xxx.x.9x.x...x
x*o*xxx.....xxx.9x...9x.x.x
xOxxx9....9xxx..x..x...9x.x
xxx.......xxx...x..x......x
x.......9xxx9..x.....x....x
x.......xxx...9x..x..x....x
x......xxx9...x..9x....x..x
x.....xxx*....x.......9x..x
x....xxxp**..x...x.9x.....x
 ...xxxP****9x...x..x.....
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

# 19 *, 12 monsters
NAME:    vaults_end_grunt_pinched
TAGS:    vaults_end_quadrant unrand
SHUFFLE: Oo / Pp
SUBST:   o = k, p = *, P = .
SUBST:   9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 ........x...............
x.......xx...9............x
x...9...xx...x............x
x......xx....xx....9......x
x.....xx9....*x...........x
x...xxxxx....*xx..........x
x9xxxx.xxx....9xx......9..x
x.......xx..9.*xxxx.......x
x...9....9..**xx.9xxx.....x
x.9.x**....*Oxx*...xxxx...x
x...xxxx...oxx*.....**x.9.x
x.....xxx9*xxP*...9.......x
x.......xxxxp*............x
x..9....xxx*..............x
x......xxxxx9..9.xx..9.xx9x
x.....xx...xx*...xxxxxxxx.x
x....xx.....x*....xxxx....x
x...xx......xx....xx......x
x..xx....9...x.9..x....9..x
x.xx.........9...xx.......x
 ................x........
  .xxxxxxxxxxxxxxxxxxxxxx
ENDMAP

# 18 *, 12 monsters
NAME:    vaults_end_grunt_door_to_door
TAGS:    vaults_end_quadrant unrand
SHUFFLE: 456
NSUBST:  1 = 1:9 / *:*
NSUBST:  2 = 1:9 / *:*
NSUBST:  3 = 1:9 / *:*
NSUBST:  4 = 1:9 / *:*
NSUBST:  5 = 1:9 / *:*
NSUBST:  6 = 1:O / 1:k / *:*
SUBST:   9 = 8 9 .:30
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 +xxxxxxxxxxxxxxxxxxxxxxx
xx..........xxx.........+xx
x.9..+xx+..9.+.9..+xx+..9.x
x....x11x....x....x22x....x
x....x11x....x....x22x....x
x.9..+xx+..9.+.9..+xx+..9.x
xx..........xxx..........xx
xx+xx+xx+xx+xxx+xx+xx+xx+xx
xx..........xxx..........xx
x.9..+xx+..9.x.9..+xx+..9.x
x....x44x....x....x33x....x
x....x44x....x....x33x....x
x.9..+xx+..9.+.9..+xx+..9.x
xx..........xxx..........xx
xx+xx+xx+xx+xxx+xx+xx+xx+xx
xx..........xxx..........xx
x.9..+xx+..9.+.9..+xx+..9.x
x....x55x....x....x66x....x
x....x55x....x....x66x....x
xx9..+xx+..9.+.9..+xx+..9xx
 +x.........xxx.........x+
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

# 17 *, 12 monsters
NAME:   vaults_end_grunt_cloverleaf
TAGS:   vaults_end_quadrant unrand
SUBST:  9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 ...+xxxxxxxxxxxxxxxxx+..
x.xxx....xxxxxxxxx....xxx.x
x+x....9..*xxxxx*..9....x+x
xx...9.....xxxxx.....9...xx
xx.........*xxx*.........xx
xx.9........xxx........9.xx
xx........9..x..9........xx
xxx*.........+.........*xxx
xxxxx*...9.+xxx+.9...*xxxxx
xxxxxxxx...x.9kx...xxxxxxxx
xxxxxxxxx+xx9O9xx+xxxxxxxxx
xxxxxxxx...x*9.x...xxxxxxxx
xxxxx*...9.+xxx+.9...*xxxxx
xxx*.........+.........*xxx
xx........9..x..9........xx
xx.9........xxx........9.xx
xx..........xxx..........xx
xx...9.....*xxx*.....9...xx
x+x....9..*xxxxx*..9....x+x
x.xxx....xxxxxxxxx....xxx.x
 ...+xxxxxxxxxxxxxxxxx+...
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

# 20 *, 14 monsters
NAME:   vaults_end_grunt_tight_spiral
TAGS:   vaults_end_quadrant unrand
NSUBST: k = 1:k / *:*
SUBST:  9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 ..xx........9........xx.
x..x....xxxxxxxxxxxxx..x..x
xx....9xx....9......9....xx
xxx.x9.x..xxxxxxxxxx.9..xxx
xx..x.xx.xx..9.....xxx...xx
xx..x.x..x..xxxxxx...xx..xx
xx..x.x.xx.xx9...xxx..x..xx
xx..x.x.x..xx*xx...xx.x..xx
x...x.x.x.xx*k*xxx..x.x...x
x...x.x.x.x*9*9*xxx.x.x...x
x..9x9x9x9*k*O*k*9x9x9x9..x
x...x.x.xxx*9*9*x.x.x.x...x
x...x.x..xxx*k*xx.x.x.x...x
xx..x.xx...xx*xx..x.x.x..xx
xx..x..xxx...9xx.xx.x.x..xx
xx..xx...xxxxxx..x..x.x..xx
xx...xxx.....9..xx.xx.x..xx
xxx..9.xxxxxxxxxx..x.9x.xxx
xx....9......9....xx9....xx
x..x..xxxxxxxxxxxxx....x..x
 ..xx........9........xx..
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

# 18 *, 12 monsters
NAME:   vaults_end_grunt_simple_division
TAGS:   vaults_end_quadrant unrand
SUBST:  9 = 8 9 .:20
NSUBST: O = 1:O / *:*
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 ..9.........+.........9.
x...........xxx...........x
x9.........xxOxx.........9x
x....9....xx***xx.....9...x
x.......xxx.9.9.xxx.......x
x......+x.........x+......x
x.....x+...........+x.....x
x...xxx.............xxx...x
x..xx........9........xx..x
x.xx*9......*........9*xx.x
x+xO*......9.k.9......*Ox+x
x.xx*9........*......9*xx.x
x..xx........9........xx..x
x...xxx.............xxx...x
x.....x+...........+x.....x
x......+x.........x+......x
x.......xxx.9.9.xxx.......x
x....9....xx***xx.....9...x
x9.........xxOxx.........9x
x...........xxx...........x
 ..9.........+.........9..
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

# 20 *, 14 monsters
NAME: vaults_grunt_end_bulge
TAGS: vaults_end_quadrant unrand
NSUBST: O = 1:O / 1:k / *:*
SUBST: 9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxx.
 ..xxx.9.................
x..xxx.....9..........xx...
x..xxx.9...........9xxxxx.x
x..xxxx.........xxx.xxxxx.x
x....xxxx....xxxxxx+xxxx..x
x.....xxxx9.xxxxx....+.9..x
x..9...xxxxxxx**..9..xx...x
x9...9..xxxxx*.....*xxx...x
x......xxxxO*..9..*xxx....x
x......xxx*.9.....*xx.....x
x.....xxx*.......*xxx.....x
x..9.xxx*.....9.*xxx....9.x
x....xxx*..9...Oxxx9......x
x....xx*.....**xxxx.......x
x.9.xx..9..**xxxxxxx......x
x....+.....xxxx.xxxxx.....x
x..xxxx+xxxxxx....xxxx....x
x.xxxxx.xxx.....9...xxxx..x
x.xxxxx...........9..xxx..x
x9.xx.......9...9....xxx..x
 .9.....9............xxx..
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

# 18 *, 12 monsters
NAME:  vaults_end_grunt_zigzag
TAGS:  vaults_end_quadrant unrand
SUBST: 9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxx.
 ..9...9xxx9***9xxx....9..
x....9.xxx.....*xx..xxxx9..
x.....xx...xx..xx..xx*Ox.9x
x....xx..xxx..xx..xx*k*x..x
x.x.xx..xx...xx..xx9**xx..x
x.x....xx..xxx..xx.9xxx...x
x.x9.xxx..xx...xx..xx...xxx
x.x.xx...xx..xxx..xx..xxx9x
x.xxx..xxx..xx...xx..xx.**x
x.xx..xx...xx..xxx..xx...*x
x.x..xx..xxx9.xx...xx..x.*x
x.x.xx..xx...xx..xxx..xx.9x
x.x....xx..xxx..xx...xx..xx
x.x.9.xx..xx...xx..xxx..xxx
x.xx...9.xx..xxx..xx...xxxx
x9*xxx...x..xx...xx..xxx.9x
x..*xxxx...xx..xxx..xx....x
xx..9xxx..xx..xx...xx...9.x
xx...*xx.9...xx..9....xx..x
x.....*xxxxxxxxxxxxxxxx..9x
 ..xx.9...................
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 16 * (2.667 |), 10 monsters, 8 $
NAME:    johnstein_vaults_end_maze
TAGS:    vaults_end_quadrant unrand
SHUFFLE: Oo / Pp / Qq / Rr / Ss
NSUBST:  o = 1:k / *:.
SUBST:   pqrs = ., PQRS = *, 9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 ........................
x.xxx.................xxx.x
x.x*xxxxxxx.....xxxxxxx*x.x
x.xx*$9...xx.9.xx...9$*xx.x
x..x$.................$x..x
x..x9...xxx..9..xxx...9x..x
x..xx...xOxxx.xxxPx...xx..x
x...xx..xxo.xxx.pxx..xx...x
x....x..x..x.9.x..x..x....x
x.......x.x9qxq9x.x.......x
x....9....x.xQx.x....9....x
x.......x.x9qxq9x.x.......x
x....x..x..x.9.x..x..x....x
x...xx..xxr.xxx.sxx..xx...x
x..xx...xRxxx.xxxSx...xx..x
x..x9...xxx..9..xxx...9x..x
x..x$.................$x..x
x.xx*$9...xx.9.xx...9$*xx.x
x.x*xxxxxxx.....xxxxxxx*x.x
x.xxx.................xxx.x
 .........................
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

###############################################################################
# Vaults:$ prize quadrants
###############################################################################

############################################################
# 11 |, 12 *, 15 monsters
NAME:    vaults_end_minmay_curved2
TAGS:    vaults_end_quadrant_prize unrand
SHUFFLE: Oo / Pp
SUBST:   o = k, p = ., P = |
SUBST:   9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 ......x|****o..9xxx.....
x......xO|*||...xx9.......x
x......xx|*....9x........xx
x...x...xxx....xx........xx
x...x..........x9......9xxx
x...x9........9x.....9xxx9x
x...xx........xx...xxxx9..x
x....x9......9x..xxx9.....x
x....xx9....9xx.xx9......px
x.....xxx99xxx..x9......|*x
x.......xxxx...xx.......|*x
x..............x9.....x***x
x...xxxx.......x9.....x||*x
x.....9xxx.....xx.....xxP|x
x.......9xx.....x9.....xxxx
xxxx.....9x.....xx9.......x
x..xx.....xx.....xxx9.....x
x...x.....9x.......xxxx...x
x...x.....9x..............x
x.........xx..............x
 ........9x...............
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 31 *, 18 $, 20 monsters
NAME:    vaults_end_minmay_connected_circles
TAGS:    vaults_end_quadrant_prize unrand
SHUFFLE: OPQRST
NSUBST:  O = 1:O / 1:k / *:*
SUBST:   PQRST = *
SUBST:   9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 x.9.xxxxxxO9xxxxxxxxxxxx
x.....xxxx9..Oxxxxxxxxxx.xx
x9.$.9xxxxO..9xxxxxxxxx.xxx
x.....xxx.x9Oxxxxxxxxx.xxxx
xx.9.xxx.xxxx.xxx.9.x.xxxxx
xxx.xxx.xx$9xx.x.....xxxxxx
xxxx.x.xx$P$9xx.9.$.9xxxxxx
xxx.9.xxx9$P$xxx.....xxxxxx
xx.$.$.x.x9$P$xxx.9.x.xxxxx
xx9.$.9.xxxx$P$xxx.xxx.xxxx
xx.$.$.x.xxxx$x.x.xxxxxQ9xx
xxx.9.xxx.xxxxxx.xxxxx9..Qx
xxxxxxxxxx.xxxx.xxxxx.Q..9x
xxx9R.RxxxxS9x.xxxxx.xx9Qxx
xx.R.R.Rxx9..Sxxxxx.xxxxxxx
x........xS..9xxxx.xxx.9xxx
x.......9xx9SxxT9Txxx.$.9xx
x9.......x.xxxT.T.Txx9...xx
x.........xxxx9T.T9x.x9..xx
x.......xxxxxxT.T.T.xxx...x
 x....9xxxxxxxxT9Txxxxxx.x
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 3 |, 24 *, 18 monsters
NAME:    vaults_end_minmay_x
TAGS:    vaults_end_quadrant_prize unrand
SHUFFLE: Oo / Pp / Qq / Rr
SUBST:   o = k, pqr = *, PQR = |
SUBST:   9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 ........................
x..xx9...............9xx..x
x..xxx...............xxx..x
x..9xxx.............xxx9..x
x....xxx...........xxx....x
x.....xxx.........xxx.....x
x......xxx9999999xxx......x
x......9xxx**o**xxx9......x
x......9*xxx***xxx*9......x
x......9**xxxOxxx**9......x
x......9p*PxxxxxQ*q9......x
x......9**xxxRxxx**9......x
x......9*xxx***xxx*9......x
x......9xxx**r**xxx9......x
x......xxx9999999xxx......x
x.....xxx.........xxx.....x
x....xxx...........xxx....x
x..9xxx.............xxx9..x
x..xxx...............xxx..x
x..xx9...............9xx..x
 .........................
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 8 |, 20 *, 16 monsters
NAME:   vaults_end_minmay_split_x
TAGS:   vaults_end_quadrant_prize unrand
SUBST:  9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 .9......9xxxxxxx9.......
x9.........xxxxx..........x
x..xxxxx....xxx....xxxxx..x
x..xxx..x...9x9...x..xxx..x
x..xx|...x.......x...|xx..x
x..x..9...x.....x...9..x..x
x..x...9..x.....x..9...x..x
x...x...|xx9...9xx|...x...x
x9...x..xxxx***xxxx..x...9x
xx....xxxxx*****xxxxx....xx
xxx9..xxxxx**O**xxxxx..9xxx
xx....xxxxx*k***xxxxx....xx
x9...x..xxxx***xxxx..x...9x
x...x...|xx9...9xx|...x...x
x..x...9..x.....x..9...x..x
x..x..9...x.....x...9..x..x
x..xx|...x.......x...|xx..x
x..xxx..x...9x9...x..xxx..x
x..xxxxx....xxx....xxxxx..x
x9.........xxxxx.........9x
 .9......9xxxxxxx9......9.
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 18 |, 12 *, 21 monsters
NAME:   vaults_end_minmay_slanted
TAGS:   vaults_end_quadrant_prize unrand
SUBST:  9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 ...............9..**|xxxx
x......xxxx..9..9..xxxx....
x...xxxx..9..9..xxxx......x
xxxxx.....9..xxxx.........x
x.........xxxx..9.........x
x......xxxx..9..9..xxxx999x
x999xxxx..9..9..xxxx......x
x.........9..xxxx.........x
x.........xxxx||......xxxxx
x|.....xxxx||k||999xxxx***x
x***xxxx999||O||xxxx.....|x
xxxxx......||xxxx.........x
x.........xxxx..9.........x
x......xxxx..9..9..xxxx999x
x999xxxx..9..9..xxxx......x
x.........9..xxxx.........x
x.........xxxx..9.....xxx.x
x|.....xxxx..9..9..xxxx...x
x***xxxx..9..9..xxxx......x
xxxxx.....9..xxxx.........x
 .........xxxx|**.........
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 16 |, 14 *, 20 monsters
NAME:    vaults_end_minmay_not_circular
TAGS:    vaults_end_quadrant_prize unrand
SHUFFLE: abcd
SUBST:   a : ., b : x .:1, c : x .:1, d : x .:1
SUBST:   9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
  ................xxxxxx..
x...................9xx...x
x.....................9..xx
x.......9xxcccccxx.....9xxx
x....9xxxx9.....9xxxx...xxx
x...9xx9...........9xx..9xx
x...xx...............xx..xx
x..9x9...xxaaaaaxx...9x..xx
x..xx..xxx9.*.*.9xxx..xx..x
x..d9.xx9**|||||**9xx.9b..x
x..d..b..*|||O|||*..d..b.*x
x..d9.xx9**|||||**9xx.9b.*x
x..xx..xxx9.*.k.9xxx..xx.*x
xx..x9...xxcccccxx...9x..xx
xx..xx...............xx..xx
xx9..xx9...........9xx..9xx
xxx...xxxx9.....9xxxx...xxx
xxx9.....xxaaaaaxx.....9xxx
xx..9.................9..xx
x...xx9.............9xx...x
 ..xxxxxx**......*xxxxxx..
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# about 21 |, 29 *
NAME:    vaults_end_mu_corners
TAGS:    vaults_end_quadrant_prize unrand
SHUFFLE: Oo / Pp
SUBST:   o = k, pP = $
SUBST:   9 = 8 9 .
SUBST:   $ = | *:15 $:5
SUBST:   a = x.
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
  ...x.......x99...x......
x....x.......x99...x..x...x
x....x..xxx..x..x..x..x...x
x.xxxx..xxx..x..x..x..x...x
x.......xxx..x..x..x..xxxxx
x.......xxx.....x99.......x
xxxxxx..xxx.....x99.......x
x.......xxxxxxxxxxxxxxxx..x
x.......x99x$$$$$$x99.....x
x..xxxxxx99x$$$O$$x99.....x
x99........x$$o$$$x..xxxxxx
x99........+$$$$$$x.......x
xxxxxx..x..x$$$$$$x.......x
x.......x..xxxxxxxxxxxxx..x
x.......x...............99x
x..xxxxxx...............99x
x99.....x..xxxx+xxxx..xxxxx
x99.....x..x$$$$$$$x..x...x
xxxxxx..x..x$$p$$$$x..x...x
a.......x99x$$$$$$$x..x...x
 .......x99x$$$$P$$x......
  axxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# about 21 |
NAME:   vaults_end_mu_flips
TAGS:   vaults_end_quadrant_prize unrand
NSUBST: ; = 3=D / 3=E / 3=F / .
SUBST:  9 = 8 9
SUBST:  $ = | * $
KFEAT:  D = teleport trap / dispersal trap
KFEAT:  E = zot trap
KFEAT:  F = alarm trap
SUBST:  s = x:250 +:1
SUBST:  a = x.
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 ........................
x.99xxxxxxxxxxxxxxxxxxxxs.x
x.9999..................x.x
x.x9xxxxxxxxxxxxxxxxxxs.x.x
x.x9x999..............x.x.x
x.x.x999xxxxxxxxxxxxs.x.x.x
x.x.x999;;;;;;;;$$$$x.x.x.x
x.x.x.x;;;;;;;;;$$$$x.x.x.x
x.x.x.x;;;;;;;;;$$$$x.x.x.x
x.x.x.x;;;;;;;;;$$$$x.x.x.x
x.x.x.x;;;;;;;;;$$$$x.x.x.x
x.x.x.x;;;;;;;;;$$$$x.x.x.x
x.x.x.x$$$$$$$$$$$$$x.x.x.x
x.x.x.x$$$$$$$$$$$k$x.x.x.x
x.x.x.x$$$$$$$$$$$$Ox.x.x.x
x.x.x.sxxxxxxxxxxxxxx.x.x.x
x.x.x................999x.x
x.x.sxxxxxxxxxxxxxxxx999x.x
x.x..................999x.x
x.sxxxxxxxxxxxxxxxxxxxxxx.a
 ........................
  xxxxxxxxxxxxxxxxxxxxxxa
ENDMAP

############################################################
# about 21 |
NAME:    vaults_end_mu_construction
TAGS:    vaults_end_quadrant_prize unrand
SHUFFLE: Qq, Oo / Pp / Qq / Rr / Ss
SUBST:   o = k, pqrsPQRS = $, $ = |*$.
SUBST:   c = xn9.
SUBST:   9 = 8 9 .
NSUBST:  D = 1:+ / *:x, E = 1:+ / *:x, F = 1:+ / *:x, G = 1:+ / *:x
SUBST:   a = xn..
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  axxxxxxxxxxxxxxxxxxxxxa
  .c.c.c..x$$O$$x..c.c.c..
a.c.c.c.c.+$$$$$+.c.c.c.c.a
xc.c.c.c..x$$o$$x..c.c.c.cx
x.c.c.c.c.xxxxxxx.c.c.c.c.x
xc.c.c.c.cx$$P$$xc.c.c.c.cx
x.c.c.c.c.x$$$$$x.c.c.c.c.x
xc.c.c.c.cx$$p$$xc.c.c.c.cx
x.c.c.c.c.x$$$$$x.c.c.c.c.x
xDxDxDxDxDxxx+xxxExExExExEx
x.........x$$q$$x.........x
x.x9.x..x.+$$9$$+.x..x.9x.x
x.........x$$Q$$x.........x
xFxFxFxFxFxxx+xxxGxGxGxGxGx
x.c.c.c.c.x$$$$$x.c.c.c.c.x
xc.c.c.c.cx$$r$$xc.c.c.c.cx
x.c.c.c.c.x$$$$$x.c.c.c.c.x
xc.c.c.c.cx$$R$$xc.c.c.c.cx
x.c.c.c.c.xxxxxxx.c.c.c.c.x
xc.c.c.c..x$$s$$x..c.c.c.cx
a.c.c.c.c.+$$$$$+.c.c.c.c.a
 ..c.c.c..x$$S$$x..c.c.c..
  axxxxxxxxxxxxxxxxxxxxxa
ENDMAP

############################################################
# about 19 |
NAME:    vaults_end_mu_triangles
TAGS:    vaults_end_quadrant_prize unrand
SHUFFLE: Oo / Pp
SUBST:   o = k, p = ., P = |
SUBST:   9 = 8 9 .:20
SUBST:   " = +:1 x:99
SUBST:   ! = x:20 .
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  x.xxxxxxxxxxxxxxxxxxxxx
 .........................
x.!x..9..xx............x!.x
...xx.....xx.9...9..9.xx..x
x...xx..9..xx........xx.9.x
x....xx.....xx.9..9.xx....x
x..9..xx..9..xx****xx.9...x
x......xx.....xx**xx......x
x....9..xx..9.."xxx|9.....x
x........xx.....xx||....9.x
x......9.|x"..9.."x|9.....x
x..9.....*|xx.....xx......x
x......9.|xxx"..9..xx.9...x
x........xx||xx.....xx....x
x....9..xx||||xx..9..xxp9|x
x......xx..9.9.xx.....xx||x
x..9..xx........xx..9..xxPx
x....xx..9.....9.xx.....xxx
x...xx............xx..9..xx
x..xx..9....9....9oxx.....x
x.!x...............|xx....x
 ..................|Oxx..
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# Two guaranteed good shops. Perhaps more shops.
# Almost all monsters are in the rooms.
NAME:    vaults_end_dpeg_mall
TAGS:    vaults_end_quadrant_prize vaults_end_quadrant_prize_mall unrand
SHUFFLE: AB, CD, Ee / Ff / Gg / Hh / Ii
SUBST:   A = +, B : xx+, C : xxx+, D : xxxx+
SUBST:   E = O, e = k, fghi = ', FG = S, HI : RRU9
KFEAT:   S = jewellery shop / antique armour shop / distillery shop
KFEAT:   R = general shop / book shop / scroll shop / \
             antique weapon shop / distillery shop
KFEAT:   U = stone_arch
NSUBST:  ' = 22:9 / *:., . = 2:9 / *:.
SUBST:   9 = 89
SUBST:   z : x.
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  zzxxxxxxxxxxxxxxxxxxxzz
 .........................
z.........................z
z..................xxx....z
x..............x+++xxx....x
x..........x+++x'''xxx....x
x..........x'''D'I'xx.....x
x..........x'H'D''ixx.....x
x........xxx''hxxxxxx.....x
x........xxxBBBxxxxxx.....x
x........xx''''xx.........x
x......T.xx'GTgxx.T.......x
x........xx''''xx.........x
x....xxxxxxAAAxxx.........x
x....xxxxxxf''xxx.........x
x....xxe''C'F'x...........x
x....xx'E'C'''x...........x
x...xxx'''x+++x...........x
x...xxx+++x...............x
z...xxx...................z
z.........................z
 ........................
  zzxxxxxxxxxxxxxxxxxxxzz
ENDMAP

############################################################
# 26 *, 16 monsters
NAME:   vaults_end_minmay_bent_boxes
TAGS:   vaults_end_quadrant_prize unrand
SUBST:  9 = 8 9 .:20
NSUBST: O = 1:O / *:|
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 .....9............9.....
x.....9............9......x
x.....xxxxxxxxxxxxxx......x
x................9.xx.....x
x................9..xx....x
x99x.....xxxxxxxxx...xx...x
x..x....xx.9..........xx99x
x..x...xx*.9...........x..x
x..x..xx**.xxxxxxx..x99x..x
x..x..x...*******x..x..x..x
x..x..x99x***O***x99x..x..x
x..x..x..x**k****...x..x..x
x..x99x..xxxxxxx.**xx..x..x
x..x...........9.*xx...x..x
x99xx..........9.xx....x..x
x...xx...xxxxxxxxx.....x99x
x....xx..9................x
x.....xx.9................x
x......xxxxxxxxxxxxxx.....x
x......9............9.....x
 ......9............9.....
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 28 *, 1 |, 20 monsters
NAME:    vaults_end_minmay_cup_spider
TAGS:    vaults_end_quadrant_prize unrand
SUBST:   9 = 8 9 .:20
NSUBST:  O = 1:O / 1:k / *:.
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 ........................
x.........................x
x..xxxx..xxxxxxxxx..xxxx..x
x.....x..9..*x*..9..x.....x
x.....x..9..*x*..9..x.....x
x..x99xxxxxxxxxxxxxxx99x..x
x..x..x**xO..|..Ox**x..x..x
x..x**x..xx..x..xx..x**x..x
x..xxxx99xx99x99xx99xxxx..x
x........x.......x........x
x........x.......x........x
x..xxxx99xx99x99xx99xxxx..x
x..xxxx..xx..x..xx..xxxx..x
x..9.*x......x......x*.9..x
x..9.*x**....x....**x*.9..x
x..xxxxxxxx99x99xxxxxxxx..x
x..x**x**x*..x..*x**x**x..x
x..x..x..x*..x..*x..x..x..x
x..x99x99xxxxxxxxx99x99x..x
x.........................x
 .........................
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 11 |, 18 *, 20 monsters
NAME:    vaults_end_minmay_30_sandwiches
TAGS:    vaults_end_quadrant_prize unrand
SHUFFLE: Ll / Mm / Nn / Oo / Pp / Qq / Rr / Ss / Tt / Uu / Vv / Ww
NSUBST:  o = 1:k / *:.
SUBST:   lmnpqrstuvw = ., LMNPQRSTUVW = |
SUBST:   9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 9...9...9...9...9...9...
x.x.x.xxx.x.x.xxx.x.x.xxx.x
x.x*x..*..x*x..*..x*x..*..x
x.x.x.xxx.x.x.xxx.x.x.xxx.x
x9...9...9...9...9...9...9x
x.xxx.xlx.xxx.xnx.xxx.x.x.x
x..*..xLx.mMm.xNx.oOo.x*x.x
x.xxx.xlx.xxx.xnx.xxx.x.x.x
x9...9...9...9...9...9...9x
x.x.x.xxx.xqx.xxx.xsx.xxx.x
x.x*x.pPp.xQx.rRr.xSx..*..x
x.x.x.xxx.xqx.xxx.xsx.xxx.x
x9...9...9...9...9...9...9x
x.xxx.xtx.xxx.xvx.xxx.x.x.x
x..*..xTx.uUu.xVx.wWw.x*x.x
x.xxx.xtx.xxx.xvx.xxx.x.x.x
x9...9...9...9...9...9...9x
x.x.x.xxx.x.x.xxx.x.x.xxx.x
x.x*x..*..x*x..*..x*x..*..x
x.x.x.xxx.x.x.xxx.x.x.xxx.x
 ....9...9...9...9...9...9
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 11 |, 16 *, 18 monsters
NAME:    vaults_end_minmay_small_xes
TAGS:    vaults_end_quadrant_prize unrand
SHUFFLE: Oo / Pp
SUBST:   o = k, pP = |
SUBST:   9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 ........................
x.xx9..9xx.......xx9..9xx.x
x.xxx**xxx.......xxx**xxx.x
x.9xxxxxx9.xxxxx.9xxxxxx9.x
x..*xxxx*..x|O|x..*xxxx*..x
x..*xxxx*..xo||x..*xxxx*..x
x.9xxxxxx9.xx+xx.9xxxxxx9.x
x.xxx**xxx.......xxx**xxx.x
x.xx9..9xx.xx9xx.xx9..9xx.x
x..........xxxxx..........x
x..........9xxx9..........x
x..........xxxxx..........x
x.xx9..9xx.xx9xx.xx9..9xx.x
x.xxx**xxx.......xxx**xxx.x
x.9xxxxxx9.xx+xx.9xxxxxx9.x
x..*xxxx*..xp||x..*xxxx*..x
x..*xxxx*..x|P|x..*xxxx*..x
x.9xxxxxx9.xxxxx.9xxxxxx9.x
x.xxx**xxx.......xxx**xxx.x
x.xx9..9xx.......xx9..9xx.x
 .........................
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 11 |, 12 *, 16 monsters
NAME:    vaults_end_minmay_plusses
TAGS:    vaults_end_quadrant_prize unrand
SHUFFLE: Oo / Pp / Qq / Rr
SUBST:   o = k, pqr = *, PQR = |
SUBST:   9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 ..xx.....8x8.......8x8..
x..........x.........x....x
xx....x.........x.........x
xx...9x9.......9x9.......8x
x...xxxxx..x..xxxxx..x..xxx
x....9x9.......9x9.......8x
xxxx..x.........x.........x
xO|x.......x.........x....x
x*ox......9x9.......9x9...x
x.....x..xxxxx..x..xxxxx..x
x*px......9x9.......9x9...x
xP|x.......x.........x....x
xxxx..x.........x.........x
x....9x9.......9x9.......8x
x...xxxxx..x..xxxxx..x..xxx
x....9x9.......9x9.......8x
x.....x.........x.........x
xx.......................xx
xx....xxxxx.....xxxxx....xx
x.......x|q**.**r|x.......x
 ..xx...xQ|**.**|Rx...xx..
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 11 |, 16 *, 16 monsters
NAME:    vaults_end_minmay_circles_and_squares
TAGS:    vaults_end_quadrant_prize unrand
SHUFFLE: Oo / Pp
SUBST:   o = k, pP = |
SUBST:   9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 ........................
x..xx9..9xx.....xx9..9xx..x
x.xxxx..xxxx...xxxx..xxxx.x
x.xxxx..xxxx...xxxx..xxxx.x
x.9xx....xx9...9xx....xx9.x
x.....||...........||.....x
x.9xx....xx9...9xx....xx9.x
x.xxxx..xxxx...xxxx..xxxx.x
x.xxxx..xxxx...xxxx..xxxx.x
x..xx9..9xx.....xx9..9xx..x
x.....xx...........xx.....x
x..xx9xx9xx.....xx9xx9xx..x
x..xx....xx.....xx....xx..x
x..9..**..9.....9..**..9..x
x.xx.*|o*.xx...xx.*p|*.xx.x
x.xx.*O|*.xx...xx.*|P*.xx.x
x..9..**..9.....9..**..9..x
x..xx....xx.....xx....xx..x
x..xx9xx9xx.....xx9xx9xx..x
x.....xx...........xx.....x
 .........................
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 14 |, 6 *, 20 monsters
NAME:   vaults_end_minmay_odd_checkers
TAGS:   vaults_end_quadrant_prize unrand
SUBST:  9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 .999x......xx......xx...
x....x......xx......xx....x
x....9..xx...9..xx....9...x
x....9..xx...9..xx.....9..x
x....x......xx..........xxx
x....x......xx..9.......xxx
x.99.x..xx.......9..xx....x
x....x*.xx..........xx....x
x....x*...9.....xx..9...xxx
x....x|....9....xx..9...xxx
x...9x|.....xx......xx....x
x..9.x|99...xx......xx....x
x.9..x|9xx......xx......xxx
x9...x||xx9.....xx......xxx
x....x|k|99.....9........9x
x....xO||||||**.9........9x
xxxx.xxxxxxxxxxxxxxxxx..xxx
x..........9.............9x
x....x....9..........9...9x
x....x...9...........9...9x
 ....x..9.................
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 8 |, 19 *, 18 monsters
NAME:    vaults_end_minmay_bends
TAGS:    vaults_end_quadrant_prize unrand
SHUFFLE: Oo / Pp
SUBST:   o = k, p = ., P = |
SUBST:   9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 ....x9***9x9....x9.......
x....x.9|9.x.9...x.9......x
x....x..x..x..x..x..xxxx..x
x....x..x..x..x..x...**x..x
x9xxxx..x..x..x..x...**x..x
x...9x..x..x..x..x..x..x..x
x..9.x..x..x..x...9.....9.x
x.9..x..x..x..x....9.....9x
x....x..x..x..xxxx..xxxxxxx
x....x..x..x9.o|Ox........x
x....x..x..x.9.||x.......*x
x....x..x..x..x..xxxxxxx.*x
x....x..x||....9........9*x
x....x..xP|p....9........9x
x....x..xxxx..xxxxxxxxxxxxx
x....x*...9x9............9x
x....x**.9.x.9..........9.x
x....xxxx..xxxxxxxxxxxxx..x
x.9.9......x...**x.....x..x
x..9.......x...**x.....x..x
 .9........9...**x.....9..
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 7 |, 18 *, 20 monsters
NAME:    vaults_end_minmay_plus_grid_2
TAGS:    vaults_end_quadrant_prize unrand
SHUFFLE: Oo / Pp / Qq / Rr
SUBST:   o = k, pqr = *, PQR = |
SUBST:   9 = 8 9 .:20
SUBST:   X : x., Y : x.
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
 .xxxxxxxxxxxxxxxxxxxxxxx
.....x.9.x.9.x.9.x.9.x.9.
x.x.x.x.x.x.xox.x.x.x.x.x.x
x..x.9.x.9.x*O*x.9.x.9.x.9x
x.x.x.x.x.xYx*xYx.x.x.x.x.x
xx.9.x.9.xYYYxYYYx.9.x.9.xx
x.x.x.x|xXxYxYxYxXx*x.x.x.x
x9.x.9|xXXXxYYYxXXXx.9.x.9x
x.x.x.xYxXxXxYxXxXxYx.x.x.x
xx.9.xYYYxXXXxXXXxYYYx.9.xx
x*x*xXxYxYxXxXxXxYxYxXx*x*x
x9PxXXXxYYYxXXXxYYYxXXXxQ9x
xpx*xXxYxYxXxXxXxYxYxXxqx*x
xx.9.xYYYxXXXxXXXxYYYx.9.xx
x.x.x.xYxXxXxYxXxXxYx.x.x.x
x9.x.9.xXXXxYYYxXXXx|9.x.9x
x.x.x.x*xXxYxYxYxXx|x.x.x.x
xx.9.x.9.xYYYxYYYx.9.x.9.xx
x.x.x.x.x.xYxrxYx.x.x.x.x.x
x..x.9.x.9.x*R*x.9.x.9.x..x
x.x.x.x.x.x.x*x.x.x.x.x.x.x
 ....x.9.x.9.x.9.x.9.x....
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 16 *, 8 |, 16 monsters
NAME:   vaults_end_minmay_odd_hourglass
TAGS:   vaults_end_quadrant_prize unrand
SUBST:  9 = 8 9 .:20
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 ....9x.................x
x....x.x...............x9xx
x....xx9x.............x.xxx
x...x.xx.x...........x9xx.x
x...9..xx9x.........x.xx..x
x...x...xx.x.......x9xx...x
x........xx9x.....x.xx..x9x
x...x.....xx.x...x9xx..xx9x
x...9......xxxxxxxxx..xx*.x
x...x......9.9..9.9..xx**.x
x...................xx|**.x
x...x......9.9..9.9xx||**.x
x...9......xxxxxxxxxO||k*.x
x...x.....xx9x...x.xx||**.x
x........xx.x.....x9xx|**.x
x...x...xx9x.......x.xx**.x
x...9..xx.x.........x9xx*9x
x...x.xx9x...........x.xx9x
x....xx.x.............x9xxx
x....x9x...............x.xx
 .....x.................x9
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 16 *, 10 |, 16 monsters
NAME:    vaults_end_nooodl_tilted_maze
TAGS:    vaults_end_quadrant_prize unrand
SUBST:   9 = 8 9 .:10
SHUFFLE: Oo / Pp
SUBST:   o = k, P = |, p = .
SUBST:   * = * $:4
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 ........9...xx..xx.......
x........xx..xx...9....9..x
x....xx..xx...x.......xxxxx
xxx..xx.......x.9.xx..xx..x
xxx.......9...xx..xx......x
x.9.......xxxxxx...x.9....x
x.....xx|.xx.9.....x...xx.x
x.xx..xx|.o........xxxxxx.x
xxxx..*x|9..$$$xx*.xx.9...x
x....9*xO||xxxxxx*........x
x..$***xxxxxx||Px*......xxx
x..xxxxxx$$$..9|x***xx..xxx
x9.xx$$..9...p.|xxxxxx...9x
x...9.......xx.*xx***$....x
x.......xxxxxx..*x*9.....xx
x...xx..xx...9..*x*..xx..xx
xx..xx..9x...$***xx..xx...x
x........x...xxxxxx.......x
x........xx..xx$$9........x
x....xx..xx...........xx..x
 ....xx9..x9......xx..xx..
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

# 21 |, 20 monsters
NAME:    vaults_end_grunt_nonplussed
TAGS:    vaults_end_quadrant_prize unrand
NSUBST:  9 = 10:8 / 10:9 / *:.
NSUBST:  O = 1:O / *:|
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 ..xxx|xxx|xxx|xxx|xxx|x.
x.9.x.9.x.9.x.9.x.9.x.9.x.x
xx.x.x.x.x.x.x.x.x.x.x.x.xx
xxx.9.x.9.x.9.x.9.x.9.x.9|x
xx.x.x.x.x.x.x.x.x.x.x.x.xx
x|9.x.9.x.9.x.9.x.9.x.9.xxx
xx.x.x.x.x.x.x.x.x.x.x.x.xx
xxx.9.x.9.x.9.x.9.x.9.x.9|x
xx.x.x.x.x.x.x.x.x.x.x.x.xx
x|9.x.9.x.9.x.9.x.9.x.9.xxx
xx.x.x.x.x.xOx.x.x.x.x.x.xx
xxx|9.x.9.x.9kx.9.x.9.x.9|x
xx.x.x.x.x.x.xOx.x.x.x.x.xx
x|9.x.9.x.9.x.9.x.9.x.9.xxx
xx.x.x.x.x.x.x.x.x.x.x.x.xx
xxx.9.x.9.x.9.x.9.x.9.x.9|x
xx.x.x.x.x.x.x.x.x.x.x.x.xx
x|9.x.9.x.9.x.9.x.9.x.9.xxx
xx.x.x.x.x.x.x.x.x.x.x.x.xx
x.x.9.x.9.x.9.x.9.x.9.x.9.x
 ..x|xxx|xxx|xxx|xxx|xxx..
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# 18 *, 8 | (11 total), 20 monsters, 8 $
NAME:   johnstein_vaults_end_asymmetric
TAGS:   vaults_end_quadrant_prize unrand
SUBST:  9 = 8 9 *:10
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
  xxxxxxxxxxxxxxxxxxxxxxx
 ........................
x........9.........9......x
x..xxxxx...xxxxxxx...xxx..x
x...xxxxx...xxxxx...xxx...x
x.9..xxxxx...xxx...xxx..9.x
x.....xxxxx...xx..xxx.....x
x..x...xxxxx*9999*xx...x..x
x..xx...xxxxx$99$xx...xx..x
x..xxx...xxxxx||xxx...xx..x
x...xx...xxxx9k9xxxx...x..x
x......9*9$|9O99|$9*9.....x
x...xx...xxx9*9xxxxx...x..x
x..xx...xx||||xxxxx...xx..x
x..x...xx$99$xxxxx...xxx..x
x.....xx*99*xxxxx...xxx...x
x.9..xx..9xxxxxx...xxx..9.x
x...xx...xxxxxx...xxx.....x
x..xxx...xxxxx...xxx...x..x
x..xxx...xxxx...xxx...xx..x
x......9............9.....x
 .........................
  xxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

############################################################
# Vaults:$ - Rooms Quadrant
#
# This quadrant uses a subvault for each room. Any subvault tagged
# vaults_end_room_rune should be guaranteed to provide a rune. Any subvault
# tagged vaults_end_room should just provide loot. Note that the rooms
# are not all the same sizes.
#
# about 24 |
NAME:     vaults_end_classical_rooms
TAGS:     vaults_end_quadrant_prize unrand
SHUFFLE:  AC/BD, EG/FH, IKN/MJL
SUBST:    A=., B=xx+, C=+, D=x, E=+, F=xx+, G=., H=x
SUBST:    I=., M=xx+, J=x, K=+, N=+, L=xx+
SUBST:    a:x.
SHUFFLE:  VXYZ
SUBVAULT: V : vaults_end_room_rune
SUBVAULT: X : vaults_end_room
SUBVAULT: Y : vaults_end_room
SUBVAULT: Z : vaults_end_room
SUBST:    VXYZ = .
: if (dgn.persist.vaults_end_crystal) then
SUBST:    x = b
: else
SUBST:    x = v
: end
MAP
  axxxxxxxxxxxxxxxxxxxxxa
 ............99...........
a.xxxxxxxxxxx..xxxxxxxxJxIa
x.xVVVVVVVVVx..xXXXXXXXXx.x
x.xVVVVVVVVVx..xXXXXXXXXx.x
x.xVVVVVVVVVx..xXXXXXXXXx.x
x.xVVVVVVVVVx..xXXXXXXXXx.x
x.xVVVVVVVVVx..xXXXXXXXXx.x
x.xVVVVVVVVVx..xXXXXXXXXx.x
x.NVVVVVVVVVL..KXXXXXXXXx.x
xMxxxxxxxxxxxxxxxxxxxxxxx.x
x.9.........G998........A.x
x.9.........G998........x.x
x.xxxxxxxxxFx88xxxxxxxxDx.x
x.xYYYYYYYYYx..xZZZZZZZZx.x
x.xYYYYYYYYYx..xZZZZZZZZx.x
x.xYYYYYYYYYx..xZZZZZZZZx.x
x.xYYYYYYYYYx..xZZZZZZZZx.x
x.xYYYYYYYYYx..xZZZZZZZZx.x
x.xYYYYYYYYYx..CZZZZZZZZx.x
a.xxxxxxxxxEx..xxxxxxxxxx.a
 ...........H..B.........
  axxxxxxxxxxxxxxxxxxxxxa
ENDMAP

# Vaults:$ - Rooms Quadrant - Traps and Loot Subvault
#            Replace each square with traps or loot, but mostly floor.
NAME: vaults_end_room_traps_and_loot
TAGS: vaults_end_room
: default_subvault_glyphs()
SUBST: . = ?
: vaults_end_loot(_G)
MAP
ENDMAP

# Vaults:$ - Rooms Quadrant - Border Subvault
#            Fill the room with loot, but leave an empty border.
NAME: vaults_end_room_border
TAGS: vaults_end_room
{{
    default_subvault_glyphs()
    local w, h = subvault_size()

    local i
    for i in iter.subvault_iterator(_G) do
      if i.x == 0 or i.x == w-1 or i.y == 0 or i.y == h-1 then
        -- border
        mapgrd[i.x][i.y] = '.'
      else
        -- inside
        mapgrd[i.x][i.y] = '*'
      end
    end
}}
: vaults_end_loot(_G)
MAP
ENDMAP

# Vaults:$ - Rooms Quadrant - Diamond Subvault
#            Fill the room with money in a diamond pattern.
NAME: vaults_end_room_diamond
TAGS: vaults_end_room
{{
    default_subvault_glyphs()
    local w, h = subvault_size()

    local i
    for i in iter.subvault_iterator(_G) do
      if (i.x + i.y) % 2 == 0 then
        mapgrd[i.x][i.y] = '$'
      else
        mapgrd[i.x][i.y] = '.'
      end
    end
}}
: vaults_end_loot(_G)
MAP
ENDMAP

# Vaults:$ - Rooms Quadrant - Rune Subvault
#            Potentially contains the rune.
NAME: vaults_end_room_rune
TAGS: vaults_end_room_rune
: vaults_end_loot(_G)
: vaults_end_rune(_G)
MAP
......
......
..|k..
..||..
..O|..
......
......
ENDMAP
