Page 1 of 1

[svn] autopickup and autoidentify are erratic

Posted: Wed Aug 31, 2011 3:02 am
by greycat
This started happening within the last couple days' updates. If there's a pile of several gold on a tile, and you step on it, you don't always pick up all of it. Sometimes I've had to step on the pile 3 times to get it all. Also, I've seen items that should have been auto-identified (single-ego daggers, etc.) that were not. These items were also part of a large pile, and I suspect that's connected.

Re: [svn] autopickup and autoidentify are erratic

Posted: Wed Aug 31, 2011 3:56 am
by tiger_eye
Yeah, whoops.

Gold is "picked up" via on_prepickup and not put into inventory, so the function pickupFloor wasn't returning a true value signifying the object was picked up. I had only tested a recent fix on gems, which are automatically put into the inventory. Anyway, good catch, and the following change fixes this:

Code: Select all

Index: game/engines/default/engine/interface/ActorInventory.lua
===================================================================
--- game/engines/default/engine/interface/ActorInventory.lua	(revision 4307)
+++ game/engines/default/engine/interface/ActorInventory.lua	(working copy)
@@ -139,7 +139,9 @@
 			return o
 		elseif not prepickup then
 			if vocal then game.logSeen(self, "%s has no room for: %s.", self.name:capitalize(), o:getName{do_color=true}) end
+			return
 		end
+		return true
 	else
 		if vocal then game.logSeen(self, "There is nothing to pickup there.") end
 	end

Re: [svn] autopickup and autoidentify are erratic

Posted: Wed Aug 31, 2011 9:06 am
by darkgod
fixed

Re: [svn] autopickup and autoidentify are erratic

Posted: Thu Sep 08, 2011 5:03 pm
by tiger_eye
whoops again.

"on_prepickup" returns true when gold is picked up AND when the golem can't pickup quest items. Hence, the original problem from here exists again. There needs to be a way to differentiate whether "on_prepickup" removes the item (like gold) or needs to skip over the item (like quest gems). The following is one way to do this:

Code: Select all

diff --git a/game/engines/default/engine/interface/ActorInventory.lua b/game/engines/default/engine/interface/ActorInventory.lua
index 066bf09..1efcb4f 100644
--- a/game/engines/default/engine/interface/ActorInventory.lua
+++ b/game/engines/default/engine/interface/ActorInventory.lua
@@ -140,6 +140,8 @@ function _M:pickupFloor(i, vocal, no_sort)
                elseif not prepickup then
                        if vocal then game.logSeen(self, "%s has no room for: %s.", self.name:capitalize(), o:getName{do_color=true}) end
                        return
+               elseif prepickup == "skip" then
+                       return
                else
                        return true
                end
diff --git a/game/modules/tome/class/Object.lua b/game/modules/tome/class/Object.lua
index 7c7aeba..4132bd2 100644
--- a/game/modules/tome/class/Object.lua
+++ b/game/modules/tome/class/Object.lua
@@ -1096,7 +1096,7 @@ end
 --- Called when trying to pickup
 function _M:on_prepickup(who, idx)
        if self.quest and who ~= game.party:findMember{main=true} then
-               return true
+               return "skip"
        end
        if who.player and self.lore then
                game.level.map:removeObject(who.x, who.y, idx)
This has been tested and verified with stacks of items including lots of gold and for the golem trying to auto-pickup quest gems.