From fa15385686ee6541f1987684aa1a977a700c1f6d Mon Sep 17 00:00:00 2001 From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54> Date: Tue, 1 Jun 2010 16:07:23 +0000 Subject: [PATCH] staves are 2 handed cannot wield a 2handed weapon + 1 offhand git-svn-id: http://svn.net-core.org/repos/t-engine4@735 51575b47-30f0-44d4-a5cc-537603b46e54 --- game/engine/interface/ActorInventory.lua | 9 +++++---- game/modules/tome/data/general/objects/staves.lua | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/game/engine/interface/ActorInventory.lua b/game/engine/interface/ActorInventory.lua index 392b08c4f3..0dde9112b7 100644 --- a/game/engine/interface/ActorInventory.lua +++ b/game/engine/interface/ActorInventory.lua @@ -216,7 +216,7 @@ function _M:showPickupFloor(title, filter, action) end --- Can we wear this item? -function _M:canWearObject(o) +function _M:canWearObject(o, try_slot) local req = rawget(o, "require") -- Check prerequisites @@ -250,7 +250,8 @@ function _M:canWearObject(o) for id, inven in pairs(self.inven) do if self.inven_def[id].is_worn then for i, wo in ipairs(inven) do - if wo.slot_forbid and wo.slot_forbid == o.slot then + print("fight: ", o.name, wo.name, "::", wo.slot_forbid, try_slot or o.slot) + if wo.slot_forbid and wo.slot_forbid == (try_slot or o.slot) then return nil, "cannot use currently due to an other worn object" end end @@ -277,8 +278,8 @@ function _M:wearObject(o, replace, vocal) if self:addObject(inven, o) then if vocal then game.logSeen(self, "%s wears: %s.", self.name:capitalize(), o:getName{do_color=true}) 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{do_color=true}) end + elseif o.offslot and self:getInven(o.offslot) and #(self:getInven(o.offslot)) < self:getInven(o.offslot).max and self:canWearObject(o, o.offslot) then + if vocal then game.logSeen(self, "%s wears(offslot): %s.", self.name:capitalize(), o:getName{do_color=true}) end -- Warning: assume there is now space self:addObject(self:getInven(o.offslot), o) return true diff --git a/game/modules/tome/data/general/objects/staves.lua b/game/modules/tome/data/general/objects/staves.lua index ab59ccbb79..4c7231b056 100644 --- a/game/modules/tome/data/general/objects/staves.lua +++ b/game/modules/tome/data/general/objects/staves.lua @@ -20,6 +20,7 @@ newEntity{ define_as = "BASE_STAFF", slot = "MAINHAND", + slot_forbid = "OFFHAND", type = "weapon", subtype="staff", add_name = " (#COMBAT#)", display = "\\", color=colors.LIGHT_RED, -- GitLab