###############################################################################
# Grated Community (by Mu.)
#
# A few creatures have built their own little community deep underground,
# complete with quaint little homes and a handful of local shops.
# How wonderful!
#
# Digging or teleportation is required to enter the vault.
# A wand of digging and scroll of teleportation is guaranteed in the
# home of a local kobold to ensure random teleporters can escape. If
# all else fails there is an escape hatch in the mall's washroom.

default-depth:  Depths, !Depths:$

NAME:   grated_community_mu
TAGS:   no_rotate no_monster_gen no_item_gen no_descent
ORIENT: north
MONS:   patrolling vault guard, patrolling wolf, patrolling centaur warrior
MONS:   generate_awake lemure, kobold
  : if you.absdepth() < 23 then
KMONS:  a = patrolling two-headed ogre
  : else
KMONS:  a = patrolling two-headed ogre / patrolling stone giant
  : end
KMONS:  b = patrolling ettin
KMONS:  k = patrolling vampire mage / patrolling boggart
KMONS:  d = orc warlord
  : if you.absdepth() < 23 then
KMONS:  e = vampire / yaktaur / kobold /\
            ettin / orc / wolf / gargoyle / iron troll / warg /\
            deep troll / cyclops / centaur / occultist / arcanist
KMONS:  i = frost giant / fire giant
  : else
KMONS:  e = vampire / yaktaur / w:5 frost giant / w:5 fire giant /\
            ettin / orc / wolf / gargoyle / iron troll / deep troll /\
            cyclops / kobold / centaur / warg / occultist / arcanist
KMONS:  i = titan
  : end
KMONS:  P = plant
KMONS:  h = generate_awake human / generate_awake elf / generate_awake kobold
KFEAT:  = = floor
KPROP:  4 = no_tele_into
FTILE:  =E79 = floor_grass
COLOUR: =E7 = green
SUBST:  E = e
SUBST:  e = e.
: kitem("$ = q:" .. crawl.random_range(50, 500) .. " gold")
KITEM:  * = animal skin, any good_item
KITEM:  ' = ident:type wand of digging, ident:type scroll of teleportation
MARKER: + = lua:restrict_door()
MARKER: # = lua:fog_machine { cloud_type = "flame", \
                pow_min = 10, pow_max = 10, delay = 10, \
                size = 1, walk_dist = 0, start_clouds = 1, excl_rad = 0 }
KFEAT:  g = iron_grate
SUBST:  9 = 8
KFEAT:  8 = granite_statue
KFEAT:  f = fountain_blue
KFEAT:  j = fountain_sparkling
KFEAT:  ~ = closed_door
KFEAT:  7 = tree
KFEAT:  A = general shop
# TODO: removed food shop on B, is there a good replacement?
KFEAT:  C = distillery shop type:Miraculous suffix:Elixirs count:10 \
            greed:50 ; potion of mutation
: local smithy = string.gsub(crawl.make_name(), " ", "_")
: kfeat("D = armour shop name:The_Legendary_" .. smithy .. " \
:        type:Legendary suffix:Smithy count:10 greed:40 ;\
:        damaged plate armour ego:none | damaged chain mail ego:none |\
:        damaged long sword ego:none | damaged kite shield ego:none |\
:        damaged tower shield ego:none | damaged battleaxe ego:none")
SHUFFLE:  QRSTUVX
SUBVAULT: Q : grated_community_mu_home1
SUBVAULT: R : grated_community_mu_home2
SUBVAULT: S : grated_community_mu_home3
SUBVAULT: T : grated_community_mu_home4
SUBVAULT: U : grated_community_mu_home5
SUBVAULT: V : grated_community_mu_home6
SUBVAULT: X : grated_community_mu_home
SUBST:    QRSTUVX : .
TILE:     c = wall_stone_smooth
TILE:     Z = wall_vines
TILE:     - = wall_brick_darkgray
SUBST:    - = c
SUBST:    Z = c
MAP
cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
cZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZc
cZ==========EE========EE========EE========...===============================EEZc
cZ==========EE========EE========EE========...==============================EEEZc
cZ==-------===QQQQQQQ===TTTTTTT===UUUUUUU=...=ccccccccccccccccccccccccccccccE=Zc
cZ==-W+..'-===QQQQQQQ===TTTTTTT===UUUUUUU=...=ccccccccccccc$ccccccccccccc$cc==Zc
cZ==---..--===QQQQQQQ===TTTTTTT===UUUUUUU=...=cc4c4c4c4cca.acW.Wc....c.b.bcc==Zc
cZ==-#-..P-===QQQQQQQ===TTTTTTT===UUUUUUU=...=ccgcgcgcgcc.A.cc>cc.h..+..B.cc==Zc
cZ==-5....-===QQQQQQQ===TTTTTTT===UUUUUUU=...=9c...eee..+.a.cW.Wch.h.c.b..cc==Zc
cZ==-*....-===QQQQQQQ===TTTTTTT===UUUUUUU=...==n....e...cccccc+cc.h..ccc+ccc==Zc
cZ==---n-+-===QQQQQQQ===TTTTTTT===UUUUUUU=.....~................ccnncc....cc==Zc
cZ..........e.......Q.e.......T.e.......U......~.......eee.......e........cc==Zc
cZ...=7=7=.efe.=7=7=.efe.=7=7=.ife.=7=7=.....==n.......eee.......ee.i...e.cc==Zc
cZ........R.e.......S.e.......V.e.......X......~.................e........cc==Zc
cZ==RRRRRRR===SSSSSSS===VVVVVVV===XXXXXXX=.....~........ccccccccccccccccc+cc==Zc
cZ==RRRRRRR===SSSSSSS===VVVVVVV===XXXXXXX=...==n........+.......c.k.......cc==Zc
cZ==RRRRRRR===SSSSSSS===VVVVVVV===XXXXXXX=...=9c....e...c.b..c.dc..k......cc==Zc
cZ==RRRRRRR===SSSSSSS===VVVVVVV===XXXXXXX=...=cc...eee..cc..cc.Dc.kj.C.j..cc==Zc
cZ==RRRRRRR===SSSSSSS===VVVVVVV===XXXXXXX=...=cc........cW..#c..c....k....cc==Zc
cZ==RRRRRRR===SSSSSSS===VVVVVVV===XXXXXXX=...=ccccccccccccccccc$c$cccccccccc==Zc
cZ==RRRRRRR===SSSSSSS===VVVVVVV===XXXXXXX=...=ccccccccccccccccccccccccccccccE=Zc
cZ==========EE========EE==================...==============================EEEZc
cZ==========EE========EE==================...===============================EEZc
cZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZgggZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZc
ccccccccccccccccccccccccccccccccccccccccccgggccccccccccccccccccccccccccccccccccc
                                   ccc...........ccc
                                   ccc.c~c...c~c.ccc
                                   ccc.c1n.3.n1c.ccc
                                   ccc.cnc...cnc.ccc
                                   ccc...........ccc
                                   ccc...2...2...ccc
                                   ccc.2...1...2.ccc
                                   c8c...........c8c
                                   .................
                                   .................
ENDMAP

####  Room subvaults for the homes in grated_community_mu
####  vampire, some bound demons, bloody lounge, bricked up window, guard dogs
NAME: grated_community_mu_vampire_home
TAGS: grated_community_mu_home grated_community_mu_home1 unrand
KMONS:   1 = generate_awake lemure
KMONS:   2 = generate_awake spectral hound
KMONS:   3 = generate_awake spectral wolf
KMONS:   4 = generate_awake spectral warg
KMONS:   V = vampire knight / vampire mage
KITEM:   V = any good_item
KFEAT:   g = iron_grate
KFEAT:   _ = altar_kikubaaqudgha
KFEAT:   ! = fountain_blood
SHUFFLE: _!
SHUFFLE: 234
KPROP:   . = bloody / w:4 nothing
KPROP:   1 = no_tele_into
MARKER:  + = lua:restrict_door()
KFEAT:   = = floor
TILE:    c = wall_stone_dark
TILE:    x = wall_brick_darkgray
FTILE:   !1234cVg+._x+ = floor_crypt
MAP
ccccccc
c1cVc1c
cgc+cgc
c.....c
c.2.2.c
c_....c
ccxc+cc
      =
ENDMAP

####  giant, some hides, hearth, deep washroom, closet, lounge feature
NAME: grated_community_mu_giant_home
TAGS: grated_community_mu_home grated_community_mu_home2 unrand
MONS: patrolling ettin / patrolling stone giant / patrolling fire giant /\
      patrolling titan / patrolling cyclops
MONS: patrolling frost giant
FTILE:  123456cw#+%*.8$n~ = floor_grey_dirt
KITEM:  % = animal skin / nothing
MARKER: + = lua:restrict_door()
KFEAT:  ~ = closed_door
SUBST: * = *:35 -:1
KITEM: - = animal skin
: dgn.delayed_decay_extra(_G, '*', 'human skeleton / yak skeleton /\
:                            elf skeleton / kobold skeleton /\
:                            elephant skeleton / dream sheep skeleton /\
:                            manticore skeleton', 'animal skin')
KFEAT:  8 = granite_statue / orcish_idol / w:5 altar_trog /\
            w:5 altar_beogh / w:1 altar_makhleb / w:4 floor
KITEM:  $ = giant spiked club / giant club / nothing
: local frosty = crawl.random2(6)
: if frosty == 5 then
SUBST:  1 = 2
SUBST:  # = ?
: end
####  The frost giant has an ice fireplace ok that's just how he cooks
MARKER: # = lua:fog_machine { cloud_type = "flame", \
                pow_min = 10, pow_max = 10, delay = 10, \
                size = 1, walk_dist = 0, start_clouds = 1, excl_rad = 0 }
MARKER: ? = lua:fog_machine { cloud_type = "freezing vapour", \
                pow_min = 10, pow_max = 10, delay = 10, \
                size = 1, walk_dist = 0, start_clouds = 1, excl_rad = 0 }
KFEAT:  = = floor
TILE:   c = wall_brick_dark_2

MAP
ccccccc
cwcc#cc
c+c%%*c
c...1.c
ccc.8.c
c$+...c
cccnc~c
      =
ENDMAP

####  spellcaster, living room, workshop, closet
NAME: grated_community_mu_spellcaster_home
TAGS: grated_community_mu_home grated_community_mu_home3 unrand
FTILE:   c*1.8+&P!?n = floor_crystal_squares
SHUFFLE: 8P
MARKER:  + = lua:restrict_door()
: if crawl.coinflip() then
SUBST: * = "
: else
: end
: local occupant = crawl.random2(3)
  : if occupant == 0 then
MONS:  lich / w:4 ancient lich / w:4 dread lich / w:5 royal mummy
KFEAT: * = altar_kikubaaqudgha / w:4 altar_sif_muna / w:1 altar_yredelemnul
KITEM: " = gold, any wand / w:15 nothing, any scroll / nothing
KFEAT: 8 = granite_statue / w:2 fountain_blood / w:1 floor
: kitem("? = q:" .. crawl.random_range(1, 3) .. " scroll of torment ident:type /\
:        nothing, any scroll / nothing")
: kitem("! = q:" .. crawl.random_range(1, 3) .. " potion of magic ident:type /\
:        nothing, any potion / nothing")
KITEM: & = book of necromancy / book of death / book of unlife / book of decay /\
           w:12 nothing
KMONS: P = withered plant
  : elseif occupant == 1 then
MONS:  occultist w:5 / arcanist w:5 / ogre mage / deep elf sorcerer
KFEAT: * = altar_sif_muna / w:5 altar_ashenzari
KITEM: " = gold, any potion / nothing, any potion / nothing, any potion /\
           nothing
KFEAT: 8 = granite_statue / fountain_sparkling / fountain_blue / w:1 floor
KITEM: ? = scroll of vulnerability ident:type / nothing, any scroll / nothing
: kitem("! = q:" .. crawl.random_range(1, 3) .. " potion of magic ident:type /\
:        nothing, any potion / nothing")
KITEM: & = book of power / book of party tricks / book of transmutation /\
           book of the senses / book of chaos / nothing
KMONS: P = plant

  : elseif occupant == 2 then
MONS:  deep elf annihilator / draconian annihilator / draconian scorcher
KFEAT: * = altar_vehumet / w:2 altar_makhleb
KITEM: " = gold, any beam wand / any blast wand, \
           potion of brilliance ident:type / nothing
KFEAT: 8 = granite_statue / w:1 floor
KITEM: ? = scroll of immolation ident:type / nothing, any scroll / nothing
: kitem("! = q:" .. crawl.random_range(1, 3) .. " scroll of immolation ident:type /\
:        nothing, any potion / nothing")
KITEM: & = book of fire / book of power / book of ice /\
       book of storms / book of lightning / the unrestrained analects /\
       w:12 nothing
KFEAT: P = granite_statue
: end
KFEAT:   = = floor
TILE:    c = dngn_stone_wall_brown

MAP
ccccccc
c*c1.8c
c.+...c
ccc+c.c
c&..c.c
cP!?c.c
cccnc+c
      =
ENDMAP

####  orc, possible family, messy living room w/features, hearth, closet
NAME: grated_community_mu_orcish_home
TAGS: grated_community_mu_home grated_community_mu_home4 unrand
MONS: orc warlord, orc high priest, orc, warg
FTILE:   1238c$+1#_W+~n%&$. = floor_pebble_yellow
SHUFFLE: $W
SHUFFLE: 8_
SUBST:   _ = _8
SUBST:   2 = 2.
SUBST:   3 = 3.
NSUBST:  . = 5:% / *:.
KITEM:   % = w:12 animal skin / club / hand axe
KFEAT:   8 = orcish_idol / w:5 floor
KFEAT:   _ = altar_beogh / w:15 floor
KITEM:   $ = battleaxe / nothing, plate armour / nothing, \
             gold, any, any
MARKER:  # = lua:fog_machine { cloud_type = "flame", \
                 pow_min = 10, pow_max = 10, delay = 10, \
                 size = 1, walk_dist = 0, start_clouds = 1, excl_rad = 0 }
MARKER: + = lua:restrict_door()
KFEAT:  ~ = closed_door
KFEAT:  = = floor
TILE:   c = wall_brick
MAP
ccccccc
c$+.1.c
ccc.82c
c#.3..c
ccc._.c
cW+...c
cccnc~c
      =
ENDMAP

####  troll, cookfire, remains
NAME: grated_community_mu_troll_home
TAGS: grated_community_mu_home grated_community_mu_home5 unrand
MONS: patrolling iron troll / patrolling deep troll
FTILE:   1.c~+#$%& = floor_dirt
KITEM:   $ = animal skin
NSUBST:  . = 7:% / 2:$ / *:.
: dgn.delayed_decay_extra(_G, '%', 'w:20 any skeleton', 'any / nothing')
KFEAT:   ~ = floor
MARKER:  # = lua:fog_machine { cloud_type = "flame", \
                 pow_min = 10, pow_max = 10, delay = 10, \
                 size = 1, walk_dist = 0, start_clouds = 1, excl_rad = 0 }
MARKER:  + = lua:restrict_door()
KFEAT:   = = floor
KPROP:   . = bloody
TILE:    c = wall_lab_rock
MAP
ccccccc
cc...cc
c.1...c
c..#..c
c.....c
cc~~~cc
ccc+ccc
      =
ENDMAP

####  taur, entrace w/feature, shooting range, closets
NAME: grated_community_mu_taur_home
TAGS: grated_community_mu_home grated_community_mu_home6 unrand
FTILE:  12.c'+%$W8n~ = floor_grass_dirt_mix
: if crawl.coinflip() then
MONS:   patrolling centaur warrior, plant
KITEM:  $ = any good_item
: else
MONS:   patrolling yaktaur captain, plant
KITEM:  $ = any good_item
:end
SHUFFLE: %$
SUBST:  % = %W
KITEM:  % = any potion
SUBST:  8 = 82
KFEAT:  8 = granite_statue / floor
MARKER: + = lua:restrict_door()
KFEAT:  ~ = closed_door
KFEAT:  = = floor
TILE:   c = wall_brick_vines
MAP
ccccccc
c'''..c
ccccc+c
c%+.1.c
ccc.8.c
c$+...c
cccnc~c
      =
ENDMAP

NAME: grated_community_mu_unbuilt_plot
TAGS: grated_community_mu_home unrand
FTILE:  . = floor_grass_dirt_mix
COLOUR: . = green
SHUFFLE: %$
KFEAT:  = = floor
MAP
.......
.......
.......
.......
.......
.......
.......
      =
ENDMAP
