###############################################################################
# ghost.des
#
# Vaults that place player ghosts. For now, all such vaults that don't place in
# the Vaults branch should appear in this file, even if they're
# branch-specific. For Vaults ghost vaults, we currently use
# branches/vaults_rooms_ghost.des. See the ghost vault guidelines in
# docs/develop/levels/guidelines.md. All vaults here should call the function
# ghost_setup().
#
# Organization:

# <<1>>      General/Abstract ghost vaults
# <<2>>      Themed ghost vaults
#
# General ghost vaults in <<1>> use 098 monsters and any specified monsters
# would be generic things like statue monsters or branch-representative
# monsters. For more thematic vaults, put them in <<2>>.
###############################################################################

: crawl_require("dlua/ghost.lua")
: crawl_require("dlua/vault.lua")

{{
-- Set up the non-flaming edged weapon "left" by the ghost in
-- gammafunk_ghost_hydra_chop.
function setup_hydra_weapon(e)
    -- Possible weapon types with weights. We stick to weapons wieldable by all
    -- non-felids.
    local weapons = {["long sword"] = 8, ["scimitar"] = 12,
                     ["demon blade"] = 1, ["double sword"] = 1,
                     ["war axe"] = 8, ["broad axe"] = 12, ["lajatang"] = 2}

    -- Basic set of egos with weights.
    local egos = {["none"] = 30, ["vorpal"] = 15, ["freezing"] = 15,
            ["electrocution"] = 10, ["venom"] = 10, ["protection"] = 10,
            ["vampirism"] = 5, ["holy_wrath"] = 5, ["draining"] = 5,
            ["pain"] = 2, ["distortion"] = 2, ["antimagic"] = 2, ["speed"] = 1}

    local quality = crawl.one_chance_in(3) and "randart" or "good_item"
    local weapon_def = dgn.random_item_def(weapons, egos, quality)
    e.kitem("O = " .. weapon_def)
end

function wrathful_weapon(class, quality)
    local egos
    -- Only the egos Trog gifts, using equal weights for good_item but giving
    -- the more desireable antimagic brand for randarts, which are trying to be
    -- better quality.
    if quality == "good_item" then
        egos = {["antimagic"] = 10, ["vorpal"] = 10, ["flaming"] = 10}
    elseif quality == "randart" then
        -- Increased chance for antimagic.
        egos = {["antimagic"] = 25, ["vorpal"] = 10, ["flaming"] = 10}
    else
        error("Unknown weapon quality: " .. quality)
    end

    return dgn.monster_weapon(class, egos, quality)
 end

function disto_weapon(class, quality)
    return dgn.monster_weapon(class, "distortion", quality)
end
}}

# Only the below levels and Vaults:1-4 place ghost vaults. A specific ghost
# vault may only be appropriate for a subset of these levels, in which case
# they should set their own DEPTH. Note that if this default depth is changed,
# vaults below with branch-specific item/monster placement may need to be
# updated.
default-depth: D:3-, Lair, Elf, Orc, Snake, Shoals, Swamp, Spider, Depths, \
               Crypt, Zot

###############################################################################
#
# <<1>> General/Abstract ghost vaults.
#
#
###############################################################################

NAME:   gammafunk_ghost_grave
TAGS:   allow_dup
ORIENT: float
: lone_ghost_guarded_loot(_G, "O")
: lone_ghost_extra_loot(_G, "-")
KMONS:  O = player ghost
KMONS:  p = withered plant
SUBST:  t : tp
TILE:   G = dngn_gravestone
TILE:   t = dngn_tree_dead
COLOUR: t = brown
: set_feature_name("granite_statue", "a gravestone")
: set_feature_name("tree", "dead tree")
FTILE:  -|*%$OGt = floor_pebble_brown / floor_pebble_darkgray
: ghost_setup(_G)
MAP
 cccc
.ndtc
@=OGc
.netc
 cccc
ENDMAP

NAME:   gammafunk_ghost_split
TAGS:   transparent allow_dup
ORIENT: float
KMONS: O = player ghost
: ghost_good_loot(_G)
: if you.in_branch("D") then
:     if you.depth() < 6 then
SUBST:  d = *%, e = %$, fgh = .
NSUBST: D = 2=0 / 2=0. / 9. / .
:     elseif you.depth() < 9 then
SUBST:  d = *, e = *%, f = %$..,  gh = .
NSUBST: D = 2=0 / 3=0. / 9. / 98.. / .
:     elseif you.depth() < 12 then
SUBST:  e = *, f = %$,  gh = .
NSUBST: D = 2=0 / 4=0. / 2=9. / 8. / .
:     elseif you.depth() < 14 then
SUBST:  f = *, g = %$, h = .
NSUBST: D = 2=0 / 3=0. / 9 / 9. / 2=8. / 98.. / .
:     else
SUBST:  f = |*, g = *%, h = %$--
NSUBST: D = 2=0 / 2=0. / 9 / 2=9. / 8 / 8. / .
:     end
: elseif you.in_branch("Lair") then
SUBST:  f = *%, g = %$..
NSUBST: D = 3=0 / 3=0. / 2=9. / 8. / 98.. / .
: elseif you.in_branch("Orc") then
SUBST:  f = *, g = %$
NSUBST: D = 2=0 / 4=0. / 9 / 9. / 2=8. / .
# All remaining branches.
: else
SUBST:  fgh = |*
NSUBST: D = 0 / 2=0. / 2=9 / 2=9. / 8 / 2=8. / .
: end
SUBST:  p : x., q : x., x : xc
: ghost_setup(_G)
MAP
...........
.cccnnnccc.
.nD..D..Dc.
.n..qpqg.c.
.=.Dpqpe.n.
@=...O.dDn.
.=.Dpqpf.n.
.n..qpqh.c.
.nD..D..Dc.
.cccnnnccc.
...........
ENDMAP

NAME:   gammafunk_ghost_arena
TAGS:   allow_dup
ORIENT: float
KMONS: O = player ghost
: ghost_good_loot(_G)
: if you.in_branch("D") then
:     if you.depth() < 6 then
SUBST:  d = *%, e = %$, f = %$.., ghij = .
NSUBST: D = 2=0 / 2=0. / 9. / .
:     elseif you.depth() < 9 then
SUBST:  d = *, e = *%, f = %$,  ghi = .
NSUBST: D = 2=0 / 2=0. / 098. / 9. / .
:     elseif you.depth() < 12 then
SUBST:  e = *, f = *%,  g = %$.., hi = .
NSUBST: D = 2=0 / 3=0. / 2=9. / 8. / .
:     elseif you.depth() < 14 then
SUBST:  f = |*, g = *, h = %$, ij = .
NSUBST: D = 2=0 / 4=0. / 098. / 9 / 9. / 2=8. / .
:     else
SUBST:  f = |*, g = *, h = %$, ij = .
NSUBST: D = 3=0 / 3=0. / 9 / 2=9. / 8 / 8. / .
:     end
: elseif you.in_branch("Lair") then
SUBST:  f = *, g = %$, hij = .
NSUBST: D = 2=0 / 3=0. / 098. / 2=9. / 8. / .
: elseif you.in_branch("Orc") then
SUBST:  f = |*, g = *%, h = %$.., ij = .
NSUBST: D = 2=0 / 4=0. / 9 / 9. / 2=8. / .
: elseif you.in_branch("Elf") then
SUBST:  fg = |*, h = *, i = %$, j = .
NSUBST: D = 3=0 / 4=0. / 9 / 3=9. / 8 / 2=8. / .
: elseif you.in_branch("Crypt") then
SUBST:  fgh = |*, i = *%, j = %$..
NSUBST: D = 3=0 / 4=0. / 098. / 9 / 3=9. / 8 / 2=8. / .
: elseif you.in_branch("Depths") then
SUBST:  fgh = |*, i = *, j = %$
NSUBST: D = 3=0 / 5=0. / 2=9 / 2=9. / 8 / 3=8. / .
: elseif you.in_branch("Zot") then
SUBST:  fghij = |*
NSUBST: D = 3=0 / 5=0. / 2=9 / 3=9. / 2=8 / 2=8. / .
# Lair branches
: else
SUBST:  fg = |*, h = *%, i = %$.., j = .
NSUBST: D = 3=0 / 3=0. / 098. / 9 / 2=9. / 8 / 8. / .
: end
SUBST:  r : x., s : x., x : cx
NSUBST: R = R / .
MARKER: P = lua:transp_loc("ghost_arena_entry")
MARKER: Q = lua:transp_dest_loc("ghost_arena_entry")
MARKER: R = lua:transp_loc("ghost_arena_exit")
MARKER: S = lua:transp_dest_loc("ghost_arena_exit")
KMASK: - = !opaque
: ghost_setup(_G)
MAP
  -----------
 --nnnnnnnnn--
 -nnRD...DRnn-
 -nG.rsDsrDGn-
 -nD.sr.rsqgn-
--n.D..D.Djen--
@Pn.O.DQD.idnS@
--n.D..D.Dkfn--
 -nD.sr.rsphn-
 -nG.rsDsrDGn-
 -nnRD...DRnn-
 --nnnnnnnnn--
  -----------
ENDMAP

NAME:    gammafunk_ghost_cemetery
TAGS:    allow_dup
ORIENT:  float
KMASK:   . = !opaque
KMONS:   DFH = player ghost
KMONS:   p = withered plant
# 1/12 chance for 5 ghosts, 1/6 for 4, 1/4 for 3, 1/2 for 2.
SHUFFLE: FfrHhs / ZyzHhs / ZyzHhs / FfrZyz / FfrZyz / FfrZyz / ZyzZyz / \
         ZyzZyz / ZyzZyz / ZyzZyz / ZyzZyz / ZyzZyz
# 1.5 items per ghost, upgrading quality with depth.
: ghost_good_loot(_G)
: if you.in_branch("D") then
:     if you.depth() < 6 then
NSUBST:  de = 2=*% / %$--, f = *% / %$--, h = 2=*% / %$--
:     elseif you.depth() < 9 then
NSUBST:  de = 2=* / *%--, f = * / *%--, h = 2=* / *%--
:     elseif you.depth() < 12 then
# From here on, one 'd' glyph is used by the good loot item, so we don't
# replace that one.
NSUBST:  d = d / *-, e = |* / *-, f = |* / *-, h = 2=|* / *-
:     else
# From here on, one 'd' glyph and one 'e' glyph are used by the good loot
# items, so we don't replace those.
NSUBST:  d = d / |*--, e = e / |*--, f = |* / |*--, h = 2=|* / |*--
:     end
# All non-Dungeon branches.
: else
NSUBST:  d = d / |*--, e = e / |*--, f = |* / |*--, h = 2=|* / |*--
: end
SUBST:   qrs = G, Z = -, y = p, z = V, p : tp
TILE:    G = dngn_gravestone
TILE:    t = dngn_tree_dead
COLOUR:  t = brown
FTILE:   -de|*%$DFHpGt = floor_pebble_brown / floor_pebble_darkgray
: set_feature_name("granite_statue", "a gravestone")
: set_feature_name("tree", "dead tree")
: ghost_setup(_G)
MAP
  ccccccc
 ccdfrfecc
ccq--F--qcc
cd-D---D-ec
ch-------hc
csH-----Hsc
ch-------hc
ccnn===nncc
  ...@...
ENDMAP

NAME:   ebering_ghost_inner_flame
WEIGHT: 5 (D:3-7)
KPROP:  cn'O = w:5 bloody / nothing
KMONS:  O = player_ghost
KITEM:  O = scroll of immolation ident:all
NSUBST: ' = |* / |*$ / 998 / 2=F. / .
MARKER: F = lua:fog_machine { cloud_type = "black smoke", \
            pow_min = 10000, pow_max = 10000, delay = 1, \
            size = 1, walk_dist = 0, start_clouds = 1 }
: ghost_setup(_G)
MAP
 ccccc
.n'''c
@='O'c
.n'''c
 ccccc
ENDMAP

NAME:   ebering_ghost_gozag
DEPTH:  D:3-, Orc, Shoals, Snake, Elf, Crypt, Depths, Zot
WEIGHT: 5 (D:3-7)
ORIENT: float
: kitem("DE = " .. dgn.loot_potions)
# If ghost selectors ever happen this should be a gozag ghost
KMONS:  O = player_ghost
# D and F place an 8 monster plus potion or shop, E and H place the potion/shop
# without any monster. D, E, and J place an abandoned shop for decor.
KMONS:  DF = 8
MONS:   obsidian statue
: if you.in_branch("D") then
:     if you.depth() < 6 then
NSUBST: M = 0 / 2=0' / 9 / 8-JJ / J
SUBST:  1 = G
:     elseif you.absdepth() < 9 then
NSUBST: M = 0 / 2=09 / 8J / J
SUBST:  1 = G, D = DF, E = EH
:     elseif you.absdepth() < 12 then
# The 4th term gives a 50% chance of placing a potion/shop and an independent
# %50 chance of placing an 8.
NSUBST: M = 0 / 2=09 / 9J / DE8J / J
SUBST:  1 = 1GGGG, D = DF, E = EH
:     elseif you.absdepth() < 14 then
# The 5th term gives a 33% chance of placing a second potion/shop and an
# independent 50% chance of placing an 8.
NSUBST: M = 0 / 2=09 / 9 / DE / DE88JJ / J
SUBST:  1 = 1GG, D = DF, E = EH
:     else
# Chance like the one above, but 50% for second potion/shop.
NSUBST: M = 0 / 2=09 / 9 / D / DE8J / J
SUBST:  1 = 1G, D = DF, E = EH
:     end
: elseif you.in_branch("Orc") then
NSUBST: M = 0 / 2=09 / 9 / DE / DE88JJ / J
SUBST:  1 = 1GG, D = DF, E = EH
: else
NSUBST: M = 0 / 2=09 / 9 / 2=D / J
SUBST:  D = DF
: end
# The ' glyph is used to place gold.
: setup_gozag_gold(_G)
KFEAT:  ODEJ = abandoned_shop
KFEAT:  FH = antiques shop
KFEAT:  _ = altar_gozag
TILE:   G = dngn_golden_statue
FTILE:  -_DEFHJ$0189OG = floor_limestone
COLOUR: G = yellow
: set_feature_name("granite_statue", "golden statue")
: set_feature_name("stone_wall", "golden wall")
: ghost_setup(_G)
MAP
 ccccccc
ccMGOGMcc
cM'''''Mc
cG''1''Gc
cM''_''Mc
cc'''''cc
 nn===nn
 ...@...
ENDMAP

NAME:   ebering_ghost_rock_garden
TAGS:   allow_dup
ORIENT: float
KMONS:  O = player_ghost
: local large_rocks = crawl.random_range(3,7)
: kitem("O = large rock q:" .. large_rocks)
KITEM:  ' = stone q:1 / large rock w:1
NSUBST: r = O / d / e / tG / t'' / '
: lone_ghost_extra_loot(_G, "'")
COLOUR: '-O|*%$tG = yellow, c = white
FTILE:  '-O|*%$tG = floor_dirt
: ghost_setup(_G)
MAP
ccccccccc
c---r-r-c
crr-----c
c----r--c
c--r----c
cr----r-c
cnn===nnc
 ...@...
ENDMAP

NAME:   ebering_ghost_reflecting_pool
TAGS:   allow_dup
ORIENT: float
KMONS:  O = player_ghost
KFEAT:  O = shallow_water
: lone_ghost_guarded_loot(_G, "O")
: lone_ghost_extra_loot(_G, "-")
FTILE:  -|*%$O : floor_pebble_brown / floor_pebble_darkgray
: ghost_setup(_G)
MAP
ccccc
cdOec
c-w-c
c-w-c
c-w-c
c-W-c
cn=nc
 .@.
ENDMAP

NAME:   hellmonk_ghost_happy_afterlife
DEPTH:  D:3-, Lair
ORIENT: float
ITEM:   any potion
: item(dgn.loot_potions)
KMONS:  O = player ghost
: if you.absdepth() < 6 then
SUBST:  g = -
: elseif you.absdepth() < 9 then
SUBST:  e = ef, g = e-
: elseif you.absdepth() < 12 then
SUBST:  e = f, g = e
: elseif you.absdepth() < 14 then
SUBST:  e = f, g = ef
: else
SUBST:  eg = f
: end
COLOUR: -1deOf = green
FTILE:  -1defOTt = floor_grass
: ghost_setup(_G)
MAP
   .....
  ..nnn..
 ..nnTnn..
..nn---nn..
.nn--g--nn.
.nT-dte-Tn.
.nn--O--nn.
..nn---nn..
 ..nn-nn..
  ..n=n..
   .....
ENDMAP

NAME:   ebering_ghost_disaster_area
TAGS:   allow_dup
ORIENT: float
KMONS:  O = player ghost
NSUBST: ' = d / e / 8=wWl / -
: lone_ghost_guarded_loot(_G, "O")
: lone_ghost_extra_loot(_G, "-")
SUBST: P = GTV
: ghost_setup(_G)
MAP
cccccccccc
cccc'c'ccc
cc''O''c'c
c'c'''''cc
c''P'c''cc
cc'''''''c
ccnn==nncc
  ..@@..
ENDMAP

NAME:   gammafunk_ghost_door_vault
DEPTH:  D:13-, Depths, Elf, Crypt, Zot
WEIGHT: 2
ORIENT: float
: ghost_good_loot(_G, "45")
KMONS:  1 = 9
KMONS:  2 = 8
KMONS:  345 = player_ghost
# Ghosts on 4 and 5 will get upgraded loot.
NSUBST: 3 = 4 / 5 / 3, 1 = 5=23 / 3 / 1
: door_vault_setup(_G)
: ghost_setup(_G)
MAP
aaaaaaaaaa
a++++++++a
a++++++++a
a++1111++a
a++1331++a
a++1331++a
a++1111++a
a++++++++a
a++++++++a
aaaaaaaaaa
ENDMAP

NAME:    nzn_ghost_randoct
DEPTH:   D:7-, Depths, Lair, Crypt, Spider, Zot
ORIENT:  float
: ghost_good_loot(_G)
MONS:    player_ghost, Arachne / spark wasp, royal mummy / curse skull
MONS:    caustic shrike / juggernaut / titan
MONS:    orb of fire / ancient lich w:5 / dread lich w:5
MONS:    ice statue / oklob plant, w:5 orange crystal statue / obsidian statue
SHUFFLE: PS, QR
NSUBST:  Q = Q / ', R = R / '
NSUBST:  x = 2=' / c
SUBST:   DEFH = ':75 $:5, J = ':50 W:30 0, K = ':50 $ 0
: if you.in_branch("Zot") then
NSUBST:  M = 2=1 / 5
SUBST:   L = ':30 9:20 d:20 8 |
SUBST:   y = G:30 7, c : ccb, W : Wwl
: elseif you.in_branch("Depths") then
NSUBST:  M = 2=1 / 4
SUBST:   L = ':30 9:20 d:20 8 *, * = *|
SUBST:   y = G:30 7, c : cvb, W : Wwl
: elseif you.in_branch("Crypt") then
NSUBST:  M = 2=1 / 3
SUBST:   L = ':30 9:20 d:20 8 *, * = *|
SUBST:   y = G, W = '
: elseif you.in_branch("Spider") then
NSUBST:  M = 1 / 2 / M
SUBST:   M = * 1:5 8:5, L = ':40 %:30 9:20, % = %**ee, * = **|, f = dde
SUBST:   y = G:70 6, ' = ':80 WW
: elseif you.absdepth() >= 13 then
NSUBST:  M = 1 / d / M
SUBST:   M = * 9:6 1:2 8:2, L = ':20 %:50 9:20, % = %**ee, * = **|, f = dde
SUBST:   y = G:30 6
: else
NSUBST:  M = 1 / 9 / e / %
SUBST:   L = ':60 9 0 %, % = %*, * = **e|
SUBST:   y = G:70 6
: end
MARKER:  P = lua:transp_loc("ghost_randoct_entry")
MARKER:  Q = lua:transp_dest_loc("ghost_randoct_entry")
MARKER:  R = lua:transp_loc("ghost_randoct_exit")
MARKER:  S = lua:transp_dest_loc("ghost_randoct_exit")
: ghost_setup(_G)
MAP
        .@.
       .@P@.
      .ncncn.
     .cnEREnc.
    .ccEcncEcc.
   .ncJKJKJKJcn.
  .ccyJJKJKJJycc.
 .ccJJcKxnxKcJJcc.
.nnDKJKxxMxxKJKHnn.
.cDcJKxxLLLxxKJcHc.
.nQnKJnMLLLMnJKnRn.
.cDcJKxxLLLxxKJcHc.
.nnDKJKxxMxxKJKHnn.
 .ccJJcKxnxKcJJcc.
  .ccyJJKJKJJycc.
   .ncJKJKJKJcn.
    .ccFcncFcc.
     .cnFQFnc.
      .ncncn.
       .@S@.
        .@.
ENDMAP
###############################################################################
#
# <<2>> Themed ghost vaults.
#
#
###############################################################################

NAME:   gammafunk_ghost_necromancy
TAGS:   allow_dup
# Omit Elf since that branch has few good monsters for derived undead.
WEIGHT: 0 (Elf)
ORIENT: float
KMONS:  O = player ghost
: ghost_good_loot(_G)
# Progressive depth/numbers of zombies and type/amount of loot.
: if you.in_branch("D") then
:     if you.depth() < 6 then
MONS:   skeleton place:D:6 / zombie place:D:6
SUBST:  d = *%, e = %$, fghij = -
NSUBST: 1 = 2=1 / 1---
:     elseif you.depth() < 9 then
MONS:   skeleton place:D:9 / zombie place:D:9 / spectre place:D:9 / \
        simulacrum place:D:9
SUBST:  d = *, e = *%, f = %$--, ghij = -
NSUBST: 1 = 2=1 / 1-
:     elseif you.depth() < 12 then
MONS:   w:5 zombie place:D:12 / spectre place:D:12 / simulacrum place:D:12
SUBST:  e = *, f = %$, ghij = -
NSUBST: 1 = 3=1 / 1-, - = 1- / -
:     elseif you.depth() < 14 then
MONS:   w:5 zombie place:D:15 / spectre place:D:15 / simulacrum place:D:15
SUBST:  f = |*, g = *%, h = %$--, ij = -
NSUBST: - = 4=1- / -
:     else
MONS:   place:Depths:1 zombie / place:Depths:1 spectre / \
        place:Depths:1 simulacrum
SUBST:  f = |*, g = *%, h = %$--, ij = -
NSUBST: - = 1 / 4=1- / -
:     end
# Set up derived undead from branch end for non-Dungeon branches.
: else
{{
  local undead_place = "place:" .. you.branch() .. ":" ..
                       dgn.br_depth(you.branch())
  mons(undead_place .. " spectre / " .. undead_place .. " simulacrum")
}}
# Handle loot/monsters for non-Dungeon branches.
:     if you.in_branch("Lair") then
SUBST:  f = *%, g = %$--, hij = -
NSUBST: 1 = 4=1 / 1-, - = 2=1- / -
:     elseif you.in_branch("Orc") then
SUBST:  f = *, g = %$, hij = -
NSUBST: 1 = 5=1 / 1-, - = 3=1- / -
:     elseif you.in_branch("Crypt") then
MONS: revenant / curse skull
SUBST:  fg = |*, h = *, i = %$, j = -
NSUBST: 1 = 12 / 1, - = 3=1 / 6=1- / -
:     elseif you.in_branch("Depths") then
MONS: ancient lich / dread lich
SUBST:  fgh = |*, i = *%, j = %$--
NSUBST: 1 = 2=12 / 1, - = 3=1 / 8=1- / -
:     elseif you.in_branch("Zot") then
MONS: ancient lich / dread lich, curse toe
SUBST:  fghij = |*
NSUBST: 1 = 12 / 123 / 1, - = 4=1 / 8=1- / -
# Lair branches
:     else
SUBST:  f = |*, g = *, h = %$, ij = -
NSUBST: - = 2=1 / 4=1- / -
:     end
: end
FTILE:  -de|*%$O12G = floor_pebble_brown / floor_pebble_darkgray
: ghost_setup(_G)
MAP
 ccccccc
.n1c1c1c
.n---igc
.=---ecc
@=---dOc
.=---fcc
.n---jhc
.n1c1c1c
 ccccccc
ENDMAP

NAME:   gammafunk_ghost_spectres
DEPTH:  D:8-, Crypt
ORIENT: float
KMONS:  O = player ghost
: ghost_good_loot(_G)
: if you.in_branch("D") then
:     if you.depth() < 9 then
MONS:   wraith, shadow / freezing wraith
SUBST:  d = *, e = *%, f = %$--,  ghi = -
NSUBST: D = 2=1 / 1-
:     elseif you.depth() < 12 then
MONS:   wraith, shadow / freezing wraith
SUBST:  e = *, f = %$,  ghi = -
NSUBST: D = 3=1 / 2=1- / 2-, - = 1- / -
:     elseif you.depth() < 14 then
MONS:   wraith, shadow / freezing wraith
MONS:   shadow wraith / flayed ghost / phantasmal warrior
SUBST:  f = |*, g = *%, h = %$--, i = -
NSUBST: D = 2=1 / 2 / 2=2- / 23--, - = 3=1- / -
:     else
MONS:   wraith, shadow / freezing wraith
MONS:   shadow wraith / flayed ghost / phantasmal warrior
SUBST:  f = |*, g = *%, h = %$--, i = -
NSUBST: D = 2=2 / 2=2- / 2=3-, - = 2=1 / 2=1- / -
:    end
# Crypt
: else
MONS:   wraith / shadow
MONS:   freezing wraith / shadow wraith / phantasmal warrior / flayed ghost w:5
MONS:   eidolon, revenant / curse skull
SUBST:  fg = |*, h = *, i = %$
NSUBST: D = 2 / 3 / 2=3- / 4-, - = 2=1 / 2=1- / 2=2 / 2=2- / -
: end
FTILE:  -de|*%$O1234G = floor_pebble_brown / floor_pebble_darkgray
: ghost_setup(_G)
MAP
 ccccccc
.nDcDcDc
.n----gc
.=---eGc
@=--idOc
.=---fGc
.n----hc
.nDcDcDc
 ccccccc
ENDMAP

NAME:   gammafunk_ghost_ooze
DEPTH:  D:8-, Lair, Depths
ORIENT: float
KMONS:  O = player ghost
MONS:   jelly, slime creature, quicksilver ooze
: ghost_good_loot(_G)
: if you.in_branch("D") then
:     if you.depth() < 10 then
SUBST:  d = *, e = *%, f = %$--,  ghi = -
NSUBST: - = 2=1 / 4=1. / 2 / 2=2. / .
:     elseif you.depth() < 12 then
SUBST:  e = *, f = %$,  ghi = -
NSUBST: - = 2=1 / 4=1. / 2=2 / 2=2. / .
:     elseif you.depth() < 14 then
SUBST:  f = |*, g = *%, h = %$--, ij = -
NSUBST: - =  2=1 / 3=1. / 2=2 / 4=2. / 3. / .
:     else
SUBST:  fg = |*, h = *, i = %$, j = -
NSUBST: - =  2=1 / 2=1. / 2=2 / 5=2. / 3 / 3. / .
:     end
: elseif you.in_branch("Lair") then
:     if you.depth() < 5 then
SUBST:  f = |*, g = *%, h = %$--, ij = -
NSUBST: - =  2=1 / 3=1. / 2=2 / 4=2. / 3. / .
:     else
SUBST:  fg = |*, h = *, i = %$, j = -
NSUBST: - =  2=1 / 2=1. / 2=2 / 5=2. / 3 / 3. / .
:     end
# Depths
: else
SUBST:  fgh = |*, i = *%, j = %$--
NSUBST: - = 6=2 / 7=2. / 4=3 / 8=3. / .
: end
KFEAT:  _ = altar_jiyva
COLOUR: c = green
COLOUR: n = lightgreen
: ghost_setup(_G)
MAP
  ccccc
 cc---cn.
cci----n.
ceg----=.
c_dO---=@
cfh----=.
ccj----n.
 cc---cn.
  ccccc
ENDMAP

NAME:   gammafunk_ghost_mausoleum
DEPTH:  D:3-, Swamp, Crypt, Depths, Zot
ORIENT: float
KMONS:  O = player ghost
: ghost_good_loot(_G)
: if you.in_branch("D") then
:     if you.depth() < 6 then
MONS:   skeleton place:D:6 / zombie place:D:6
MONS:   mummy / shadow imp / wight / necrophage / phantom
SUBST:  d = *%, e = %$, f = %$--, ghij = -
NSUBST: D = 2=1 / 2=1- / 2- / -
:     elseif you.depth() < 9 then
MONS:   skeleton place:D:9 / zombie place:D:9 / spectre place:D:9 / \
        simulacrum place:D:9 / mummy / shadow imp / wight / necrophage / \
        phantom
MONS:   wraith / vampire
SUBST:  d = *, e = *%, f = %$,  ghi = -
NSUBST: D = 2=1 / 3=1- / 2- / 2--- / -
:     elseif you.depth() < 12 then
MONS:   mummy / wight / zombie place:D:12 / spectre place:D:12 / \
        simulacrum place:D:12 / phantom / wraith / vampire
MONS:   vampire mosquito band / shadow / death knight / skeletal warrior / \
        freezing wraith w:5
SUBST:  e = *, f = *%,  g = %$--, hi = -
NSUBST: D = 2=1 / 4=1- / 2=2- / -
:     elseif you.depth() < 14 then
MONS:   zombie place:D:15 / spectre place:D:15 / simulacrum place:D:15 / \
        vampire mosquito band / death knight / skeletal warrior
MONS:   freezing wraith / necromancer / shadow wraith / vampire knight / \
        phantasmal warrior / flayed ghost
SUBST:  f = |*, g = *, h = %$, ij = -
NSUBST: D = 3=1 / 5=1- / 2 / 222- / -
:     else
MONS:   zombie place:Depths:1 / spectre place:Depths:1 / \
        simulacrum place:Depths:1 / \
        vampire mosquito band / death knight / skeletal warrior / \
        freezing wraith
MONS:   necromancer / shadow wraith / vampire knight / phantasmal warrior / \
        flayed ghost
SUBST:  f = |*, g = *, h = %$, ij = -
NSUBST: D = 4=1 / 4=1- / 2 / 2=2- / -
:     end
: elseif you.in_branch("Swamp") then
MONS:   spectre place:Swamp:4 / simulacrum place:Swamp:4 / bloated husk / \
        bog body / vampire mosquito band / tyrant leech
MONS:   ghost crab / hydra spectre / hydra simulacrum
SUBST:  fg = |*, h = *%, i = %$--, j = -
NSUBST: D = 4=1 / 5=1- / 2 / 2=2- / 2--- / -
: elseif you.in_branch("Crypt") then
SUBST:  fgh = |*, i = *%, j = %$..
NSUBST: D = 5=0 / 5=0- / 98 / 3=98-- / 98------ / -
: elseif you.in_branch("Depths") then
MONS:   spectre place:Depths:5 / simulacrum place:Depths:5 / \
        necromancer / vampire knight / vampire mage / sphinx / flayed ghost w:5
MONS:   lich / deep elf death mage / juggernaut simulacrum / \
        juggernaut spectre / caustic shrike simulacrum / caustic shrike spectre
MONS:   ancient lich / dread lich
SUBST:  fgh = |*, i = *, j = %$
NSUBST: D = 5=0 / 6=0- / 2 / 4=2- / 3- / -
: elseif you.in_branch("Zot") then
MONS:   simulacrum place:Zot:5 / spectre place:Zot:5 / shadow dragon / \
        death cob
MONS:   golden dragon simulacrum / golden dragon spectre / \
        quicksilver dragon simulacrum / quicksilver dragon spectre / \
        killer klown simulacrum / killer klown spectre / \
        ancient lich / dread lich
MONS:   curse toe
SUBST:  fghij = |*, 2 = 12
NSUBST: D = 5=0 / 7=0- / 2=2 / 2=2- / 3- / -
: end
NSUBST: R = R / -
MARKER: P = lua:transp_loc("ghost_mausoleum_entry")
MARKER: Q = lua:transp_dest_loc("ghost_mausoleum_entry")
MARKER: R = lua:transp_loc("ghost_mausoleum_exit")
MARKER: S = lua:transp_dest_loc("ghost_mausoleum_exit")
FTILE:  -de|*%$O012389G = floor_pebble_brown / floor_pebble_darkgray
: ghost_setup(_G)
MAP
 ...............
 .nnnnnnnnnnnnn.
 .nR--D---D--Rn.
 .n-D---D---D-n.
 .n--ccc-ccc-in.
 .n-DcGcDcGcDgn.
..n----------en..
@PnOD-D-Q-D-DdnS@
..n----------fn..
 .n-DcGcDcGcDhn.
 .n--ccc-ccc-jn.
 .n-D---D---D-n.
 .nR--D---D--Rn.
 .nnnnnnnnnnnnn.
 ...............
ENDMAP

NAME:   gammafunk_ghost_hydra_chop
DEPTH:  D:8-, Lair, Swamp
ORIENT: float
: setup_hydra_weapon(_G)
KMONS:  O = player ghost
{{
-- Set up hydra monster entry with a range of possible extra heads based on
-- depth.
local max_heads = 11 + math.floor((you.absdepth() - 8) / 2)
local hydra_def
for h = 9, max_heads do
    if hydra_def == nil then
        hydra_def = h .. "-headed hydra"
    else
        hydra_def = hydra_def .. " / " .. h .. "-headed hydra"
    end
end
mons(hydra_def)
}}
KMONS:  pq = plant
KFEAT:  q = W
SUBST:  t = tttWpq'
NSUBST: ' = d / e / f / g / -
: ghost_good_loot(_G)
: if you.absdepth() < 10 then
SUBST:  d = *, e  = *%
NSUBST: - = 1 / 1--- / -
: elseif you.absdepth() < 12 then
SUBST:  e = *, f =  %$--
NSUBST: - = 1 / 1- / -
: elseif you.absdepth() < 14 then
SUBST:  f = %$
NSUBST: - = 1 / 111- / -
: elseif you.absdepth() <= 16 then
SUBST:  f = *%, g = %$--
NSUBST: - = 1 / 2=1- / -
: else
SUBST:  fg = |*
NSUBST: - = 1 / 3=1- / -
: end
: ghost_setup(_G)
MAP
  ccccc
 cctttcn.
cct'''-n.
ct''---=.
ct'-O--=@
ct''---=.
cct'''-n.
 cctttcn.
  ccccc
ENDMAP

NAME:   gammafunk_ghost_fury_of_okawaru
DEPTH:  D:12-, Orc, Elf, Crypt
ORIENT: float
KFEAT:  OP = altar_okawaru
KMONS:  OP = player ghost
# Bad Oka gift.
KITEM:  O = hat damaged ident:all / cloak damaged ident:all / \
        animal skin damaged ident:all / robe damaged ident:all / \
        leather armour damaged ident:all / whip damaged ident:all / \
        spear damaged ident:all / short sword damaged ident:all / \
        dagger damaged ident:all / hand axe damaged ident:all / \
        scythe damaged ident:all / club damaged ident:all / \
        hunting sling damaged ident:all
KITEM:  P = robe plus:-8 randart ident:all
# An "Oka weapon gift" using the more useful types on 'd'
ITEM:   quick blade good_item w:5 / rapier good_item / scimitar good_item / \
        double sword good_item w:5 / demon blade good_item w:5 / \
        triple sword good_item w:5 /  morningstar good_item / \
        eveningstar good_item w:5 / demon whip good_item w:5 / \
        dire flail good_item / great mace good_item / broad axe good_item / \
        battleaxe good_item / executioner's axe good_item w:5 / \
        demon trident good_item w:5 / glaive good_item / \
        bardiche good_item w:5 / lajatang good_item w:5
# An "Oka armour gift" on 'e'
ITEM:   any armour good_item / any armour randart
# Rarely place the robe of misfortune or a bad randart robe.
SUBST:  O = O:49 P:1
: if you.in_branch("D") then
:      if you.depth() < 14 then
MONS:   orc warrior / centaur warrior / tengu warrior
MONS:   orc knight / naga warrior / merfolk impaler
MONS:   merfolk javelineer / deep elf knight / deep elf archer
SUBST:  e = |*e, f = |*, g = *%, h = %$--, ij = -
NSUBST: - = 2=1 / 4=1- / 12-- / 2 / 2=2- / 3- / -
:      else
MONS:   orc warrior / centaur warrior / tengu warrior / orc knight / \
        naga warrior / merfolk impaler
MONS:   merfolk javelineer / deep elf knight / deep elf archer
MONS:   stone giant / minotaur / fire giant / frost giant / orc warlord
SUBST:  e = |*ee, f = |*, g = *, h = %$, ij = -
NSUBST: - = 3=1 / 3=1- / 2 / 3=2- / 333- / -
:      end
: elseif you.in_branch("Orc") then
MONS:   orc warrior / centaur warrior / tengu warrior / orc knight
MONS:   naga warrior / merfolk impaler / merfolk javelineer / \
        deep elf knight / deep elf archer
MONS:   minotaur / stone giant / orc warlord
SUBST:  e = |*e, f = |*, g = *, h = %$--, ij = -
NSUBST: - = 2=1 / 4=1- / 12-- / 2 / 2=2- / 3- / -
: elseif you.in_branch("Elf") then
MONS:   centaur warrior / tengu warrior / orc knight / naga warrior / \
        merfolk impaler / merfolk javelineer / deep elf knight / \
        deep elf archer
MONS:   minotaur / stone giant / orc warlord
MONS:   fire giant / frost giant / deep elf blademaster / \
        deep elf master archer / titan
SUBST:  fg = |*, h = *, i = %$, j = -
NSUBST: - = 3=1 / 4=1- / 2=2 / 2=2- / 2=3- / 3--- / -
# Crypt
: else
MONS:   centaur warrior / tengu warrior / naga warrior / merfolk impaler / \
        merfolk javelineer / deep elf knight / deep elf archer
MONS:   minotaur / stone giant / orc warlord / fire giant / frost giant / \
        deep elf blademaster / deep elf master archer
MONS:   titan
SUBST:  fgh = |*, i = *%, j = %$..
NSUBST: - = 3=1 / 4=1- / 12-- / 2=2 / 2=2- / 3 / 3- / -
: end
: ghost_setup(_G)
MAP
ccccccccccc
cGvvvvvvvGc
c-igvOvhj-c
c---edf---c
c-vG---Gv-c
c---------c
c-vG---Gv-c
c---------c
cnnn===nnnc
 ....@....
ENDMAP

NAME:   muffindrake_ghost_dual_entry
DEPTH:  D:10-, Depths
ORIENT: float
KMONS:  O = player_ghost
: if you.in_branch("D") then
MONS:   skeletal warrior / vampire
MONS:   wraith / simulacrum place:D:15
MONS:   necromancer
MONS:   lich
: else
MONS:   vampire knight / vampire mage
MONS:   flayed ghost / juggernaut simulacrum
MONS:   deep elf death mage
MONS:   ancient lich / dread lich
: end
: ghost_good_loot(_G)
NSUBST: - = 2=1 / 2=1- / 2 / 2=2- / 3 / -
TILE:   G = dngn_gravestone
TILE:   t = dngn_tree_dead
COLOUR: t = brown
FTILE:  GtO123498$*|- = floor_pebble_brown / floor_pebble_darkgray
: set_feature_name("granite_statue", "a gravestone")
: set_feature_name("tree", "dead tree")
: ghost_setup(_G)
MAP
     .@.
  cccc.ccc
  cd-n.n-cc
  c-$nnn-eccc
  c-|cGc$$-*c
  cc-cOc-cc$c
  cG-G4G-Gc-c
 cc---9-----c
 ct8-nnn-8--c
cc--nn.nn-t-c
c---n...n---c
c-t-n.T.nt-cc
cc--c...c--c
 c=cc. .cc=c
  @... ...@
ENDMAP

NAME:   muffindrake_ghost_three_little_ghosts
DEPTH:  Depths
ORIENT: float
KMONS:  O = player_ghost
MONS:   deep troll shaman band
MONS:   stone giant / deep troll earth mage / golden dragon
MONS:   iron troll / iron dragon, iron giant
: ghost_good_loot(_G)
NSUBST:  2 = 2=2 / 2=2., 3 = 2=3 / 2=3.
: ghost_setup(_G)
MAP
vvvvvvv
v$d|e$v
v$3O3$v
v.343.v
v.....v
v.....v
vvn=nvv
 v...v
bbb+bbb
b.*|$.b
b.2O2.b
b.2.2.b
b.....b
b.....b
bbn=nbb
 b...b
ccc+ccc
c.*|$.c
c..O..c
c..1..c
c.....c
c.....c
ccn=ncc
  .@.
ENDMAP

NAME:   muffindrake_ghost_dead_mans_drink
DEPTH:  Depths
ORIENT: float
KMONS:  p = col:brown fungus
KMONS:  O = player_ghost
MONS:   stone giant zombie / stone giant simulacrum / spectral stone giant
MONS:   titan zombie / titan simulacrum / spectral titan
MONS:   juggernaut zombie / juggernaut simulacrum / spectral juggernaut
: ghost_good_loot(_G)
NSUBST: 1 = 3=1 / 4=1., 2 = 2=2 / 4=2., 3 = 2=3 / 4=3.
: dgn.delayed_decay(_G, "'", "felid corpse")
: ghost_setup(_G)
MAP
 ccccccc
 c--+*Tc
.cT1xxxc  .@.
@n--+3Tccccncccc
.cT2xxxc|$$-2--c
 c--+3Tcd$$-3--c
 c+cccccvvvccc+c
 c----'vTOe--+-c
 c-----ppppppp-c
 c3p-'---3--2--c
 c-p1-1---2----c
 c2p--p2-3p-1p2c
 c-1--1-'----1-c
 ccncccn=ncccncc
  ......@.'....
ENDMAP

NAME:   biasface_ghost_demon_polymorph
DEPTH:  Depths
KITEM:  O = wand of polymorph ident:type
KMONS:  O = player ghost
MONS:   any common demon
MONS:   balrug / blizzard demon / cacodemon / green death / \
        hell beast / lorocyproca / shadow demon
MONS:   brimstone fiend / tzitzimitl / ice fiend / hell sentinel
: ghost_good_loot(_G)
SUBST:  f = |*
NSUBST: - = 4=1 / 6=1. / 2=2. / .
TILE:   G = dngn_statue_imp / dngn_statue_cerebov / \
            dngn_statue_demonic_bust / dngn_statue_ancient_evil
: ghost_setup(_G)
MAP
vvvvvvvvv
vGffdefGv
v$$232$$v
v--lll--v
v--lll--v
v--lll--v
v-.O...-v
vnn===nnv
G...@...G
ENDMAP

NAME:   ebering_ghost_funeral_grove
# Don't place on Swamp:$ since Lerny can knock down the trees.
DEPTH:  D:8-, Lair, Swamp, !Swamp:$
ORIENT: float
# Monsters and loot
KITEM:  O = potion of lignification ident:all
KMONS:  O = player ghost
MONS:   wolf / black bear / polar bear
MONS:   spriggan ; spear | trident, spriggan ; spear randart | trident randart
MONS:   spriggan rider, spriggan rider ; spear randart | trident randart
MONS:   boggart, spriggan druid
# Place the loot glyphs randomly in the loot area.
NSUBST: ' = d / e / f / g / '
: ghost_good_loot(_G)
: if you.in_branch("Swamp") then
SUBST:  fg = |*
NSUBST: ' = 098 / 098. / 444. / 5 / 7 / .
# Lair and Dungeon
: else
:     if you.absdepth() < 10 then
SUBST:  d = *, e = *%, fg = '
NSUBST: ' = 1 / 1. / 2 / 2. / 3 / .
:     elseif you.absdepth() < 12 then
SUBST:  e = *, f = %$'', g = '
NSUBST: ' = 1 / 1. / 2 / 2. / 3 / 4. / .
:     elseif you.absdepth() < 14 then
SUBST:  f = %$, g = '
NSUBST: ' = 1 / 1. / 2 / 24.. / 5 / 6. / .
:     else
SUBST:  f = *%, g = %$''
NSUBST: ' = 1 / 122. / 244. / 5 / 6 / .
:     end
: end
# Foliage, 1/5 chance for death theme in swamp or Autumn theme elsewhere.
: if crawl.one_chance_in(5) then
:     if you.in_branch("Swamp") then
KMONS:  p = withered plant / fungus
COLOUR: t = lightgrey / brown / yellow
TILE: t = dngn_tree_dead / dngn_tree_yellow w:5
: set_feature_name("tree","dead tree")
:     else
KMONS:  p = plant / fungus
COLOUR: t = lightred / red w:4 / yellow w:4
TILE:   t = dngn_tree_lightred / dngn_tree_red w:4 / dngn_tree_yellow w:4
:     end
: else
KMONS:  p = plant / fungus w:2
: end
SUBST:  - = pt., S : GV A:1
# Dungeon needs floor color and tiles.
: if you.in_branch("Dungeon") then
COLOUR: .pO012345689de|*$ = green
FTILE:  tGVA.pO012345689de|*$ = floor_moss
: end
# Don't burn down or polar vortex down these sacred trees
MARKER: t = lua:props_marker { veto_destroy="veto" }
: ghost_setup(_G)
MAP
  ttttttt
 tt'''--tt
 t'-t-..-t
 tt-'O--.t
tt-..t--.tt
t-'-.---t't
t'tnn=nnt't
ttnS...Sntt
 ....@....
ENDMAP

NAME:   biasface_ghost_orc_armoury
DEPTH:  D:3-, Orc
:item(dgn.aux_armour)
:item(dgn.good_aux_armour)
ITEM:   any armour, any armour good_item, any weapon, any weapon good_item
ITEM:   any jewellery, any jewellery good_item
KMONS:  O = player ghost
MONS:   orc, orc ; any weapon good_item | any weapon randart . \
            leather armour good_item | leather armour randart | \
            ring mail good_item | ring mail randart | scale mail good_item | \
            scale mail randart | chain mail good_item | chain mail randart
MONS:   orc priest, warg, orc warrior, orc knight, orc high priest
: setup_armoury_orcs(_G)
: if you.in_branch("D") then
:     if you.depth() < 4 then
SUBST:  hj = -
NSUBST: - = 3=1 / 6=1. / 2 / 3... / .
:     elseif you.depth() < 6 then
SUBST:  h = h-, j = -
NSUBST: - = 3=1 / 6=1. / 2 / 3 / 3. / D... / .
:     elseif you.depth() < 9 then
SUBST:  d = e, j = -
NSUBST: - = 3=1 / 6=1. / 3 / 3. / 4... / D / 2=5. / .
:     elseif you.depth() < 12 then
SUBST:  d = e, f = g, j = j-
NSUBST: - = 3=1 / 6=1. / 3 / 3. / 4. / D / 5 / 2=5. / .
:     elseif you.depth() < 14 then
SUBST:  d = e, f = g, h = i
NSUBST: - = 3=1 / 4=1. / 3 / 2=3. / 4. / DDDE / 2=5 / 4=5. / .
:     else
SUBST:  d = e, f = g, h = i, j = k
NSUBST: - = 3=1 / 4=1. / 3 / 3. / 4. / 2=5 / 2=5. / EEEF / 2=6 / 2=6. / .7 / .
:    end
# Orc
: else
SUBST:  d = e, f = g, h = i, j = k
NSUBST: - = 3=1 / 4=1. / 3 / 3. / 4. / 2=5 / 2=5. / EEEF / 2=6 / 2=6. / .7 / .
: end
KFEAT:  _ = altar_beogh
: ghost_setup(_G)
MAP
ccccccccccccccc
cI---hd_fj---Ic
c-------------c
c-cIc--I--cIc-c
c-cnc--O--cnc-c
c----ccncc----c
c.............c
cnnnnn===nnnnnc
I......@......I
ENDMAP

NAME:   gammafunk_ghost_icy
DEPTH:  D:3-, Lair, Depths
ORIENT: float
KMONS:  O = player ghost
MONS:   simulacrum, white imp, ice beast, rime drake, ice devil
MONS:   blizzard demon, ice dragon
KMONS:  D = frost giant
KMONS:  E = ice fiend
: ghost_good_loot(_G)
: if you.in_branch("D") then
:     if you.depth() < 4 then
KITEM:  O = ring of fire ident:type
SUBST:  d = *%, e = %$, fghij = -
NSUBST: - = 3=1 / 4=1' / 2''' / '
:     elseif you.depth() < 6 then
KITEM:  O = ring of fire ident:type
SUBST:  d = *%, e = %$, fghij = -
NSUBST: - = 3=1 / 4=1' / 23 / 23'' / '
:     elseif you.depth() < 9 then
KITEM:  O = ring of fire ident:type / ring of fire randart ident:all w:5
SUBST:  d = *, e = *%, f = %$--, ghij = -
NSUBST: - = 3=12 / 4=12'' / 3 / 3=3' / '
:     elseif you.depth() < 12 then
KITEM:  O = ring of fire ident:type / ring of fire randart ident:all w:5
SUBST:  e = *, f = %$, ghij = -
NSUBST: - = 3=12 / 4=12'' / 2=3 / 3=3' / 45'''''' / '
:     elseif you.depth() < 14 then
KITEM:  O = ring of fire ident:type / ring of fire randart ident:all
SUBST:  f = *, g = %$, hij = -
NSUBST: - = 4=1 / 6=1' / 2=45 / 3=45'' / 67'''''' / '
:     else
KITEM:  O = ring of fire ident:type / ring of fire randart ident:all
SUBST:  f = |*, g = *%, h = %$--, ij = -
NSUBST: - = 4=1 / 6=1' / 2=45 / 3=45'' / 67 / D''' / '
:     end
: elseif you.in_branch("Lair") then
KITEM:  O = ring of fire ident:type / ring of fire randart ident:all
SUBST:  f = *%, g = %$--, hij = -
NSUBST: - = 4=1 / 5=1' / 2=4 / 2=4' / 7''' / '
# Depths
: else
KITEM:  O = ring of fire randart ident:all
SUBST:  fghij = |*
NSUBST: - = 4=1 / 6=1' / 5 / 2=5' / 6 / 2=6' / 2=7D / 2=7D'' / E' / '
: end
COLOUR: xc = white
COLOUR: O1234567DEde|*%$' = blue
RTILE:  x = wall_ice_block
FTILE:  =cnO1234567DEde|*%$' = floor_ice
: ghost_setup(_G)
MAP
     ...........
    ..cnn===nnc..
   ..cc'''''''cc.
   .cc'''''''''c..
  ..c''''''''''cc.
  .cc''''xxxx'''c..
  .c'''xxxdexx''cc.
  .c''xxhfijgxx''c.
 ..n''x---O---x''n.
 .cc''x------xx''c.
 .c'''-----xxx''cc.
 .cc''--------''c..
 ..ccc--cnnc--'cc.
  ...cccc..ccccc..
    .............
ENDMAP

NAME:   maelrawn_ghost_gauntlet_escape
# Same depths where Gauntlets can place
TAGS:   transparent
DEPTH:  D:11-, Lair, Orc:$
ORIENT: float
KPROP:  x = bloody
KMONS:  O = player ghost
MONS:   minotaur
: ghost_good_loot(_G)
NSUBST: ' = 1 / -
: if you.in_branch("D") then
:     if you.depth() < 12 then
SUBST:  e = *, f = %$, gh = -
NSUBST: - = 2=0 / 2=0- / -
:     elseif you.depth() < 14 then
SUBST:  f = *, g = %$, h = -
NSUBST: - = 2=0 / 3=0- / 2=9- / -
:     else
SUBST:  f = |*, g = *%, h = %$--
NSUBST: - = 2=0 / 3=0- / 9 / 9- / -
:     end
: elseif you.in_branch("Lair") then
SUBST:  f = *%, g = %$--, h = -
NSUBST: - = 2=0 / 2=0- / 9- / -
: elseif you.in_branch("Orc") then
SUBST:  f = *, g = %$, h = -
NSUBST: - = 2=0 / 2=0- / 2=9- / -
: end
SUBST:  a = c.
KFEAT:  O = expired_portal
FTILE:  O = dngn_portal_gauntlet_gone
: ghost_setup(_G)
MAP
...........
.nnccnccnn.
.n-gxOxh-n.
.cc'edf'cc.
.c-c'''c-c.
.cac-caa-c.
.c-a---cac.
.c-cc--c-c.
.c-------c.
.cnn===nnc.
.....@.....
ENDMAP

NAME:   ebering_ghost_xom
TAGS:   transparent allow_dup
WEIGHT: 0 (D:3-5), 5 (D:6-7)
ORIENT: float
: lone_ghost_guarded_loot(_G, "O")
: lone_ghost_extra_loot(_G, "-")
: setup_xom_dancing_weapon(_G)
KMONS:  O = player_ghost
KFEAT:  O = altar_xom
FTILE:  -|*%$O1 : floor_pebble_brown / floor_pebble_darkgray
: ghost_setup(_G)
MAP
 ccc
cc1cc
cdOec
cn=nc
..@..
ENDMAP

# based on sewer_entry_d
NAME:   ebering_ghost_sewer_d
TAGS:   transparent
ORIENT: float
DEPTH:  D:3-6
KMONS:  O = player_ghost
KFEAT:  O = expired_portal
KMONS:  1 = adder
KMONS:  2 = bullfrog
KFEAT:  12*%$ = W
: lone_ghost_guarded_loot(_G, "O")
: if you.depth() < 6 then
SUBST:  d = %$, e = W
NSUBST: 1 = 1 / 1W / 122WWW / W
: else
SUBST:  d = *%, e = %$WW
NSUBST: 1 = 1 / 2 / 12WW / W
: end
COLOUR: 12*%$W = lightgreen / cyan w:5
FTILE:  O = dngn_portal_sewer_rusted
: ghost_setup(_G)
MAP
       ..
ccccccnn.
cdOe111=.
ccccccnn.
       ..
ENDMAP

# based on sewer_entry_f
NAME:   ebering_ghost_sewer_f
ORIENT: float
DEPTH:  D:3-6
KMONS:  O = player_ghost
KMONS:  1 = quokka / giant cockroach / rat / ball python
KMONS:  2 = adder / worm / river rat
KMONS:  3 = bullfrog
KFEAT:  O = expired_portal
KFEAT:  123*%$ = W
: lone_ghost_guarded_loot(_G, "O")
: if you.depth() < 6 then
SUBST:  d = %$, e = W
NSUBST: W = 1 / 2=112WWW / 2 / 2W / 3WW / W
: else
SUBST:  d = *%, e = %$WW
NSUBST: W = 1 / 2=1223WW / 2 / 3 / 3W / W
: end
COLOUR: 123*%$W = lightgreen / cyan w:5
FTILE:  O = dngn_portal_sewer_rusted
: ghost_setup(_G)
MAP
 ccccccccccc
.nWWWWeWWWWn.
@=WWWWOWWWW=@
.nWWWWdWWWWn.
 ccccccccccc
ENDMAP

NAME:   ploomutoo_gammafunk_ghost_potion_laboratory
DEPTH:  D:8-, Elf, Depths
ORIENT: float
ITEM:   potion of mutation ident:type q:1
: item(dgn.loot_potions)
ITEM:   hat / robe good_item / pair of gloves / pair of boots / cloak
ITEM:   hat good_item / robe good_item / pair of gloves good_item \
        / pair of boots good_item / cloak good_item
ITEM:   hat randart / robe randart / pair of gloves randart \
        / pair of boots randart / cloak randart
KITEM:  O = potion of cancellation q:2 ident:type
KMONS:  O = player ghost
MONS:   ugly thing, neqoxec, shapeshifter, glowing orange brain
MONS:   large abomination, very ugly thing, glowing shapeshifter
KMONS:  D = cacodemon
KMONS:  E = tentacled monstrosity
NSUBST: - = 2=P / 2=P; / ;, ' = 2=P` / `
: if you.in_branch("D") then
:     if you.depth() < 9 then
NSUBST: ; = d. / 2=e / 2=1 / 4=1. /  46.. / .
NSUBST: " = d / d. / f / ", ` = 2=3 / 2=3. / 2 / 2. / .
:     elseif you.depth() < 12 then
NSUBST: ; = d. / 2=e / e. / 3=1 / 3=1. / 4. / 6. / .
NSUBST: " = 2=d / ffg / ", ` = 2=3 / 3=3. / 2 / 2=2. / 7... / .
:     elseif you.depth() < 14 then
NSUBST: ; = d / 3=e / 3=1 / 4=1. / 2=4. / 6 / 6. / .
NSUBST: " = 2=d / d. / e. / fg / ", ` = 3=3 / 3=3. / 2 / 3=2. / 7. / D... / .
:     else
NSUBST: ; = d / 3=e / e. / 3=1 / 4=1. / 4 / 4. / 6 / 2=6. / .
NSUBST: " = 3=d / e. / ggh / ", ` = 3=3 / 3=3. / 2 / 3=2. / 7 / D. / .
:     end
: elseif you.in_branch("Elf") then
NSUBST: ; = d / d. / 4=e / 5=5 / 5=5. / 2=E / 2=E. / .
NSUBST: " = 3=d / d. / e / h / ", ` = 4=3 / 4=3. / 7 / 3=7. / D / 2=D. / .
# Depths
: else
NSUBST: ; = d / d. / 5=e / 4=6 / 5=6. / 4 / 4. / 3=E / 3=E. / .
NSUBST: " = 4=d / d. / e / h / ", ` = 4=3 / 4=3. / 2=7 / 3=7. / 2=D / 2=D. / .
: end
MARKER: P = lua:fog_machine { cloud_type = "mutagenic fog", pow_min = 3, \
                pow_max = 5, delay = 5, start_clouds = 3, size = 1, \
                spread_rate = 0, excl_rad = 0 }
MARKER: U = lua:fog_machine { cloud_type = "mutagenic fog", pow_min = 3, \
                pow_max = 5, delay = 5, start_clouds = 3, size = 2, \
                spread_rate = 0, excl_rad = 0 }
: ghost_setup(_G)
MAP
bbbbbbbbb
bbU"P"Ubb
b"""O"""b
b'''''''b
b'b'''b'b
b```````b
bnn===nnb
c-------c
c-c---c-c
cc-c-c-cc
c-c---c-c
c;;;c;;;c
c;c;;;c;c
c;;;;;;;c
cnn===nnc
c...@...c
ENDMAP

NAME:    ebering_ghost_davey_jones
DEPTH:   Shoals
ORIENT:  float
TAGS:    water_ok
KMONS:   O = player_ghost
KITEM:   O = any ring randart w:20 / ring of the octopus king w:1
KMONS:   1 = snapping turtle / sea snake / alligator snapping turtle w:2
KMONS:   2 = spectral snapping turtle / spectral sea snake \
             / spectral alligator snapping turtle w:2
KMONS:   E = water elemental
{{
kmons("F = merfolk ; " .. dgn.monster_weapon("merfolk", "draining") ..
      "    . throwing net w:3 | nothing w:9")
local quality = crawl.one_chance_in(3) and "randart" or "good_item"
kmons("3 = merfolk aquamancer ; " ..
      dgn.monster_weapon("blademaster", "electrocution", quality) ..
      "    . robe good_item")
kmons("4 = merfolk impaler ; " ..
      dgn.monster_weapon("impaler", "draining", quality) ..
      "    . robe good_item | leather armour good_item")
}}
KMONS:   5 = kraken
KMONS:   6 = spectral kraken
KFEAT:   O = W
KFEAT:   123456EF = w
# Place 2-6 corpses around the perimiter. Place monsters on D, excluding the
# merfolk leader's band, which goes on the E.
NSUBST:  - = 2=- / 4=-s / s, D = 2=1 / 4=1w / 2=E / 3=Ew / 3 / w
# Either the normal or spectral set. Also randomize wall patterns.
SHUFFLE: 1E35 / 2F46, pq
SUBST:   d = |*, r = wW, p = x, q = s, s = W.
TILE:    G = dngn_statue_mermaid
MARKER:  P = lua:transp_loc("davey_jones_entry")
MARKER:  Q = lua:transp_dest_loc("davey_jones_entry")
MARKER:  R = lua:transp_loc("davey_jones_exit")
MARKER:  S = lua:transp_dest_loc("davey_jones_exit")
{{
dgn.delayed_decay(_G, "-", "minotaur skeleton / elf skeleton" ..
  " / dwarf skeleton / human skeleton / kobold skeleton" ..
  " / felid skeleton / orc skeleton / ogre skeleton")
ghost_setup(_G)
}}
MAP
 WWssssSssssWW
WWcccccccccccWW
WccG---Q---GccW
WcGspqpqpqpsGcW
Wc-sqqrprqqs-cW
Wc-srDDDDDrs-cW
Wn-prDDDDDrp-nW
Wn-qpDD5DDpq-nW
Wn-prDDDDDrp-nW
Wc-srDDDDDrs-cW
Wc-sqqrprqqs-cW
WcGspqpOpqpsGcW
WccG-ddRdd-GccW
WWccccnnnccccWW
 WWssssPssssWW
ENDMAP

NAME:   gammafunk_ghost_stat_death
DEPTH:  D:3-, Orc
ORIENT: float
KMONS:  O = player ghost
MONS:   quasit, neqoxec
NSUBST: R = R / -
: ghost_good_loot(_G)
: if you.in_branch("D") then
:     if you.depth() < 6 then
KITEM:  O = ring of dexterity ident:type
SUBST:  d = *%, e = %$, fgh = -
NSUBST: - = 2=1 / 2=1- / -
:     elseif you.depth() < 9 then
KITEM:  O = ring of dexterity ident:type / \
            ring of dexterity good_item ident:type w:5
SUBST:  d = *, e = *%, f = %$--, gh = -
NSUBST: - = 2=1 / 4=1- / -
:     elseif you.depth() < 12 then
KITEM:  O = ring of dexterity ident:type / \
            ring of dexterity good_item ident:type w:5 / \
            ring of intelligence ident:type / \
            ring of intelligence good_item ident:type w:5
SUBST:  e = *, f = %$, gh = -
NSUBST: - = 2=1 / 2=1- / 2 / 2=2- / -
:     elseif you.depth() < 14 then
KITEM:  O = ring of dexterity good_item ident:type / \
            ring of dexterity randart ident:all w:5 / \
            ring of intelligence good_item ident:type / \
            ring of intelligence randart ident:all w:5
SUBST:  f = *, g = %$, h = -
NSUBST: - = 2=1 / 2=1- / 2=2 / 4=2- / -
:     else
KITEM:  O = ring of dexterity good_item ident:type / \
            ring of dexterity randart ident:all / \
            ring of intelligence good_item ident:type / \
            ring of intelligence randart ident:all
SUBST:  f = |*, g = *%, h = %$--
NSUBST: - = 2=1 / 2=1- / 3=2 / 4=2- / -
:     end
: elseif you.in_branch("Orc") then
KITEM:  O = ring of dexterity good_item ident:type / \
            ring of dexterity randart ident:all w:5 / \
            ring of intelligence good_item ident:type / \
            ring of intelligence randart ident:all w:5
SUBST:  f = *, g = %$, h = -
NSUBST: - = 2=1 / 2=1- / 2=2 / 4=2- / -
: end
MARKER: P = lua:transp_loc("stat_death_entry")
MARKER: Q = lua:transp_dest_loc("stat_death_entry")
MARKER: R = lua:transp_loc("stat_death_exit")
MARKER: S = lua:transp_dest_loc("stat_death_exit")
: ghost_setup(_G)
MAP
    ....@.....
   ..cncScccc.....
  ..ccRccc--cccnc.
  .cc------x---Rc..
  .c----x---x---cc.
  .c--xx--x------c.
 ..nR--x--Q--xx-Rn.
 .cc-x-----x-----c.
 .c----xxxO--xx-cc.
 .cc--x-gedfh---c..
 ..ccc--cnnnc--cc.
  ...cccc.P.cccc..
    ......@......
ENDMAP

NAME:   gammafunk_ghost_smash
DEPTH:  D:3-, Orc
ORIENT: float
KMONS:  O = player ghost
MONS:   ogre, ogre ; dire flail good_item | dire flail randart | \
        great mace good_item | great mace randart
MONS:   two-headed ogre, two-headed ogre ; dire flail good_item | \
            dire flail randart | great mace good_item | great mace randart \
            . dire flail good_item | dire flail randart | \
            great mace good_item | great mace randart
MONS:   ettin, ettin ; great mace good_item | great mace randart \
            .  great mace good_item | great mace randart
MONS:   fire giant ; great mace ego:flaming randart
KMONS:  D = frost giant ; great mace ego:freezing randart
# Use one of the two inner wall patterns.
SHUFFLE: xv
SUBST: v = -, x : xcbv
NSUBST: R = R / -
: ghost_good_loot(_G)
# Only one of the highest-tier monsters gets a fancy weapon (or two).
: if you.in_branch("D") then
:     if you.depth() < 6 then
SUBST:  d = *%, e = %$, fgh = -
NSUBST: - = 2=1- / 2 / -
:     elseif you.depth() < 9 then
SUBST:  d = *, e = *%, f = %$--, gh = -
NSUBST: - = 1 / 2=1- / 24 / -
:     elseif you.depth() < 12 then
SUBST:  e = *, f = %$, gh = -
NSUBST: - = 1 / 2=1- / 2=3- / 4 / -
:     elseif you.depth() < 14 then
SUBST:  f = *, g = %$, h = -
NSUBST: - = 1 / 2=1- / 2=3 / 2=3- / 4444467D / -
:     else
SUBST:  f = |*, g = *%, h = %$--
NSUBST: - = 1 / 2=1- / 2=3 / 35 / 2=3- / 67D / -
:     end
: elseif you.in_branch("Orc") then
SUBST:  f = *, g = %$, h = -
NSUBST: - = 1 / 2=1- / 2=3 / 2=3- / 46 / -
: end
MARKER: P = lua:transp_loc("smash_entry")
MARKER: Q = lua:transp_dest_loc("smash_entry")
MARKER: R = lua:transp_loc("smash_exit")
MARKER: S = lua:transp_dest_loc("smash_exit")
: ghost_setup(_G)
MAP
     .@.
.....P.S.....
nnnnnnnnnnnnn
cR--gedfh--Rc
c-vxxvOvxxv-c
c-xvvx-xvvx-c
c-xvvx-xvvx-c
c-vxxv-vxxv-c
cR----Q----Rc
ccccccccccccc
ENDMAP

NAME:   gammafunk_ghost_nasty_kobolds
DEPTH:  D:3-13
KMONS:  pq = plant / fungus
KFEAT:  q = W
KMONS:  O = player ghost
MONS:   kobold, kobold brigand, kobold demonologist
KMONS:  D = kobold ; dart ego:poisoned . dagger | short sword | whip
KMONS:  E = kobold ; wand of flame | wand of acid | wand of iceblast \
                | wand of mindburst | wand of polymorph | wand of charming \
                | wand of paralysis . dagger | short sword | whip
KMONS:  F = kobold brigand ; dart ego:poisoned | dart ego:curare w:5 \
                . wand of flame | wand of acid | wand of iceblast \
                | wand of mindburst | wand of polymorph | wand of charming \
                | wand of paralysis . dagger | short sword | whip
# Define some kobolds with more general nasty ego weapons.
{{
    kmons("H = kobold ; " .. disto_weapon("kobold"))
    kmons("J = kobold brigand ; dart ego:poisoned | dart ego:curare w:5 . " ..
          disto_weapon("kobold"))

    local egos = {["chaos"] = 10, ["venom"] = 10, ["draining"] = 10,
                  ["pain"] = 5, ["electrocution"] = 5, ["distortion"] = 5}
    local basic_def = dgn.monster_weapon("kobold", egos)
    local good_def = dgn.monster_weapon("kobold", egos,
        crawl.coinflip() and "randart" or "good_item")
    kmons("K = kobold ; " .. basic_def)
    kmons("L = kobold brigand ; dart ego:poisoned | dart ego:curare w:5 . " ..
          basic_def)
    kmons("M = kobold brigand ; dart ego:poisoned | dart ego:curare w:5 . " ..
          good_def)
}}
# 50% of time put statue/tree/fountain with plants and vertical wall, otherwise
# add some diagonal wall instead. The second shuffle makes any statue sometimes
# be fountain + water plants.
SHUFFLE: Gprs / Zrsr, Gp / Tq
SUBST: r = -, Z = T, s = x, G : GGt, T : TTUV, x : xcbv
: ghost_good_loot(_G)
: if you.depth() < 6 then
SUBST:  d = *%, e = %$, fg = -
NSUBST: - = 2=1 / 4=1. / DE / DE.. / H / 2=K. / M / .
: elseif you.depth() < 9 then
SUBST:  d = *, e = *%, f = %$--, g = -
NSUBST: - = 2=2 / 4=2. / F / F. / J / 3=L. / M / 3. / .
: elseif you.depth() < 12 then
SUBST:  e = *, f = %$, g = -
NSUBST: - = 2=2 / 2=2. / F / 2=F. / J / 3=L. / M / 3 / 2=3. / .
: else
SUBST:  f = *, g = %$
NSUBST: - = 2 / F / 2=F. / 2=M / 2=J / 3=L. / 2=3 / 4=3. / .
: end
: ghost_setup(_G)
MAP
  ccccc
 ccedfcc
cc--g--cc
cprs-srpc
cG-xOx-Gc
cprs-srpc
cn-----nc
.nn===nn.
....@....
ENDMAP

NAME:   gammafunk_ghost_hive
DEPTH:  D:5-, Lair
KITEM:  ' = potion of ambrosia ident:type
KMONS:  O = player ghost
MONS:   killer bee, queen bee, hornet, meliai
# Chance to make a partial wall in each of the full cells. Add 0-4 ambrosias.
NSUBST: p = x- / -, q = x- / -, r = x- / -, s = x- / -, - = 4='- / -
: ghost_good_loot(_G)
: if you.in_branch("D") then
:   if you.depth() < 6 then
SUBST:  de = *%, f = %$, ghi= -
NSUBST: - = 4=1 / 4=1. / 3... / .
:   elseif you.depth() < 9 then
SUBST:  de = *, f = *%, g = %$--, hi= -
NSUBST: - = 4=1 / 4=1. / 2. / 3. / .
:   elseif you.depth() < 12 then
SUBST:  e = |*, f = *, g = %$, hi= -
NSUBST: - = 4=1 / 4=1. / 2 / 2=3. / 4... / .
:   elseif you.depth() < 14 then
SUBST:  f = |*, g = *, h = %$, i= -
NSUBST: - = 4=1 / 4=1. / 2 / 3 / 2=3. / 2=4. / .
:   else
SUBST:  fg = |*, h = *%, i = %$--
NSUBST: - = 4=1 / 4=1. / 2 / 3 / 2=3. / 4 / 2=4. / .
:   end
# Lair
: else
:   if you.depth() < 4 then
SUBST:  f = |*, g = *, h = %$--, i= -
NSUBST: - = 4=1 / 4=1. / 2 / 3 / 3. / 4. / .
:   else
SUBST:  f = |*, g = *, h = %$, i= -
NSUBST: - = 4=1 / 4=1. / 2 / 3 / 2=3. / 2=4. / .
:   end
: end
COLOUR: x = yellow
TILE:   x = wall_wax
: ghost_setup(_G)
MARKER: P = lua:transp_loc("ghost_hive_entry")
MARKER: Q = lua:transp_dest_loc("ghost_hive_entry")
MARKER: R = lua:transp_loc("ghost_hive_exit")
MARKER: S = lua:transp_dest_loc("ghost_hive_exit")
MAP
         @
  .......P.......
 ..cccccnnnccccc..
..cnxxxfdRegxxxnc..
.cnx-q-xhOix-p-xnc.
.cx--x--xxx--x--xc.
.cnx-q-x---x-p-xnc.
@.ccxxx--x--xxxcc.@
.cnx-r-x---x-s-xnc.
.cx--x--xxx--x--xc.
.cnx-r-x---x-s-xnc.
..cnxxx--Q--xxxnc..
 ..cccccnnnccccc..
  .......S.......
         @
ENDMAP

# Inspired by lemuel_castle_with_subvaults
NAME:    gammafunk_ghost_gnarly_gnolls
TAGS:    no_pool_fixup
DEPTH:   D:3-8
ITEM:    any manual
ITEM:    any jewellery, any jewellery good_item, any jewellery randart
KMONS:   p = plant
KMONS:   O = player ghost
MONS:    gnoll, gnoll shaman, gnoll sergeant, grum band
KMONS:   D = gnoll ; wand of flame | wand of acid | wand of polymorph | \
                wand of charming | wand of paralysis | \
                wand of mindburst \
            . spear w:20 | halberd | club | whip | flail | nothing w:15
# Define some gnolls with reach weapons.
{{
    local basic_weapons = {["halberd"] = 1, ["spear"] = 1}
    local sgt_weapons = {["trident"] = 1, ["spear"] = 1}
    egos = {["venom"] = 15, ["vampirism"] = 5, ["pain"] = 5,
            ["electrocution"] = 5, ["chaos"] = 5}

    local basic_def = dgn.random_item_def(basic_weapons, egos, nil, "|")
    local sgt_basic_def = dgn.random_item_def(sgt_weapons, egos, nil, "|")

    local quality = crawl.one_chance_in(3) and "randart" or "good_item"
    local good_def = dgn.random_item_def(basic_weapons, egos, quality, "|")
    local sgt_good_def = dgn.random_item_def(sgt_weapons, egos, quality, "|")

    kmons("E = gnoll ; " .. basic_def .. " . throwing net | nothing")
    kmons("F = gnoll ; " .. good_def .. " . throwing net | nothing")
    kmons("H = gnoll sergeant ; " .. sgt_basic_def ..
          "    . buckler | kite shield | nothing w:40" ..
          "    . ring mail | scale mail")
    kmons("J = gnoll sergeant ; " .. sgt_good_def ..
          "    . buckler good_item | buckler randart w:5 " ..
          "        | kite shield good_item | kite shield randart w:5 " ..
          "    . ring mail good_item | ring mail randart w:5 " ..
          "        | scale mail good_item | scale mail randart w:5")
}}
# Sometimes add an additional pairs of doors near the landing area. Also
# randomize exit transporters and tower inner walls.
SHUFFLE: qK / rL
NSUBST:  R = R / '
SUBST:   q = c, r = ~, K = T, L = -, s : ccG-
# Scale loot and monsters with depth.
: if you.depth() < 5 then
SUBST:   h = %$, ij= `, 2 = 2'
NSUBST:  - = 2=1 / 2=1. / D / D. / ., ' = E / E. / FFFJ / .
NSUBST:  R = R / E / E.
: elseif you.depth() < 7 then
SUBST:   e = f, h = *, i = %$, j= `
NSUBST:  - = 2=1 / 2=1. / D / D. / ., ' = E / E. / 3 / H. / J / .
: else
SUBST:   e = g, h = |*, i = *, j = %$
NSUBST:  - = 2=1 / 2=1. / D / 2=D. / ., ' = E / 2=E. / 3 / 3. / 2=H. / J / .
:     if not you.uniques("Grum") and crawl.one_chance_in(3) then
NSUBST:   3 = 4 / 3
:     end

: end
KFEAT:   ~ = closed_clear_door
MARKER:  P = lua:transp_loc("gnarly_gnolls_entry")
MARKER:  Q = lua:transp_dest_loc("gnarly_gnolls_entry")
MARKER:  R = lua:transp_loc("gnarly_gnolls_exit")
MARKER:  S = lua:transp_dest_loc("gnarly_gnolls_exit")
TILE:    c = wall_stone_smooth
COLOUR:  `defghij|*%$O = cyan
FTILE:   `defghij|*%$O = floor_cobble_blood
COLOUR:  " = brown
FTILE:   " = floor_mud
: ghost_setup(_G)
MAP
...........................
.wwwwwwwwwwwwWwwwwwwwwwwww.
.wwwwwwwwwwwwWwwwwwwwwwwww.
.wwncccn...........ncccnww.
.wwc's-c.cnc.S.cnc.c-s'cww.
.wwc---cncRccnccRcnc---cww.
.wwncc---------------ccnww.
.ww.Gc-cnqncc~ccncnc-cG.ww.
.ww.cc-cpKpcp-Gcej$c-cc.ww.
.WW.n'-~-----QTcdO$~-2n.WW.
.ww.cc-cpKpcp-Gchi$c-cc.ww.
.ww.Gc-cnqncc~ccncnc-cG.ww.
.wwncc---------------ccnww.
.wwc---cncRccnccRcnc---cww.
.wwc's-c.cnc.P.cnc.c-s'cww.
.wwncccn...........ncccnww.
.wwwwwwwwwww"""wwwwwwwwwww.
.wwwwwwwwwww"""wwwwwwwwwww.
...........................
ENDMAP

NAME:   gammafunk_ghost_tricky_traps
DEPTH:  D:15, Shoals, Spider, Elf, Depths, Zot
KFEAT:  ^ = zot trap / dispersal trap w:5 / alarm trap w:1 / floor w:16
KFEAT:  ' = zot trap / dispersal trap w:5 / alarm trap w:1 / floor w:8
: kitem("O = " .. dgn.randart_aux_armour)
KMONS:  O = player ghost
: ghost_good_loot(_G)
: if you.in_branch("D") then
MONS:   boggart
SUBST:  f = |*, g = %$, hi = -
NSUBST: - = 1 / 2=1. / 4=0 / 6=0. / .
: elseif you.in_branch("Shoals") then
MONS:   merfolk aquamancer
SUBST:  f = |*, g = *%, h = %$--, i = -
NSUBST: - = 1 / 2=1. / 5=0 / 6=0. / .
: elseif you.in_branch("Spider") then
MONS:   jumping spider
SUBST:  f = |*, g = *%, h = %$--, i = -
NSUBST: - = 1 / 2=1. / 5=0 / 6=0. / .
: elseif you.in_branch("Elf") then
MONS:   deep elf archer
SUBST:  f = |*, g = *, h = %$, i = -
NSUBST: - = 1 / 2=1. / 6=0 / 6=0. / .
: elseif you.in_branch("Depths") then
MONS:   boggart, rakshasa
SUBST:  fg = |*, h = *, i = %$
NSUBST: - = 1 / 2=1. / 6=0 / 8=0. / 2 / .
: elseif you.in_branch("Zot") then
MONS:   draconian shifter, electric golem
SUBST:  fghi = |*
NSUBST: - = 1 / 2=1. / 7=0 / 8=0. / 2 / 2.. / .
: end
SUBST:  G : GGtU
: ghost_setup(_G)
MAP
ccccccccccccc
cG-hfdOegi-Gc
c-n-n-n-n-n-c
c'-'-'-'-'-'c
c-'-n-n-n-'-c
cG-'-'-'-'-Gc
cccnn===nnccc
.^.^.....^.^.
^.^.^.^.^.^.^
.^.^.^.^.^.^.
^.^.^.^.^.^.^
ENDMAP

NAME:    gammafunk_ghost_crypt
DEPTH:   D:13-, Crypt, Depths, Zot
: item(dgn.loot_scrolls .. " / " .. dgn.loot_potions)
# Always place one randart aux, one randart jewel, and one nice book, each
# using the possible ghost locations.
: kitem("D = " .. dgn.randart_aux_armour)
KITEM:   EHK = any jewellery randart
KITEM:   FJL = randbook owner:Kikubaaqudgha disc:necromancy numspells:6 \
               / necronomicon / manual of necromancy
KITEM:   12 = superb_item / star_item
KMONS:   DEF = player ghost
KMONS:   HJ1 =  lich
KMONS:   KL2 =  ancient lich / dread lich
# 1/7 chance for 3 ghosts, 2/7 chance for 2 ghosts, 4/7 chance for 1 ghost.
# Any ghost that doesn't place will place a depth-appropriate lich instead.
SHUFFLE: EF / EJ / EJ / HJ / HJ / HJ / HJ
# For later branches, guarantee at least one ancient or dread lich and
# upgrade ordinary liches by depth.
: if you.in_branch("Crypt") then
SUBST:   H = HHK, J = JJL
NSUBST:  1 = 2 / 112
: elseif you.in_branch("Depths") then
SUBST:   H = HK, J = JL
NSUBST:  1 = 2 / 12
: elseif you.in_branch("Zot") then
SUBST:   H = K, J = L, 1 = 2
: end
# 1.5 loot items per ghost/lich total. Mix in good loot scrolls and potions.
SUBST:  d = dd|*----, V = VY
KFEAT:  _ = altar_kikubaaqudgha
FTILE:  -d|*%$ODEFHJKL12VY_ = floor_pebble_brown / floor_pebble_darkgray
: ghost_setup(_G)
MAP
    ccc
  cccDccc
cccEcdcFccc
c1ddV_Vdd1c
cc-------cc
 cnn===nnc
 ....@....
ENDMAP

NAME:   gammafunk_ghost_berserking_beasts
DEPTH:  D:7-, Lair, Orc, Shoals, Snake, Spider, Swamp, Elf, Depths, Zot
KITEM:  D = any jewellery good_item
: kitem("E = " .. dgn.good_aux_armour)
KITEM:  F = any jewellery randart
: kitem("H = " .. dgn.randart_aux_armour)
KMONS:  DEFH = player ghost
MONS:   moth of wrath
NSUBST: R = R / -
: ghost_good_loot(_G)
: if you.in_branch("D") then
:     if you.depth() < 9 then
MONS:   water moccasin / ice beast / bullfrog / black bear
MONS:   yak / wyvern / killer bee band
MONS:   komodo dragon / redback / basilisk / hydra / hornet / manticore /\
        acid dragon / catoblepas
SUBST:  D = DE, d = *, e = *%, f = %$, ghij= -
NSUBST: - = 1 / 2=2 / 3=2. / 3. / 4... / .
:     elseif you.depth() < 12 then
MONS:   killer bee band / yak / water moccasin / wyvern / komodo dragon
MONS:   hydra / redback / basilisk / hornet / manticore / acid dragon
MONS:   catoblepas / fire dragon / wolf spider / ice dragon
SUBST:  D = DE, e = *, f = *%, g = %$--, hij= -
NSUBST: - = 1 / 2=2 / 4=2. / 3 / 4... / .
:     elseif you.depth() < 14 then
MONS:   water moccasin / komodo dragon / hydra / redback / basilisk /\
        manticore / acid dragon
MONS:   catoblepas / harpy
MONS:   fire dragon / wolf spider / ice dragon
SUBST:  D = DEFH, f = |*, g = *%, h = %$--, ij= -
NSUBST: - = 1 / 1. / 3=2 / 3=2. / 3 / 3. / 4. / .
:     else
MONS:   hydra / redback / manticore / acid dragon / catoblepas / harpy
MONS:   fire dragon / wolf spider / ice dragon
MONS:   storm dragon / shadow dragon / iron dragon
SUBST:  D = FH, f = |*, g = *, h = %$, ij= -
NSUBST: - = 1 / 1. / 3=2 / 4=2. / 3 / 2=3. / 4. / .
:     end
: elseif you.in_branch("Lair") then
SUBST:  D = DEFH, f = *, g = %$, hij= -
NSUBST: - = 1 / 1. / 2=0 / 4=0. / 9 / 9. / 8... / .
: elseif you.in_branch("Orc") then
# I hope you like wargs.
MONS:   warg
SUBST:  D = DEFH, f = |*, g = *%, h = %$--, ij= -
NSUBST: - = 1 / 1. / 4=2 / 5=2. / .
: elseif you.in_branch("Shoals") then
MONS:   snapping turtle / manticore
MONS:   harpy / sea snake
MONS:   alligator snapping turtle
SUBST:  D = FH, fg = |*, h = *%, i = $%--, j= -
NSUBST: - = 1 / 1. / 3=2 / 5=2. / 3 / 3=3. / 4. / .
: elseif you.in_branch("Snake") then
MONS:   black mamba / mana viper / anaconda
MONS:   guardian serpent / shock serpent
SUBST:  D = FH, fg = |*, h = *%, i = $%--, j= -
NSUBST: - = 1 / 1. / 3=2 / 5=2. / 3 / 4=3. / .
: elseif you.in_branch("Spider") then
MONS:   hornet / redback / tarantella / jumping spider / orb spider
MONS:   wolf spider / emperor scorpion / spark wasp
MONS:   torpor snail / ghost moth
SUBST:  D = FH, fg = |*, h = *%, i = $%--, j= -
NSUBST: - = 1 / 1. / 3=2 / 5=2. / 3 / 3=3. / 4. / .
: elseif you.in_branch("Swamp") then
MONS:   goliath frog / tyrant leech
MONS:   hydra / alligator / swamp dragon
MONS:   bunyip
SUBST:  D = FH, fg = |*, h = *%, i = $%--, j= -
NSUBST: - = 1 / 1. / 3=2 / 5=2. / 3 / 3=3. / 4. / .
: elseif you.in_branch("Elf") then
MONS:   shapeshifter
MONS:   glowing shapeshifter
SUBST:  D = FH, fg = |*, h = *, i = $%, j= -
NSUBST: - = 1 / 2=1. / 4=2 / 4=2. / 2=3 / 2=3. / .
: elseif you.in_branch("Depths") then
MONS:   spark wasp / very ugly thing / fire dragon / ice dragon \
        / floating eye w:5
MONS:   storm dragon / shadow dragon / quicksilver dragon / golden dragon \
        / iron dragon
MONS:   caustic shrike
SUBST:  D = FH, fgh = |*, i = *, j= %$
NSUBST: - = 2=1 / 1. / 4=2 / 4=2. / 2=3 / 2=3. / 4 / 4. / .
: elseif you.in_branch("Zot") then
MONS:   ghost moth / storm dragon / shadow dragon / quicksilver dragon \
        / golden dragon
MONS:   caustic shrike / shard shrike
SUBST:  D = FH, fghij = |*
NSUBST: - = 2=1 / 2=1. / 4=2 / 5=2. / 3=3 / 3=3. / .
: end
MARKER: P = lua:transp_loc("berserking_beasts_entry")
MARKER: Q = lua:transp_dest_loc("berserking_beasts_entry")
MARKER: R = lua:transp_loc("berserking_beasts_exit")
MARKER: S = lua:transp_dest_loc("berserking_beasts_exit")
: ghost_setup(_G)
MAP
    ....@.....
   ..cncScccc.....
  ..ccRccc--cccnc.
  .cc------x---Rc..
  .c----x---x---cc.
  .c--xx--x------c.
 ..nR--x--Q--xx-Rn.
 .cc-x-----x-----c.
 .c----xxxD--xx-cc.
 .cc--xigedfhj--c..
 ..ccc--cnnnc--cc.
  ...cccc.P.cccc..
    ......@......
ENDMAP

# Map inspired by trog_three_pillars_becter
NAME:    gammafunk_ghost_wrathful_warriors
DEPTH:   D:7-, Lair, Orc, Shoals, Snake, Swamp, Elf, Depths, Zot
KMONS:   O = player ghost
MONS:    moth of wrath
# Definitions needed across branches
{{
kmons("D = orc knight; " .. wrathful_weapon("knight", "randart") ..
      "    . arbalest good_item . bolt" ..
      "    . chain mail good_item | plate armour good_item")
kmons("E = ettin ; " .. wrathful_weapon("ogre", "randart") ..
      "    . " .. wrathful_weapon("ogre",
                      crawl.coinflip() and "randart" or "good_item"))
kmons("F = orc warlord; " .. wrathful_weapon("knight", "randart") ..
      "    . arbalest good_item . bolt " ..
      "    . chain mail good_item | plate armour good_item")
kmons("H = spriggan rider; " .. wrathful_weapon("rider", "randart") ..
      "    . robe good_item . buckler good_item")
kmons("J = spriggan berserker; " .. wrathful_weapon("berserker", "randart") ..
      "    . robe good_item | buckler good_item")
kmons("K = spriggan defender; " .. wrathful_weapon("defender", "randart") ..
      "    . robe good_item  . buckler good_item")
kmons("L = deep elf blademaster; " ..
       wrathful_weapon("blademaster", "randart") ..
       " . " .. wrathful_weapon("blademaster",
                    crawl.coinflip() and "randart" or "good_item") ..
       " . leather armour good_item")
}}
SUBST:  ' = x--, " = xx-
NSUBST: R = R / -
: ghost_good_loot(_G)
: if you.in_branch("D") then
{{
kmons("q = kobold; " .. wrathful_weapon("kobold",
               crawl.one_chance_in(3) and "randart" or "good_item") ..
      "    . dart ego:curare | dart ego:poisoned w:5")
kmons("r = gnoll sergeant; " .. wrathful_weapon("sergeant",
               crawl.one_chance_in(3) and "randart" or "good_item") ..
      "    . leather armour good_item | ring mail good_item" ..
      "    . buckler good_item | kite shield good_item w:5")
kmons("s = orc warrior ; " .. wrathful_weapon("warrior",
               crawl.one_chance_in(3) and "randart" or "good_item") ..
      "    . chain mail good_item | plate armour good_item")
kmons("u = ogre ; " .. wrathful_weapon("ogre",
               crawl.one_chance_in(3) and "randart" or "good_item"))
kmons("y = two-headed ogre ; " .. wrathful_weapon("ogre",
               crawl.one_chance_in(3) and "randart" or "good_item") ..
      "    . " .. wrathful_weapon("ogre", "good_item"))
kmons("z = tengu warrior ; " .. wrathful_weapon("warrior", "randart") ..
      "    . leather armour good_item | ring mail good_item" ..
      "    . buckler good_item | kite shield good_item")
}}
:     if you.depth() < 9 then
MONS:   kobold brigand / gnoll sergeant / ogre / orc warrior
MONS:   troll
MONS:   cyclops
SUBST:  d = *, e = *%, f = %$, ghij= -
NSUBST: - = 1 / qrsu / 2 / 3=2. / 3y.. / 4z...... / .
:     elseif you.depth() < 12 then
MONS:   orc warrior / troll / two-headed ogre
MONS:   cyclops
MONS:   deep troll
SUBST:  e = *, f = *%, g = %$--, hij= -
NSUBST: - = 1 / sy / 2 / 4=2. / 3z / 4D...... / .
:     elseif you.depth() < 14 then
MONS:   troll / two-headed ogre / cyclops
MONS:   tengu warrior / orc knight
MONS:   deep troll / stone giant
SUBST:  f = |*, g = *%, h = %$--, ij= -
NSUBST: - = 1 / 1. / 3=2 / 3=2. / zD / zD.. / 4E.. / .
:     else
MONS:   two-headed ogre / cyclops / tengu warrior
MONS:   deep troll
MONS:   stone giant
SUBST:  f = |*, g = *, h = %$, ij= -
NSUBST: - = 1 / 1. / 3=2 / 4=2. / D / 2=D3.. / 4EF... / .
:     end
: elseif you.in_branch("Lair") then
MONS:   spriggan
SUBST:  f = *, g = %$, hij= -
NSUBST: - = 1 / 1. / 2=2 / 4=2. / H / H. / J... / .
: elseif you.in_branch("Orc") then
MONS:   orc warrior / troll / two-headed ogre
MONS:   deep troll
MONS:   stone giant
SUBST:  f = |*, g = *%, h = %$--, ij= -
NSUBST: - = 1 / 1. / 2=2 / 4=2. / D / D3.. / 4EF... / .
: elseif you.in_branch("Shoals") then
# Place merfolk through merfolk impaler bands so they get better equipment.
# Each band is 2-5 merfolk, 3.5 on-average.
{{
kmons("q = merfolk impaler band; " .. wrathful_weapon("impaler", "randart") ..
      "    . robe good_item | leather armour good_item")
-- Specifying jav quantity so they get their usual quantity bonus.
kmons("r = merfolk javelineer; " .. wrathful_weapon("impaler", "randart") ..
      "    . robe good_item . javelin good_item q:" ..
               tostring(9 + crawl.random2(15)))
}}
MONS:   cyclops
MONS:   merfolk impaler / merfolk javelineer w:5
SUBST:  fg = |*, h = *%, i = $%--, j= -
NSUBST: - = 1 / 1. / 3=2. / q / r / 3=3. / .
: elseif you.in_branch("Snake") then
{{
kmons("q = naga warrior; " .. wrathful_weapon("warrior", "randart") ..
      "    . nothing w:95 | robe good_item w:95 | barding good_item" ..
      "    . nothing w:40 | kite shield good_item | tower shield good_item")
}}
MONS:   naga / salamander
MONS:   naga warrior
SUBST:  fg = |*, h = *%, i = $%--, j= -
NSUBST: - = 1 / 1. / 3=2 / 5=2. / q / 2=q. / 2=3. / .
: elseif you.in_branch("Swamp") then
MONS:   spriggan w:20 / spriggan rider
MONS:   spriggan rider / spriggan berserker
SUBST:  fg = |*, h = *%, i = $%--, j= -
NSUBST: - = 1 / 1. / 3=2 / 5=2. / J / HJ.. / 2=3. / K. / .
: elseif you.in_branch("Elf") then
{{
-- Specifying arrow quantity so they get their usual quantity bonus.
kmons("q = deep elf master archer; longbow randart " ..
      "    . arrow q:" ..  tostring(37 + crawl.random2(38)) ..
      "    . leather armour good_item")
}}
MONS:   deep elf blademaster / deep elf master archer
SUBST:  fg = |*, h = *, i = $%, j= -
# There aren't any good lower-tier, trog-appropriate warrior types. So use all
# blademasters and master archers, but reduce the monster count.
NSUBST: - = 1 / 2=1. / 2=L / q / 3=2. / .
: elseif you.in_branch("Depths") then
MONS:   tengu warrior / deep troll / spriggan berserker / stone giant / ettin
MONS:   deep elf blademaster / spriggan defender
MONS:   juggernaut
SUBST:  fgh = |*, i = *, j= %$
NSUBST: - = 2=1 / 1. / 4=2 / 4=2. / 2=KL / KL.. / 3. / 4 / 4. / .
: elseif you.in_branch("Zot") then
{{
kmons("q = base draconian; " .. wrathful_weapon("knight", "randart"))
kmons("r = draconian monk; cloak randart")
}}
MONS:   base draconian
MONS:   draconian monk
SUBST:  fghij = |*
NSUBST: - = 2=1 / 2=1. / 3=q / 2 / 5=2. / 2=r / 3 / 3=3. / .
: end
KFEAT:  _ = altar_trog
MARKER: P = lua:transp_loc("wrathful_warriors_entry")
MARKER: Q = lua:transp_dest_loc("wrathful_warriors_entry")
MARKER: R = lua:transp_loc("wrathful_warriors_exit")
MARKER: S = lua:transp_dest_loc("wrathful_warriors_exit")
COLOUR: x = lightred
TILE:   x = wall_pebble_red
: ghost_setup(_G)
MAP
      .@.
    ...P...
  ...cnnnc...
 ..ccc-R-ccc..
 .cc-----'xcc.
..cx''--"xxxc..
.cc'xx"-xlx'cc.
.n-'xledfxx'-n.
.nR'xxg_h---Rn.
.n----iOjx'--n.
.cc----"lx'-cc.
..c----'xx--c..
 .cc----''xcc.
 ..ccc-Q-ccc..
  ...cnnnc...
    ...S...
      .@.
ENDMAP

NAME:   gammafunk_ghost_abyssal_escape
KITEM:  N = scroll of teleportation q:3 ident:all w:20 \
            / scroll of blinking ident:all w:20 \
            / boomerang ego:dispersal ident:all \
            / book of spatial translocations \
            / book of the warp \
            / there-and-back book \
            / inescapable atlas \
            / book of displacement \
            / randbook owner:Lugonu disc:translocation ident:all w:5 \
            / manual of translocations w:2 / rift w:2 / ring of the hare w:2
KMONS:  O = player ghost
KFEAT:  O = enter_abyss
KFEAT:  ^ = dispersal trap
KFEAT:  tJ = demonic_tree
SUBST:  c = c:40 v b t:5, . = '''.
COLOUR: -apQJ = magenta
RTILE:  x = wall_abyss
FTILE:  -'apPQntcbv = floor_nerves
# Randomize transporter feature placement among set of specific locations on
# 'P', using remaining instances for loot.
NSUBST: P = P / S, Q = Q / R, R = R / k, S = S / '
NSUBST: k = d / e / f / g / h / i / j / -
# Place some rocks and dispersal traps in the inner area and along the inner
# wall, but with lower density along wall to make fewer choke points.
SUBST:  a = x -:7 ^:1, p = x -:37 ^:1
# Place ghost and translocation loot, remaining instances of '-' will be used
# for further loot and monster placement.
NSUBST: - = O / N / -
: ghost_good_loot(_G)
# Some monsters we use in multiple branches
{{
kmons("D = orc knight; " .. disto_weapon("knight", "randart") ..
      "    . chain mail good_item | plate armour good_item")
kmons("E = spriggan rider; " .. disto_weapon("rider", "randart") ..
      "    . robe good_item . buckler good_item")
kmons("F = deep elf knight; " .. disto_weapon("elf knight", "randart") ..
      "    . leather armour good_item | ring mail good_item" ..
      "      | scale mail good_item | chain mail good_item" ..
      "    . buckler good_item")
kmons("H = orc warlord; " .. disto_weapon("knight", "randart") ..
      "    . chain mail good_item | plate armour good_item")
}}
: if you.in_branch("D") then
{{
kmons("q = kobold; " .. disto_weapon("kobold",
               crawl.one_chance_in(3) and "randart" or "good_item"))
kmons("r = gnoll; " .. disto_weapon("gnoll",
               crawl.one_chance_in(3) and "randart" or "good_item"))
kmons("s = kobold brigand; " .. disto_weapon("kobold",
               crawl.one_chance_in(3) and "randart" or "good_item"))
kmons("u = gnoll sergeant; " .. disto_weapon("sergeant",
               crawl.one_chance_in(3) and "randart" or "good_item") ..
      "    . leather armour good_item | ring mail good_item" ..
      "    . buckler good_item | kite shield good_item w:5")
kmons("y = orc warrior ; " .. disto_weapon("warrior",
               crawl.one_chance_in(3) and "randart" or "good_item") ..
      "    . chain mail good_item | plate armour good_item")
kmons("z = skeletal warrior ; " .. disto_weapon("warrior", "randart"))
}}
:     if you.depth() < 6 then
MONS:   any lesser demon / small abomination
MONS:   toenail golem / ancient zyme
SUBST:  d = *%, e = %$, fghij= -
NSUBST: - = qrs / 2=1 / 2=1. / 2... / .
:     elseif you.depth() < 9 then
MONS:   any lesser demon w:5 / small abomination
MONS:   toenail golem / ancient zyme / any common demon / ugly thing
MONS:   worldbinder / large abomination / raiju / shapeshifter / rakshasa \
        / wizard / hell hog / thrashing horror
SUBST:  d = *, e = *%, f = %$, ghij= -
NSUBST: - = suy / 2=1 / 2=1. / 2=2. / 3... / .
:     elseif you.depth() < 12 then
MONS:   small abomination / toenail golem / any common demon w:5
MONS:   ugly thing / large abomination / raiju / shapeshifter / wizard \
        / hell hog / thrashing horror
MONS:   ancient zyme / worldbinder / rakshasa
MONS:   great orb of eyes / glowing orange brain / very ugly thing \
        / lurking horror / wretched star / tentacled starspawn
SUBST:  e = *, f = *%, g = %$--, hij= -
NSUBST: - = uyz / 2=1 / 2=1. / 2 / 2. / 3. / 4... / .
:     elseif you.depth() < 14 then
MONS:   any common demon / ugly thing / large abomination / worldbinder
MONS:   raiju / shapeshifter / thrashing horror / wizard / hell hog \
        / very ugly thing
MONS:   ancient zyme / rakshasa / great orb of eyes / glowing orange brain
MONS:   lurking horror / wretched star / tentacled starspawn / cacodemon \
        / hellion / apocalypse crab / glowing shapeshifter / crystal guardian \
        / tentacled monstrosity w:2 / starcursed mass w:2 / daeva god:Xom w:2 \
        / executioner w:2 / profane servitor w:2
SUBST:  f = |*, g = *%, h = %$--, ij= -
NSUBST: - = yzDF / 2=1 / 3=1. / 2 / 2=2. / 3 / 4. / .
:     else
MONS:   ugly thing / large abomination / worldbinder / raiju / shapeshifter \
        / rakshasa / thrashing horror / wizard
MONS:   wizard / hell hog / great orb of eyes / very ugly thing \
        / glowing orange brain / tentacled starspawn / cacodemon
MONS:   lurking horror / wretched star / hellion / apocalypse crab
MONS:   glowing shapeshifter / crystal guardian / tentacled monstrosity \
        / starcursed mass / daeva god:Xom / executioner / profane servitor \
        / hell sentinel w:5 / hellephant w:5
SUBST:  f = |*, g = *, h = %$, ij= -
NSUBST: - = qDFH / 2=1 / 3=1. / 2 / 3=2. / 3 / 4 / .
:     end
: elseif you.in_branch("Lair") then
{{
kmons("q = spriggan; " .. disto_weapon("spriggan",
      crawl.one_chance_in(3) and "randart" or "good_item"))
}}
MONS:   any common demon / ugly thing
MONS:   large abomination / raiju / shapeshifter / rakshasa / hell hog \
        / thrashing horror
MONS:   ancient zyme / worldbinder
MONS:   great orb of eyes / glowing orange brain / very ugly thing \
        / lurking horror / tentacled starspawn / wretched star \
        / cacodemon / hellion / apocalypse crab / glowing shapeshifter
SUBST:  f = *, g = %$, hij= -
NSUBST: - = qE / 2=1 / 2=1. / 2 / 2=2. / 3. / 4. / .
FTILE:  'PSntcbv = floor_nerves_green
: elseif you.in_branch("Orc") then
MONS:   any common demon / ugly thing / large abomination / worldbinder / raiju
MONS:   shapeshifter / rakshasa / thrashing horror / wizard / hell hog \
        / very ugly thing
MONS:   ancient zyme / great orb of eyes / glowing orange brain
MONS:   lurking horror / wretched star / tentacled starspawn / cacodemon \
        / hellion / apocalypse crab / glowing shapeshifter / crystal guardian \
        / tentacled monstrosity w:2 / starcursed mass w:2 / daeva god:Xom w:2 \
        / executioner w:2 / profane servitor w:2
SUBST:  f = |*, g = *%, h = %$--, ij= -
NSUBST: - = DH / 2=1 / 3=1. / 2 / 2=2. / 3 / 4. / .
FTILE:  'PSntcbv = floor_nerves_brown
: elseif you.in_branch("Shoals")
:        or you.in_branch("Snake")
:        or you.in_branch("Swamp")
:        or you.in_branch("Spider") then
# Use the same basic monster list for all 4 Lair branches.
MONS:   ugly thing / large abomination / worldbinder / raiju \
        / thrashing horror / wizard / hell hog
MONS:   great orb of eyes / glowing orange brain / very ugly thing \
        / tentacled starspawn / cacodemon
MONS:   lurking horror / wretched star / hellion / apocalypse crab
MONS:   glowing shapeshifter / crystal guardian / tentacled monstrosity \
        / starcursed mass / daeva god:Xom / executioner / profane servitor \
        / hell sentinel / hellephant
# Define any branch-specific disto warriors and other substitutions.
:     if you.in_branch("Shoals") then
{{
kmons("q = merfolk impaler ; " .. disto_weapon("impaler", "randart") ..
      "    . robe good_item | leather armour good_item")
}}
NSUBST: - = q / -
FTILE:  'PSntcbv = floor_nerves_yellow
:     elseif you.in_branch("Snake") then
{{
kmons("q = naga warrior ; " .. disto_weapon("warrior", "randart") ..
      "    . nothing w:95 | robe good_item w:95 | barding good_item" ..
      "    . nothing w:40 | kite shield good_item | tower shield good_item")
kmons("r = nagaraja ; " .. disto_weapon("warrior", "randart") ..
      "    . robe good_item w:40 | barding good_item")
}}
NSUBST: - = qr / -
FTILE:  'PSntcbv = floor_nerves_green
:     elseif you.in_branch("Swamp") then
{{
kmons("q = spriggan druid ; " .. disto_weapon("druid", "randart") ..
      "    . robe good_item")
}}
# Potential druids need some trees!
SUBST:  x = Jxxx, cvb = c:30 v b t:15
NSUBST: - = Eq / -
FTILE:  'PSntcbv = floor_nerves_brown
:     elseif you.in_branch("Spider") then
# No good humanoids to wield distortion in Spider, so let's go with a narrative
# of the player getting banished by a zot trap.
KFEAT:  ~ = zot trap
NSUBST: - = ~ / 2=~- / -
FTILE:  'PSntcbv = floor_nerves_brown
:     end
# Common monster/loot placement for all Lair branches.
SUBST:  fg = |*, h = *%, i = $%--, j= -
NSUBST: - = 2=1 / 4=1. / 2=2 / 2=2. / 3 / 4 / .
: elseif you.in_branch("Elf") then
{{
kmons("q = deep elf blademaster; " .. disto_weapon("blademaster", "randart") ..
      " . " .. disto_weapon("blademaster",
                   crawl.one_chance_in(3) and "randart" or "good_item") ..
      " . leather armour good_item")
}}
MONS:   large abomination / worldbinder / shapeshifter / thrashing horror \
        / rakshasa / very ugly thing / great orb of eyes / glowing orange brain
MONS:   tentacled starspawn / cacodemon / deep elf demonologist \
        / deep elf sorcerer / glowing shapeshifter / crystal guardian
MONS:   wretched star / lurking horror / hellion / apocalypse crab
MONS:   tentacled monstrosity / starcursed mass / daeva god:Xom / executioner \
        / profane servitor / hellephant / hell sentinel
SUBST:  fg = |*, h = *, i = $%, j= -
NSUBST: - = Fq / 3=1 / 3=1. / 2=2 / 2=2. / 3 / 4 / 4. / .
FTILE:  'PSntcbv = floor_nerves_cyan
: elseif you.in_branch("Crypt") then
{{
kmons("q = ancient champion ; " .. disto_weapon("warrior", "randart") ..
      "    . chain mail good_item | plate armour good_item")
}}
MONS:   thrashing horror / rakshasa / very ugly thing / great orb of eyes \
        / glowing orange brain / tentacled starspawn / cacodemon
MONS:   glowing shapeshifter / crystal guardian / lich
MONS:   lurking horror / wretched star / hellion / apocalypse crab
MONS:   tentacled monstrosity / starcursed mass / daeva god:Xom / executioner \
        / profane servitor / hellephant / hell sentinel
SUBST:  fgh = |*, i = *%, j= $%--
NSUBST: - = q / 3=1 / 4=1. / 2=2 / 2=2. / 3 / 3. / 4 / 4. / .
: elseif you.in_branch("Depths") then
{{
kmons("q = spriggan defender; " .. disto_weapon("defender", "randart") ..
      "    . robe good_item  . buckler good_item")
kmons("r = tengu reaver; " .. disto_weapon("knight", "randart") ..
      "    . scale mail good_item  . buckler good_item")
}}
MONS:   rakshasa / very ugly thing / great orb of eyes / glowing orange brain \
        / tentacled starspawn / cacodemon
MONS:   glowing shapeshifter / crystal guardian / tentacled monstrosity \
        / daeva god:Xom / executioner / profane servitor
MONS:   lurking horror / wretched star / hellion / apocalypse crab \
        / starcursed mass
MONS:   ancient lich / dread lich / hellephant / hell sentinel
SUBST:  fgh = |*, i = *, j= %$
NSUBST: - = Hqr / 4=1 / 4=1. / 2=2 / 2=2. / 3 / 3. / 4 / 4. / .
: elseif you.in_branch("Zot") then
{{
kmons("q = draconian knight; " .. disto_weapon("knight", "randart") ..
      "    . cloak good_item . kite shield good_item | tower shield good_item")
kmons("r = killer klown; club ego:distortion plus:" ..
       tostring(8 + crawl.random2(5)))
}}
MONS:   rakshasa w:5 / very ugly thing w:5 / great orb of eyes w:5 \
        / glowing orange brain / tentacled starspawn / cacodemon \
        / glowing shapeshifter / crystal guardian / tentacled monstrosity
MONS:   draconian shifter / daeva god:Xom / executioner / profane servitor \
        / killer klown
MONS:   lurking horror / wretched star / hellion / apocalypse crab \
        / starcursed mass
MONS:   ancient lich / dread lich / hellephant / hell sentinel
SUBST:  fghij = |*
NSUBST: - = qr / 4=1 / 4=1. / 2=2 / 3=2. / 3 / 3. / 4 / 2=4. / .
: end
MARKER: P = lua:transp_loc("abyssal_escape_entry")
MARKER: Q = lua:transp_dest_loc("abyssal_escape_entry")
MARKER: R = lua:transp_loc("abyssal_escape_exit")
MARKER: S = lua:transp_dest_loc("abyssal_escape_exit")
# Color weights similar to that used for rock in the Abyss.
COLOUR: x = blue:13 / red:66 / magenta:50 / brown:90 / lightgreen:68 \
            / lightred:110 / lightmagenta:38 / yellow / white
RTILE:  x = wall_abyss
: ghost_setup(_G)
MAP
     ....
   ...cc..  ..P..
 ...Pcccc....cnc.
..ccnc-pcc''ccQc.
.cc-Q-a-QnP'cp-c..
.c-aaappcc''cc-cc.
.cc-apccc'''cc-pc.
.'cc-pc''''cc-apc.
.'ccp-ccPcccp-pcc.
.ccpaa-cncpp-ccc..
PnQ-aaa-Q-aaQnP'.
.cc-aaaaa-aa-cc'.
..cc-aap-Q--a-cc..
 .'c-aa-cnccpa-cc.
 .ccp--ccP'cppa-c.
 .cpQccc'''cccQcc.
 .ccnc.......cnc..
 ...P..     ..P..
ENDMAP
