Can I edit my autopickup to get missiles based on my skills?


Problems running or configuring the software, commands & options, compiling, different platforms, using the interface, documentation, etc.

Dungeon Dilettante

Posts: 3

Joined: Friday, 30th March 2012, 22:06

Post Saturday, 21st April 2012, 23:55

Can I edit my autopickup to get missiles based on my skills?

What I mean is, tell autopickup that if say my bows skill is >=3, pick up any arrows lying around. If slings >=3 pick up all sling bullets and stones. I see that there's already some "if/then" code in there by default to tell it which races should pick up rings of sustenance, so I'm wondering if something like this could be possible for skill levels?
User avatar

Abyss Ambulator

Posts: 1249

Joined: Sunday, 18th September 2011, 02:11

Post Sunday, 22nd April 2012, 00:02

Re: Can I edit my autopickup to get missiles based on my ski

Yes, it is possible. I don't know how to do it, but you can dive MarvinPA's awesome rcfile for the code. Here's one section that's relevant, but I don't know if it's dependent on anything else.
  Code:
local function ammo_pickup(it, name)
   local class = it.class(true)

   local sp = init_spells()

   local top_ranged_skill = math.max(
      you.skill("Slings"),
      you.skill("Bows"),
      you.skill("Crossbows"))

   if pickup_missile then
      -- Pick up ammunition needed by our skills
      if class == "missile" then
         if you.skill("Slings") > top_ranged_skill / 3 then
            if name:find("stone")  then return true end
            if name:find("bullet") then return true end
         end
         if you.skill("Bows") > top_ranged_skill / 3 then
            if name:find("arrow") then return true end
         end
         if you.skill("Crossbows") > top_ranged_skill / 3 then
            if name:find("bolt") then return true end
         end
      end
   end

   if pickup_snakable then
      if sp["Sticks to Snakes"] and it.snakable then
        if name:find("arrow") then
           return true
        end
     end
  end

  if pickup_sandblast then
     if sp["Sandblast"] then
        if name:find("stone") then
           return true
        end
     end
  end

   return false
end

and here's the whole file:
http://crawl.develz.org/configs/trunk/MarvinPA.rc

For this message the author Blade has received thanks: 4
blackflame, njvack, rchandra, Styro

Dungeon Dilettante

Posts: 3

Joined: Friday, 30th March 2012, 22:06

Post Sunday, 22nd April 2012, 00:18

Re: Can I edit my autopickup to get missiles based on my ski

Huh, thanks. I'll see if I can puzzle that out. It looks better but a lot more complicated than the solution I managed to hammer out two minutes after I posted.

  Code:
: if you.skill("Bows") >= 3 then
ae = <arrow
: end

: if you.skill("Slings") >= 3 then
ae = <bullet
ae = <stone
: end

: if you.skill("Crossbows") >= 3 then
ae = <bolt
: end

For this message the author blackflame has received thanks: 2
sir_laser, Styro
User avatar

Spider Stomper

Posts: 231

Joined: Saturday, 1st October 2011, 18:32

Post Monday, 23rd April 2012, 08:36

Re: Can I edit my autopickup to get missiles based on my ski

The previous post should be stickied.
"It's lucky to be smart, but smarter to be lucky."
- sirlaser the Eclecticist (Human Wanderer), worshipper of Ashenzari

Dungeon Master

Posts: 1613

Joined: Thursday, 16th December 2010, 21:54

Post Monday, 23rd April 2012, 14:59

Re: Can I edit my autopickup to get missiles based on my ski

What I'm using is a heavily cut-down and edited version of this by rriegs. But I don't play ranged combat builds very often so I've never really polished that section up much, I mainly just keep it for stone autopickup with sandblast.

The main advantage of doing it entirely as a Lua function like that and then using "add_autopickup_func(ammo_pickup)" is that you don't need to save and reload the game for it to work. If you just have a list of if/else lines then they'll only get called when you first load the game, so you'd have to save and reload once a skill hits 3 in this example. Not really a big deal, but nice to avoid since it's possible to do so! At some point I want to rewrite all the conditional parts of my autopickup config to work that way.

An even more simplified version should look something like:
  Code:
{
local function ammo_pickup(it, name)
   local class = it.class(true)

   if class == "missile" then
      if you.skill("Slings") >= 3 then
         if name:find("stone") then return true end
         if name:find("bullet") then return true end
      end
      if you.skill("Bows") >= 3 then
         if name:find("arrow") then return true end
      end
      if you.skill("Crossbows") >= 3 then
         if name:find("bolt") then return true end
      end
   end

   return false
end

add_autopickup_func(ammo_pickup)
}

For this message the author Kate has received thanks:
Styro

Return to Technical Support

Who is online

Users browsing this forum: No registered users and 26 guests

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