explore_stop for unequipped slots


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

Post Saturday, 11th June 2016, 23:26

explore_stop for unequipped slots

I suggest some form of explore_stop for unequipped slots, like in the early game stopping for the first glove/boot/cloak/helmet/etc then once equipped it only stops if it meets your other conditions such as glowing_items/artefacts/etc, if it's not too hard to implement that is.

For this message the author xbon has received thanks: 3
dowan, qwesdf, Rast
User avatar

Vestibule Violator

Posts: 1509

Joined: Wednesday, 21st September 2011, 01:10

Location: St. John's, NL, Canada

Post Sunday, 12th June 2016, 07:37

Re: explore_stop for unequipped slots

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)
}
Won all race/bg, unwon (online): Nem* Hep Uka
Favourites: 15-rune Trog, OgNe/OgIE/OgSu (usually Ash), Ds, Ru, SpEn, Ce of Chei, Qaz

For this message the author rchandra has received thanks:
xbon
User avatar

Vestibule Violator

Posts: 1591

Joined: Saturday, 3rd August 2013, 18:59

Post Sunday, 12th June 2016, 08:03

Re: explore_stop for unequipped slots

Perhaps it could auto-pickup once and only once for an armour slot that has not been occupied, then turn it off immediately.
To all new players: Ignore all strategy guides posted on the wiki, ask questions in the Advice forum, players with lots of posts normally have the best advice.

crawl.akrasiac.org:8080 <- take this link to play online or spectate.

Lair Larrikin

Posts: 29

Joined: Thursday, 13th March 2014, 16:44

Post Sunday, 12th June 2016, 22:48

Re: explore_stop for unequipped slots

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)
}


Thanks a bunch for the share, this works; never dabbled too much in lua coding so I didn't really think of the possibilities.

Return to Game Design Discussion

Who is online

Users browsing this forum: No registered users and 31 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.