# 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({"rapier", "athame",
                 "long sword", "scimitar", "partisan", "bardiche",
                 "broad axe", "battleaxe", "quarterstaff",
                 "lajatang", "morningstar", "great mace"})
    local item = {
         ["No God"] = "amulet of faith pre_id",
         Ashenzari = "ring of see invisible pre_id",
         Beogh = "orc corpse",
         Cheibriados = "potion of haste pre_id q:3 /\
                        orb ego:mayhem pre_id",
         Dithmenos = "scroll of noise pre_id q:3",
         Elyvilon = "book of Necromancy / book of Death / book of Unlife",
         Gozag = "parchment of Animate Dead",
         Kikubaaqudgha = "rat corpse / kobold corpse",
         Okawaru = "any ally scroll pre_id q:3 / any ally misc /\
                    phantom mirror",
         Qazlal = "cloak plus:-1 ego:stealth /\
                   pair of boots plus:-1 ego:stealth",
         ["Sif Muna"] = "plate armour randart plus:-1 artprops:*silence:1&&int:-6",
         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 pre_id / ring of wizardry pre_id",
         Vehumet = "tower shield randart plus:-1 artprops:*silence:1&&int:-6",
         ["Wu Jian"] = "mundane ring of slaying pre_id",
         Xom = "manual of Invocations",
         Yredelemnul = "good_item " .. weapon .. " ego:holy_wrath pre_id",
         Zin = "good_item " .. weapon .. " ego:chaos pre_id /\
                wand of polymorph pre_id /\
                potion of lignification pre_id q:3",
         ["the Shining One"] = "good_item " .. weapon .. " ego:pain pre_id /\
              good_item " .. weapon .. " ego:draining pre_id /\
              good_item " .. weapon .. " ego:vampirism pre_id /\
              potion of invisibility pre_id q:3 / orb ego:light",
    }
    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 extra
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
