# Lugonu's bribes, an altar by tgw.
#
# The altar will feature an item which your current god forbids to use.

{{
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("slave_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", "sabre",
                 "long sword", "scimitar", "glaive", "bardiche",
                 "broad axe", "battleaxe", "quarterstaff",
                 "lajatang", "morningstar", "great mace"})
  local item = {["No God"]="amulet of Faith",
         Ashenzari="amulet of clarity / ring of see invisible",
         Beogh="good_item battleaxe ego:orc_slaying / disc of storms /\
              good_item broad axe ego:orc_slaying w:5 /\
              scroll of immolation q:3-6 / scroll of fear q:3-6",
         Cheibriados="wand of hasting w:5 / potion of speed q:2-4 /\
              potion of berserk rage q:2-4 / good_item quick blade",
         Elyvilon="lantern of shadows / book of Necromancy w:5 /\
              book of Death w:5 / book of Unlife w:5",
         Fedhas="randbook owner:Lugonu spells:necromutation numspells:1 /\
              randbook owner:Lugonu spells:simulacrum|twisted_resurrection \
                       numspells:2 /\
              randbook owner:Lugonu spells:animate_dead|sublimation_of_blood \
                       numspells:2",
         Jiyva="stone q:10-20 / large rock q:2-4",
         Kikubaaqudgha="book of Necromancy / rat corpse w:5 /\
              kobold corpse w:5 / adder corpse w:5",
         Lugonu="no",
         Makhleb="tome of destruction / rod of demonology",
         ["Nemelex Xobeh"]="scroll of random uselessness q:5-10",
         Okawaru="randbook owner:Lugonu spells:summon_butterflies numspells:1 /\
              book of Callings / scroll of unholy creation q:2-3",
         ["Sif Muna"]="staff of channeling / good_item plate armour",
         ["the Shining One"]="wand of invisibility w:20 / rod of venom /\
              book of Envenomations / Young Poisoner's Handbook /\
              potion of invisibility q:3-6",
         Trog="manual of Spellcasting w:100 / manual of Air Magic /\
              manual of Earth Magic / manual of Fire Magic /\
              manual of Ice Magic / manual of Poison Magic / any magical staff /\
              ring of wizardry",
         Vehumet="book of Callings w:5 / book of Power w:5 /\
              randbook owner:Lugonu spells:magic_dart numspells:1",
         Xom="manual of Invocations",
         Yredelemnul= "scroll of holy word q:2-4 /\
              good_item " .. weapon .. " ego:holy_wrath",
         Zin="good_item " .. weapon .. " ego:draining /\
              good_item " .. weapon .. " ego:pain /\
              good_item " .. weapon .. " ego:chaos /\
              wand of draining w:7 / wand of polymorph other w:14",
       }
         data.triggered = true
         if item[you.god()] == "no" then return else
            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
DEPTH:  D:12-27
KFEAT:  _ = altar_lugonu
MARKER: _ = lua:portal_desc {slave_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
