# Vehumet wants you to burn the damn trees down.
# Currently disabled for being too problematic to access.
# TODO: make the outside border bigger, then have Vehumet burn down the trees
# as one enter the vault entirely, instead of being stuck behind the trees.

{{
function callback.dk_vehumet_trees_move(data, triggerable, triggerer, marker, ev)
  if not dgn.persist.dk_vt_stepped and not dgn.persist.dk_vt_tree_died then
    crawl.god_speaks("Vehumet", "Vehumet offers to free you in exchange " ..
                                "for your devotion to destruction.")
    dgn.persist.dk_vt_stepped = true
  end
end

function callback.dk_vehumet_trees_died(data, triggerable, triggerer, marker, ev)
  local x,y = marker:pos()
  if you.see_cell(x, y) then
    dgn.persist.dk_vt_tree_died = true
  end
end

function callback.dk_vehumet_trees_los(data, triggerable, triggerer, marker, ev)
  if not dgn.persist.dk_vt_tree_died and you.god() == "Vehumet" then
    crawl.mpr("Suddenly, the trees start to burn!")
    for replica in iter.replica_iterator("tree", 1) do
        dgn.terrain_changed(replica.x, replica.y, "floor", false)
        dgn.place_cloud(replica.x, replica.y, "flame", crawl.random2(15) + 5)
    end
    triggerable:remove(marker)
  end
end
}}

NAME:    dk_vehumet_trees
TAGS:    temple_overflow_vehumet temple_overflow_1
WEIGHT:  0
KPROP:   :_ = no_tele_into
KFEAT:   _ = altar_vehumet
SUBST:   x : G:1 t:1 x:8
{{
dgn.persist.dk_vt_stepped = false
dgn.persist.dk_vt_tree_died = false

local move_marker = TriggerableFunction:new{
  func="callback.dk_vehumet_trees_move",
  repeated=true
}
move_marker:add_triggerer(DgnTriggerer:new {
  type="player_move"})

local tree_marker = TriggerableFunction:new{
  func="callback.dk_vehumet_trees_died",
  repeated=true
}
tree_marker:add_triggerer(DgnTriggerer:new {
  type="feat_change"})

local los_marker = TriggerableFunction:new{
  func="callback.dk_vehumet_trees_los",
  repeated=true
}
los_marker:add_triggerer(DgnTriggerer:new {
  type="player_los"})

lua_marker(':', move_marker)
lua_marker('t', tree_marker)
lua_marker('x', tree_marker)
lua_marker('G', tree_marker)
lua_marker('t', props_marker {tree=1})
lua_marker('_', los_marker)
lua_marker('_', props_marker {altar=1})
}}
MAP
.......
.xtxtx.
.t:::t.
.x:_:x.
.t:::t.
.xtxtx.
.......
ENDMAP
