Low level inventory question
Posted: Tue Feb 12, 2013 11:45 pm
I've been having a few issues with the Weapon Bond talent, whose general gist is to improve the weapon your wielding "on the fly" so to speak.
It works, kinda, but I need to unequip and equip the weapon to get it note the wielder effects. Also, I've seen some cases where when it removes, certain stats are lowered to below starting (i.e. 4% physical penetration, levels up to 8%, remove it, now I have a base -4% physical penetration).
What I'd like to do is when it does the upgrade bit is:
1) remove the weapon in question from its inventory (whether MAINHAND, OFFHAND, or PSIONIC FOCUS), decreasing stats as approriate
2) Changes it properties
3) Re-equip, ignoring any requirements (and hopefully increasing stats and traits appropriately)
The above code seems to pass along the object no problem. And I'm able to change the stats of that o object no problem. But recently, when I added the following to the do_upgrade function call, I ran into some problems:
When I try to access the properties of "object", it doesn't seem to have them. If however, I don't removeObject, but reference o directly, it works fine.
At the end, I'm guessing I'll need to do a
Any help would be appreciated.
It works, kinda, but I need to unequip and equip the weapon to get it note the wielder effects. Also, I've seen some cases where when it removes, certain stats are lowered to below starting (i.e. 4% physical penetration, levels up to 8%, remove it, now I have a base -4% physical penetration).
What I'd like to do is when it does the upgrade bit is:
1) remove the weapon in question from its inventory (whether MAINHAND, OFFHAND, or PSIONIC FOCUS), decreasing stats as approriate
2) Changes it properties
3) Re-equip, ignoring any requirements (and hopefully increasing stats and traits appropriately)
Code: Select all
do_trigger = function(self,t,target)
if target and not target.weapon_bond_done then
target.weapon_bond_done = true
if self:getInven(self.INVEN_MAINHAND) then
for i, o in ipairs(self:getInven(self.INVEN_MAINHAND)) do
if (o.combat and (o.combat.talented == "axe" or o.combat.talented == "sword" or o.combat.talented == "mace" or o.combat.talented == "whip" or o.combat.talented == "trident" or o.combat.talented == "knife")) or (o.special_combat and o.special_combat.talented == "shield") then
t.do_upgrade(self,t,i,o,target)
end
end
end
if self:getInven(self.INVEN_OFFHAND) then
for i, o in ipairs(self:getInven(self.INVEN_OFFHAND)) do
if (o.combat and (o.combat.talented == "axe" or o.combat.talented == "sword" or o.combat.talented == "mace" or o.combat.talented == "whip" or o.combat.talented == "trident" or o.combat.talented == "knife")) or (o.special_combat and o.special_combat.talented == "shield") then
t.do_upgrade(self,t,i,o,target)
end
end
end
if self:getInven("PSIONIC_FOCUS") then
for i,o in ipairs(self:getInven("PSIONIC_FOCUS")) do
if type(o) == "boolean" then o = nil end
if o and ((o.combat and (o.combat.talented == "axe" or o.combat.talented == "sword" or o.combat.talented == "mace" or o.combat.talented == "whip" or o.combat.talented == "trident" or o.combat.talented == "knife")) or (o.special_combat and o.special_combat.talented == "shield")) then
t.do_upgrade(self,t,i,o,target)
end
end
end
end
Code: Select all
do_upgrade = function(self,t,inven,o,target)
... some stuff ...
local object = self:removeObject(inven, 1)
At the end, I'm guessing I'll need to do a
Code: Select all
self:addObject(inven, object)