Lair Larrikin
Posts: 29
Joined: Thursday, 13th March 2014, 16:44
Although the central place for design discussion is ##crawl-dev on freenode, some may find it helpful to discuss requests and suggestions here first.
Lair Larrikin
Posts: 29
Joined: Thursday, 13th March 2014, 16:44
Vestibule Violator
Posts: 1509
Joined: Wednesday, 21st September 2011, 01:10
Location: St. John's, NL, Canada
# autopickup by Medar, tweaked by rchandra
{
local function armour_plus(it)
local plus = string.gsub(it.name(), "+", "", 1)
return tonumber(string.gsub(plus, "[^-%d]", ""))
end
local function autopickup(it, name)
if it.is_useless then
return false
end
if it.artefact then
return true
end
local class = it.class(true)
if class == "armour" then
local good_slots = {cloak="Cloak", helmet="Helmet",
gloves="Gloves", boots="Boots",
shield="Shield"}
st, _ = it.subtype()
weap = items.equipped_at("Weapon")
if st == "shield" and weap ~=nil and weap.hands == 2 then return false end
if good_slots[st] ~= nil then
if it.branded then return true end
local cur = items.equipped_at(good_slots[st])
if cur == nil then return true end
if cur.branded or cur.artefact then return false end
if armour_plus(it) ~= nil then
if armour_plus(it) > armour_plus(cur) then return true end
else
if armour_plus(cur) < 0 then return true end
end
elseif st == "body" then
local cur = items.equipped_at("armour")
if cur == nil then return false end
if cur.name("qual") ~= it.name("qual") then return false end
if it.branded then return true end
if cur.branded or cur.artefact then return false end
if armour_plus(it) ~= nil then
if armour_plus(it) > armour_plus(cur) then return true end
else
if armour_plus(cur) < 0 then return true end
end
end
end
return
end
add_autopickup_func(autopickup)
}
Vestibule Violator
Posts: 1591
Joined: Saturday, 3rd August 2013, 18:59
Lair Larrikin
Posts: 29
Joined: Thursday, 13th March 2014, 16:44
rchandra wrote:doable in the rcfile. Mine autopicks them, I assume that's close enough - there's some other stuff in there like picking up enchanted items that might be better than your own, relatively easy to tweak:
- Code:
# autopickup by Medar, tweaked by rchandra
{
local function armour_plus(it)
local plus = string.gsub(it.name(), "+", "", 1)
return tonumber(string.gsub(plus, "[^-%d]", ""))
end
local function autopickup(it, name)
if it.is_useless then
return false
end
if it.artefact then
return true
end
local class = it.class(true)
if class == "armour" then
local good_slots = {cloak="Cloak", helmet="Helmet",
gloves="Gloves", boots="Boots",
shield="Shield"}
st, _ = it.subtype()
weap = items.equipped_at("Weapon")
if st == "shield" and weap ~=nil and weap.hands == 2 then return false end
if good_slots[st] ~= nil then
if it.branded then return true end
local cur = items.equipped_at(good_slots[st])
if cur == nil then return true end
if cur.branded or cur.artefact then return false end
if armour_plus(it) ~= nil then
if armour_plus(it) > armour_plus(cur) then return true end
else
if armour_plus(cur) < 0 then return true end
end
elseif st == "body" then
local cur = items.equipped_at("armour")
if cur == nil then return false end
if cur.name("qual") ~= it.name("qual") then return false end
if it.branded then return true end
if cur.branded or cur.artefact then return false end
if armour_plus(it) ~= nil then
if armour_plus(it) > armour_plus(cur) then return true end
else
if armour_plus(cur) < 0 then return true end
end
end
end
return
end
add_autopickup_func(autopickup)
}
Return to Game Design Discussion
Users browsing this forum: No registered users and 31 guests