###############################################################################
# slime.des: All maps and branch endings relating to the Slime Pits
###############################################################################

{{
function fixup_slime_vaults(data, triggerable, triggerer, marker, ev)
  if not dgn.persist.fix_slime_vaults then
    return
  end

  -- Restore teleport control.
  dgn.change_level_flags("!no_tele_control")

  local to_feat
  if you.god() == "Jiyva" and you.piety() > 160 then
    to_feat = "floor"
  else
    to_feat = "clear_rock_wall"
  end

  local seen = dgn.seen_replace_feat("stone_wall", to_feat)
        seen = dgn.seen_replace_feat("clear_stone_wall", to_feat) or seen

  if you.god() == "Jiyva" and you.piety() > 160 then
    if you.silenced() then
        crawl.mpr("An unexplained breeze blows through the dungeon.", "god")
    else
        crawl.mpr("You hear the sound of toppling stones.", "god")
    end
  else
    if seen then
        crawl.mpr("Suddenly, all colour oozes out of the stone walls.",
                  "monster_enchant")
    else
        crawl.mpr("You feel a strange vibration for a moment.",
                  "monster_enchant")
    end
  end

  local gxm, gym = dgn.max_bounds()
  for p in iter.rect_iterator(dgn.point(1, 1), dgn.point(gxm-1, gym-1)) do
    if dgn.fprop_at(p.x, p.y, "no_jiyva") then
      dgn.fprop_changed(p.x, p.y, "no_jiyva")
    end
  end

  -- We're done.
  dgn.persist.slime_fixup_done = true

  triggerable:remove(marker)
end
}}

##############################################################################
# Slime Pit entry vaults
##############################################################################

# Weight balancer
NAME: slime_dummy
TAGS: slime_entry
KFEAT: O = enter_slime_pits
MAP
O
ENDMAP

# Slime entries featuring an altar to Jiyva
NAME:   slime_altar_1
TAGS:   slime_entry
WEIGHT: 5
KFEAT:  Z = altar_jiyva
KFEAT:  O = enter_slime_pits
MAP
....
.OZ.
....
ENDMAP

NAME:   slime_altar_2
TAGS:   slime_entry
WEIGHT: 2
KFEAT:  Z = altar_jiyva
SUBST:  1 : 111223
NSUBST: 1 = 1 / 1. , 2 = 2 / 2... , 3 = 3 / 3....
MONS:   jelly / ooze / brown ooze / giant amoeba
MONS:   acid blob / slime creature w:5
MONS:   azure jelly
KFEAT:  O = enter_slime_pits
MARKER: + = lua:restrict_door({ \
            door_open_prompt="This door is covered in warnings. Open " .. \
                             "it anyway?", \
            door_description_prefix="warning-scrawled " \
         })
MAP
ccccc
c111m.
cO1_+@
c111m.
ccccc
ENDMAP

NAME:   minmay_slime_entry_eyes
TAGS:   slime_entry ruin_lair
WEIGHT: 2
MONS:   eye of devastation, eye of draining / giant eyeball
KFEAT:  O = enter_slime_pits
MAP
 ....   ....
..xx..x..xx..
.xxxx.x.xxxx.
.xxx..x..xxx.
..x.x...x.x..
 ...........
 xxx.1O2.xxx
 ...........
..x.x...x.x..
.xxx..x..xxx.
.xxxx.x.xxxx.
..xx..x..xx..
 ....   ....
ENDMAP

NAME:   minmay_slime_entry_pillars
TAGS:   slime_entry ruin_lair
MONS:   giant amoeba / brown ooze
KFEAT:  O = enter_slime_pits
MAP
...........
.ccc...ccc.
.ccc.1.ccc.
.ccc...ccc.
...........
..1..O..1..
...........
.ccc...ccc.
.ccc.1.ccc.
.ccc...ccc.
...........
ENDMAP

# In-game the boxes rarely stay closed due to ruination; this is intentional.
NAME:   minmay_slime_entry_jelly_boxes
TAGS:   slime_entry ruin_lair
WEIGHT: 5
MONS:   jelly / ooze w:1 / nothing w:1
KFEAT:  O = enter_slime_pits
MAP
.............
.xxxxx.xxxxx.
.xxx1x.x11xx.
.xx11x.xx1xx.
.xx1x...x1xx.
.xxxx....xxx.
......O......
.xxxx...xxxx.
.xx1.x.x.1xx.
.x11x.xx11xx.
.xx1x.xxxxxx.
.xxxxx.xxxxx.
.............
ENDMAP

NAME:   minmay_slime_entry_oklob_open
TAGS:   slime_entry
WEIGHT: 8
MONS:   oklob plant / nothing w:20
KFEAT:  O = enter_slime_pits
MAP
 .....
.......
..111..
..1O1..
..111..
.......
 .....
ENDMAP

NAME:   minmay_slime_entry_oklob_enclosed
TAGS:   slime_entry ruin_lair
ORIENT: northeast
WEIGHT: 2
MONS:   oklob plant / nothing w:20
KFEAT:  O = enter_slime_pits
MAP
xxxxxxxxxxxxxxxxxxxxx
xxxxxxxxx......xxxxxx
xxxxxx...........xxxx
xxx11.......xx....xxx
xxx11.....xxxx....xxx
xxxO11..xxxxx....xxxx
xxxx11xxxxxx.....xxxx
xxxxxxxxxxx.....xxxxx
xxxxxxxxxx.....xxxxxx
xxxxxxxx.....xxxxxxxx
xxxxxxx.@..xxxxxxxxxx
ENDMAP

##############################################################################
# Slime Pit specific non-ending non-entry vaults
##############################################################################

################################################################################
# Slime Pit
################################################################################
NAME:    slime_pit
PLACE:   Slime:6
ORIENT:  encompass
TAGS:    no_rotate no_dump
MONS:    the royal jelly
MONS:    acid blob
MONS:    great orb of eyes / nothing
SUBST:   ' : ' .:1,  ' : ' x:1,  ' = .x
SUBST:   " : " .:3,  " = .c
NSUBST:  P = O / *|
KMASK:   |O* = no_monster_gen
KPROP:   |O* = no_jiyva
KPROP:   |O* = no_rtele_into
KFEAT:   Z = altar_jiyva
KITEM:   O = slimy rune of Zot
KITEM:   * = star_item
SHUFFLE: ([{
LFLAGS:  no_tele_control

{{
-- Attach function to the royal jelly itself. This will follow it wherever
-- it goes, even through polymorphs, and set dgn.persist.royal_jelly_dead
-- when it dies through means other than being banished.
local function monster_die(monster, killer_type, killer_index, silent, wizard)
    if killer_type == "reset" then
       if monster.you_can_see then
          crawl.mpr("You feel a great sense of loss.")
       else
          crawl.mpr("You feel a great sense of loss, and a brush of " ..
                    "the abyss.")
       end
    else
      dgn.persist.fix_slime_vaults = true
    end
end
}}
MARKER: 1 = lua: MonPropsMarker:new {monster_dies_lua_key = monster_die}

{{
local fixup_marker = TriggerableFunction:new(
  {
    func="fixup_slime_vaults",
    repeated=true
  }
)

fixup_marker:add_triggerer(DgnTriggerer:new {
  type="monster_dies",
  target="any"
})

fixup_marker:add_triggerer(DgnTriggerer:new {
  type="entered_level"
})

}}
# Doesn't matter where thisw marker goes, so we might as well chose
# the altar.
: lua_marker("Z", fixup_marker)

{{
    dgn.set_feature_desc_short("stone wall", "rune carved stone wall")
    dgn.set_feature_desc_long("stone wall",
"This strangely slime-free stone wall is carved all over with countless "..
"mystical runes. One often repeated set of runes seems to refer to "..
"'the royal jelly.'")
}}
MAP
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx''''xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx''xxxx''''...''xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxxx'''..'''''........'''xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxxx'.....................'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxxx'.......................''x'xxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxxx'..........................'.xxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxx'............................'xxxxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxx'.............................'''xxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxx'...............................''xxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxx''..(..............................''xxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxx'''....................................''xxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxx'.........................................'xxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxx''.........................................'xxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxx'...........................................'xxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxx''xx'..........................................'xxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxx'..''................""""."""""...........]....''xxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxx'x.................."cccc2ccccc".................'xxxxxxxxxxxxxxxxx
xxxxxxxxxxxxx'.'................"cc*cc..cc*cc".................''xxxxxxxxxxxxxxx
xxxxxxxxxxxxx'................."cc***cc4c***cc".................xxxxxxxxxxxxxxxx
xxxxxxxxxxxxx'................"cc*|*cc..cc*|*cc"................'xxxxxxxxxxxxxxx
xxxxxxxxxxxx''..............."cc*|P|*c4cc*|P|*cc"...............'xxxxxxxxxxxxxxx
xxxxxxxxxxxx'................"cc**|*cc..cc*|**cc"................'''xxxxxxxxxxxx
xxxxxxxxxxxx'................"ccc**c|cc4c|c**ccc"..................xxxxxxxxxxxxx
xxxxxxxxxxx'................."cccccccc.3cccccccc"..................'xxxxxxxxxxxx
xxxxxxxxxxx'................."c.4.c.4.1..4.c.4.c"..................''xxxxxxxxxxx
xxxxxxxxxxx'..................2.c.4.c..Z.c.4.c.2....................'xxxxxxxxxxx
xxxxxxxxxx'..........)......."cccccccc3.cccccccc"...................'xxxxxxxxxxx
xxxxxxxxxx'.................."ccc**c|cc4c|c**ccc"...................'xxxxxxxxxxx
xxxxxxxxxx'.................."cc**|*cc..cc*|**cc"..................'xxxxxxxxxxxx
xxxxxxxxx'..................."cc*|P|*c4cc*|P|*cc"..................'xxxxxxxxxxxx
xxxxxxxxx''..................."cc*|*cc..cc*|*cc"..................'xxxxxxxxxxxxx
xxxxxxxxxxx'..................."cc***cc4c***cc"...................'xxxxxxxxxxxxx
xxxxxxxxxxxx'..................."cc*cc..cc*cc"....................'xxxxxxxxxxxxx
xxxxxxxxxxxx'...................."cccc2ccccc"....................'xxxxxxxxxxxxxx
xxxxxxxxxxxxx'...................."""".""""".....................'xxxxxxxxxxxxxx
xxxxxxxxxxxxx'...........................................[........'xxxxxxxxxxxxx
xxxxxxxxxxxx''..............................................'''....'xxxxxxxxxxxx
xxxxxxxxxxxx'.............................................''xxx''.'xxxxxxxxxxxxx
xxxxxxxxxxxxx'..........................................''xxxxxxx.xxxxxxxxxxxxxx
xxxxxxxxxxxxx'''.......................................'xxxxxxxxx.xxxxxxxxxxxxxx
xxxxxxxxxxxxxxxx'......................................'xxxxxxxxx'xxxxxxxxxxxxxx
xxxxxxxxxxxxxxxx'.......................................'xxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxx''.....................................'xxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxx'.....................................'xxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxx''....................................'xxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxx'...................................'xxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxx'............................}......'xxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxx''................................'xxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxx'.............................''xxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxxxxxx'.............................'xxxxxxxxxxxxxxxxxxxxxxxxx
xx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