{{
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 slave in iter.slave_iterator("revealing_wall", 1) do
        dgn.terrain_changed(slave.x, slave.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
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_slave = true, listen_to_slaves = true })))
lua_marker('d', props_marker {revealing_wall=1})
}}
KFEAT: d = stone_wall
KFEAT: _ = altar_ashenzari
MAP
ccccc.@.ccccc
ceeed...dfffc
ceeed...dfffc
ceeed...dfffc
ceeed...dfffc
ceeed:::dfffc
ceeed:::dfffc
ceeed:::dfffc
ceeed:_:dfffc
ceeed:::dfffc
ceeed:::dfffc
ceeed:::dfffc
ceeed...dfffc
ceeed...dfffc
ceeed...dfffc
ceeed...dfffc
ccccc.@.ccccc
ENDMAP

NAME: grunt_ashenzari_visionary_trees
TAGS: grunt_ashenzari_visionary no_trap_gen no_monster_gen unrand
MONS: butterfly
FTILE:  . = floor_grass_dirt_mix
KPROP:  . = no_tele_into
SUBST:  . = ....t1
COLOUR: . = green / brown
MAP
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
ENDMAP

NAME: grunt_ashenzari_visionary_swamp
TAGS: grunt_ashenzari_visionary_swamp no_trap_gen no_monster_gen unrand
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 }
# Monsters specified here to omit aquatic placements.
MONS: plant w:150 / fungus w:99 / vampire mosquito band w:75 / will-o-the-wisp w:50 / \
      swamp drake w:80 / alligator w:75 / goliath frog w:75
KPROP: w = no_tele_into
SUBST: w = wwwWWt1
FTILE: 1 = floor_swamp
MAP
www
www
wHw
www
www
www
www
wHw
www
www
www
www
wHw
www
www
ENDMAP

NAME: grunt_ashenzari_visionary_lava
TAGS: grunt_ashenzari_visionary no_trap_gen no_monster_gen unrand
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 }
KPROP: l = no_tele_into
MAP
lll
lll
lHl
lll
lll
lll
lll
lHl
lll
lll
lll
lll
lHl
lll
lll
ENDMAP

NAME: grunt_ashenzari_visionary_spider
TAGS: grunt_ashenzari_visionary_spider no_trap_gen no_monster_gen unrand
MONS: giant cockroach w:15 / scorpion w:35 / worm w:20 / hornet w:15 / \
      redback w:100 / wolf spider w:50
KPROP:  . = no_tele_into
SUBST:  . = ....x1
COLOUR: 1. = brown
COLOUR: x = yellow
FTILE:  1. = floor_spider
RTILE:  x = wall_spider
MAP
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
ENDMAP

NAME: grunt_ashenzari_visionary_snake
TAGS: grunt_ashenzari_visionary_snake no_trap_gen no_monster_gen unrand
MONS: place:Snake:1 spells:none
KPROP:  . = no_tele_into
SUBST:  . = ....x1
COLOUR: 1. = lightgreen
COLOUR: x = yellow
FTILE:  1. = floor_mosaic
RTILE:  x = wall_snake
MAP
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
ENDMAP

NAME: grunt_ashenzari_visionary_shoals
TAGS: grunt_ashenzari_visionary_shoals no_trap_gen no_monster_gen unrand
# Monsters specified here to omit aquatic placements.
MONS: bat w:35 / merfolk w:90 / merfolk siren w:40 / wind drake w:35 / \
      centaur w:20 / sea snake w:40
SUBST:  w = wwww.1
COLOUR: 1. = brown
FTILE:  1. = floor_sand
KPROP:  1w. = no_tele_into
MAP
www
www
w.w
www
www
www
www
w.w
www
www
www
www
w.w
www
www
ENDMAP
