ae := autopickup_exceptions

#### inclusions ###

# Autopickup runes by default.
ae = <rune of Zot

### exclusions ###

# Exclude items useless in general or for your current character (such as
# inedible food or armour you can't wear).
ae += useless_item

# Exclude potentially useful items of high risk, like ?torment or
# !mutation.
ae += dangerous_item

# Exclude items which your god disapproves of.
ae += forbidden

# Ignore books that you have already seen
ae += [^n]identified.*spellbook

# Don't pick up misc items when duplication doesn't help.
:add_autopickup_func(function (it, name)
:  local itname = it.name(true) -- Not the name parameter, which includes prefixes.
:  if string.find(itname, "lamp of fire")
:  or string.find(itname, "phial of floods")
:  or string.find(itname, "fan of gales")
:  or string.find(itname, "lightning rod")
:  or string.find(itname, "crystal ball of energy") then
:    for inv in iter.invent_iterator:new(items.inventory()) do
:      if itname == inv.name() then
:        return false
:      end
:    end
:  end
:  return
:end)

# If you've sacrificed a hand, don't pick up pointless duplicate rings
:add_autopickup_func(function (it, name)
:  local itsubtype = it.subtype()
:  if you.mutation("missing a hand") == 1 and you.race() ~= "octopode"
:  and it.class(true) == "jewellery"
:  and (itsubtype == "ring of positive energy"
:   or itsubtype == "ring of flight"
:   or itsubtype == "ring of poison resistance"
:   or itsubtype == "ring of wizardry"
:   or itsubtype == "ring of stealth"
:   or itsubtype == "ring of teleportation"
:   or itsubtype == "ring of protection from fire"
:   or itsubtype == "ring of protection from cold"
:   or itsubtype == "ring of resist corrosion"
:   or itsubtype == "ring of see invisible"
:   or itsubtype == "ring of magical power"
:   or itsubtype == "ring of ice"
:   or itsubtype == "ring of fire") then
:    for inv in iter.invent_iterator:new(items.inventory()) do
:      if it.class(true) == inv.class(true)
:      and itsubtype == inv.subtype() then
:        return false
:      end
:    end
:  end
:  return
:end)

: add_autopickup_func(function (it, name)
:   return it.stacks() or nil
: end)

# Excluding most amulets as you only need one of each. Likewise for some
# rings. Some items may already be excluded as bad_item, e.g. inaccuracy.
:add_autopickup_func(function (it, name)
:  if (not it.class(true) == "jewellery") or it.artefact then
:    return
:  end
:  local itsubtype = it.subtype()
:  if itsubtype == "amulet of faith"
:  or itsubtype == "amulet of guardian spirit"
:  or itsubtype == "amulet of harm"
:  or itsubtype == "amulet of inaccuracy"
:  or itsubtype == "amulet of magic regeneration"
:  or itsubtype == "amulet of nothing"
:  or itsubtype == "amulet of rage"
:  or itsubtype == "amulet of regeneration"
:  or itsubtype == "amulet of the acrobat"
:  or itsubtype == "amulet of the gourmand"
:  or itsubtype == "ring of flight"
:  or itsubtype == "ring of poison resistance"
:  or itsubtype == "ring of resist corrosion"
:  or itsubtype == "ring of see invisible" then
:    for inv in iter.invent_iterator:new(items.inventory()) do
:      if inv.class(true) == "jewellery" and inv.subtype() == itsubtype then
:        return false
:      end
:    end
:  end
:  return
:end)
