Skip to content
Snippets Groups Projects
Commit c8c2478f authored by dg's avatar dg
Browse files

fix amulet bug

git-svn-id: http://svn.net-core.org/repos/t-engine4@226 51575b47-30f0-44d4-a5cc-537603b46e54
parent 1b7860be
No related branches found
No related tags found
No related merge requests found
......@@ -175,18 +175,21 @@ end
function _M:addTemporaryValue(prop, v, noupdate)
self.compute_vals[prop] = self.compute_vals[prop] or {}
local t = self.compute_vals[prop]
t[#t+1] = v
local id = #t+1
while t[id] do id = id + 1 end
t[id] = v
-- Update the base prop
if not noupdate then
if type(v) == "number" then
-- Simple addition
self[prop] = (self[prop] or 0) + v
print("addTmpVal", prop, v)
print("addTmpVal", prop, v, " :=: ", #t, id)
elseif type(v) == "table" then
for k, e in pairs(v) do
self[prop][k] = (self[prop][k] or 0) + e
print("addTmpValTable", prop, k, e)
print("addTmpValTable", prop, k, e, " :=: ", #t, id)
if #t == 0 then print("*******************************WARNING") end
end
-- elseif type(v) == "boolean" then
-- -- False has precedence over true
......@@ -200,7 +203,7 @@ function _M:addTemporaryValue(prop, v, noupdate)
end
end
return #t
return id
end
--- Removes a temporary value, see addTemporaryValue()
......@@ -209,6 +212,7 @@ end
-- @param noupdate if true the actual property is not changed and needs to be changed by the caller
function _M:removeTemporaryValue(prop, id, noupdate)
local oldval = self.compute_vals[prop][id]
print("removeTempVal", prop, oldval, " :=: ", id)
self.compute_vals[prop][id] = nil
if not noupdate then
if type(oldval) == "number" then
......
......@@ -213,10 +213,12 @@ function _M:wearObject(o, replace, vocal)
if vocal then game.logSeen(self, "%s wears: %s.", self.name:capitalize(), o:getName()) end
return true
elseif o.offslot and self:getInven(o.offslot) and #(self:getInven(o.offslot)) < self:getInven(o.offslot).max then
if vocal then game.logSeen(self, "%s wears: %s.", self.name:capitalize(), o:getName()) end
-- Warning: assume there is now space
self:addObject(self:getInven(o.offslot), o)
elseif replace then
local ro = self:removeObject(inven, 1)
if vocal then game.logSeen(self, "%s wears: %s.", self.name:capitalize(), o:getName()) end
-- Warning: assume there is now space
self:addObject(inven, o)
return ro
......
......@@ -74,6 +74,7 @@ function _M:init(t, no_default)
end
function _M:act()
print("[memory]", collectgarbage("count"))
if not engine.Actor.act(self) then return end
-- Cooldown talents
......
......@@ -369,6 +369,7 @@ function _M:setupCommands()
self.player:showPickupFloor(nil, nil, function(o, item)
self.player:pickupFloor(item, true)
self.player:sortInven()
self.player:useEnergy()
end)
else
self.player:pickupFloor(1, true)
......@@ -390,6 +391,7 @@ function _M:setupCommands()
self.player:showInventory("Drop object", inven, nil, function(o, item)
self.player:dropFloor(inven, item)
self.player:sortInven()
self.player:useEnergy()
end)
end,
-- Wear item
......@@ -404,6 +406,7 @@ function _M:setupCommands()
self.player:removeObject(self.player.INVEN_INVEN, item)
end
self.player:sortInven()
self.player:useEnergy()
end)
end,
-- Takeoff item
......@@ -413,6 +416,7 @@ function _M:setupCommands()
self.player:addObject(self.player.INVEN_INVEN, o)
end
self.player:sortInven()
self.player:useEnergy()
end)
end,
......@@ -432,6 +436,7 @@ function _M:setupCommands()
self.log("You have no more "..o:getName())
self.player:sortInven()
end
self.player:useEnergy()
end
end
)
......
......@@ -7,7 +7,7 @@ newTalent{
require = spells_req1,
points = 5,
sustain_mana = 45,
cooldown = 10,
-- cooldown = 10,
tactical = {
DEFEND = 10,
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment