##############################################################################
#
# Treasure Trove (by due)
#
# Troves are once-only tolled portals to a treasure chamber, most of which
# are weighted acquirement-esque towards your skills.  Of course, there's a
# chance that you'll get rubbish (casters in an weapon/armour room and melee
# fighters in a library), but that's kind of the point.
#
# Two Trove portals are 'nasty': one features vampires behind (diggable) glass,
# and the other features two wandering shining eyes. Have a nice time!
#
##############################################################################
{{

trove = {}

function trove.get_trove_item(e, value, base_item)
  -- This function should return a table with the following values:
  --  quantity=0 (number of items, 1 unless consumables)
  --  base_type="armour" (armour, weapon, potion, scroll, jewellery, book, or miscellaneous)
  --  sub_type="robe" (short sword, etc)
  --  ego_type="resistance" (or false)
  --  plus1=4 (or false)
  --  plus2=false
  --  artefact_name=false (setting this will compare artefact names and status
  --                       and will be used as the full title for artefact books
  --                       and so-on. leave as false for non-artefacts.)
  local item = {
    quantity=1,
    base_type="",
    sub_type="",
    ego_type=false,
    plus1=false,
    plus2=false,
    artefact_name=false,
  }

  -- For testing purposes, you can force an item.
  if base_item ~= nil then
    item.quantity = base_item.quantity
    local p1, p2 = base_item.pluses()
    item.plus1 = p1
    item.plus2 = p2
    item.ego_type = base_item.ego_type
    item.base_type = base_item.base_type
    item.sub_type = base_item.sub_type
    item.artefact_name = base_item.artefact_name
    return item
  end

  -- 1/3 chance of trying to get a shop item
  if crawl.one_chance_in(3) then
  local floorlist, shoplist
  floorlist, shoplist = dgn.stash_items(value, true)
  if #shoplist ~= 0 then
    shop_item = shoplist[crawl.random2(#shoplist)+1]
    if not shop_item.identified() then
      shop_item = shoplist[crawl.random2(#shoplist)+1]
    end
    local jwith_pluses = {"ring of protection", "ring of evasion",
                          "ring of strength", "ring of intelligence",
                          "ring of dexterity"}
    local bt = shop_item.base_type
    if bt == "armour" or bt == "weapon" or bt == "jewellery" or bt == "book" then
      if shop_item.identified() then
        item.quantity = shop_item.quantity
        item.base_type = shop_item.base_type
        item.sub_type = shop_item.sub_type
        item.ego_type = shop_item.ego_type
        if shop_item.artefact then
          item.artefact_name = shop_item.artefact_name
        end
        local shop_plus1, shop_plus2 = shop_item.pluses()
        if item.base_type == "armour" then
          item.plus1 = shop_plus1
          item.plus2 = false
        elseif item.base_type == "weapon" then
          item.plus1 = shop_plus1
          item.plus2 = shop_plus2
        elseif item.base_type == "jewellery" then
          if item.sub_type == "ring of slaying" then
            item.plus1 = shop_plus1
            item.plus2 = shop_plus2
          elseif util.contains(jwith_pluses, item.sub_type) then
            item.plus1 = shop_plus1
            item.plus2 = false
          end
        elseif item.base_type == "book" and string.find(item.sub_type, "manual") then
            item.plus1 = shop_plus1
            item.plus2 = false
        else
          item.plus1 = false
          item.plus2 = false
        end
        return item
      end
    end
  end
  end

  local d = crawl.roll_dice

  -- base is item.base_type, type is item.sub_type, quant is an additional parameter (quantity, charges, etc)
  -- currently 20% armour, 15% weapon, 50% consumable, 15% miscellaneous (which are not actually taken from the player)
  local prices = {
       {base="armour", type="gold dragon armour", quant=1+d(3), weight=1},
       {base="armour", type="storm dragon armour", quant=1+d(3), weight=1},
       {base="armour", type="fire dragon armour", quant=2+d(3), weight=1},
       {base="armour", type="ice dragon armour", quant=2+d(3), weight=1},

       {base="weapon", type="demon whip", quant=3+d(3),
                                          quant2=3+d(3), weight=1},
       {base="weapon", type="demon trident", quant=3+d(3),
                                             quant2=3+d(3), weight=1},
       {base="weapon", type="demon blade", quant=3+d(3),
                                           quant2=3+d(3), weight=1},

       {base="wand", type="heal wounds", quant=7+d(2), weight=1},
       {base="potion", type="curing", quant=12+d(4)+d(4), weight=1},
       {base="potion", type="heal wounds", quant=8+d(3)+d(3), weight=1},

       {base="wand", type="hasting", quant=7+d(2), weight=1},
       {base="potion", type="speed", quant=3+d(3)+d(2), weight=1},
       {base="scroll", type="blinking", quant=3+d(3), weight=1},
       {base="scroll", type="teleportation", quant=10+d(3)+d(4), weight=1},

       {base="potion", type="cure mutation", quant=2, weight=1},
       {base="scroll", type="acquirement", quant=2, weight=1},
       {base="scroll", type="identify", quant=12+d(4)+d(4), weight=1},

       {base="miscellaneous", type="rune of Zot", quant=3, name="slimy", weight=1},
       {base="miscellaneous", type="rune of Zot", quant=11, name="abyssal", weight=1},
       {base="miscellaneous", type="horn of Geryon", weight=1} }

  local chosen = util.random_weighted_from('weight', prices)
  item.base_type = chosen.base
  item.sub_type = chosen.type
  if chosen.base == "armour" or chosen.base == "wand" then
    item.plus1 = chosen.quant
  elseif chosen.base == "weapon" then
    item.plus1 = chosen.quant
    item.plus2 = chosen.quant2
  elseif chosen.base == "scroll" or chosen.base == "potion" then
    item.quantity = chosen.quant
  end
  if chosen.type == "rune of Zot" then
    item.plus1 = chosen.quant
    item.ego_type = chosen.name -- not an actual ego, just the name of the rune
  end
  return item
end

function trove.portal(e)
    local item = trove.get_trove_item(e, 1000)

    local function stair ()
        return trove_marker  {
            toll_item = item,
            entity = "portal",
            toll_desc = "to enter a treasure trove",
            desc = "portal to a secret trove of treasure",
            overview = "Trove",
            dst = "Trove",
            floor = "expired_portal",
            feat_tile = "dngn_portal_trove_gone",
        }
    end
    e.lua_marker("O", stair)
    e.kfeat("O = enter_portal_vault")
    e.colour("O = blue")
    e.tile("O = dngn_portal_trove")
end

-- Use the following line in destination maps after all SUBSTs
-- : trove.setup_features(_G)
-- Note that the function also defines < to be the exit portal.
function trove.setup_features(e)
    e.kfeat("< = exit_portal_vault")
    e.colour("< = blue")
end

-- "any scroll good_item" still gets you 'scroll of noise', 'scroll of curse weapon', etc
-- so let's limit it to the enchant/recharge scrolls, tloc scrolls, identify scrolls,
-- mapping scrolls with a low chance of silence, vulnerability or acquirement (lowest)
function trove.good_scroll (e)
    e.item([[scroll of enchant weapon i / scroll of enchant weapon ii /
             scroll of enchant weapon iii w:5 / scroll of vorpalise weapon w:3 /
             scroll of enchant armour / scroll of identify w:20 /
             scroll of magic mapping w:5 / scroll of blinking / scroll of silence w:2 /
             scroll of recharging / scroll of acquirement w:1 / scroll of teleportation w:20 /
             scroll of vulnerability w:2 / scroll of holy word w:8 / scroll of fog w:8]])
end

function trove.place_fog(e, type, strength)
   e.lua_marker("m", fog_machine { pow_max = strength, cloud_type = type,
                     delay_min = 50, delay_max = 300, size = 12,
                     start_clouds = 1 } )
end

function trove.weapon_skills (e)
  local weapon_skills = {"Short Blades", "Long Blades", "Axes", "Maces & Flails", "Polearms", "Staves"}
  local skill_total = 0
  local nonzero_skills = 0
  for _, skill in ipairs(weapon_skills) do
    skill_total = skill_total + you.skill(skill)
    if you.skill(skill) > 0 then
      nonzero_skills = nonzero_skills + 1
    end
  end
  return skill_total / nonzero_skills
end

function trove.spell_skills (e)
  local spell_skills = {"Spellcasting", "Conjurations", "Enchantments", "Summoning", "Necromancy", "Translocation", "Transmutation", "Fire Magic", "Ice Magic", "Air Magic", "Earth Magic", "Poison Magic"}
  local skill_total = 0
  local nonzero_skills = 0
  for _, skill in ipairs(spell_skills) do
    skill_total = skill_total + you.skill(skill)
    if you.skill(skill) > 0 then
      nonzero_skills = nonzero_skills + 1
    end
  end
  return skill_total / nonzero_skills
end
}}

default-depth: D:10-, Elf:1-, Vaults:1-

##############################################################################
#
# Relevant entry portals.
#
##############################################################################

NAME:   enter_trove_0
TAGS:   uniq_trove no_monster_gen chance_trove
CHANCE: 5%
: trove.portal(_G)
MAP
O
ENDMAP

NAME:   enter_trove_1
TAGS:   uniq_trove no_monster_gen chance_trove
CHANCE: 5%
: trove.portal(_G)
COLOUR: . = blue
MAP
...
.O.
...
ENDMAP

NAME:   enter_trove_2
TAGS:   uniq_trove no_monster_gen chance_trove
CHANCE: 5%
: trove.portal(_G)
COLOUR: . = blue
COLOUR: G = blue
MAP
 @G@
@G.G@
G.O.G
@G.G@
 @G@
ENDMAP

NAME:   enter_trove_3
TAGS:   uniq_trove no_monster_gen no_wall_fixup chance_trove
CHANCE: 5%
: trove.portal(_G)
COLOUR: .cx = blue
SUBST:  x = c:20 =:6
TILE:   cx = wall_stone_dark
FTILE:  =.cxO = floor_marble
MAP
cxxxc
x...x
x.O.x
x...x
cxxxc
ENDMAP

# Of course, not everyone is willing for you to take their treasure...
NAME:   enter_trove_5
TAGS:   uniq_trove no_monster_gen chance_trove
CHANCE: 5%
: trove.portal(_G)
COLOUR: . = blue
COLOUR: c = blue
: if you.absdepth() <= 15 then
# Got drafted in from Vaults:8, while the mages try and close the portal down.
KMONS:  e = vault guard
: else
# And this time he brought some friends...
KMONS:  e = vault guard
KMONS:  l = vault guard
: end
KFEAT:  e = .
COLOUR: e = blue
KFEAT:  l = .
COLOUR: l = blue
MAP
ccccc
c...c
c.O.c
c...c
cc+cc
cl.lc
c.e.c
cl.lc
cc+cc
  @
ENDMAP

# Someone left some gold behind for you!
NAME:   enter_trove_6
TAGS:   uniq_trove no_monster_gen no_wall_fixup chance_trove
CHANCE: 5%
: trove.portal(_G)
MARKER: X = lua: props_marker { connected_exclude="true" }
SUBST:  X = =
COLOUR: = = blue
MAP
ccccccc
c$$$$$c
c$XXX$c
c$XOX$c
c$XXX$c
c$$$$$c
ccc+ccc
   @
ENDMAP

NAME:   trove_entry_trowel
TAGS:   transparent trowel_portal unrand uniq_trove
DEPTH:  *, !Trove
veto {{ return you.is_level_on_stack("Trove") }}
: trove.portal(_G)
MAP
O
ENDMAP

##############################################################################
#
# The portal vaults:
#
# Most of the vaults have 16 items of loot. Usually weighted 'd', 'e', 'f', from
# good to "worse". Some vaults have more than 16 items for specific reasons.
#
##############################################################################

default-depth: Trove

NAME:    trove_simple
WEIGHT:  60
ORIENT:  encompass
TAGS:    no_item_gen no_monster_gen allow_dup
# Loot: 16 items.
ITEM:   any useful good_item
ITEM:   acquire jewellery / any useful good_item
ITEM:   acquire weapon / acquire armour / any useful good_item
: trove.setup_features(_G)
MAP
xxxxxx
xddddx
xfeedx
xefedx
xdefdx
xx++xx
xx..xx
xx..xx
xx..xx
x....x
x.<A.x
x....x
xxxxxx
ENDMAP

NAME:    trove_garden
WEIGHT:  40
ORIENT:  encompass
TAGS:    no_item_gen no_monster_gen allow_dup
# Loot: 16 items, spread out a bit.
KFEAT:   x = X
COLOUR:  o = blue
#
# Plants come in two pattern: regular or random. Vegetation can be thin or thick.
# There are more plants near the river.
SUBST:   W = w .
: if crawl.coinflip() then
SUBST:   " = . 1:20
SUBST:   1 = . 1:1
SUBST:   ' = .
:else
SUBST:   1 = .
SUBST:   " = '
SUBST:   w = w 1:2
NSUBST:  . = 12:M / 12:1 / *:.
SHUFFLE: Mm
SUBST:   M = .
SUBST:   . = . 1:1
SUBST:   ' = . 1:3
:end
#
SUBST:   V=w. , v=w, _=.
SUBST:   1 : 1 2
SUBST:   2 = 1 .
SUBST:   1 : 1 2:2 3:1
#
MONS:    plant col:white
MONS:    plant col:white / plant col:blue w:6
MONS:    plant col:white / plant col:cyan w:3 / plant col:blue w:3
#
ITEM:    any useful good_item
ITEM:    any useful jewellery good_item / any useful good_item
ITEM:    any useful weapon good_item / any useful armour good_item / any useful good_item
KFEAT:   w = W
: trove.setup_features(_G)
: trove.place_fog(_G, "blue smoke", 30)
KFEAT:  m = .
MAP
'"WwwW'"'1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.<
"'"wwW"'".1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.
."'"ww'"'1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1
1'"'ww"'".1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.
.1'"WwW"'".1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1
1."'"ww'"'1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.
.1'"'www'"'m.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1
1."'"Www"'".1.1.1.1.m.1.1.1.1.m.1.1.1.1.1.
.1."'"ww'"'1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1
1.1'"'wwW'".1ooooooooooooooo1.1.1.1.1.1.1.
.1."'"wwW''1.o_____________o.1.1.1.1.1.1.1
1.1'"'Www'm'1o_____________o1.1.1.1.1.1.1.
.1.1'"'wwW'''o__xxxx+xxxx__o.1.m.1.1.1.1.1
1.1."'"Www'''o__xddx_xedx__o1.1.1.1.1.1.1.
.1.1."'"Www''o__xefx_xdex__o.1.1.1.1.1.1.1
1.1.1."'"Ww''o__xxx=_=xxx__o1.1.1.1.1.1.1.
.1.1.1."'"ww'o__+___1___+__o.1.m.1.1.1.1.1
1.1.1.1'"'mwWo__xxx=_=xxx__o1.1.1.1.1.1.1.
.1.1.1.1'"'wwo__xdfx_xdex__o.1.1.1.1.1.1.1
1.1.1.1."'"WwoV_xdex_xdfx__o1.1.1.1.1.1.1.
.1.1.1.1.1'"'ovvxxxx+xxxx__o.1.1.1.1.1.1.1
1.1.1.1.1.1'"oVvV__________o1.1.1.1.1.1.1.
.1.1.1.1.m.1'o_vvvV________o.1.m.1.1.1.1.1
1.1.1.1.1.1.1o_vvvvvv______o1.1.1.1.1.1.1.
.1.1.1.1.1.1.o__vvvvvvv____o.1.1.1.1.1.1.1
1.1.1.1.1.1.1o__Vvv<_Avv___o1.1.1.1.1.1.1.
.1.1.1.1.1.1.o____vvvvvvv__o.1.1.1.1.1.1.1
1.1.1.1.1.1.1o________VvvvVo"'1.1.1.1.1.1.
.1.1.1.1.1.1.ooooooooooooooo'"'1.1.1.1.1.1
1.1.1.1.1.1.1.1.1.1.1."'"Www"'".1.1.1.1.1.
.1.1.1.1.1.m.1.1.1.m.1.1'"'WwwW"'".1.1.1.1
1.1.1.1.1.1.1.1.1.1.1.1.1'"'WwmW"'".1.1.1.
.1.1.1.1.1.1.1.1.1.1.1.1.1'"'wwwW"'".1.1.1
1.1.1.1.1.1.1.1.1.1.1.1.1.1."'"WwWw'"'1.1.
.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1'"'wWwW"'".1
1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."'"WwwwW"'
<1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1.1."'"WwW"
ENDMAP

# A "library", geared towards scrolls and books (either spell or manual).
NAME:   trove_library
: if trove.spell_skills() >= trove.weapon_skills() then
WEIGHT: 30
: else
WEIGHT: 5
: end
ORIENT: encompass
TAGS:   no_item_gen no_monster_gen allow_dup
: trove.setup_features(_G)
: trove.good_scroll(_G)
ITEM:   acquire book
ITEM:   acquire:sif_muna book
MAP
xxxxxxxxxxxxx
xd.........dx
xx.xxx.xxx.xx
xf.dxe.dxe.dx
xx.xxx.xxx.xx
xe.fxd.fxd.ex
xx.xxx.xxx.xx
xe.........dx
xxxxx+++xxxxx
    x...x
    x...x
    x...x
   xx...xx
   x.....x
   x.<.A.x
   xxxxxxx
ENDMAP

# A 'jewellery shoppe' or display cabinet.
NAME:   trove_jewel_1
WEIGHT: 20
ORIENT: encompass
TAGS:   no_item_gen no_monster_gen allow_dup
# Loot: once again, 16 items.
ITEM:   acquire jewellery / any useful jewellery good_item / any jewellery
: trove.setup_features(_G)
MAP
xxxxxxxx
x......x
x.<..A.x
x......x
xxx++xxx
x......x
x+o..o+x
xdo..odx
xdo..odx
xdo..odx
xdo..odx
xdoooodx
xddddddx
xxxxxxxx
ENDMAP

# A simple treasure chamber.
NAME:   trove_jewel_2
WEIGHT: 20
ORIENT: encompass
TAGS:   no_item_gen no_monster_gen allow_dup
# Loot: 15 items this time.
ITEM:   acquire jewellery / any useful jewellery good_item / any jewellery w:2
COLOUR: x = blue
: trove.setup_features(_G)
MAP
xxxxxxxx
xddd+<Ax
xdddxxxx
xdddx
xdddx
xdddx
xxxxx
ENDMAP

# A 'weapon shoppe', same template as the jewellery shop.
NAME:   trove_weapon_1
: if trove.weapon_skills() >= trove.spell_skills() and trove.weapon_skills() >= you.skill("Unarmed Combat") then
WEIGHT: 15
: else
WEIGHT: 5
: end
ORIENT: encompass
TAGS:   no_item_gen no_monster_gen allow_dup no_species_fe
# Loot: once again, 16 items.
ITEM:   acquire weapon / any useful weapon good_item / any weapon w:2
: trove.setup_features(_G)
MAP
xxxxxxxx
x......x
x.<..A.x
x......x
xxx++xxx
x......x
x+o..o+x
xdo..odx
xdo..odx
xdo..odx
xdo..odx
xdoooodx
xddddddx
xxxxxxxx
ENDMAP

# A simple treasure chamber.
NAME:   trove_weapon_2
: if trove.weapon_skills() >= trove.spell_skills() and trove.weapon_skills() >= you.skill("Unarmed Combat") then
WEIGHT: 15
: else
WEIGHT: 5
: end
ORIENT: encompass
TAGS:   no_item_gen no_monster_gen allow_dup no_species_fe
# Loot: 15 items.
COLOUR: x = blue
ITEM:   acquire weapon / any useful weapon good_item / any weapon w:2
: trove.setup_features(_G)
MAP
xxxxxxxx
xddd+<Ax
xdddxxxx
xdddx
xdddx
xdddx
xxxxx
ENDMAP

# An 'armour shoppe', same template as the jewellery shop.
NAME:   trove_armour_1
WEIGHT: 15
ORIENT: encompass
TAGS:   no_item_gen no_monster_gen allow_dup no_species_fe no_species_op no_species_oc
# Loot: once again, 16 items.
ITEM:   acquire armour / any useful armour good_item / any armour w:2
: trove.setup_features(_G)
MAP
xxxxxxxx
x......x
x.<..A.x
x......x
xxx++xxx
x......x
x+o..o+x
xdo..odx
xdo..odx
xdo..odx
xdo..odx
xdoooodx
xddddddx
xxxxxxxx
ENDMAP

# A simple treasure chamber.
NAME:   trove_armour_2
WEIGHT: 15
ORIENT: encompass
TAGS:   no_item_gen no_monster_gen allow_dup no_species_fe no_species_op no_species_oc
# Loot: 15 items.
COLOUR: x = blue
ITEM:   acquire armour / any useful armour good_item / any armour w:2
: trove.setup_features(_G)
MAP
xxxxxxxx
xddd+<Ax
xdddxxxx
xdddx
xdddx
xdddx
xxxxx
ENDMAP

# A "themed" trove.
NAME:    trove_hunter_1
WEIGHT:  5
ORIENT:  encompass
TAGS:    no_item_gen no_monster_gen allow_dup no_species_fe no_species_op no_species_oc
# Loot:  15 items, this time.
COLOUR:  x = blue
MONS:    storm dragon zombie
MONS:    golden dragon zombie
MONS:    dragon skeleton
ITEM:    animal skin good_item / any armour good_item
ITEM:    gold dragon hide / storm dragon hide / fire dragon hide / troll hide / any useful armour good_item
ITEM:    arrow good_item / dart good_item / bolt good_item / any missile good_item
ITEM:    bow good_item / crossbow good_item / any useful weapon good_item
SHUFFLE: 123
SHUFFLE: defg
: trove.setup_features(_G)
MAP
xxxxxxx
x1x2x3x
xooooox
xdededx
xfgfgfx
xgfffgx
xxx+xxx
x.....x
x.<.A.x
x.....x
xxxxxxx
ENDMAP

# A "nasty" monsters-behind-glass map for dpeg.
NAME:   trove_nasty
ORIENT: encompass
TAGS:   no_item_gen no_monster_gen allow_dup no_vmirror no_rotate
WEIGHT: 2
COLOUR: x = blue
COLOUR: = = blue
NSUBST: " = 1:= / *:x
NSUBST: ' = 1:= / *:x
# Rock is actually diggable for those people driven mad by hatred.
MONS:   vampire
# 24 items, just because we're feeling generous.
ITEM:   any useful good_item w:10 / any
ITEM:   any useful jewellery good_item / any useful good_item
ITEM:   acquire weapon / acquire armour / any useful good_item
KFEAT:  m = iron_grate
: trove.setup_features(_G)
MAP
        mmmmmmmmmm
        mmm1..1mmm
xxxxxxxxmmmmmmmmmmxxxxxxxx
x........................x
x.x'x'xxxxxxxxxxxxxxxxxx.x
x.'edd+...............<x.x
x.xdedx.mmmmmmmmmm.xx"xx"x
x.'ddex.mmm1..1mmm."dedddx
x'xxxxx.mmmmmmmmmm.xededfx
xA................."fffedx
xxxxxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

# Another nasty vault, because dpeg asked.
NAME:   trove_treasure_island
ORIENT: encompass
TAGS:   no_item_gen no_monster_gen allow_dup no_vmirror no_rotate no_pool_fixup
WEIGHT: 2
COLOUR: x = blue
COLOUR: o = blue
COLOUR: = = blue
KFEAT:  1 = deep_water
KMONS:  1 = shining eye
# 21 items, 'cos this one is *nasty*. There are 4 extra potions of cure mutation.
ITEM:   any useful good_item / any
ITEM:   any useful jewellery good_item / any useful good_item
ITEM:   acquire weapon / acquire armour / any useful good_item
ITEM:   potion of cure mutation
: trove.setup_features(_G)
: set_border_fill_type("open_sea")
MAP
wwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwww1wwwwwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwww.wwwwwwwwwwwwww
wwwwwwwwwwww..g.wwwwwwwwwwwww
wwwwwwwwww...ge...wwwwwwwwwww
wwwwwwwwww..<dded.wwwwwwwwwww
wwwwwwwww...d...d..wwwwwwwwww
wwwwwwww.e.fd.A.d..dwwwwwwwww
wwwwwwwww...d...df..wwwwwwwww
wwwwwwwwww..gddd<d.wwwwwwwwww
wwwwwwwwwww..g.dd..wwwwwwwwww
wwwwwwwwwwwww.f..wwwwwwwwwwww
wwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwwwwwwwwww1ww
wwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwwwwwwwwwwwww
wwwwwwwwwwwwwwwwwwwwwwwwwwwww
ENDMAP

###################################
#
# minmay's troves
#
# A severe exaggeration of the "game-changing or junk" aspect of treasure
# troves. Three items, very likely to be unrandarts, and generally either
# extremely useful or extremely useless.
#
NAME:    trove_artefacts
TAGS:    no_item_gen no_monster_gen allow_dup no_species_fe
WEIGHT:  1
ORIENT:  encompass
######## There should be a better way than listing all of the unrandarts...
ITEM:    chain mail unrand:lears_chain_mail                                  /\
 randart plate armour w:50                                                   /\
         plate armour unrand:maxwells_patent_armour                          /\
 randart fire dragon armour                                                  /\
         gold dragon armour unrand:armour_of_the_dragon_king                 /\
 randart crystal plate armour                                                /\
 randart robe w:50                                                           /\
         leather armour unrand:salamander_hide_armour / robe unrand:robe_of_night /\
         robe unrand:robe_of_misfortune / animal skin unrand:skin_of_zhor    /\
         robe unrand:robe_of_augmentation / robe unrand:robe_of_folly        /\
 randart buckler / randart shield / randart large shield                     /\
         shield unrand:shield_of_resistance / shield unrand:bullseye         /\
         shield unrand:large_shield_of_ignorance                             /\
 randart cloak w:25                                                          /\
         cloak unrand:cloak_of_flash / cloak unrand:cloak_of_starlight       /\
         cloak unrand:cloak_of_the_thief
ITEM:    ring of evasion unrand:ring_of_shaolin / any randart jewellery w:60 /\
         ring of protection unrand:ring_of_robustness                        /\
         ring of invisibility unrand:ring_of_shadows                         /\
         amulet of controlled flight unrand:amulet_of_the_air                /\
         amulet of clarity unrand:amulet_of_the_four_winds                   /\
         amulet of warding unrand:amulet_of_cekugob                          /\
         amulet of warding unrand:brooch_of_shielding                        /\
         amulet of rage unrand:necklace_of_bloodlust                         /\
         helmet unrand:crown_of_dyrovepreva / randart helmet / randart cap   /\
         cap unrand:mask_of_the_dragon / randart wizard hat                  /\
         wizard hat unrand:hat_of_the_alchemist / randart pair of gloves     /\
         wizard hat unrand:hat_of_pondering / randart pair of boots          /\
         pair of boots unrand:boots_of_the_assassin                          /\
         pair of gloves unrand:gauntlets_of_war                              /\
         pair of gloves unrand:fencers_gloves
ITEM:    dagger unrand:vampires_tooth / dagger unrand:dagger_of_chilly_death /\
         dagger unrand:spriggans_knife / long sword unrand:sword_of_jihad    /\
         dagger unrand:morg / great sword unrand:sword_of_the_doom_knight    /\
         great sword unrand:sword_of_power / long sword unrand:bloodbane     /\
         scimitar unrand:scimitar_of_flaming_death / war axe unrand:arga     /\
         dagger unrand:knife_of_accuracy / long sword unrand:plutonium_sword /\
         demon blade unrand:leech / long sword unrand:sword_of_zonguldrok    /\
         staff of poison unrand:staff_of_olgreb / scythe unrand:finisher     /\
         staff unrand:elemental_staff / glaive unrand:glaive_of_prune        /\
         battleaxe unrand:wrath_of_trog / glaive unrand:glaive_of_the_guard  /\
         trident unrand:trident_of_the_octopus_king / spear unrand:wyrmbane  /\
         scythe unrand:scythe_of_curses / giant club unrand:skullcrusher     /\
         great mace unrand:undeadhunter / whip unrand:snakebite              /\
         mace unrand:sceptre_of_torment / mace unrand:mace_of_variability    /\
         sling unrand:punk / bow unrand:bow_of_krishna_"sharnga"             /\
         crossbow unrand:hellfire / longbow unrand:piercer                   /\
         randart demon blade  / blowgun unrand:blowgun_of_the_assassin
SHUFFLE: def
: trove.setup_features(_G)
MAP
xxxxxxx
xG...Gx
x.....x
x.A.<.x
x.....x
xG...Gx
xxx+xxx
 xdefx
 xxxxx
ENDMAP

# Alchemist's storehouse, has 14-26 desirable potions
NAME:    trove_alchemists_storehouse
TAGS:    no_item_gen no_monster_gen allow_dup no_species_mu
WEIGHT:  5
ORIENT:  encompass
ITEM:    potion of curing / potion of heal wounds / \
         potion of curing q:2 / potion of heal wounds q:2
ITEM:    potion of experience / potion of gain strength / \
         potion of gain intelligence / potion of gain dexterity
ITEM:    potion of might / potion of resistance / \
         potion of magic / potion of speed / \
         potion of might q:2 / potion of resistance q:2 / \
         potion of magic q:2 / potion of speed q:2
ITEM:    potion of cure mutation
SHUFFLE: df
SHUFFLE: eg
: trove.setup_features(_G)
MAP
      xxx xxx xxx
      xdx xfx xfx
xxxxx xdx xfx xfx
x.A.xxx+xxx+xxx+xxxxxx
x...+.............+egx
x.<.xxx+xxx+xxx+xxxxxx
xxxxx xdx xfx xfx
      xdx xfx xfx
      xxx xxx xxx
ENDMAP

# 20 items, but you have to dig for them.  Wand is included.
NAME:    trove_dig
TAGS:    no_item_gen no_monster_gen allow_dup no_species_fe
WEIGHT:  5
ORIENT:  encompass
ITEM:    acquire armour / any useful armour good_item / any armour w:2
ITEM:    acquire weapon / any useful weapon good_item / any weapon w:2
ITEM:    acquire jewellery / any useful jewellery good_item / any jewellery w:2
: trove.good_scroll(_G)
ITEM:   wand of digging
SHUFFLE: defg
: trove.setup_features(_G)
MAP
  vvvvv
vvv...vvv
vem.<.mfv
vvv...vvv
vem...mfv
vvv...vvv
vem...mfv
vvv...vvv
vem...mfv
vvv...vvv
vem...mfv
vvv.h.vvv
vdm...mgv
vvv...vvv
vdm...mgv
vvv...vvv
vdm...mgv
vvv...vvv
vdm...mgv
vvv...vvv
vdm.A.mgv
vvv...vvv
  vvvvv
ENDMAP

# 16 pieces of armour
NAME:   trove_armour_six_rooms
TAGS:   no_item_gen no_monster_gen allow_dup no_species_fe no_species_op no_species_oc
ORIENT: encompass
ITEM:   acquire armour / any useful armour good_item / any armour w:2
: trove.setup_features(_G)
MAP
xxxxxxxxxx
xdd+ddx.Ax
xddxdd+..x
x+xxxxxxxx
xddxdd+..x
xdd+ddx.<x
xxxxxxxxxx
ENDMAP

# 16 weapons
NAME:   trove_weapons_four_rooms
TAGS:   no_item_gen no_monster_gen allow_dup no_species_fe
ORIENT: encompass
ITEM:   acquire weapon / any useful weapon good_item / any weapon w:2
NSUBST: " = 16:d / *:.
: trove.setup_features(_G)
MAP
xxxxxxxxxxxxxxx
xA............x
x.ccccc.ccccc.x
x.c"""c.c"""c.x
x.c"T"c.c"T"c.x
x.c"""c.c"""c.x
x.cc+cc.cc+cc.x
x.............x
x.cc+cc.cc+cc.x
x.c"""c.c"""c.x
x.c"T"c.c"T"c.x
x.c"""c.c"""c.x
x.ccccc.ccccc.x
x............<x
xxxxxxxxxxxxxxx
ENDMAP

# 16 pieces of jewellery
NAME:   trove_jewellery_lava
TAGS:   no_item_gen no_monster_gen allow_dup
ORIENT: encompass
ITEM:   acquire jewellery / any useful jewellery good_item / any jewellery w:2
: trove.setup_features(_G)
MAP
xxxxxxxxxxxxxxxxxxxxxxxxxxx
xlllllllllllllllllllllllllx
xlllllllllllllllllllllllllx
xlllllllllllllllllllllllllx
xlllllllllllllllllllllllllx
xlllllllllllllllllllllllllx
xlllllllllllllllllllllllllx
xlllllllllllllllllllllllllx
xlllllllllllllllllllllllllx
xllllllllxxxmmmxxxllllllllx
xllllllllxA.ddd.Axllllllllx
xllllllllx...d...xllllllllx
xllllllllmd.....dmllllllllx
xllllllllmdd.<.ddmllllllllx
xllllllllmd.....dmllllllllx
xllllllllx...d...xllllllllx
xllllllllxA.ddd.Axllllllllx
xllllllllxxxmmmxxxllllllllx
xlllllllllllllllllllllllllx
xlllllllllllllllllllllllllx
xlllllllllllllllllllllllllx
xlllllllllllllllllllllllllx
xlllllllllllllllllllllllllx
xlllllllllllllllllllllllllx
xlllllllllllllllllllllllllx
xlllllllllllllllllllllllllx
xxxxxxxxxxxxxxxxxxxxxxxxxxx
ENDMAP

# 16 scrolls and books
NAME:   trove_books_scrolls
TAGS:   no_item_gen no_monster_gen allow_dup
ORIENT: encompass
ITEM:   acquire magical staff / acquire book / acquire:sif_muna book / any book
SUBST:  d = de
: trove.good_scroll(_G)
: trove.setup_features(_G)
MAP
     xxxxx
     xd.dx
     xx.xx
     xd.dx
    xxx+xxx
xxxxx.....xxxxx
xdxdx.....xdxdx
x...+.<.A.+...x
xdxdx.....xdxdx
xxxxx.....xxxxx
    xxx+xxx
     xd.dx
     xx.xx
     xd.dx
     xxxxx
ENDMAP

# 16 scrolls and wands
NAME:   trove_wands_scrolls
TAGS:   no_item_gen no_monster_gen allow_dup no_species_fe
ORIENT: encompass
ITEM:   acquire wand
SUBST:  e = eeed
: trove.good_scroll(_G)
: trove.setup_features(_G)
MAP
xxxxx
x...xxxx
x.A.eeexxxx
x...exe...xxxx
xxxxeee.x.eeexxxx
   xxxx...exe...x
      xxxxeee.<.x
         xxxx...x
            xxxxx
ENDMAP
