# DES-related lua only needed for save compatability.
# Please remove the code in this file when the next line is false.
# TAG_MAJOR_VERSION == 34
{{
function callback.grunt_victim_ignite(data, triggerable, triggerer, marker, ev)
  -- the victims don't spawn before; do nothing
end

function callback.ldierk_statue_collapse(data, triggerable, triggerer, marker, ev)
  -- wall_hit events removed; do nothing
end

function callback.wall_jericho_stepped(data, triggerable, triggerer, marker, ev)
  -- do nothing
end

function callback.wall_jericho_tick(data, triggerable, triggerer, marker, ev)
  -- do nothing
end

function callback.fedhas_growing_garden_grow(data, triggerable,
                                             triggerer, marker, ev)
  -- do nothing
end

function callback.monster_doors_stepped(data, triggerable, triggerer, marker, ev)
  -- do nothing
end

function callback.cloud_trap_stepped(data, triggerable, triggerer, marker, ev)
  -- do nothing
end

function callback.dk_crumbling_pickup(data, triggerable, triggerer, marker, ev)
  -- do nothing
end

function callback.dk_crumbling_turn(data, triggerable, triggerer, marker, ev)
  -- do nothing
end

-- I'm keeping the code here in case someone is unfortunate enough to
-- have this vault present in the game; connectivity might be broken
-- otherwise.
-- -- Grunt
function callback.grunt_zot_stairs_roulette_spawn_doors(data, triggerable,
                                                        triggerer, marker, ev)
  if data.triggered then
    return
  end

  data.triggered = true

  dgn.persist.grunt_zot_stairs_roulette_doors_spawned = true

  for p in iter.slave_iterator("hidden_door", 1) do
    dgn.terrain_changed(p.x, p.y, "clear_stone_wall", false)
  end
end

function callback.grunt_zot_stairs_roulette_door_open(data, triggerable,
                                                      triggerer, marker, ev)
  if data.triggered then
    return
  end

  if dgn.persist.grunt_zot_stairs_roulette_doors_spawned == false then
    return
  end

  data.triggered = true

  crawl.mpr("Several panes of glass retract into the floor.")
  for p in iter.slave_iterator("hidden_door", 1) do
    dgn.terrain_changed(p.x, p.y, "floor", false)
  end
end

function callback.grunt_zot_stairs_roulette_teleport(data, triggerable,
                                                     triggerer, marker, ev)
  slave = dgn.find_marker_positions_by_prop("dest", data.dest)
  if you.teleport_to(slave[1].x, slave[1].y) then
      crawl.mpr("Your surroundings suddenly seem different.")
  else
      crawl.mpr("There is a strange hissing noise.")
  end
end

function teleporter_serial_action_fn
                      (data, triggerable, triggerer, marker, ev)
  local position = dgn.point(marker:pos())
  my_slaves = dgn.find_marker_positions_by_prop("teleport_spot",
                                                data.teleport_spot)

  -- third parameter is whether to teleport whatever is on the reciving pad
  if you.teleport_to(my_slaves[1].x, my_slaves[1].y, false) then
    crawl.mpr("Your surroundings suddenly seem different!")
  else
    crawl.mpr("There is a strange hissing noise.")
  end
end

function callback.xom_trap_step(data, triggerable, triggerer, marker, ev)
  -- do nothing
end

function callback.xom_item_pickup(data, triggerable, triggerer, marker, ev)
  -- do nothing
end

function callback.amethyst_srp_altar(data, triggerable, triggerer, marker, ev)
  local slaves = dgn.find_marker_positions_by_prop("teleport_spot",
                                                   data.teleport_spot)
  you.teleport_to(slaves[1].x, slaves[1].y)
  crawl.mpr("Your surroundings suddenly seem different.")
end

-- Allow people with the ancient champion vault to still clear it.
function callback.ancient_champions_mu_skele_death(data, triggerable,
                                                    triggerer, marker, ev)
  data.skele_number = data.skele_number + 1

  -- Only 7 skeles!
  if data.skele_number > 7 then
    return
  end

  local function get_slave (slavenum)
    local myslaves = dgn.find_marker_positions_by_prop("skele_slave", slavenum)
    return myslaves[1]
  end

  local wall_pos = get_slave(data.skele_number)
  if wall_pos == nil then
    crawl.mpr("Couldn't find a slave!")
  end

  dgn.terrain_changed(wall_pos.x, wall_pos.y, "floor", false)

  if you.see_cell(wall_pos.x, wall_pos.y) then
    crawl.mpr("As the champion is destroyed, a metal wall slides away!")
  else
    crawl.mpr("As the champion is destroyed, you hear a distant grinding noise.")
  end
end

function tukima_machine (data, triggerable, triggerer, marker, ev)
  -- do nothing
end

function wizlab_eringya_grow(data, triggerable, triggerer, marker, ev)
  -- do nothing
end

function callback.spiders_nest_cobweb_light(data, triggerable, triggerer, marker, ev)
  -- do nothing
end

function callback.spiders_nest_web_lair(data, triggerable, triggerer, marker, ev)
  -- do nothing
end

-- let this vault still function if it already exists
function callback.beogh_warn_stepped(data, triggerable, triggerer, marker, ev)
  local x, y = marker:pos()

  if you.god() == "Beogh" or (you.race() == "Hill Orc" and you.god() == "No God") then
     crawl.god_speaks("Beogh" , "Your presence is welcomed at the altar of Beogh.")
     dgn.grid(x, y, "floor")
  elseif you.race() == "Hill Orc" then
     crawl.god_speaks("Beogh" , "The orc god booms: Stay away, heretic!")
  else
     crawl.god_speaks("Beogh" , "The orc god booms: Stay away, mortal!")
  end
end

function callback.beogh_trap_stepped(data, triggerable, triggerer, marker, ev)
  local x, y = marker:pos()
-- This enacts the changes. First it checks to see if the player is a Beogh
-- worshipper or a godless orc (a potential worshipper). If the player is one of
-- these things nothing happens. Otherwise the trap is sprung.
  if monster_step == true then
    return
  elseif you.god() == "Beogh" or (you.race() == "Hill Orc" and you.god() == "No God") then
    dgn.grid(x, y, "floor")
  else
    crawl.god_speaks("Beogh", "Beogh's servants are called upon to defend the altar!")
    for slave in iter.slave_iterator("bridge", 1) do
      dgn.terrain_changed(slave.x, slave.y, "floor", false)
    end
    dgn.grid(x, y, "floor")
  end
end

function callback.boulder_grate_trap_stepped(data, triggerable, triggerer,
                                             marker, ev)
  -- do nothing
end

function callback.grate_trap_stepped(data, triggerable, triggerer,
                                             marker, ev)
  -- do nothing
end

callback.grunt_nemelex_gamble_announce = callback.nemelex_gamble_announce

function callback.grunt_nemelex_gamble_start(data,triggerable,triggerer,marker,ev)
    if dgn.persist.grunt_nemelex_gamble_triggered then
        return
    end
    dgn.persist.grunt_nemelex_gamble_triggered = true
    slave = dgn.find_marker_positions_by_prop("start_tele", 1)
    dgn.terrain_changed(slave[1].x, slave[1].y, "floor", false)
    if crawl.coinflip() then
        slave = dgn.find_marker_positions_by_prop("prize", 1)
        you.teleport_to(slave[1].x, slave[1].y)
        crawl.god_speaks("Nemelex Xobeh", "Nemelex Xobeh says, \"You win!\"")
    else
        slave = dgn.find_marker_positions_by_prop("peril", 1)
        you.teleport_to(slave[1].x, slave[1].y)
        crawl.god_speaks("Nemelex Xobeh", "Nemelex Xobeh says, \"You lose!\"")
    end
    crawl.mpr("Your surroundings suddenly seem different.")
end

function callback.grunt_nemelex_gamble_finish1(data,triggerable,triggerer,marker,ev)
    slave = dgn.find_marker_positions_by_prop("exit", 1)
    you.teleport_to(slave[1].x, slave[1].y)
    crawl.mpr("Your surroundings suddenly seem different.")
end

function callback.grunt_nemelex_gamble_finish2(data,triggerable,triggerer,marker,ev)
    slave = dgn.find_marker_positions_by_prop("exit", 1)
    you.teleport_to(slave[1].x, slave[1].y)
    crawl.mpr("Your surroundings suddenly seem different.")
end

function callback.grunt_nemelex_gamble_expire(data,triggerable,triggerer,marker,ev)
    if dgn.persist.grunt_nemelex_gamble_triggered then
        return
    end
    if not dgn.persist.grunt_nemelex_gamble_announced then
        return
    end
    data.dur = data.dur - ev:ticks()
    if data.dur > 0 then
        return
    end
    dgn.persist.grunt_nemelex_gamble_triggered = true
    slave = dgn.find_marker_positions_by_prop("start_tele", 1)
    dgn.terrain_changed(slave[1].x, slave[1].y, "floor", false)
    if (you.see_cell(slave[1].x, slave[1].y)) then
        crawl.mpr("<white>The teleporter glows with a rainbow of weird colours and disappears.</white>")
    end
end

-- Find the slave of the teleporter and move to it.
function teleporter_vault_action_fn(data, triggerable, triggerer, marker, ev)
    local position = dgn.point(marker:pos())
    my_slaves = dgn.find_marker_positions_by_prop("teleport_spot",
                                                  data.teleport_spot)

    if you.teleport_to(my_slaves[1].x, my_slaves[1].y, true) then
        crawl.mpr("Your surroundings suddenly seem different!")
    else
        crawl.mpr("There is a strange hissing noise.")
    end
end

-- Find the slave of the teleporter and move to it.
function callback.ice_cave_statue_garden_teleporter(data, triggerable,
                                                     triggerer, marker, ev)
  local position = dgn.point(marker:pos())
  my_slaves = dgn.find_marker_positions_by_prop("teleport_spot",
    data.teleport_spot)

  you.teleport_to(my_slaves[1].x, my_slaves[1].y)
  crawl.mpr("Your surroundings suddenly seem different!")
end

function teleporter_golubria_switch_fn(data, triggerable, triggerer, marker, ev)
  local position = dgn.point(marker:pos())
  my_slaves = dgn.find_marker_positions_by_prop("teleport_spot",
                                                data.teleport_spot)

  if you.teleport_to(my_slaves[1].x, my_slaves[1].y, true) then
    crawl.mpr("Your surroundings suddenly seem different!")
  else
    crawl.mpr("There is a strange hissing noise.")
  end
end

function callback.spider_trap_stepped(data, triggerable, triggerer, marker, ev)
  data.mons="generate_awake redback"
  data.msg="A basket of spiders falls from above!"
  data.max=8
  callback.drop_trap_stepped(data, triggerable, triggerer, marker, ev)
end

-- Save compat for gammafunk_pakellas_* vaults, formerly in
-- pakellas_experiments.des.
function make_dummy_trigger_func()
  return function (data, triggerable, triggerer, marker, ev)
    -- do nothing.
   end
end

callback.pakellas_cloud_experiment_begin = make_dummy_trigger_func()
callback.pakellas_cloud_experiment_end = make_dummy_trigger_func()
callback.pakellas_cloud_cloud_cycle = make_dummy_trigger_func()
cycle_cloud_type = callback.pakellas_cloud_cycle
callback.pakellas_statue_experiment_begin = make_dummy_trigger_func()
callback.pakellas_statue_experiment_end = make_dummy_trigger_func()
callback.pakellas_its_alive_clouds = make_dummy_trigger_func()
callback.pakellas_its_alive_begin = make_dummy_trigger_func()
callback.pakellas_its_alive_end = make_dummy_trigger_func()

}}
