diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua index 901786ed31b8b80f9fc323bae8fea90dff82c037..8225419acc10c50ba8794e32406d42db1445f8c6 100644 --- a/game/modules/tome/class/Actor.lua +++ b/game/modules/tome/class/Actor.lua @@ -441,15 +441,21 @@ function _M:getMaxEncumbrance() return math.floor(40 + self:getStr() * 1.8) + (self.max_encumber or 0) end -function _M:checkEncumbrance() +function _M:getEncumbrance() -- Compute encumbrance - local enc, max = 0, self:getMaxEncumbrance() + local enc = 0 for inven_id, inven in pairs(self.inven) do for item, o in ipairs(inven) do o:forAllStack(function(so) enc = enc + so.encumber end) end end - print("Total encumbrance", enc, max) + print("Total encumbrance", enc) + return enc +end + +function _M:checkEncumbrance() + -- Compute encumbrance + local enc, max = self:getEncumbrance(), self:getMaxEncumbrance() -- We are pinned to the ground if we carry too much if not self.encumbered and enc > max then diff --git a/game/modules/tome/class/Game.lua b/game/modules/tome/class/Game.lua index 7f3271f3a1f845a56b6f5014440ad9575fe5e680..6b8d4fd8eb279644980f36cade3baba6797228cb 100644 --- a/game/modules/tome/class/Game.lua +++ b/game/modules/tome/class/Game.lua @@ -508,16 +508,16 @@ function _M:setupCommands() end), SHOW_INVENTORY = function() local d - d = self.player:showEquipInven(nil, nil, function(o, inven, item) + local titleupdator = self.player:getEncumberTitleUpdator("Inventory") + d = self.player:showEquipInven(titleupdator(), nil, function(o, inven, item) local ud = require("mod.dialogs.UseItemDialog").new(self.player, o, item, inven, function() d:generateList() + d.title = titleupdator() end) self:registerDialog(ud) end) end, - SHOW_EQUIPMENT = function() - self.player:showEquipment(nil, nil, function() end) - end, + SHOW_EQUIPMENT = "SHOW_INVENTORY", WEAR_ITEM = function() self.player:playerWear() end, diff --git a/game/modules/tome/class/Player.lua b/game/modules/tome/class/Player.lua index 7e25dc82ea9917a269c27e51ca0fd256ea7f6b33..e34e212855eb8dedb28987e6a3ea0b285540659f 100644 --- a/game/modules/tome/class/Player.lua +++ b/game/modules/tome/class/Player.lua @@ -311,13 +311,22 @@ function _M:doTakeoff(inven, item, o) self.changed = true end +function _M:getEncumberTitleUpdator(title) + return function() + local enc, max = self:getEncumbrance(), self:getMaxEncumbrance() + return ("%s - Encumbered %d/%d"):format(title, enc, max) + end +end + function _M:playerPickup() -- If 2 or more objects, display a pickup dialog, otehrwise just picks up if game.level.map:getObject(self.x, self.y, 2) then - self:showPickupFloor(nil, nil, function(o, item) + local titleupdator = self:getEncumberTitleUpdator("Pickup") + local d d = self:showPickupFloor(titleupdator(), nil, function(o, item) self:pickupFloor(item, true) self:sortInven() self.changed = true + d.title = titleupdator() end) else self:pickupFloor(1, true) @@ -329,14 +338,16 @@ end function _M:playerDrop() local inven = self:getInven(self.INVEN_INVEN) - self:showInventory("Drop object", inven, nil, function(o, item) + local titleupdator = self:getEncumberTitleUpdator("Drop object") + self:showInventory(titleupdator(), inven, nil, function(o, item) self:doDrop(inven, item) end) end function _M:playerWear() local inven = self:getInven(self.INVEN_INVEN) - self:showInventory("Wield/wear object", inven, function(o) + local titleupdator = self:getEncumberTitleUpdator("Wield/wear object") + self:showInventory(titleupdator(), inven, function(o) return o:wornInven() and true or false end, function(o, item) self:doWear(inven, item, o) @@ -344,7 +355,8 @@ function _M:playerWear() end function _M:playerTakeoff() - self:showEquipment("Take off object", nil, function(o, inven, item) + local titleupdator = self:getEncumberTitleUpdator("Take off object") + self:showEquipment(titleupdator(), nil, function(o, inven, item) self:doTakeoff(inven, item, o) end) end @@ -373,7 +385,8 @@ function _M:playerUseItem(object, item) if object and item then return use_fct(object, item) end - self:showInventory(nil, self:getInven(self.INVEN_INVEN), + local titleupdator = self:getEncumberTitleUpdator("Use object") + self:showInventory(titleupdator(), self:getInven(self.INVEN_INVEN), function(o) return o:canUseObject() end, diff --git a/game/modules/tome/data/general/objects/potions.lua b/game/modules/tome/data/general/objects/potions.lua index 8494c97e0ca3ad6a811dc363c40c91f09fbab572..0a10a0f05a34b804a118bc4b4c3c6d458dfe412e 100644 --- a/game/modules/tome/data/general/objects/potions.lua +++ b/game/modules/tome/data/general/objects/potions.lua @@ -159,12 +159,67 @@ newEntity{ base = "BASE_POTION", cost = 3, use_simple = { name="cures poison", use = function(self, who) - if who:hasEffect(who.EFF_POISONED) then - who:removeEffect(who.EFF_POISONED) - game.logSeen(who, "%s cure %s from poisoning!", self:getName():capitalize(), who.name) - return "destroy", true + local target = who + local effs = {} + local known = false + + -- Go through all spell effects + for eff_id, p in pairs(target.tmp) do + local e = target.tempeffect_def[eff_id] + if e.type == "poison" then + effs[#effs+1] = {"effect", eff_id} + end + end + + for i = 1, 2 + math.floor(who:getMag() / 10) do + if #effs == 0 then break end + local eff = rng.tableRemove(effs) + + if eff[1] == "effect" then + target:removeEffect(eff[2]) + known = true + end + end + if known then + game.logSeen(who, "%s cure %s from poisons!", self:getName():capitalize(), who.name) + end + return "destroy", known + end} +} + +newEntity{ base = "BASE_POTION", + name = "potion of cure disease", + color = colors.LIGHT_GREEN, + level_range = {1, 50}, + rarity = 7, + cost = 3, + + use_simple = { name="cures poison", use = function(self, who) + local target = who + local effs = {} + local known = false + + -- Go through all spell effects + for eff_id, p in pairs(target.tmp) do + local e = target.tempeffect_def[eff_id] + if e.type == "disease" then + effs[#effs+1] = {"effect", eff_id} + end + end + + for i = 1, 2 + math.floor(who:getMag() / 10) do + if #effs == 0 then break end + local eff = rng.tableRemove(effs) + + if eff[1] == "effect" then + target:removeEffect(eff[2]) + known = true + end + end + if known then + game.logSeen(who, "%s cure %s from diseases!", self:getName():capitalize(), who.name) end - return "destroy", false + return "destroy", known end} } diff --git a/game/modules/tome/data/talents/techniques/weaponshield.lua b/game/modules/tome/data/talents/techniques/weaponshield.lua index 5c1bec8101fd3258776eb222eecf76dcc7296749..a6b06e2cc24b11d2d71bff9dd0c974fe1b3becfc 100644 --- a/game/modules/tome/data/talents/techniques/weaponshield.lua +++ b/game/modules/tome/data/talents/techniques/weaponshield.lua @@ -178,8 +178,8 @@ newTalent{ return { atk = self:addTemporaryValue("combat_dam", -10), dam = self:addTemporaryValue("combat_atk", -10), - def = self:addTemporaryValue("combat_def", 5 + self:getDex(4) * self:getTalentLevel(t) + self:getTalentLevel(self.T_SHIELD_EXPERTISE) * 2), - armor = self:addTemporaryValue("combat_armor", 5 + self:getCun(4) * self:getTalentLevel(t) + self:getTalentLevel(self.T_SHIELD_EXPERTISE)), + def = self:addTemporaryValue("combat_def", 5 + (1 + self:getDex(4)) * self:getTalentLevel(t) + self:getTalentLevel(self.T_SHIELD_EXPERTISE) * 2), + armor = self:addTemporaryValue("combat_armor", 5 + (1 + self:getDex(4)) * self:getTalentLevel(t) + self:getTalentLevel(self.T_SHIELD_EXPERTISE)), stun = stun, knock = knock } @@ -196,8 +196,8 @@ newTalent{ info = function(self, t) return ([[Enter a protective battle stance, increasing defense by %d and armor by %d at the cost of 10 attack and 10 damage. At level 5 it also makes you immune to stuns and knockbacks.]]):format( - 5 + self:getDex(4) * self:getTalentLevel(t) + self:getTalentLevel(self.T_SHIELD_EXPERTISE), - 5 + self:getCun(4) * self:getTalentLevel(t) + self:getTalentLevel(self.T_SHIELD_EXPERTISE) + 5 + (1 + self:getDex(4)) * self:getTalentLevel(t) + self:getTalentLevel(self.T_SHIELD_EXPERTISE), + 5 + (1 + self:getDex(4)) * self:getTalentLevel(t) + self:getTalentLevel(self.T_SHIELD_EXPERTISE) ) end, } diff --git a/game/modules/tome/dialogs/CharacterSheet.lua b/game/modules/tome/dialogs/CharacterSheet.lua index c9aa8c21fa489f12d59757185bb82d29285457e7..8b4ed83d05904d6205ea9e0bced36b47351f85e7 100644 --- a/game/modules/tome/dialogs/CharacterSheet.lua +++ b/game/modules/tome/dialogs/CharacterSheet.lua @@ -112,7 +112,7 @@ function _M:drawDialog(s) h = h + self.font_h for i, t in ipairs(DamageType.dam_def) do - if self.actor.inc_damage[DamageType[t.type]] then + if self.actor.inc_damage[DamageType[t.type]] and self.actor.inc_damage[DamageType[t.type]] ~= 0 then s:drawColorString(self.font, ("%s damage: #00ff00#%3d%%"):format(t.name:capitalize(), self.actor.inc_damage[DamageType[t.type]]), w, h, 255, 255, 255) h = h + self.font_h end end @@ -131,7 +131,7 @@ function _M:drawDialog(s) h = h + self.font_h for i, t in ipairs(DamageType.dam_def) do - if self.actor.resists[DamageType[t.type]] then + if self.actor.resists[DamageType[t.type]] and self.actor.resists[DamageType[t.type]] ~= 0 then s:drawColorString(self.font, ("%s Resist: #00ff00#%3d%%"):format(t.name:capitalize(), self.actor.resists[DamageType[t.type]]), w, h, 255, 255, 255) h = h + self.font_h end end