# A subvaulted transporter vaults that places 098 monsters and loot that scales
# counts of each with depth. The loot contains some more focused consumables
# and good_item or artefact jewellery or aux armour.

{{
-- Common setup needed for all the_bubble subvaults.
function gammafunk_the_bubble_setup(e, entry_glyph, exit_glyph)
    -- Subvault transporter entry/exit and monster setup. Only one instance of
    -- exit_glyph is used; the rest become floor.
    e.lua_marker(entry_glyph, transp_dest_loc("the_bubble_entry"))
    e.nsubst(exit_glyph .. " = " .. exit_glyph .. " / .")
    e.lua_marker(exit_glyph, transp_loc("the_bubble_exit"))

    -- Scale up monsters by depth.
    if you.in_branch("D") then
        if you.depth() < 10 then
            e.nsubst(". = 5=0 / 6=0. / 2=9 / 4=9. / 8... / .")
        elseif you.depth() < 13 then
            e.nsubst(". = 5=0 / 6=0. / 3=9 / 3=9. / 8. / .")
        else
            e.nsubst(". = 6=0 / 6=0. / 3=9 / 4=9. / 2=8. / .")
        end
    elseif you.in_branch("Snake") then
        e.nsubst(". = 6=0 / 7=0. / 3=9 / 5=9. / 2=8. / .")
    elseif you.in_branch("Elf") or you.in_branch("Vaults") then
        e.nsubst(". = 6=0 / 8=0. / 3=9 / 5=9. / 8 / 8. / .")
        if you.in_branch("Vaults") then
            e.ftile(".-098DEFGHIJK = floor_metal_gold")
        end
    elseif you.in_branch("Crypt") then
        e.nsubst(". = 6=0 / 8=0. / 4=9 / 4=9. / 8 / 2=8. / .")
    elseif you.in_branch("Depths") then
        e.nsubst(". = 7=0 / 8=0. / 4=9 / 4=9. / 8 / 2=8. / .")
    else
        e.nsubst(". = 7=0 / 8=0. / 4=9 / 5=9. / 8 / 3=8. / .")
    end

    -- Add some more specific monsters among the 8s for the very late branches
    -- a good out-of-depth monster set.
    if you.in_branch("Crypt") then
       e.kmons("2 = ancient lich / dread lich / vampire bloodprince w:5")
       e.nsubst("8 = 1:2 / 8")
    elseif you.in_branch("Zot") then
       e.kmons("2 = ancient lich w:5 / dread lich w:5 / curse toe / \
                    orb of appropriateness / protean progenitor band")
       e.kfeat("t = petrified_tree")
       e.subst("8 = 28")
    elseif you.in_branch("Pandemonium") then
       -- 8 and 9 spawns both aren't a thing in Pan, so make these ourself.
       e.kmons("2 = greater demon w:20 / demonspawn soul scholar w:5 / \
                    demonspawn blood saint w:5 / demonspawn corrupter w:5 / \
                    demonspawn warmonger w:5")
       e.kmons("3 = executioner / brimstone fiend / ice fiend / \
                    tzitzimitl / hell sentinel / nekomata w:2")
       e.subst("8 = 39")
       e.subst("9 = 02")
    end
end
}}

NAME:   gammafunk_the_bubble
TAGS:   no_monster_gen no_trap_gen no_descent
# Allow placement in Vaults as a room.
TAGS:   vaults_hard no_wall_fixup passable
DEPTH:  Crypt, D:7-, Depths, Elf, Pan, Snake, Vaults, Zot
ORIENT: float
: item(dgn.loot_scrolls .. " / " .. dgn.loot_potions)
ITEM:   any jewellery good_item, any jewellery randart
ITEM:   cloak good_item / scarf good_item / helmet good_item \
        / hat good_item / pair of gloves good_item / pair of boots good_item
ITEM:   cloak randart / helmet randart / hat randart / pair of gloves randart \
        / pair of boots randart
# Set up increasing loot count and quality with depth.
: if you.in_branch("D") then
:   if you.depth() < 10 then
NSUBST: ' = ddeg / 3=|* / * / *% / 2=$ / .
:   elseif you.depth() < 13 then
NSUBST: ' = d / eg / 3=|* / * / %$.. / 2=$ / .
:   else
NSUBST: ' = 2=d / eg / 3=|* / *% / %$.. / 2=$ / .
:   end
: elseif you.in_branch("Snake") then
NSUBST: ' = 2=d / eg / 3=|* / * / %$ / 2=$ / .
: elseif you.in_branch("Elf") or you.in_branch("Vaults") then
NSUBST: ' = 2=d / fh / 4=|* / *% / %$.. / 2=$ / .
: elseif you.in_branch("Crypt") then
NSUBST: ' = 2=d / fh / 4=|* / * / %$ / 2=$ / .
: elseif you.in_branch("Depths") then
NSUBST: ' = 2=d / f / h / 4=|* / *% / %$.. / 2=$ / .
: else
NSUBST: ' = 2=d / f / h / 4=|* / *% / %$ / 2=$ / .
: end
# Statue decorations.
SUBST:  G : GGGTTUttt, H : GGGTTUttt
SUBVAULT: A : the_bubble
: if you.in_branch("Vaults") then
FTILE:    .@defgh$%*|DEFGHJKRS = floor_metal_gold
FTILE:    t = floor_pebble_green
: elseif you.in_branch("Zot") then
KFEAT:    t = petrified_tree
: end
MARKER:   D = lua:transp_loc("the_bubble_entry")
MARKER:   E = lua:transp_dest_loc("the_bubble_exit")
MAP
   ......@.......
 ...cccc...ccccc..
..cccAAnnnnnAAAcc..
.ccHcAAAAAAAAAAAcc.
.n''cAAAAAAAAAAAAc.
.n''+AAAAAAAAAAAAc.
.n''cAAAAAAAAAAAAc.
.ccccAAAAAAAAAAAnc.
.G..nAAAAAAAAAAAn..
@..DnAAAAAAAAAAAnE@
.G..nAAAAAAAAAAAn..
.ccccAAAAAAAAAAAnc.
.n''cAAAAAAAAAAAAc.
.n''+AAAAAAAAAAAAc.
.n''cAAAAAAAAAAAAc.
.ccHcAAAAAAAAAAAcc.
..cccAAnnnnnAAAcc..
 ...cccc...ccccc..
   ......@.......
ENDMAP

NAME: the_bubble_gammafunk_split
TAGS: the_bubble unrand
SUBST: x : bcvx
: gammafunk_the_bubble_setup(_G, "R", "S")
MAP
.S     ..-
........x-.
.xx..x...-..
..xx...xx-x-
...xx.xx.---
.x.x...xxx-
...xx.xx---
S.xx...xx-R
...xx.xx---
.x.x...xxx-
...xx.xx.---
..xx...xx-x-
.xx..x...-..
........x-.
.S     ..-
ENDMAP

NAME: the_bubble_gammafunk_plus_minus
TAGS: the_bubble unrand
SUBST: x : bcvx
: gammafunk_the_bubble_setup(_G, "R", "S")
MAP
.S     ..-
.........--
..x..x..x---
.xxx.x-xxx--
..x..x--x---
.......----
..x..x..x--
S.x.xxx.x-R
..x..x..x--
.......----
..x..x--x---
.xxx.x-xxx--
..x..x..x---
.........--
.S     ..-
ENDMAP

NAME: the_bubble_gammafunk_crates
TAGS: the_bubble unrand
SUBST: A = a., D = d., E = e., F = f., H = h., J = j.,  P = p., Q = q., R = r.
SUBST: S = s., a : bcvx, d : bcvx, e : bcvx, f : bcvx, h : bcvx, j : bcvx
SUBST: k : bcvx, p : bcvx, q : bcvx, r : bcvx, s : bcvx, u = u.., u = bcvx
NSUBST: . = Z / .
: gammafunk_the_bubble_setup(_G, "y", "Z")
MAP
uu     u.-
....u...Ee-
.a.a.Dd.ee-u
..Aa.dd.S--u
.Aaa...-ss-u
u....hHh-s-
.fFf-hhh--u
.Fff------y
u...-kk-r-u
.jj..Kk.rr-
.Jjj.kk.Rr-u
.Jj.P....--u
.jj.ppp.qq-u
...u....Qq-
uu     u.-
ENDMAP

NAME: the_bubble_gammafunk_roulette
TAGS: the_bubble unrand
# Randomize orientation of transporter/landing site pairs, then where each pair
# resides, then were the exit transporter resides.
SHUFFLE: DFJM / LEHK, DL / FE / JH / MK, MD, MF, MJ
# Make transporter markers. Glyphs are set up so that each transporter takes
# you to a landing site other than the closest one. The shuffles above respect
# this property.
{{
local trans_glyphs = "DFJ"
local dest_glyphs = "EHK"
for i = 1, #trans_glyphs do
  lua_marker(trans_glyphs:sub(i,i), transp_loc("roulette_" .. tostring(i)))
  lua_marker(dest_glyphs:sub(i,i), transp_dest_loc("roulette_" .. tostring(i)))
end
}}
SUBST:  x : bcvx
: gammafunk_the_bubble_setup(_G, "L", "M")
MAP
..     ...
...-----...
...-E-F-....
...-----....
...x...x....
--xx...xx--
D-..x.x..-H
--...x...--
L-..x.x..-J
--xx...xx--
...x...x....
...-----....
...-M-K-....
...-----...
..     ...
ENDMAP

NAME: the_bubble_gammafunk_grid
TAGS: the_bubble unrand
SHUFFLE: AB
SUBST: A = b, B = ., C : .b, D : .b, E : .b
SHUFFLE: bv
: gammafunk_the_bubble_setup(_G, "R", "S")
MAP
.S     .v.
.v.v-v.v.vE
..v.v-v.vDv.
.v.vAv-vCv.v
..vAAAv-v.v.
.vBvAvBv-v.
vAvBvBvAv-v
AAAvBvAAAvR
vAvBvBvAv-v
.vBvAvBv-v.
..vAAAv-v.v.
.v.vAv-vCv.v
..v.v-v.vDv.
.v.v-v.v.vE
.S     .v.
ENDMAP
