diff --git a/game/engines/default/engine/interface/ActorInventory.lua b/game/engines/default/engine/interface/ActorInventory.lua index 363e0a11f70791bc4c64f68f8ed59fc9a3735662..7b651fedd3d047f6717d968d43d22cbdc06aee3d 100644 --- a/game/engines/default/engine/interface/ActorInventory.lua +++ b/game/engines/default/engine/interface/ActorInventory.lua @@ -373,7 +373,7 @@ function _M:wearObject(o, replace, vocal) elseif replace then local ro = self:removeObject(inven, 1, true) - if vocal then game.logSeen(self, "%s wears: %s.", self.name:capitalize(), o:getName{do_color=true}) end + if vocal then game.logSeen(self, "%s wears(replacing): %s.", self.name:capitalize(), o:getName{do_color=true}) end -- Can we stack the old and new one ? if o:stack(ro) then ro = true end diff --git a/game/loader/init.lua b/game/loader/init.lua index e274afefe0f1ccffbd76b696329021f094562271..302742a6e575544ae0c6d7b0129d1a075ccfa6c0 100644 --- a/game/loader/init.lua +++ b/game/loader/init.lua @@ -133,6 +133,33 @@ load(...) fs.umount(homepath) +local te4_loader = function(name) + local bname = name + + -- Base loader + local prev = loadfile("/"..bname:gsub("%.", "/")..".lua") + + name = name:gsub("%.", "/") + for i, addon in ipairs(fs.list("/mod/addons/")) do + local fn = "/mod/addons/"..addon.."/superload/"..name..".lua" + if fs.exists(fn) then + local f = loadfile(fn) + local base = prev + setfenv(f, setmetatable({ + loadPrevious = function() + print("FROM ", fn, "loading previous!") + base(bname) + return package.loaded[bname] + end + }, {__index=_G})) + prev = f + end + end + return prev +end + +table.insert(package.loaders, 2, te4_loader) + local oldload = loadfile local dlcd_loader = function(name) if not fs.exists("/"..name:gsub("%.", "/")..".lua.stub") then return end diff --git a/game/modules/tome/class/Object.lua b/game/modules/tome/class/Object.lua index 598ec903e2f825d0715b254ceb9f6076288afb4f..c7de5dec32dc559617182e5cbb49673063ad7ac3 100644 --- a/game/modules/tome/class/Object.lua +++ b/game/modules/tome/class/Object.lua @@ -151,7 +151,7 @@ function _M:descAttribute(attr) return c.dam.."-"..(c.dam*(c.damrange or 1.1)).." power, "..(c.apr or 0).." apr, "..DamageType:get(c.damtype).name.." damage" elseif attr == "SHIELD" then local c = self.special_combat - if c and (game.player:knowTalentType("technique/shield-offense") or game.player:knowTalentType("technique/shield-defense")) then + if c and (game.player:knowTalentType("technique/shield-offense") or game.player:knowTalentType("technique/shield-defense")) or game.player:attr("show_shield_combat") then return c.dam.." dam, "..c.block.." block" else return c.block.." block" @@ -1031,7 +1031,7 @@ function _M:getTextualDesc(compare_with) desc_combat(self, compare_with, "combat") end - if (self.special_combat or can_special_combat) and (game.player:knowTalentType("technique/shield-offense") or game.player:knowTalentType("technique/shield-defense")) then + if (self.special_combat or can_special_combat) and (game.player:knowTalentType("technique/shield-offense") or game.player:knowTalentType("technique/shield-defense") or game.player:attr("show_shield_combat")) then desc:add({"color","YELLOW"}, "When used to attack (with talents):", {"color", "LAST"}, true) desc_combat(self, compare_with, "special_combat") end diff --git a/game/modules/tome/class/interface/Combat.lua b/game/modules/tome/class/interface/Combat.lua index 5f83223d28d7de0fe6a46b03cb1786904059e160..4111003c0d9c33daf5a1f2e7816c9d9e7935535b 100644 --- a/game/modules/tome/class/interface/Combat.lua +++ b/game/modules/tome/class/interface/Combat.lua @@ -139,14 +139,15 @@ function _M:attackTarget(target, damtype, mult, noenergy) -- All weapons in main hands if self:getInven(self.INVEN_MAINHAND) then for i, o in ipairs(self:getInven(self.INVEN_MAINHAND)) do - if o.combat and not o.archery then + local combat = self:getObjectCombat(o, "mainhand") + if combat and not o.archery then print("[ATTACK] attacking with", o.name) - local s, h = self:attackTargetWith(target, o.combat, damtype, mult) + local s, h = self:attackTargetWith(target, combat, damtype, mult) speed = math.max(speed or 0, s) hit = hit or h - if hit and not sound then sound = o.combat.sound - elseif not hit and not sound_miss then sound_miss = o.combat.sound_miss end - if not o.combat.no_stealth_break then break_stealth = true end + if hit and not sound then sound = combat.sound + elseif not hit and not sound_miss then sound_miss = combat.sound_miss end + if not combat.no_stealth_break then break_stealth = true end end end end @@ -155,7 +156,7 @@ function _M:attackTarget(target, damtype, mult, noenergy) if self:getInven(self.INVEN_OFFHAND) then for i, o in ipairs(self:getInven(self.INVEN_OFFHAND)) do local offmult = self:getOffHandMult(o.combat, mult) - local combat = o.combat + local combat = self:getObjectCombat(o, "offhand") if o.special_combat and o.subtype == "shield" and self:knowTalent(self.T_STONESHIELD) then combat = o.special_combat end if combat and not o.archery then print("[ATTACK] attacking with", o.name) @@ -173,12 +174,13 @@ function _M:attackTarget(target, damtype, mult, noenergy) -- Barehanded ? if not speed and self.combat then print("[ATTACK] attacking with innate combat") - local s, h = self:attackTargetWith(target, self.combat, damtype, mult) + local combat = self:getObjectCombat(o, "barehand") + local s, h = self:attackTargetWith(target, combat, damtype, mult) speed = math.max(speed or 0, s) hit = hit or h - if hit and not sound then sound = self.combat.sound - elseif not hit and not sound_miss then sound_miss = self.combat.sound_miss end - if not self.combat.no_stealth_break then break_stealth = true end + if hit and not sound then sound = combat.sound + elseif not hit and not sound_miss then sound_miss = combat.sound_miss end + if not combat.no_stealth_break then break_stealth = true end end -- We use up our own energy @@ -205,6 +207,14 @@ function _M:attackTarget(target, damtype, mult, noenergy) return hit end +--- Determines the combat field to use for this item +function _M:getObjectCombat(o, kind) + if kind == "barehand" then return self.combat end + if kind == "mainhand" then return o.combat end + if kind == "offhand" then return o.combat end + return nil +end + --- Computes a logarithmic chance to hit, opposing chance to hit to chance to miss -- This will be used for melee attacks, physical and spell resistance diff --git a/game/modules/tome/data/talents/misc/objects.lua b/game/modules/tome/data/talents/misc/objects.lua index 33bfa4f3b9c7bae42b8fbd6400cb61e89976b305..60f12df37b8747972e0cb107ec6d832e96462ad8 100644 --- a/game/modules/tome/data/talents/misc/objects.lua +++ b/game/modules/tome/data/talents/misc/objects.lua @@ -178,7 +178,7 @@ newTalent{ hard_cap = 5, range = 1, tactical = { ATTACK = 2, DEFEND = 2 }, - on_pre_use = function(self, t, silent) if not self:hasShield() then if not silent then game.logPlayer(self, "You require a weapon and a shield to use this talent.") end return false end return true end, + on_pre_use = function(self, t, silent) if not self:hasShield() then if not silent then game.logPlayer(self, "You require a shield to use this talent.") end return false end return true end, getProperties = function(self, t) local shield = self:hasShield() --if not shield then return nil end @@ -190,9 +190,14 @@ newTalent{ return p end, getBlockValue = function(self, t) - local shield = self:hasShield() - if not shield then return 0 end - return (shield.special_combat and shield.special_combat.block) or 0 + local val = 0 + local shield1 = self:hasShield() + if shield1 then val = val + (shield1.special_combat and shield1.special_combat.block) or 0 end + + if not self:getInven("MAINHAND") then return val end + local shield2 = self:getInven("OFFHAND")[1] + if shield2 then val = val + (shield2.special_combat and shield2.special_combat.block) or 0 end + return val end, getBlockedTypes = function(self, t) local shield = self:hasShield() diff --git a/game/modules/tome/dialogs/Birther.lua b/game/modules/tome/dialogs/Birther.lua index 7a77e594de6d72061f26d6c4e6363e87e1de4213..91fdaaa1c5d8dd78627efa45a25d43c4062f605c 100644 --- a/game/modules/tome/dialogs/Birther.lua +++ b/game/modules/tome/dialogs/Birther.lua @@ -571,6 +571,8 @@ function _M:isDescriptorAllowed(d, ignore_type) end end + if d.special_check and not d.special_check(self) then return nil end + -- Check it is allowed return allowed and not d.never_show end