# Lugonu's bribes, an altar by tgw.
#
# The altar will feature an item which your current god forbids to use
# but which would be useful otherwise (if possible), or an item that is
# just useless/forbidden/redundant under your current god.

{{
function callback.tgw_lugonu_bribe_lugonu_item (data, triggerable,
                                                 triggerer, marker, ev)

  if data.triggered == true then
    return
  end

  local m = dgn.find_marker_positions_by_prop("replica_name", "altar")[1]
  if m ~= nil then
    local x, y = m:xy()

    if not you.see_cell(x, y) then
      return
    end

    local weapon = util.random_from({"short sword", "rapier",
                 "long sword", "scimitar", "glaive", "bardiche",
                 "broad axe", "battleaxe", "quarterstaff",
                 "lajatang", "morningstar", "great mace"})
    local item = {
         ["No God"]="amulet of faith ident:type",
         Ashenzari="ring of see invisible ident:type",
         Beogh="orc corpse",
         Cheibriados="potion of haste ident:type q:3",
         Dithmenos="scroll of noise ident:type q:3",
         Elyvilon="book of Necromancy / book of Death / book of Unlife",
         Gozag="randbook owner:Lugonu spells:animate_dead&simulacrum numspells:2",
         Kikubaaqudgha="rat corpse / kobold corpse",
         ["the Shining One"]="good_item " .. weapon .. " ego:pain ident:type /\
              good_item " .. weapon .. " ego:draining ident:type /\
              good_item " .. weapon .. " ego:vampirism ident:type /\
              potion of invisibility ident:type q:3",
         Okawaru="any ally scroll ident:type q:3 / any ally misc /\
              phantom mirror",
         Trog="manual of Spellcasting / manual of Air Magic w:5 /\
              manual of Earth Magic w:5 / manual of Fire Magic w:5 /\
              manual of Ice Magic w:5 / manual of Alchemy w:5 /\
              any magical staff ident:type /\
              ring of wizardry ident:type",
         Vehumet="randbook owner:Lugonu spells:magic_dart numspells:1",
         Xom="manual of Invocations",
         Yredelemnul= "good_item " .. weapon .. " ego:holy_wrath ident:type",
         Zin="good_item " .. weapon .. " ego:chaos ident:type /\
              wand of polymorph ident:type /\
              potion of lignification ident:type q:3",
    }
    data.triggered = true
    if item[you.god()] ~= nil then
      dgn.place_cloud(x, y, "purple smoke", 1)
      dgn.create_item(x, y, item[you.god()])
      crawl.god_speaks("Lugonu", "An item emerges from the Abyss! Perhaps it is an incitement to worship... or even an insult?")
    end
  end
end
}}


NAME:   tgw_lugonu_bribe
TAGS:   transparent
DEPTH:  D:12-, Depths
KFEAT:  _ = altar_lugonu
MARKER: _ = lua:portal_desc {replica_name="altar"}

{{
local tm = TriggerableFunction:new{
  func="callback.tgw_lugonu_bribe_lugonu_item",
  repeated=true,
  data={turns=you.turns(),
  tc=0, triggered=false} }
tm:add_triggerer(DgnTriggerer:new{type="player_los"})
lua_marker('_', tm)
}}

MAP
_
ENDMAP
