{{
function callback.grunt_ashenzari_visionary_reveal(data,triggerable,triggerer,marker,ev)
    if data.trig then
        return
    end
    data.trig = true
    crawl.god_speaks("Ashenzari", "Ashenzari says: See what I see, mortal...")
    for replica in iter.replica_iterator("revealing_wall", 1) do
        dgn.terrain_changed(replica.x, replica.y, "clear_stone_wall", false)
    end
    local msg = ""
    if #data.branches > 0 then
      msg = " of"
      for i, name in ipairs(data.branches) do
        if i == 1 then
        elseif i == #data.branches then
          msg = msg .. " and"
        else
          msg = msg .. ","
        end
        msg = msg .. " the " .. name
      end
      crawl.take_note("Saw a vision" .. msg .. ".")
    end
    crawl.god_speaks("Ashenzari", "You have a sudden vision" .. msg .. "!")
end
}}

NAME:     grunt_ashenzari_visionary
TAGS:     temple_overflow_1 temple_overflow_ashenzari no_trap_gen no_monster_gen
TAGS:     no_descent
WEIGHT:   5
SHUFFLE:  ef
# The branches should be in reverse order here so we don't select the
# same branch twice.
: local branches = {}
: if crawl.game_started() and dgn.br_exists("Swamp") then
:   table.insert(branches, "Swamp")
SUBVAULT: e : grunt_ashenzari_visionary_swamp
: elseif crawl.game_started() and dgn.br_exists("Shoals") then
:   table.insert(branches, "Shoals")
SUBVAULT: e : grunt_ashenzari_visionary_shoals
: elseif crawl.game_started() and dgn.br_exists("Spider") then
:   table.insert(branches, "Spider Nest")
SUBVAULT: e : grunt_ashenzari_visionary_spider
: elseif crawl.game_started() and dgn.br_exists("Snake") then
:   table.insert(branches, "Snake Pit")
SUBVAULT: e : grunt_ashenzari_visionary_snake
: else
SUBVAULT: e : grunt_ashenzari_visionary
: end
: if crawl.game_started() and dgn.br_exists("Snake") then
:   table.insert(branches, "Snake Pit")
SUBVAULT: f : grunt_ashenzari_visionary_snake
: elseif crawl.game_started() and dgn.br_exists("Spider") then
:   table.insert(branches, "Spider Nest")
SUBVAULT: f : grunt_ashenzari_visionary_spider
: elseif crawl.game_started() and dgn.br_exists("Shoals") then
:   table.insert(branches, "Shoals")
SUBVAULT: f : grunt_ashenzari_visionary_shoals
: elseif crawl.game_started() and dgn.br_exists("Swamp") then
:   table.insert(branches, "Swamp")
SUBVAULT: f : grunt_ashenzari_visionary_swamp
: else
SUBVAULT: f : grunt_ashenzari_visionary
: end
{{

lua_marker(":", Triggerable.synchronized_markers(
    function_at_spot("callback.grunt_ashenzari_visionary_reveal",
                     { trig = false, branches = branches },
                     true, { only_at_replica = true, listen_to_replicas = true })))
lua_marker('d', props_marker {revealing_wall=1})
}}
KFEAT: d = stone_wall
KFEAT: _ = altar_ashenzari
MAP
ccccccccccccccccc
ceeeeeeeeeeeeeeec
ceeeeeeeeeeeeeeec
ceeeeeeeeeeeeeeec
cdddddddddddddddc
.....:::::::.....
@....:::_:::....@
.....:::::::.....
cdddddddddddddddc
cfffffffffffffffc
cfffffffffffffffc
cfffffffffffffffc
ccccccccccccccccc
ENDMAP

NAME:   grunt_ashenzari_visionary_swamp
TAGS:   grunt_ashenzari_visionary_swamp no_tele_into no_pool_fixup unrand
TAGS:   no_monster_gen no_item_gen no_trap_gen
KFEAT:  H = w
MARKER: H = lua:fog_machine { cloud_type = "thin mist", pow_min = 3, \
                              pow_max = 10, delay = 10, start_clouds = 1, \
                              size_min = 1, size_max = 3, walk_dist = 2 }
MONS:   place:Swamp:1
SUBST:  t = ttw, w = wwW..., . = 1.
FTILE:  1. = floor_swamp
MAP
twtttwtttwtttwt
wtHtwtwHwtwtHtw
tttwtttwtttwttt
ENDMAP

NAME:   grunt_ashenzari_visionary_lava
TAGS:   grunt_ashenzari_visionary no_tele_into unrand allow_dup
TAGS:   no_monster_gen no_item_gen no_trap_gen
KFEAT:  H = l
MARKER: H = lua:fog_machine { cloud_type = "black smoke", pow_min = 3, \
                              pow_max = 10, delay = 10, start_clouds = 1, \
                              size_min = 1, size_max = 3, walk_dist = 2 }
MAP
lllllllllllllll
llHllllHllllHll
lllllllllllllll
ENDMAP

NAME:   grunt_ashenzari_visionary_spider
TAGS:   grunt_ashenzari_visionary_spider no_tele_into unrand
TAGS:   no_monster_gen no_item_gen no_trap_gen
MONS:   place:Spider:1
KFEAT:  ^ = web trap
SUBST:  x = xx^, . = W....., . = 11.
COLOUR: 1. = brown
COLOUR: x = yellow
FTILE:  1. = floor_spider
RTILE:  x = wall_spider
MAP
x.xxx^xxx^xxx.x
.x.x.x.x.x.x.x.
xxx.xxx^xxx.xxx
ENDMAP

NAME:   grunt_ashenzari_visionary_snake
TAGS:   grunt_ashenzari_visionary_snake no_tele_into unrand
TAGS:   no_monster_gen no_item_gen no_trap_gen
MONS:   place:Snake:1
SUBST:  x = x., . = l .:110, . = 1...
COLOUR: 1. = lightgreen
COLOUR: x = yellow
FTILE:  1. = floor_mosaic
RTILE:  x = wall_snake
MAP
x.xxx.xxx.xxx.x
.x.x.x.l.x.x.x.
xxx.xxx.xxx.xxx
ENDMAP

NAME:   grunt_ashenzari_visionary_shoals
TAGS:   grunt_ashenzari_visionary_shoals no_tele_into no_pool_fixup unrand
TAGS:   no_monster_gen no_item_gen no_trap_gen
KMONS:  1 = place:Shoals:1
KFEAT:  1 = w
SUBST:  w = ww., w = 1ww
COLOUR: . = brown
FTILE:  . = floor_sand
MAP
wwwwwwwwwwwwwww
ww.wwww.wwww.ww
wwwwwwwwwwwwwww
ENDMAP
