ae := autopickup_exceptions

### specific inclusions ###

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

# Make it harder to miss out on zigfigs.
ae += <figurine of a ziggurat

### exclusions ###

# Exclude items useless in general or for your current character (such as
# 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

### good_item backstop (keep last) ###

ae += <good_item

# Don't pick up misc items when duplication doesn't help.
:add_autopickup_func(function (it, name)
:  if it.class(true) ~= "misc" then
:    return
:  end
:  local itname = it.name(true) -- Not the name parameter, which includes prefixes.
:  if not string.find(itname, "ziggurat") 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 it.class(true) == "jewellery"
:  and you.mutation("missing a hand") == 1 and you.race() ~= "octopode"
:  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 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 magic regeneration"
:  or itsubtype == "amulet of nothing"
:  or itsubtype == "amulet of reflection"
:  or itsubtype == "amulet of regeneration"
:  or itsubtype == "amulet of the acrobat"
:  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)
