##############################################################################
#
# The Sewer (Eino)
#
#
# The Sewer aspires to be an exciting place to go with a low level character.
#
# Flavour: drainage and sewer themed, so rats, kobolds, etc. Water is (dark
# and light) green.
# Gameplay: an early challenge, featuring monsters which are bland later but
# interesting when encountered at low level (green rat, giant frog etc.) Loot
# consists of renewable items; the harder maps contain a few good items.
#
##############################################################################

{{
function sewer_portal(e)
  local desc_long =
"Every settlement brings forth the unpleasant sewers and drains, ignored by "..
"most but hideaways for others. Old tales speak of dangerous creatures, "..
"bathing in disgustingly green water, preying on each other without mercy.  "..
"The tales also tell of the valuable items left by daring and unfortunate "..
"visitors, left to collect dust in the damp caverns. You have an uncanny "..
"feeling that the drain will fall apart rather soon."

  local timeout_turns = crawl.random_range(1500, 2000)

  local messager =
    timed_msg {
      visible = true,
      -- $F{xxx} will be substituted with the 'entity' property of the timed
      -- marker, or with the desc property (if entity is not set).
      messages = time_messages(timeout_turns,
                               "$F{The} is slowly rusting away.",
                               "$F{The} is rusting away.",
                               "$F{The} is quickly rusting away.",
                               "$F{The} is falling apart.")
    }

  e.lua_marker('O',
      timed_marker {
        disappear = "The drain falls to bits.",
        desc = "glowing drain",
        desc_long = desc_long,
        entity = 'drain',
        dst = "sewer",
        dstorigin = "in the sewers",
        overmap = "glowing drain",
        turns = timeout_turns,
-- floor seems better than empty stone arch
--        floor = "stone_arch",
        msg = messager })
  e.kfeat("O = enter_portal_vault")
  e.colour("O = lightgreen")
end

-- Use the following line in destination maps after all SUBSTs
-- : sewer_colours(_G)
-- Note that the function also defines < to be the exit portal.
function sewer_colours(e)
  e.kfeat("< = exit_portal_vault")
  e.colour("< = darkgrey")
  e.lrockcol("darkgrey")
  e.lfloorcol("lightgrey")
  e.colour("w = green")
  e.colour("W = lightgreen")
  e.lrocktile("wall_slime")
  e.lfloortile("floor_slime")
end
}}

# A standard random monster list for Sewer. Use:
# : sewer_random_monster_list(_G)
{{
function sewer_random_monster_list(e)
  e.set_random_mon_list("giant bat w:20 / giant newt w:20 / small snake / \
                         ooze / worm / snake / giant mosquito")
end
}}

# Add the milestone.
{{
function sewer_milestone(e)
  crawl.mark_milestone("br.enter", "entered a Sewer.")
end
}}

# Basic sewer entries ##########################################
default-depth: D:3-6

NAME:   portal_sewer_entry_a
TAGS:   uniq_sewer no_monster_gen mini_float
: sewer_portal(_G)
COLOUR: W = green / cyan w:5
SUBST:  1 = 11234444444444
MONS:   rat / grey rat / green rat w:5
MONS:   small snake / snake w:2
MONS:   giant cockroach / giant mite / worm w:3
MONS:   nothing
MAP
.........
...111...
..1WWW1..
.1WWWWW1.
.1WWOWW1.
.1WWWWW1.
..1WWW1..
...111...
.........
ENDMAP

NAME:   portal_sewer_entry_b
TAGS:   uniq_sewer no_monster_gen
ORIENT: float
: sewer_portal(_G)
SUBST:  '=W. , W=WW1
KMONS:  1 = rat w:20 / grey rat w:20 / green rat/ small snake / snake w:2 / \
            giant cockroach / giant mite / worm w:3
KFEAT:  1 = W
COLOUR: W = green
MAP
xxxxxx
xOWWW'
xWWWW.
xWWW'.
xWWW..
xW'...
ENDMAP

NAME:   portal_sewer_entry_c
TAGS:   uniq_sewer no_monster_gen
WEIGHT: 4
: sewer_portal(_G)
NSUBST: c = 2:= / 2:n / *:c
NSUBST: W = 8:1 / *:W
SUBST:  1 = 111W
KMONS:  1 = rat w:20 / grey rat w:20 / green rat/ small snake / snake w:2 / \
             giant cockroach / giant mite / worm w:3
KFEAT:  1 = W
COLOUR: W = green / cyan w:5
MAP
.........
.ccccccc.
.cWWWWWc.
.cWWOWWc.
.cWWWWWc.
.cWWWWWc.
.ccccccc.
.........
ENDMAP

NAME:	portal_sewer_entry_d
TAGS:   uniq_sewer no_monster_gen
: sewer_portal(_G)
KMONS:  1 = big fish
KFEAT:  1 = W
COLOUR: W = green / cyan w:5
MAP
xxxxxxxxxx
xWOW1WWWWW@
xxxxxxxxxx
ENDMAP

# The actual portal vaults #####################################
default-depth:

############################################################################
# Sewer with a small kobold camp, potion treasure and Ely/Zin altar.
# The easiest one, so most probable (5 out of 10 sewers).
#
NAME:     sewer_kobolds
TAGS:     sewer no_item_gen no_monster_gen no_pool_fixup
WEIGHT:   50
ORIENT:   encompass
: if crawl.one_chance_in(12) then
SUBST:    C=c, X=w, V=W, v=w, *=f
: else
SUBST:    X=c, C=x, V=x, v=x, *=x
: end
SUBST:    ' = .W
SUBST:    ? = .x
: sewer_colours(_G)
: sewer_random_monster_list(_G)
: sewer_milestone(_G)
# some fresh water for the kobolds
KFEAT:    Y = deep_water
KFEAT:    y = shallow_water
KFEAT:    E = altar_zin / altar_elyvilon w:30
KMONS:    q = big fish
KFEAT:    q = w
COLOUR:   q = green
MONS:     jackal / w:3 nothing, kobold / w:5 nothing, big kobold
SHUFFLE:  deef
ITEM:     potion of heal wounds / potion of healing
ITEM:     potion of healing / potion of healing q:2 w:5 / \
          potion of heal wounds / potion of heal wounds q:2 w:5
ITEM:     potion of restore abilities w:7 / potion of cure mutation / \
          potion of gain intelligence / potion of gain strength / \
          potion of gain dexterity
MONS:     rat / grey rat / green rat w:2 / nothing w:3
MAP
          xxxxxxxxxxxxxx
        cccCCCCCCCCCCCCxxx       xxxxx
        cwXvvvvvvvvvvvCCCxxxx   xxCCCxxx
        cwccCCCCCCCCCvvVCCCCxxxxxxC*CCCx
        cwwcxxxxxxxxCCCvvvvCCCCxxCCvvvCx
        ccwc       xxxCCCCvvvvCCCCvvvvCx
         cwcc        xxxxCCCCvvvvvvvvvCx
        ccwwc           xxxxCCCCCCCCCCCx
        cwwwc              xxxxxxxxxxxxx
        cwwwc
        cwwwc
        cWwwc
       ccWwWcc
       c.WwW.c
     ccc.WwW.c
     c<..WwW.c
     ccc.Www'c
       c.WwW.c
      cc'WwW'cc
      c.'WwW''ccccccccccccccccccccccccccccccccc
      c''WwWWWWWWWWWWWWWWWWWWWWWW..444.A.<..44c
      c''WwW''ccccccccccccccccccccccccccccccccc
      c.'WwW''c
      c.WWwWW'c
      c'WwwwW'c
      c'WwqwW'c
      c'WwwwW'c
      c.'WWW''c
      c..''''.c
xxxxxxcccc1ccccx
xefExxxx.122...xx
xdexxxx.2232.y..x
xx?.?xxx....yYy.x
 xx?.xxx?....y.xx
  x?x..?.?....xx
  xx???.xxxxxxx
   xxxxxx
ENDMAP

############################################################################
# Two fairly watery vaults with (usually) two giant frogs in the end.
# More rare (3 out of 10 sewers are one of these).
# Loot are good items, and often a scroll of blinking.
#
NAME:     sewer_frog_island_01
TAGS:     sewer no_item_gen no_monster_gen no_pool_fixup
ORIENT:   encompass
WEIGHT:   15
SUBST:    - = WWW.
SHUFFLE:  |d
ITEM:     scroll of teleportation w:2 / scroll of blinking / \
          scroll of random uselessness w:1
MONS:     giant newt / small snake w:5 / \
          generate_awake giant newt / generate_awake small snake w:5 / \
          snake w:4 / nothing w:4
NSUBST:   ! = 2:! / *:w
KFEAT:    ! = w
COLOUR:   ! = green
KMONS:    ! = giant frog / nothing w:2
: sewer_colours(_G)
: sewer_random_monster_list(_G)
: sewer_milestone(_G)
MAP
ccccccccccccccccccccccccccccccccccc
c.11---------.................1111c
c1WWW-ccccccccccccccccccccccc1WWW1c
c1WwWWccccccccccccccccccccccc1WwW.c
c1WwwWccccccccccccccccccccccc.WwW.c
c.WwW1ccccccccccccccccccccccc.WwW-c
c.WwwWccccccc!!!!!!cccccccccc-WwW-c
c.Wwwwccccwwwwwwwww!!!ccccccc-WwW-c
c-WwwwccwwwWwwwwwwwwww!cccccc-WwW-c
c-WwwwcwwWW<-wwwwwwwwww!ccccc-WwW-c
c-Wwwwwwww-..-ww.--wwwww!cccc-WwW-c
c-WwWwwWww---.-.*.--wwwwwcccc-WwW-c
c-WwWWWwWww-.--*|*.wwwwwwcccc-WwW.c
c-WwWWwwwWww.---d-wwwwwwwcccc-WwW.c
c-WwWWWwwwW------wwwwwwwwcccc.WwW.c
c-WwWWWwwwwW---wwwwwwWwwccccc.WwW.c
c-WwW.WwwwwwwwwwwwwwWwwwccccc-WwW.c
c.WwW.WwwwwwWWwwwwwwwWccccccc-WwW-c
c.WwWW..WWWWwwWwWW.........---Www-c
c.WwwWWWWwwwWWwWWWWWWWWWWWWWWWWwW-c
c.WWwwwwwwwwwwwwwwwwwwwwwwwwwwwwW.c
c..WWWWWWWWWWWWWWWWWWWWWWWWWWWWwW-c
cc........................----WwW-c
 cccccccccccccccccccccccccccc-WwW-c
                     cccccccc-WwW-c
              cccccccc.----WWWWwW.ccccxxx
              c.<.A..--W-WWWWWWwwwwwwwwwx
              cccccccc.-..WW-.WWW1cccccxx
                     cccccccc11111c
                            ccccccc
ENDMAP

NAME:     sewer_frog_island_02
TAGS:     sewer no_item_gen no_monster_gen no_pool_fixup
ORIENT:   encompass
WEIGHT:   15
NSUBST:   ! = 2:! / *:w
SUBST:    - = WWWW.
KMONS:    W = giant newt / small snake / snake w:2 / jelly w:1 / \
              nothing w:250
KFEAT:    W = W
KFEAT:    ! = w
COLOUR:   ! = green
KMONS:    ! = giant frog / nothing w:2
SHUFFLE:  edfgh$|
ITEM:     any good_item, any good_item
ITEM:     scroll of teleportation w:2 / scroll of blinking / \
          scroll of random uselessness w:1
ITEM:     nothing, nothing
: sewer_colours(_G)
: sewer_random_monster_list(_G)
: sewer_milestone(_G)
MAP
           ccccccccccccc
        cccc-----------cccc
     cccc-----------------cccc
    cc-------ccccccccc-------cc
   cc-----cccc-------cccc-----cc
  cc----ccc-------------ccc----cc
  c----cc-----ccccccc-----cc----c
 cc---cc----ccc!!!!!ccc----cc---cc
 c----c----cc!w---ww!!cc----c----c
cc---cc---ccw--..---ww!cc---cc---c
c.---c----cw--.gh|.---w!c----c---c
c<.--c----c--.edf.-----!c----c---c
c.---c----c----$------w!c----c---c
cc---cc---c---.------w!cc---cc---c
 c----c---c--.------w!cc----c----c
 cc---cc--cc--c---wwccc----cc---cc
  c----cc--c--ccccccc-----cc----c
  cc----c--cc-..--------ccc----cc
   cc-------c..------cccc-----cc
    cccc---ccccccc-<-c-------cc
       cc--c-----ccccc----ccccc
        cccc-----------cccc--<c
           c---ccccccccc-...-cc
           c-----------..A.ccc
           c----------.ccccc
           ccccccccccccc
ENDMAP

############################################################################
# The hardest one, and most rare (1 out of 10). Loot is good items.
#
NAME:     sewer_big_baddie
TAGS:     sewer no_item_gen no_monster_gen
ORIENT:   encompass
: sewer_colours(_G)
: sewer_random_monster_list(_G)
: sewer_milestone(_G)
SUBST:    2 = 23
KMONS:    2 = giant lizard
KMONS:    3 = Purgy, giant lizard
ITEM:     potion of berserk rage / potion of speed w:5
MONS:     giant bat / giant mosquito w:2
MAP
 ccccccc
:c$*|*$cc
c..$*$..c
c.......c
c...2...c
c.......c
c.......c
cc.....cc
 ccc.ccc     ccccccc
   c.c      cc1.1..cc
   c.c     cc1..w...cc
   c.ccccccc...www...cc
   c..........wwwww.A.c
   c.ccccccc1..www...cc
   c.c     cc...w...cc
   c.c      cc1....cc
   c.c       ccccccc
   c.c
   c.c
   c.c
   c<c
   c.c
   cdc
   ccc
ENDMAP

###############################################################################
# If you can get to the middle, there are four doors to try; two will give you
# monsters, two will yield you treasure. As rare as the last one (1/10).
#
NAME:     sewer_fruit_machine
TAGS:     sewer no_item_gen no_monster_gen no_pool_fixup
ORIENT:   encompass
SHUFFLE:  QEDS
SUBST:    Q = 4, E = 5, D : fgh, S = $
NSUBST:   f = 1:f / *:'
NSUBST:   g = 2:g / *:'
NSUBST:   h = 3:h / *:'
# some random monsters I: flying or big fish
NSUBST:   w = 4:" / *:w
KFEAT:    " = w
KMONS:    " = big fish w:2 / giant bat / giant mosquito w:2 / nothing
COLOUR:   " = green
# some random monsters II: standard Sewers set
NSUBST:   W = 4:? / *:W
KFEAT:    ? = W
KMONS:    ? = giant bat / giant newt / small snake / ooze w:2 / worm w:2 / \
          snake w:1 / giant mosquito w:2
COLOUR:   ? = lightgreen
# a little more random shallow water
SUBST:    - = W..
: sewer_colours(_G)
: sewer_random_monster_list(_G)
: sewer_milestone(_G)
MONS:     giant bat / giant newt / small snake / ooze w:2 / worm w:2 / \
          snake w:1 / giant mosquito w:2
SHUFFLE:  23
MONS:     giant bat / giant mosquito w:2 / nothing w:2
MONS:     patrolling jackal
MONS:     worm / nothing w:3
MONS:     ooze / nothing w:2
# chances are good you'll find something to cross the deep water
SHUFFLE:  de
ITEM:     scroll of fear / scroll of fog / scroll of teleportation w:50 / \
          scroll of blinking / scroll of identify / nothing
ITEM:     potion of levitation w:50 / potion of invisibility / \
          potion of might w:3 / potion of agility w:4 / \
	  potion of brilliance w:3 / nothing
# possibly rather generous loot, if you get to the center
ITEM:     scroll of vulnerability / scroll of identify / wizard hat / \
          potion of magic / potion of brilliance / potion of resistance
ITEM:     scroll of identify / scroll of recharging / potion of invisibility / \
          pair of gloves w:5 / pair of boots w:5 / potion of agility / nothing
ITEM:     scroll of identify / scroll of recharging / \
          potion of resistance / potion of might / potion of berserk rage / \
          buckler / nothing
KITEM:    ' = scroll of paper w:50 / scroll of random uselessness w:30 / \
              scroll of identify / scroll of teleportation / \
              potion of confusion w:50 / potion of paralysis w:50 / \
              potion of mutation / potion of levitation / \
              wizard hat / buckler / pair of gloves w:5 / pair of boots w:5
MAP
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
xwwwwwwwwwwwWWW-WW-W--WWWWW-WWW--W--WW-WW-WW-W-WWwwwwwwwwwwwx
xwwwwwwwwwww-wwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww-wwwwwwwwwwwx
xwwwwwwwwwwwWwWW----WWWWWWWW-W-WWW-W-WW-WW-W-WWwWwwwwwwwwwwwx
xxxxxxxxxxxxWwWxxxxxxxxxxxxxxxxxxxxxxxWwWxxxxxWwWxxxxxxxxxxxx
           xWwWxxxxxxxxxxxxxxxxxxxxxxxWwWxxxxxWwWxxxxxxxx.1.xx
           x-wWxxxxQQQQxxxDDDDxxxxxxxxWwWxxxxx-wWxxxx1xx....1xx
           xWwWxxxxx++xxxxx++xxxxxxxxx-wWxxxxxWwW--W-.........x
           x-wWW-W..............<xxxxxWw-xxxxxWwWWW-1....A...1x
           x-wWWW--.............<xxxxxWwWxxxxxWwWW-.xxxx......x
           xWwWxxxxx++xxxxx++xxxxxxxxxWwWxxxxx-wWxxxxxxxxx.<xxx
           x-wWxxxxEEEExxxSSSSxxxxxxxx-w-xxxxxWw--xxxxxxxxxxx
   xxxxxxx x-wWxxxxxxxxxxxxxxxxxxxxxxxWwWxxxxxWw-xxxxxxxxxxxx
 xxx.d..dxxxWwWxxxxxxxxxxxxxxxxxxxxxxxWwWxxxxx-wWxxxxxxxxx.exx
xx.3...d.dxxWwWWWWWW---WW-W-WW-W-WWWW--wWxxxxxWwWxxxxxxxx-22ex
x.3....dxxxx-w-wwwwwwwwwwwwwwwwwwwwwww-w-xxxxxWwWWWWWWWW---2.ex
xx3...xxxxxxWwWW-W-WWW-W-W-WWWWW-WWWWWWw-xxxxxWw-wwwwwwww---2.x
 x3-...-xxxx-w-xxxxxxxxxxxxxxxxxxxxxxxWwWxxxxx-wWWWWWWW-----..x
 xxx------xxWwWxxxxxxxxxxxxxxxxxxxxxxxWwWxxxxxWwWxxxxxxxxx-.exx
xxxxxx------WwWxxxxxxxxxxxxxxxxxxxxxxxWwWxxxxxWwWxxxxxxxxxxxxx
xwwwwww--WWwwwWWWW-W-W-W-W-WWWW-W-W-W-W-WW---WWwwwwwwwwwwwwwx
xwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwx
xwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwx
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ENDMAP