### 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 Snake and Elf.

: crawl_require('dlua/vault.lua')

{{
function ambush_setup(e, section)
  e.tags("allow_dup")
  if section == "outer" then
    e.tags("evilmike_ambush_outer")
    e.tags("unrand")
  elseif section == "inner" then
    e.tags("evilmike_ambush_inner")
    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
  if you.in_branch("Depths") then
    e.ftile(".{([])}>Gmxcv+ = floor_etched")
  elseif you.in_branch("Dis") then
    vault_metal_statue_setup(e, "G", "iron statue")
  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
: if you.in_branch("Depths") then
FTILE:    .098 = floor_etched
: 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
WEIGHT: 25
SUBST:  G : Gx.., x : xcbwnm
: ambush_setup(_G, "outer")
MAP
 ...G...
.G     G.
.       .
.       .
G       G
.       .
.       .
.G     G.
 ...G...
ENDMAP

NAME:    evilmike_ambush_outer_pillars
SHUFFLE: x.
SUBST:   x : xxxccvvbmG
: ambush_setup(_G, "outer")
MAP
 .x.x.x.
.x     x.
x       x
.       .
x       x
.       .
x       x
.x     x.
 .x.x.x.
ENDMAP

NAME:    evilmike_ambush_outer_corners
SUBST:   y : x., x : xxxcccvvbm
: ambush_setup(_G, "outer")
MAP
 xy...yx
xx     xx
y       y
.       .
.       .
.       .
y       y
xx     xx
 xy...yx
ENDMAP

NAME:    evilmike_ambush_outer_doors
WEIGHT:  5
SHUFFLE: +D
SUBST:   D : +x
: ambush_setup(_G, "outer")
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 3
# In hell always has the upstair, with a chance of downstairs or hatch
NAME:    evilmike_ambush_inner_basic
WEIGHT:  25
SHUFFLE: <AB
SUBST:   AB = .
: ambush_setup(_G, "inner")
MAP
 ..A..
...<...
...B...
A<BGB<A
...B...
...<...
 ..A..
ENDMAP

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

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

NAME:    evilmike_ambush_inner_pond
SUBST:   w : wwwWWlm..., > : >..
: if you.in_branch("Coc") or you.in_branch("Tar") then
SUBST:   l = w
: elseif you.in_branch("Geh") then
SUBST:   wW = l
: end
: ambush_setup(_G, "inner")
MAP
 .....
..>w<..
.<www>.
.wwGww.
.>www<.
..<w>..
 .....
ENDMAP

NAME:    evilmike_ambush_inner_cross
WEIGHT:  5
SUBST:   y : x., z : x., x : xxxccvvbmm
: ambush_setup(_G, "inner")
MAP
 ..y..
...x...
..<x<..
yxxzxxy
..<x<..
...x...
 ..y..
ENDMAP
