### Ambush Vault ###############################################################
#
# A large ambush with several monsters, many potentially OOD. Can appear almost
# anywhere, any number of times.
#
# Number of monsters (and amount of ood) depends on depth and randomness. Ranges
# from 8 to 24 monsters. Very random, middle part is all subvaults.
#
# There is a lair variant that is (mostly) a joke vault; all other variants
# appear no earlier than D:14.
{{
function ambush_stairs(e)
    if you.in_branch("Dis") or you.in_branch("Coc") or you.in_branch("Tar")
       or you.in_branch("Geh") then
        e.nsubst("< = 1:{ / 1:}. / 1:>. / *:.")
    else
        e.nsubst("< = 1:{ / 1:( / 1:[} / 1:>")
    end
end
}}

NAME:     evilmike_ambush
TAGS:     allow_dup transparent no_monster_gen no_descent
DEPTH:    Lair, Depths, !Depths:$, Elf, !Elf:$, Snake, !Snake:$, \
          Dis, !Dis:$, Geh, !Geh:$, Tar, !Tar:$, Coc, !Coc:$, \
          Zot, !Zot:$, Crypt, !Crypt:$
KMONS:    P = bush / scrub nettle w:1
: if you.in_branch("Snake") then
KMONS:    0 = black mamba / naga / salamander
KMONS:    9 = mana viper / anaconda / naga mage
KMONS:    8 = naga ritualist / salamander mystic
KMONS:    & = naga warrior / naga sharpshooter
: elseif you.in_branch("Dis") then
KMONS:    0 = war gargoyle / crystal echidna w:5 / iron dragon draugr w:2
KMONS:    9 = ancient champion / quicksilver elemental / iron dragon
KMONS:    8 = iron giant / iron golem
KMONS:    & = hellion / tormentor / ancient lich
: elseif you.in_branch("Geh") then
KMONS:    0 = hell hog / fire giant w:5 / golden dragon draugr w:2
KMONS:    9 = searing wretch / balrug
KMONS:    8 = hellephant / salamander tyrant w:5
KMONS:    & = hellion / tormentor / brimstone fiend w:5
: elseif you.in_branch("Tar") then
KMONS:    0 = shadow wraith / spectral thing / shadow dragon zombie w:2
KMONS:    9 = eidolon / putrid mouth w:5
KMONS:    8 = undertaker / profane servitor / tainted leviathan w:5
KMONS:    & = tormentor / ancient lich / dread lich
: elseif you.in_branch("Coc") then
KMONS:    0 = simulacrum / frost giant w:5 / ice dragon zombie w:2
KMONS:    9 = azure jelly / wendigo / nargun
KMONS:    8 = shard shrike / caustic shrike simulacrum w:5
KMONS:    & = tormentor / titan
: elseif you.in_branch("Zot") then
KMONS:    0 = white draconian / green draconian / yellow draconian
KMONS:    9 = shadow dragon / draconian monk
KMONS:    8 = death cob / golden dragon / ghost moth w:5
KMONS:    & = curse toe / moth of wrath
: end
SUBVAULT: = : evilmike_ambush_outer
SUBVAULT: - : evilmike_ambush_inner
SUBST:    =- : .
: local x = you.absdepth() - 14 + crawl.random2(12)
: if you.in_branch("Lair") then
SUBST:    0 = PP., 1 = PP., 2 = PP0,  9 = PP0
: elseif x > 17 then
SUBST:    1 = 0, 2 = 8
: elseif x > 11 then
SUBST:    1 = 00., 2 = 89
: elseif x > 5 then
SUBST:    1 = 0., 2 = 9
: else
SUBST:    1 = 0.., 2 = 9.
: end
NSUBST:   8 = 1:&&8 / *:8
MAP
  2...0...9
 ...1...1...
9.0=======0.2
..==-----==..
.1=-------=1.
..=-------=..
0.=-------=.0
..=-------=..
.1=-------=1.
..==-----==..
2.0=======0.9
 ...1...1...
  9...0...2
ENDMAP

# Outer ring subvaults
NAME:   evilmike_ambush_outer_basic
TAGS:   evilmike_ambush_outer allow_dup unrand
WEIGHT: 25
SUBST:  G : Gx..
SUBST:  x : xcbwnm
: if you.in_branch("Dis") then
KFEAT:  G = metal_statue
TILE:   G = dngn_statue_iron
: end
MAP
 ...G...
.G     G.
.       .
.       .
G       G
.       .
.       .
.G     G.
 ...G...
ENDMAP

NAME:    evilmike_ambush_outer_pillars
TAGS:    evilmike_ambush_outer allow_dup unrand
SHUFFLE: x.
SUBST:   x : xxxccvvbmG
: if you.in_branch("Dis") then
KFEAT:  G = metal_statue
TILE:   G = dngn_statue_iron
: end
MAP
 .x.x.x.
.x     x.
x       x
.       .
x       x
.       .
x       x
.x     x.
 .x.x.x.
ENDMAP

NAME:    evilmike_ambush_outer_corners
TAGS:    evilmike_ambush_outer allow_dup unrand
SUBST:   y : x., x : xxxcccvvbm
MAP
 xy...yx
xx     xx
y       y
.       .
.       .
.       .
y       y
xx     xx
 xy...yx
ENDMAP

NAME:    evilmike_ambush_outer_doors
TAGS:    evilmike_ambush_outer allow_dup unrand
WEIGHT:  5
SHUFFLE: +D
SUBST:   D : +x
MAP
 x+D+D+x
xx     xx
+       +
D       D
+       +
D       D
+       +
xx     xx
 x+D+D+x
ENDMAP

# Inner subvaults. Always contains two stairs, with a large chance of having all 3
# In hell always has the upstair, with a chance of downstairs or hatch
NAME:    evilmike_ambush_inner_basic
TAGS:    evilmike_ambush_inner allow_dup
WEIGHT:  25
SHUFFLE: <AB
SUBST:   AB = .
: if you.in_branch("Dis") then
KFEAT:   G = metal_statue
TILE:    G = dngn_statue_iron
: end
: ambush_stairs(_G)
MAP
 ..A..
...<...
...B...
A<BGB<A
...B...
...<...
 ..A..
ENDMAP

NAME:    evilmike_ambush_inner_wall_1
TAGS:    evilmike_ambush_inner allow_dup
WEIGHT:  3
SHUFFLE: AB / {<
SUBST:   { = <
SUBST:   AB = .
SHUFFLE: yxX / "">
SUBST:   " = .
SUBST:   y : x., X = x
SUBST:   x : xxxccvvbmm
SUBST:   > = }>
: ambush_stairs(_G)
MAP
 .....
...y...
...x...
A{.X.<B
...x...
...y...
 .....
ENDMAP

NAME:    evilmike_ambush_inner_wall_2
TAGS:    evilmike_ambush_inner allow_dup
WEIGHT:  3
SHUFFLE: AB / {<
SUBST:   AB = .
SHUFFLE: yxX / ""<
SUBST:   " = .
SUBST:   y : x., X = x
SUBST:   x : xxxccvvbmm
SUBST:   > = }>
: ambush_stairs(_G)
MAP
 .....
..y.y..
..x.x..
A{X>X<B
..x.x..
..y.y..
 .....
ENDMAP

NAME:    evilmike_ambush_inner_pond
TAGS:    evilmike_ambush_inner allow_dup
SUBST:   w : wwwWWlm...
SUBST:   > : >..
: if you.in_branch("Dis") then
KFEAT:   G = metal_statue
TILE:    G = dngn_statue_iron
: elseif you.in_branch("Coc") or you.in_branch("Tar") then
SUBST:   l = w
: elseif you.in_branch("Geh") then
SUBST:   wW = l
: end
: ambush_stairs(_G)
MAP
 .....
..>w<..
.<www>.
.wwGww.
.>www<.
..<w>..
 .....
ENDMAP

NAME:    evilmike_ambush_inner_cross
TAGS:    evilmike_ambush_inner allow_dup
WEIGHT:  5
SUBST:   y : x., z : x., x : xxxccvvbmm
: ambush_stairs(_G)
MAP
 ..y..
...x...
..<x<..
yxxzxxy
..<x<..
...x...
 ..y..
ENDMAP
