###############################################################################
# altar.des: This is the place where minivaults (and floating vaults)
#            containing altars should go. Vaults particular to a specific
#            branch (Beogh altar minivaults for Orc:*, for example), may
#            go in the corresponding des-file. A few entry vaults contain
#            altars; these should always be in entry.des.
#
# Altar vaults do not just provide flavour. They are crucial for ensuring
# that granted gods without altars in the Temple will be present in the
# early part of the dungeon. Such altars are called "overflow temples".
# Sometimes, ordinary altar maps featuring a single C glyph (random altar)
# are used. However, there are also vaults dedicated to a special god.
# These look much more interesting, of course.
# There are two TAGs to be used for single-altar maps with a specified god:
#
# TAG: temple_overflow_FOO
#      Says the map will only ever be used for overflow temples to god FOO.
# TAG: uniq_altar_FOO
#      If you also add this, then the map can be placed randomly even if
#      that altar has been chosen at new-game time to be an overflow temple
#      on a specific level. If it happens to be randomly placed before being
#      generated specifically then it will only be placed once, rather than
#      being placed a second time at the location chosen at new-game time.
#
# And there is a TAG if you want a single-altar map to a random god:
#
# TAG: temple_overflow_1
#      Allows any of the overflow temple altars to be used.
#      For this, use one B glyph in your map.
#
# If you want to check overflow temple placement in wizard mode, use the &:
# command. The levels overflow temples are placed on, and which gods are
# in them, are chosen at new-game time.
#
###############################################################################

default-depth: D

######################################
# I    Temples (Multi-altar vaults)
######################################

NAME:    jmf_multi_god_temple
SHUFFLE: abc
SUBST:   a:=, b:x, c:x
DEPTH:   D:8-21, Vault
MAP
............
.axxxxxxxxa.
.x9......9x.
.bT......Tb.
.x..C..C..x.
.cT......Tc.
.xxxxmmxxxx.
.xxx$$$$xxx.
.xx8....8xx.
..xx....xx..
...xG..Gx...
............
ENDMAP

NAME:  jmf_multi_god_temple2
DEPTH: D:8-21, Vault
MAP
............
..vvvvvvvv..
.vv......vv.
.v..x..x..v.
.v.Cx..xC.v.
.v..x..x..v.
.vT8x..x8Tv.
.vvvx==xvvv.
...Gx99xG...
...+*99*+...
...GxxxxG...
............
ENDMAP


######################################
# II   General altars
######################################

NAME: old_standard_altar
TAGS: allow_dup
SHUFFLE: cvxxxx
MAP
...........
.xxxx.xxxx.
.xx.....xx.
.x.......x.
.x.......x.
.....C.....
.x.......x.
.x.......x.
.xx.....xx.
.xxxx.xxxx.
...........
ENDMAP

NAME:    lemuel_round_altar
TAGS:    allow_dup
SHUFFLE: cvxx
SUBST:   X:x.
MAP
   xxXxx
  xx...xx
 xx.....xx
 x.......x
 X...C...@
 x.......x
 xx.....xx
  xx...xx
   xxXxx
ENDMAP

NAME: lemuel_crystal_altar
TAGS: allow_dup
MAP
b.b
.C.
b.b
ENDMAP

NAME:   lemuel_altar_in_water
DEPTH:  D:2-18, Swamp, Shoals
WEIGHT: 9
: local brnd = crawl.random2(13)
: if brnd > 10 then
TAGS:   no_monster_gen no_rotate
# this case almost always has altar access
: else
TAGS:   no_monster_gen no_pool_fixup no_rotate
: end
MAP
   .........
  ...wwwww...
 ..wwwwwwwww..
..wwwwwwwwwww..
.wwwwwwwwwwwww.
.wwwwwwCwwwwww.
.wwwwwwwwwwwww.
..wwwwwwwwwww..
 .wwwwwwwww..
 ...wwwww...
   ........
ENDMAP

NAME:   lemuel_altar_in_water2
TAGS:   no_pool_fixup no_monster_gen
DEPTH:  D:2-18, Lair, Snake, Swamp, Shoals
WEIGHT: 1
MAP
   www
  wwwww
 wwwwwww
 @..Cwww
 wwwwwww
  wwwww
   www
ENDMAP

NAME:  lemuel_oklob_altar
DEPTH: D:6-18, Lair, Snake, Shoals
MONS:  oklob plant, plant
MAP
 2
2C1
 2
ENDMAP

NAME:    lemuel_hidden_altar
DEPTH:   D:1-18, Vault, Lair, Elf, Crypt
SHUFFLE: XY
SUBST:   X = .
SUBST:   Y = =
MAP
.........
.xxxXxxx.
.xxx.xxx.
.xxxYxxx.
.X.YCY.X.
.xxxYxxx.
.xxx.xxx.
.xxxXxxx.
.........
ENDMAP

NAME:   lemuel_sealed_altar_a
WEIGHT: 3
DEPTH:  D:2-18, Vault, Elf, Crypt
MAP
xxxxxxxxxxxxx
x...........x
x...........x
x...........x
x...........x
x.....>.....x
x.....C.....x
x...........x
x...........x
x...........x
x...........x
xxxxxxxxxxxxx
ENDMAP

NAME: lemuel_sealed_altar_b
WEIGHT: 7
DEPTH: D:2-18, Vault, Elf, Crypt
MAP
xxxxxxxxxxx
x.........x
x.........x
x....>....x
x....C....x
x.........x
x.........x
xxxxxxxxxxx
ENDMAP

NAME:  lemuel_tele_altar
DEPTH: D:2-18, Vault
SUBST: Y = X x
KFEAT: X = teleport trap
MAP
.............
.xxxxxXxxxxx.
.x.........x.
.x.........x.
.x.........x.
.Y....C....Y.
.x.........x.
.x.........x.
.x.........x.
.xxxxxYxxxxx.
.............
ENDMAP

NAME:  lemuel_statue_altar
DEPTH: 2-18, Vault, Elf
: if you.absdepth() < 10 then
SUBST: F = G
: end
SUBST: F = G:100 F:1
KMONS: F = orange crystal statue / silver statue / ice statue
MAP
.........
.ccccccc.
.F...>Cc.
.ccccccc.
.........
ENDMAP

NAME:   lemuel_coloured_pillars_altar
DEPTH:  D:2-18, Vault, Elf
TAGS:   no_rotate
COLOUR: c = blue / yellow / red / cyan
MAP
xxxxxxxxxxxxxxxxxxxx
...................x
c...c...c...c...c..x
@.................Cx
c...c...c...c...c..x
...................x
xxxxxxxxxxxxxxxxxxxx
ENDMAP

NAME:   lemuel_upstairs_altar
DEPTH:  D:2-12, Vault, Elf, Crypt
ORIENT: float
SUBST:  T:T., )=)}], c:ccx
KMASK:  T = no_monster_gen
MAP
ccccccc
cT...Tc
c.....ccccccc
c..C..+....)c
c.....ccccccc
cT...Tc
ccccccc
ENDMAP

######################################
# III  Special altars
######################################

NAME:  lemuel_angel_altar
DEPTH: D:3-18, Vault
: if you.absdepth() > 12 then
MONS: patrolling Daeva / patrolling Angel
: else
MONS:  patrolling Angel
: end
KFEAT: _ = altar_elyvilon / altar_zin / altar_shining_one
MAP
   .....
  ..xmx..
 ..xx>xx..
..xxx.xxx..
.xxxx1xxxx.
.m>.._..>m.
.xxxx.xxxx.
..xxx.xxx..
 ..xx>xx..
  ..xmx..
   .....
ENDMAP

NAME:  lemuel_hellish_altar
DEPTH: D:2-21, Crypt, Geh
TAGS:  no_monster_gen
MONS:  iron devil/orange demon, beast/rotting devil, lemure/iron imp, hellion
SUBST: 2 = 23
SUBST: 2 = 12
SUBST: 3 = 3L
: if you.absdepth() >14 then
SUBST: 1 = 1:20 4
: end
SUBST: L = l.
SUBST: _ = _ P:1
KFEAT: _ = altar_lugonu/altar_yredelemnul/altar_kikubaaqudgha/altar_makhleb
KFEAT: P = enter_abyss
MAP
  ..LLllLL....
  .LllllllLLL..
..Lll323lllLLL.
.LLl32123lllLL.
.LLl33_33llLL..
..Lll323llLL...
..LLll3llL.....
...LLlllL...
....LLLL....
   ..LLLLL..
   ....LLLL.
ENDMAP

NAME:  david_defended_altar_orc
DEPTH: D:7-20, Orc
MONS:  patrolling orc priest
TAGS:  uniq_defended_altar
KFEAT: _ = altar_beogh / w:1 altar_okawaru / w:1 altar_makhleb / w:1 altar_trog
MAP
ccccc...
c1..c...
c1_.+.I@
c1..c...
ccccc...
ENDMAP

NAME:  david_defended_altar_elf
DEPTH: D:7-20, Elf
MONS:  patrolling deep elf priest / w:30 nothing
TAGS:  uniq_defended_altar
MAP
ccccc...
c1..c...
c1C.+.G@
c1..c...
ccccc...
ENDMAP

# The mix of deep and shallow water is intended to keep the centaurs from
# escaping without requiring the player to be able to cross deep water.
NAME:  lemuel_centaur_altar
DEPTH: D:7-20, Shoals, Lair
TAGS:  no_pool_fixup no_monster_gen
MONS:  patrolling centaur
MAP
xxxxxxxxxxxxx
xxxxxxxxxxwxx
xxwx.1.1.xxwx
xwxx1.C.1xwwx
xwwxWwwWwWwxx
xwwWwwwwwwxxx
xxwWwWWwwWxxx
xxxwWwwWwxxxx
xxxwwwWwWxxxx
xxx...@..xxxx
ENDMAP

NAME:   lemuel_mausoleum_altar
DEPTH:  D:7-20, Crypt
MONS:   w:50 human zombie/orc zombie/elf zombie/w:5 ogre zombie/w:5 troll zombie
MONS:   w:50 human skeleton/orc skeleton/elf skeleton/w:5 ogre skeleton/\
        w:5 troll skeleton
MONS:   mummy, wight, wraith, necrophage, ghoul
NSUBST: ? = 1:_ / *:1
SUBST:  1 = 1:25 2 3 4:8 5:6 6:4 7:2
KFEAT:  _ = altar_kikubaaqudgha / altar_yredelemnul
KMONS:  _ = human zombie
MAP
ccccccccccccccc
c?c?c?c?c?c?ccG
c+c+c+c+c+c+ccc
c............+@
c+c+c+c+c+c+ccc
c?c?c?c?c?c?ccG
ccccccccccccccc
ENDMAP

###################################################################
# Nemelex altar (Shiori)
# Perhaps could have different parameters for the two types of clouds,
# and different patterns.
NAME:   nemelex_altar_shiori
DEPTH:  !Lair, !Orc
TAGS:   no_pool_fixup no_monster_gen no_item_gen
TAGS:   generate_awake patrolling mini_float no_rotate
TAGS:   layout_rooms layout_city layout_open layout_cross
KFEAT:  _ = altar_nemelex_xobeh
SUBST:  b:aa. , a:n. , d:c. , c:nn. , f:ee. , e:nn. , h:g. , g:n.
SUBST:  G:GTUVblw> , C=c
KFEAT:  z = teleport trap
MARKER: R = lua:fog_machine { cloud_type="flame", walk_dist=1, size=9, \
            pow_max=20, delay=10, buildup_amnt=14, buildup_time=7, \
            spread_rate=3, start_clouds=1 }
MARKER: B = lua:fog_machine { cloud_type="foul pestilence", walk_dist=1, \
            size=9,  pow_max=20, delay=10, buildup_amnt=14, buildup_time=7, \
            spread_rate=3, start_clouds=1 }
MAP
CCCCCCCC+++CCCCCCCC
Cnnnnnnn...nnnnnnnC
Cnab'ban...ncd'dcnC
Cnb...bn.G.nd...dnC
Cn'.B..n...n..R.'nC
Cnb...bn...nd...dnC
Cnab.ban...ncd.dcnC
Cnnnnnnn...nnnnnnnC
CG......._.......GC
Cnnnnnnn...nnnnnnnC
Cnef.fen...ngh.hgnC
Cnf...fn...nh...hnC
Cn'.R..n...n..B.'nC
Cnf...fn.G.nh...hnC
Cnef'fen...ngh'hgnC
Cnnnnnnn...nnnnnnnC
CCCCCCCC+++CCCCCCCC
ENDMAP

###################################################################
# Distorted/chaotic kobolds (Jude)
NAME:       due_chaos_kobolds
DEPTH:      D:13-27, Vault, Elf, Crypt
TAGS:       no_rotate
ORIENT:     float
SUBST:      y  = c.
COLOUR:     1. = random
MARKER:     P  = lua:fog_machine { cloud_type="blue smoke", walk_dist=1, \
            size=9, pow_max=20, delay=10, buildup_amnt=14, buildup_time=7, \
            spread_rate=3, start_clouds=1, colour="blue" }
: if crawl.coinflip() then
KFEAT:      _ = altar_lugonu
KFEAT:      P = enter_abyss
: kmons("1 = kobold w:" .. you.absdepth() .. " ; quick blade ego:distortion " ..
:       "w:6 | sabre ego:distortion | short sword ego:distortion / kobold "   ..
:       "w:80 ; short sword | sabre | quick blade w:3")
: else
KFEAT:      _ = altar_xom
:   if crawl.one_chance_in(4) then
KMONS:      P = orange crystal statue
:   else
KFEAT:      P = enter_abyss / fountain_sparkling / stone_arch
:   end
: kmons("1 = kobold w:" .. you.absdepth() .. " ; quick blade ego:chaos " ..
:       "w:6 | sabre ego:chaos | short sword ego:chaos / kobold w:80 ;"  ..
:       "short sword | sabre | quick blade w:3")
: end
MAP
  ccccc
 cc...cc
cc..P..cc
 cc...cc
 ccc.cccc
ccyy.yyyccc
cy..111.yyc
cc..1_1..cc
cyy.111..yc
cccyy..yycc
  ccc..ccc
    c++c
     @@
ENDMAP

###############################################################################
# Altars to the good gods by TGW.
NAME:    tgw_good
DEPTH:   5-27
TAGS:    no_item_gen no_monster_gen
SHUFFLE: XYZ
KFEAT:   X = altar_shining_one
KFEAT:   Y = altar_elyvilon
KFEAT:   Z = altar_zin
COLOUR:  a = darkgrey / red / blue w:3 / lightred w:2
COLOUR:  b = darkgrey w:100 / red w:50 / lightgrey / blue w:30 / cyan / lightred
COLOUR:  c = darkgrey w:7 / red w:2 / lightgrey w:4 / blue w:4 / cyan w:2
COLOUR:  d = darkgrey w:4 / lightgrey w:4 / blue / cyan w:4
COLOUR:  e = blue / cyan w:4
COLOUR:  f = blue / cyan w:7
SUBST:   abcdef = w
SUBST:   G = ...BBC
NSUBST:  H = 2:C / *:H
SUBST:   H = .BBCCC
COLOUR:  B = white
COLOUR:  C = yellow
SUBST:   B = .
NSUBST:  C = 1:M / 3:d / *:.
ITEM:    any scroll / scroll of holy word
MONS:    human; falchion / human; falchion ego:holy_wrath w:1 \
         / human; quarterstaff / human; quarterstaff ego:holy_wrath w:1 \
         / human
MONS:    gnoll; falchion / gnoll; falchion ego:holy_wrath w:1 / gnoll; \
         quarterstaff / gnoll; quarterstaff ego:holy_wrath w:1 / gnoll
MONS:    orc; falchion / orc; falchion ego:holy_wrath w:1 \
         / orc; quarterstaff / orc; quarterstaff ego:holy_wrath w:1 / orc
SUBST:   M = 123
MAP
                xxxxxxxxxxxxx
               xxaaaaaaaaaaaxx
              xxbbbbbbbbbbbbbxx
             xxcccccccccccccccxx
            xxdddddddddddddddddxx
           xxeeeeeeeeeeeeeeeeeeexx
xxxxxxxxxxxxfffffffffffffffffffffxx
x..........GGGGGGHHHHHHHHHHHGGGGGGxx
@..........GGGGGGHHHXHHYHHZHHHGGGGGGx
x..........GGGGGGHHHHHHHHHHHGGGGGGxx
xxxxxxxxxxxxfffffffffffffffffffffxx
           xxeeeeeeeeeeeeeeeeeeexx
            xxdddddddddddddddddxx
             xxcccccccccccccccxx
              xxbbbbbbbbbbbbbxx
               xxaaaaaaaaaaaxx
                xxxxxxxxxxxxx
ENDMAP

NAME:  jiyva_altar_1
DEPTH: D:2-20
KFEAT: _ = altar_jiyva
MONS:  jelly
MAP
.....
..1..
.1_1.
..1..
.....
ENDMAP

NAME:  jiyva_altar_2
DEPTH: D:2-20
KFEAT: _ = altar_jiyva
KITEM: 1 = dart
KMONS: 1 = jelly
ITEM:  dart
MAP
xxxxx
xdddx
x<_1x
xdddx
xxxxx
ENDMAP

NAME:  fedhas_bush_and_centaur_altar
DEPTH: 3-27
KFEAT: _ = altar_fedhas
MONS:  centaur, bush
MAP
......
.2222..
.21222.
.22_22.
...22..
.222..
ENDMAP

NAME:   tgw_lugonu_bribe
DEPTH:  D:12-27
KFEAT:  _ = altar_lugonu
MARKER: _ = lua:portal_desc {slave_name="altar"}

{{
function lugonu_item (data, triggerable, triggerer, marker, ev)

  if data.triggered == true then
    return
  end

  local m = dgn.find_marker_positions_by_prop("slave_name", "altar")[1]
  if m ~= nil then
    local x, y = m:xy()

    if not you.see_cell(x, y) then
      return
    end

  local weapon = util.random_from({"short sword", "sabre",
                 "long sword", "scimitar", "glaive", "bardiche",
                 "broad axe", "battleaxe", "quarterstaff",
                 "lajatang", "morningstar", "great mace"})
  local item = { Beogh="good_item battleaxe ego:orc_slaying / disc of storms \
         / good_item broad axe ego:orc_slaying w:5 / scroll of immolation q:3-6 / scroll of fear q:3-6",
         Cheibriados="wand of hasting w:5 / potion of speed q:2-4 / potion of berserk rage q:2-4 \
         / good_item quick blade",
         Elyvilon="lantern of shadows/ rod of demonology / book of Necromancy w:5 \
         / book of Death w:5 / book of Unlife w:5 / book of Callings w:5 / book of Summonings w:5",
         Fedhas="book of Necromancy / book of Death / book of Unlife / good_item "
         .. weapon .. " ego:draining / good_item " .. weapon .. " ego:pain",
         Jiyva="no",
         Kikubaaqudgha="no",
         Lugonu="no",
         Makhleb="tome of destruction / rod of demonology",
         ["Nemelex Xobeh"]="no",
         Okawaru="lantern of shadows / book of Callings / book of Summonings / rod of demonology \
         / rod of summoning",
         ["Sif Muna"]="staff of channeling / good_item plate mail \
         / randbook owner:Lugonu disc:ench spell:selective_amnesia numspells:1",
         ["The Shining One"]="wand of invisibility w:20 / book of Envenomations \
         / Young Poisoner's Handbook / rod of venom / book of Necromancy w:5 / book of Death w:5 \
         / book of Unlife w:5",
         Trog="manual of Spellcasting w:100 / manual of Air Magic / manual of Earth Magic \
         / manual of Fire Magic / manual of Ice Magic / manual of Poison Magic / any staff / ring of wizardry",
         Vehumet="manual of Invocations",
         Xom="manual of Invocations",
         Yredelemnul= "scroll of holy word q:2-4 / good_item " .. weapon .. " ego:holy_wrath",
         Zin="book of Necromancy w:5 / book of Death w:5 / book of Unlife w:5 \
         / potion of gain intelligence q:2-3 / potion of gain strength q:2-3 / potion of gain dexterity q:2-3 \
         / potion of cure mutation q:2-3 / wand of draining w:7 / wand of polymorph other w:14 \
         / amulet of resist mutation",
         ["No God"]="manual of Invocations / amulet of Faith"
       }
         data.triggered = true
         if item[you.god()] == "no" then return else
            dgn.place_cloud(x, y, "purple smoke", 1)
            dgn.create_item(x, y, item[you.god()])
            crawl.god_speaks("Lugonu", "An item emerges from the Abyss! Perhaps it is an incitement to worship... or even an insult?")
         end
  end
end

local tm = TriggerableFunction:new{func=lugonu_item, repeated=true, data={turns=you.turns(), tc=0, triggered=false} }
tm:add_triggerer(DgnTriggerer:new{type="player_los"})
lua_marker('_', tm)
}}

MAP
_
ENDMAP

######################################
# IV   Overflow altars
######################################
#
# These must feature one of the temple_overflow_* TAGs (see header).
# Altars are sorted alphabetically by god, with The Shining One coming
# after Zin. At the end, there are altar vaults which can be used for
# more than just one god.
#
######################################

### Cheibriados overflow altars ###############################################

NAME:   cheibriados_altar_1
TAGS:   uniq_altar_cheibriados temple_overflow_cheibriados
KFEAT:  _ = altar_cheibriados
MAP
...
._.
...
ENDMAP

NAME:    cheibriados_altar_2
TAGS:    uniq_altar_cheibriados
DEPTH:   D:2-20
WEIGHT:  1
KFEAT:   _ = altar_cheibriados
MONS:    giant slug, giant snail, elephant slug
SUBST:   1 : 1:50 2:30 3:10 4:10
NSUBST:  4 = 1:1 / 1:2 / 1:3
MAP
.......
.mmm...
.m1m...
.mmmmm.
.._m1m.
.mmmmm.
.m1m...
.mmm...
.......
ENDMAP

NAME:   cheibriados_altar_3
TAGS:   uniq_altar_cheibriados temple_overflow_cheibriados
DEPTH:  D:2-6
KFEAT:  _ = altar_cheibriados
ITEM:   potion of slowing
ITEM:   apple, pear, orange, banana
SUBST:  e : efgh
MAP
.d.
e_e
.d.
ENDMAP

# Golems are slow and they protect an altar to the slow god. (Lemuel)
NAME:  golem_altar_1
DEPTH: 8-12
TAGS:  patrolling no_monster_gen no_item_gen
TAGS:  uniq_golem_altar temple_overflow_cheibriados
KMONS: _ = iron golem
KFEAT: _ = altar_cheibriados
SUBST: x : xxxcccmnvb
MAP
xxx.....xxx
xxx.....xxx
xxx.....xxx
...........
...........
....._.....
...........
...........
xxx.....xxx
xxx.....xxx
xxx.....xxx
ENDMAP

NAME:    golem_altar_2
DEPTH:   8-12
TAGS:    patrolling no_monster_gen no_item_gen
TAGS:    uniq_golem_altar temple_overflow_cheibriados
KMONS:   _ = iron golem
KFEAT:   _ = altar_cheibriados
SHUFFLE: ac / XX / XX
SHUFFLE: bd / XX / XX
SUBST:   a = = , c = * , b = = , d = *
SUBST:   X : x
SUBST:   x : xxxcccvb
MAP
x..G..x
x.....x
x.....x
xx+++xx
x.....x
x.....x
x.....x
x.....x
x.._..x
xaxxxbx
xcxxxdx
xxxxxxx
ENDMAP

### Elyvilon overflow altars ##################################################

NAME:   elyvilon_altar_1
TAGS:   uniq_altar_elyvilon temple_overflow_elyvilon
DEPTH:  D:2-20
KFEAT:  C = altar_elyvilon
SUBST:  X : T G t 1 2 3
MONS:   plant, bush, fungus
KMASK:  T = no_monster_gen
MAP
      xx@xx
      x...x
      x.X.x
      x...x
      xx.xx
       x.x
xxxxx xx.xx xxxxx
x...xxx...xxx...x
@.X.....C.....X.@
x...xxx...xxx...x
xxxxx xx.xx xxxxx
       x.x
      xx.xx
      x...x
      x.X.x
      x...x
      xx@xx
ENDMAP

NAME:   elyvilon_altar_2
TAGS:   uniq_altar_elyvilon temple_overflow_elyvilon no_pool_fixup no_monster_gen
DEPTH:  D:2-20
KFEAT:  C = altar_elyvilon
NSUBST: W = 1:Z / *:W
KMONS:  Z = big fish att:good_neutral
KFEAT:  Z = W
MAP
@wWw@
wwWww
WWCWW
wwWww
@wWw@
ENDMAP

NAME:   elyvilon_altar_3
TAGS:   uniq_altar_elyvilon temple_overflow_elyvilon no_pool_fixup
DEPTH:  D:2-20
KFEAT:  C = altar_elyvilon
KMASK:  w = no_monster_gen
KMASK:  W = no_monster_gen
MONS:   butterfly
MAP
        ttttttttttttt
       ttttttttttttttt
      tttttttt.tttttttt
  .....ttttt..1..ttttt.....
 .......ttt.......ttt.......
...wWw...t...wWw...t...wWw...
..wwWww.....wwWww.....wwWww..
@.WWtWW.1.1.WWCWW.1.1.WWtWW.@
..wwWww.....wwWww.....wwWww..
...wWw...t...wWw...t...wWw...
 .......ttt.......ttt.......
  .....ttttt..1..ttttt.....
      tttttttt.tttttttt
       ttttttttttttttt
        ttttttttttttt
ENDMAP

NAME:   elyvilon_altar_4
TAGS:   uniq_altar_elyvilon temple_overflow_elyvilon no_monster_gen
DEPTH:  D:2-20
KFEAT:  C = altar_elyvilon
MONS:   patrolling quokka att:good_neutral
MAP
xxx.@.xxx
xWW...WWx
xW..t..Wx
....1....
@.t.C.t.@
.........
xW..t..Wx
xWW...WWx
xxx.@.xxx
ENDMAP

NAME:   elyvilon_altar_5
TAGS:   uniq_altar_elyvilon temple_overflow_elyvilon
DEPTH:  D:2-20
KFEAT:  C = altar_elyvilon
KMASK:  T = no_monster_gen
MAP
.............
.c.c.c.c.c.c.
.............
...T.....T...
@.....C.....@
...T.....T...
.............
.c.c.c.c.c.c.
.............
ENDMAP

### Fedhas overflow altars ####################################################

NAME:   fedhas_altar_1
TAGS:   uniq_altar_fedhas temple_overflow_fedhas
DEPTH:  D:2-20
KFEAT:  C = altar_fedhas
MONS:   plant
MAP
.....
.1.1.
..C..
.1.1.
.....
ENDMAP

NAME:   fedhas_altar_2
TAGS:   uniq_altar_fedhas temple_overflow_fedhas
DEPTH:  D:2-20
KFEAT:  C = altar_fedhas
NSUBST: w = 2:W / *:w
SUBST:  . = ..wW
SUBST:  w = wwwP
MAP
.....
.www.
.wCw.
.www.
.....
ENDMAP

NAME:   fedhas_altar_3
TAGS:   uniq_altar_fedhas temple_overflow_fedhas
DEPTH:  D:2-20
KFEAT:  C = altar_fedhas
NSUBST: b = 1:. / *:1
MONS:   plant w:5 / fungus / nothing w:3
MAP
.111.
1b1b1
11C11
1b1b1
.111.
ENDMAP

NAME:   fedhas_altar_4
TAGS:   uniq_altar_fedhas temple_overflow_fedhas mini_float
DEPTH:  D:2-20
KFEAT:  C = altar_fedhas
FTILE:  . = floor_lair
FTILE:  t = floor_lair
MAP
xxxxxxxxxxxxxxx
xxxtttttttxxxxx
xxtttttttttxxxx
xtttt.ttttttxxx
xtttt.C.ttttttt
xxtttt...ttttt.
xxtttttt.......
xxxxttttttttt..
xxxxxxttttttttx
xxxxxxxtttttttx
xxxxxxxxxxxxxxx
ENDMAP

# Threat: two big fish. Loot: some fruits.
# The oklob plant may be abusable (if so, remove it).
NAME:    tgw_fedhas
TAGS:    no_item_gen no_monster_gen
TAGS:    temple_overflow_fedhas uniq_altar_fedhas
DEPTH:   Lair, D:2-20
KFEAT:   _ = altar_fedhas
MONS:    plant, fungus, oklob plant, big fish, bush, toadstool col:random
KITEM:   d = apple / apricot / orange / pear / grape / strawberry / nothing w:70
KFEAT:   d = floor
SUBST:   x = TTPPPPP.
SHUFFLE: PQR, TU, ..."
SUBST:   P = 112 , Q = 115, R = 11125
SUBST:   T = xt, U = xx
SUBST:   " = .....6
COLOUR:  . = green / none
COLOUR:  ' = green
COLOUR:  x = green / none w:30
NSUBST:  w = 2:4 / *:w

MAP
ccccccccccccccccccccccc
cxxxxxxxxxxxxxxxxxxxxxc
cxxxxxxxxxxxxxxPxxd3xxc
cxxxxxxxxxxxxxxPddddxxc
cxxxxxxxxxxxxxxPPPx.dxc
cxxxxxxx.......xxPPxxxc
cxxxxxx..wwdww..xxPPxxc
cxxxxx..wwwdwww..xxxPxc
cxxxx..wwwwdwwww..xxxxc
cxxxx.wwwwwdwwwww.xxxxc
cxxxx.wwww'''wwww.xxxxc
cxxxx.wwww'_'wwww.xxxxc
cxxxx.wwww'''wwww.xxxxc
cxxxx.wwwwwwwwwww.xxxxc
cxxxx..wwwwwwwww..xxxxc
cxxxxx..wwwwwww..xxxxxc
cxxxxxx..wwwww..xxxxxxc
cxxxxxxx.......xxxxxxxc
cxxxxxxxxxc.cxxxxxxxxxc
cxxxxxxxxxc.cxxxxxxxxxc
ccccccccccc@ccccccccccc
ENDMAP

### Kikubaaqudgha overflow altars #############################################

# This vault contains a caged human who is killed with miasma once you see it
# and then is turned into a zombie.
#
# The show's end is not clear: the chance for getting a corpse (and then a
# zombie) is 50%. Very rarely, the human survives -- this is also okay. All of
# these shows still point out how Kikubaaqudgha enjoys suffering.
NAME:   tgw_kikubaaqudgha
TAGS:   uniq_altar_kikubaaqudgha temple_overflow_kikubaaqudgha
DEPTH:  D:2-10
KFEAT:  _ = altar_kikubaaqudgha
{{
function kill_human (data, triggerable, triggerer, marker, ev)
  if data.turns ~= you.turns() then
    data.tc = data.tc + 1
    data.turns = you.turns()
  end

  if data.tc < 3 then
    return
  end

  if data.triggered == true then
    return
  end

  local m = dgn.find_marker_positions_by_prop("slave_name", "zombie")[1]
  if m ~= nil then
    local _x, _y = m:xy()

    if not you.see_cell(_x, _y) then
      return
    end
        dgn.place_cloud(_x, _y, "foul pestilence", 4)
        crawl.god_speaks("Kikubaaqudgha",
                         "Miasma emanates from the human's flesh.")
    data.triggered = true
  end
end

local tm = TriggerableFunction:new{func=kill_human, repeated=true,
                                   data={turns=you.turns(), tc=0, triggered=false} }
tm:add_triggerer(DgnTriggerer:new{type="player_los"})
lua_marker('_', tm)
}}

{{
function zombify (data, triggerable, triggerer, marker, ev)
  local pt = dgn.find_marker_positions_by_prop("slave_name", "zombie")
  if #pt == 0 then
    return
  end

  for carrion in iter.stash_iterator(pt[1].x, pt[1].y) do
    if string.find(carrion.name(), 'human corpse') then
      carrion.destroy()
    end
  end

  -- Won't place the monster if there's a cloud there
  dgn.delete_cloud(pt[1].x, pt[1].y)

  dgn.create_monster(pt[1].x, pt[1].y, "generate_awake human zombie")
  if you.see_cell(pt[1].x, pt[1].y) then
    crawl.god_speaks("Kikubaaqudgha", "The human rises from the dead!")
  end
end
local tm = TriggerableFunction:new{func=zombify, repeated=false}
tm:add_triggerer(DgnTriggerer:new{type="monster_dies", target="dslave"})
lua_marker('_', tm)
}}
MARKER: h = lua:portal_desc {slave_name="zombie"}
MARKER: h = lua:MonPropsMarker:new{dslave="dslave"}
KFEAT:  h = .
KMONS:  h = generate_awake Human hp:12 ; nothing
TILE:   m = dngn_transparent_wall_darkgray
MAP
xxxxxxx
@..mmmx
@_.mhmx
@..mmmx
xxxxxxx
ENDMAP

### Makhleb overflow altars ###################################################

NAME:    demons_altar
DEPTH:   3-11
TAGS:    no_monster_gen patrolling temple_overflow_makhleb
TAGS:    layout_rooms layout_city layout_open layout_cross
KFEAT:   _ = altar_makhleb
# Either one slow type 3 or s or 4 demon (iron devil or demonic crawler or
#     smoke demon) or three slow type 5 demons (iron imp).
# The smoke demon can only come up in D:9-11.
SHUFFLE: 1234
NSUBST:  1 = 1:1 / *:.
NSUBST:  2 = 1:2 / *:.
NSUBST:  3 = 2:3 / *:.
: if you.absdepth() < 9 then
SUBST:   3 = 12
: end
MONS:    iron devil, demonic crawler, smoke demon, iron imp
MAP
xxxxxxxxxxxxxxx
x.............x
x.ll.......ll.x
x.ll..1_1..ll.x
x.ll...1...ll.x
x..ll.....ll..x
x...lll.lll...x
x....llGll....x
x......l......x
x.............x
x.............x
x.............x
x.............x
ENDMAP

### Nemelex overflow altars ###################################################

### Okawaru overflow altars ###################################################

NAME:   okawaru_metal_pillars_1
WEIGHT: 4
DEPTH:  2-10
TAGS:   temple_overflow_okawaru
KFEAT:  _ = altar_okawaru
MAP
.....
.v.v.
.._..
.v.v.
.....
ENDMAP

NAME:   okawaru_metal_pillars_2
WEIGHT: 3
DEPTH:  2-10
TAGS:   temple_overflow_okawaru
KFEAT:  _ = altar_okawaru
MAP
.....
..v..
.v_v.
..v..
.....
ENDMAP

NAME:   okawaru_metal_pillars_3
WEIGHT: 3
DEPTH:  2-10
TAGS:   temple_overflow_okawaru
KFEAT:  _ = altar_okawaru
MAP
.......
...v...
..v.v..
.v._.v.
..v.v..
...v...
.......
ENDMAP

NAME:   okawaru_trees_1
WEIGHT: 5
DEPTH:  2-10
TAGS:   temple_overflow_okawaru
KFEAT:  _ = altar_okawaru
MAP
.........
.v.t.t.v.
.........
.t.t.t.t.
...._....
.t.t.t.t.
.........
.v.t.t.v.
.........
ENDMAP

NAME:   okawaru_trees_2
WEIGHT: 5
DEPTH:  2-10
TAGS:   temple_overflow_okawaru
KFEAT:  _ = altar_okawaru
MAP
...........
.v...t...v.
....t.t....
...t.t.t...
..t.t.t.t..
.t.t._.t.t.
..t.t.t.t..
...t.t.t...
....t.t....
.v...t...v.
...........
ENDMAP

### Sif Muna overflow altars ##################################################

NAME:   lemuel_blue_sif_altar
DEPTH:  D:2-18, Elf, Vault
TAGS:   no_monster_gen mini_float temple_overflow_sif_muna uniq_altar_sif_muna
COLOUR: . = blue
FTILE:  . = floor_hall, C = floor_hall, @ = floor_hall, + = floor_hall
KFEAT:  _ = altar_sif_muna
MAP
xxxxxxxxxxxxxx
...........xxx
@..........+_x
...........xxx
xxxxxxxxxxxxxx
ENDMAP

NAME:       tgw_sif
DEPTH:      D:3-18, Elf
TAGS:       no_item_gen no_monster_gen no_pool_fixup
TAGS:       temple_overflow_sif_muna uniq_altar_sif_muna
KFEAT:      _ = altar_sif_muna
MONS:       orc wizard w:15 / Jessica / Blork the Orc
NSUBST:     M = 1:1 / *:"
SUBST:      ' : "'., ' = ''.
COLOUR:     . = blue
SUBST:      ' = ., " = .
ITEM:       potion of gain intelligence w:2 / potion of brilliance /\
            potion of magic / any book w:1
MAP
        xx@xx
        x...x
        x...x
      xxx...xxx
     xx'''''''xx
    xx'''...'''xx
    x'''.www.'''x
   xx''.wwwww.''xx
   x''.wwM"Mww.''x
   x''.wwM>Mww.''x
   x''.wwMMMww.''x
   xx''.wwwww.''xx
    x'''.www.'''x
    xx'''...'''xx
     xx''d'd''xx
      xxx...xxx
        x._.x
        x...x
        xxxxx
ENDMAP

### Trog overflow altars ######################################################

NAME:  bloody_trog
TAGS:  uniq_altar_trog temple_overflow_trog
DEPTH: D:2-12, Orc, Vault
KPROP: . = bloody / nothing
KFEAT: _ = altar_trog
KITEM: _ = animal skin, knife
MAP
...
._.
...
ENDMAP

# Features berserk monsters, so we're careful: no intelligent monsters, so you
# close the door. Provide a chokepoint.
NAME:   tgw_trog
TAGS:   no_item_gen no_monster_gen patrolling
TAGS:   temple_overflow_trog uniq_altar_trog
DEPTH:  D:2-9
KFEAT:  _ = altar_trog
MONS:   moth of wrath, rat / worm w:5
ITEM:   any weapon
NSUBST: M = 4:d / *:.
SUBST:  + = +....
MAP
      xxxxxxx
     xxxMMMxxx
    xxMMM2MMMxx
   xxMM22_22MMxx
   xx.........xx
   x....ooo....x
   x...oo1oo...x
   x....ooo....x
   x...........x
   xx.........xx
    xx.......xx
     xxxx+xxxx
       xx@xx
ENDMAP

NAME:   trog_book
TAGS:   uniq_altar_trog temple_overflow_trog
DEPTH:  D:2-10, Orc
KFEAT:  _ = altar_trog
{{
function convert_book (data, triggerable, triggerer, marker, ev)
  if data.turns ~= you.turns() then
    data.tc = data.tc + 1
    data.turns = you.turns()
  end

  if data.tc < 3 then
    return
  end

  if data.triggered == true then
    return
  end

  local m = dgn.find_marker_positions_by_prop("slave_name", "trog_book")[1]
  if m ~= nil then
    local _x, _y = m:xy()

    -- Only burn the book when you see both the altar and the book. This gives
    -- sneaky players the opportunity to apport the book.
    if not you.see_cell(_x, _y) then
      return
    end

    for book in iter.stash_iterator(_x, _y) do
      if string.find(book.name(), 'book') then
        book.destroy()
        dgn.place_cloud(_x, _y, "flame", 15)
        crawl.god_speaks("Trog", "The book bursts into flames! "
                              .. "Trog roars with delight!")
      end
    end
    data.triggered = true
  end
end

local tm = TriggerableFunction:new{func=convert_book, repeated=true, data={turns=you.turns(), tc=0, triggered=false} }
tm:add_triggerer(DgnTriggerer:new{type="player_los"})
lua_marker('_', tm)
}}
MARKER: b = lua:portal_desc {slave_name="trog_book"}
KFEAT:  b = .
KITEM:  b = any book
MAP
xxxxxxx
x.....xxx
x._.b....@
x.....xxx
xxxxxxx
ENDMAP

### Vehumet overflow altars ###################################################

# The cloud seems to be okay: automatic exclusion should prevent deaths.
# You can safely step on a square diagonally adjacent to the altar.
# Maximal damage is 32 per turn (at speed 10). If you want to go safe,
# wait for resistance (or have more than 32 HP).
NAME:   fiery_altar_vehumet
DEPTH:  2-10
WEIGHT: 8
TAGS:   temple_overflow_vehumet
MARKER: _ = lua:fog_machine { cloud_type = "flame", \
               pow_min = 6, pow_max = 8, delay_min = 35, delay_max = 55, \
               size = 1, walk_dist = 0, spread_rate= 0 }
KFEAT:  _ = altar_vehumet
MAP
.....
.....
.._..
.....
.....
ENDMAP

# A variation of the above. Use freezing vapours, so that the book won't 'burn'.
# The fog generator for the altar has the same parameters as above but the one
# for the book is more dangerous.
NAME:   dangerous_book
DEPTH:  2-10
WEIGHT: 2
TAGS:   temple_overflow_vehumet
MARKER: _ = lua:fog_machine { cloud_type = "freezing vapour", \
               pow_min = 6, pow_max = 8, delay_min = 35, delay_max = 55, \
               size = 1, walk_dist = 0, spread_rate= 0 }
KFEAT:  _ = altar_vehumet
MARKER: + = lua:fog_machine { cloud_type = "freezing vapour", \
             pow_min = 10, pow_max = 12, delay = 30, \
             size = 3, walk_dist = 1, spread_rate= 0 }
KITEM:  + = book of conjurations [Fire] / book of conjurations [Ice]
MAP
......
._....
......
...+..
......
......
ENDMAP

NAME:    vehumet_statue
DEPTH:   4-10
TAGS:    temple_overflow_vehumet
SHUFFLE: 12
MONS:    statue name:charred name_adjective tile:mons_statue_mage \
             hp:12 hd:3 spells:throw_flame
MONS:    statue name:frost-covered name_adjective tile:mons_statue_mage \
             hp:12 hd:3 spells:throw_frost
KFEAT:   _ = altar_vehumet
MAP
...........
.bbbbbbbbb.
.b.......b.
.b.1._.....
.b.......b.
.bbbbbbbbb.
...........
ENDMAP

NAME:    vehumet_crystals
DEPTH:   2-10
TAGS:    temple_overflow_vehumet
KFEAT:   _ = altar_vehumet
MAP
.........
..b...b..
.bbb.bbb.
..b...b..
...._....
..b...b..
.bbb.bbb.
..b...b..
.........
ENDMAP

# Vehumet wants you to burn the damn trees down.
NAME:    vehumet_trees
DEPTH:   2-10
TAGS:    temple_overflow_vehumet
KFEAT:   _ = altar_vehumet
SHUFFLE: ><
# 1KB suggests that instead of a hatch (to make sure the player can escape the
# vault, if they would get trapped by a teleport or something), make Vehumet
# burn the trees down when you take the god. If anyone would like to script
# this in, go ahead! Probably needs "beckoning messages" where Vehumet promises
# to free the player of the cage of trees. --evk
MAP
.......
.ttttt.
.t...t.
.t._.t.
.t.>.t.
.t...t.
.ttttt.
.......
ENDMAP

### Xom overflow altars #######################################################

NAME:   tgw_xom
TAGS:   no_item_gen no_monster gen temple_overflow_xom uniq_altar_xom
KFEAT:  _ = altar_xom
MONS:   orc; club ego:chaos / orc; dagger ego:chaos / orc; spear ego:chaos
MONS:   gnoll; club ego:chaos / gnoll; dagger ego:chaos / gnoll; spear ego:chaos
MONS:   place:D:1-8
NSUBST: ' = 1:_ / *:.
SUBST:  . = .:200 ~:70 W:60 w:50 x:80 n:80 v b l Z T U M:20
NSUBST: Z = 1:* / *:%
SUBST:  M : 123333M, 1 = 1.., 2 = 2.., M = 123.
COLOUR: . = random
MAP
   xxxxxx@xxxxxx
  xx...........xx
 xx.............xx
xx...............xx
x.................x
x.................x
x'...............'x
x'...............'x
xx'.............'xx
 xx'''''''''''''xx
  xx'''''''''''xx
   xxxxxxxxxxxxx
ENDMAP

### Yredelemnul overflow altars ###############################################

NAME:   yredelemnul_altar_1
TAGS:   uniq_altar_yredelemnul temple_overflow_yredelemnul
DEPTH:  D:2-20
KFEAT:  C = altar_yredelemnul
KMONS:  f = w:2 col:darkgrey plant name:withered name_adjective               \
            tile:mons_withered_plant / w:1 col:lightgrey plant name:withered  \
            name_adjective tile:mons_withered_plant
MAP
.....
.f.f.
..C..
.f.f.
.....
ENDMAP

### Zin overflow altars #######################################################

NAME:   zin_angel
TAGS:   no_item_gen no_monster_gen temple_overflow_zin
KFEAT:  _ = altar_zin
COLOUR: G = lightgray
COLOUR: c = white
MONS:   angel
: local za_desc = "A divine agent of Zin, it is a towering winged figure " ..
:   "with an aura of brilliant white light. This angel's face, though, " ..
:   "is marked by a scowl, as if its zeal against any real or perceived " ..
:   "vice overshadowed its goodness.\n"
MARKER: 1 = lua:MonPropsMarker:new {speech_key="zin_priest"; description=za_desc}
DEPTH:  2-27
MAP
xxxxxxxxx
xcccccccx
xc1m.._cx
xcmm...cx
xc.....cx
xcG...Gcx
xccc+cccx
    @
ENDMAP

### The Shining One overflow altars ###########################################

# TSO's small temple (1KB)
# Idea stolen from protected_by_tso_3.
NAME:     tso_altar
TAGS:     no_item_gen no_rotate
TAGS:     temple_overflow_the_shining_one uniq_altar_the_shining_one
COLOUR:   _ = yellow
SUBST:    _ = .
COLOUR:   c = white
KFEAT:    A = altar_shining_one
MAP
  xxxxx
xxxcccxxx
xcccAcccx
xc.___.cx
xct._.tcx
xc.._..cx
xct...tcx
xccc+cccx
ENDMAP

### Variable overflow altars ##################################################

NAME:   lemuel_zombie_altar
DEPTH:  D:2-18, Crypt
TAGS:   no_pool_fixup uniq_zombie_altar no_monster_gen
: local god = ""
: if crawl.coinflip() then god = "kikubaaqudgha" else god = "yredelemnul" end
: tags("temple_overflow_" .. god, "uniq_altar_" .. god)
: kfeat("_ = altar_" .. god)
#
: if crawl.coinflip() then
MONS:   rat zombie / giant bat zombie / nothing w:200
KMONS:  w = giant goldfish zombie / big fish zombie / nothing w:200
KFEAT:  w = deep_water
: else
SUBST:  1 : 1Ww
SUBST:  1 = WWw
NSUBST: w = 2:1 / *:w
KMONS:  1 = giant goldfish zombie / big fish zombie
KFEAT:  1 = deep_water
: end
MAP
xxxxxxxxxxxxxxxx
xxxxwwwwwwwwxxxx
xxxx11111111xxxx
@............._x
xxxx11111111xxxx
xxxxwwwwwwwwxxxx
xxxxxxxxxxxxxxxx
ENDMAP

# General overflow vault, can be used for all gods.
# B places the altar to a guaranteed god.
NAME:     general_overflow_altar
DEPTH:    D:2-16
WEIGHT:   2
TAGS:     no_monster_gen no_pool_fixup temple_overflow_1
SHUFFLE:  xXY / xXY / xXY / abc
SHUFFLE:  XY
SUBST:    X=+, Y=x, a=w, b=w, c=w
SHUFFLE:  ABCD
SUBST:    A=>, C=.GTU, D=.
SHUFFLE:  wll
MAP
........
.xXYYxx.
.xwwwwx.
.xwABwx.
.xwCDwx.
.xwwwwx.
.xxxxxx.
........
ENDMAP
