##############################################################################
# Yredelemnul's ordeal

# Before allowed to worship Yredelemnul, he demands a sacrifice!
{{
function callback.dk_yredelemnul_ordeal_los(data, triggerable, triggerer, marker, ev)
  if data.triggered == true then
    return
  end
  crawl.god_speaks("Yredelemnul", "You sense Yredelemnul urging you " ..
                                  "to kill the trapped human.")
  data.triggered = true
end

function callback.dk_yredelemnul_ordeal(data, triggerable, triggerer, marker, ev)
  crawl.god_speaks("Yredelemnul", "Yredelemnul welcomes your deed!")

  for slave in iter.slave_iterator("floor", 1) do
      if not dgn.is_passable(slave.x,slave.y) then
        dgn.terrain_changed(slave.x, slave.y, "floor", false, false, false)
        dgn.place_cloud(slave.x, slave.y, "foul pestilence", crawl.random2(15) + 5)
      else
        crawl.mpr("You feel a numb sensation.")
        return
      end
  end
  crawl.mpr("You hear a strange fizzling.")
end
}}

NAME:   dk_yredelemnul_ordeal
TAGS:   uniq_altar_yredelemnul temple_overflow_yredelemnul mini_float
DEPTH:  D:2-10
MONS:   goblin zombie / kobold zombie / human zombie / jackal zombie, \
        goblin skeleton / kobold skeleton / human skeleton / jackal skeleton
# Uses a neutral human to make the player feel extra evil. Neutral also means
# good gods will get mad if you choose to obey Yred.
KMONS:  h = generate_awake human hd:2 att:neutral
MARKER: h = lua:portal_desc {slave_name="victim"}
MARKER: h = lua:MonPropsMarker:new{yslave="yslave"}
MARKER: + = lua:restrict_door()
KFEAT:  h = .
KFEAT:  _ = altar_yredelemnul
KFEAT:  d = .
KITEM:  d = human skeleton / goblin skeleton / gnoll skeleton / troll skeleton
SUBST:  1 = ....12
FTILE:  _-M = floor_tomb
SUBST:  G : G.
{{
local tlos = TriggerableFunction:new{
  func="callback.dk_yredelemnul_ordeal_los",
  repeated=true}
tlos:add_triggerer(DgnTriggerer:new{type="player_los"})

local tm = TriggerableFunction:new{
  func="callback.dk_yredelemnul_ordeal", repeated=false}
tm:add_triggerer(DgnTriggerer:new{type="monster_dies", target="yslave"})

lua_marker('h', tlos)
lua_marker('_', tm)
lua_marker('M', props_marker { floor=1 })
}}
SUBST:  M = n
TILE:   n = dngn_transparent_wall_darkgray
TILE:   c = wall_undead
KPROP:  _- = no_tele_into
SUBST:  - = .
MAP
 xxxxxxx
 xcccccx
 xc---cx
 xc-_-cx
xxc---cxx
G.cMMMc.G
.1.....1.
...n+n...
...nhn...
.1.nnn.1.
.........
ENDMAP
