diff --git a/game/engine/interface/ActorLife.lua b/game/engine/interface/ActorLife.lua index 8ed6b654a51f482ff6b65a5ae36d6fb12c590121..3b18d2ecca26e2cf3693312ebadf49ab666cc69e 100644 --- a/game/engine/interface/ActorLife.lua +++ b/game/engine/interface/ActorLife.lua @@ -39,8 +39,8 @@ end -- If HP is reduced to 0 then remove from the level and call the die method.<br/> -- When an actor dies its dead property is set to true, to wait until garbage collection deletes it function _M:takeHit(value, src) + if self.onTakeHit then value = self:onTakeHit(value, src) end self.life = self.life - value - if self.onTakeHit then self:onTakeHit(value, src) end if self.life <= 0 then game.logSeen(self, "%s killed %s!", src.name:capitalize(), self.name) game.level:removeEntity(self) diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua index bb75b60f4e395e766636979e339a42f5608b9c58..fbe6eed890d8fc8985632a6b6f02fa43dfd806b6 100644 --- a/game/modules/tome/class/Actor.lua +++ b/game/modules/tome/class/Actor.lua @@ -122,6 +122,21 @@ function _M:tooltip() return ("%s\n#00ffff#Level: %d\nExp: %d/%d\n#ff0000#HP: %d"):format(self.name, self.level, self.exp, self:getExpChart(self.level+1) or "---", self.life) end +--- Called before taking a hit, it's the chance to check for shields +function _M:onTakeHit(value, src) + if self:attr("mana_shield") then + local mana = self:getMana() + local mana_val = value * self:attr("mana_shield") + -- We have enough to absord the full hit + if mana_val <= mana then + self:incMana(-mana_val) + return 0 + -- Or we dont! and we do nothing + end + end + return value +end + function _M:die(src) -- Gives the killer some exp for the kill if src then diff --git a/game/modules/tome/class/NPC.lua b/game/modules/tome/class/NPC.lua index cf750d2e53da5374995e7608b99cb599532ad502..09c58e3afb927dd03240d3b8bac547c00c5a81a2 100644 --- a/game/modules/tome/class/NPC.lua +++ b/game/modules/tome/class/NPC.lua @@ -22,10 +22,11 @@ end --- Called by ActorLife interface -- We use it to pass aggression values to the AIs function _M:onTakeHit(value, src) - print("took hit from", src.name, "::", self.ai_target.actor) if not self.ai_target.actor then self.ai_target.actor = src end + + return mod.class.Actor.onTakeHit(self, value, src) end function _M:tooltip() diff --git a/game/modules/tome/data/talents/physical/combat-training.lua b/game/modules/tome/data/talents/physical/combat-training.lua index 74a56cad66738bb51c0f47bdc0721a7425cc5d81..bd0d7227fc1af82f1eb1c5262ec20b5063064cbd 100644 --- a/game/modules/tome/data/talents/physical/combat-training.lua +++ b/game/modules/tome/data/talents/physical/combat-training.lua @@ -23,7 +23,7 @@ newTalent{ type = {"physical/combat-training", 1}, mode = "passive", points = 5, - require = { stat = { con=14 }, }, + require = { stat = { con=function(level) return 14 + level * 5 end }, }, on_learn = function(self, t) self.max_life = self.max_life + 40 end, diff --git a/game/modules/tome/data/talents/spells/arcane.lua b/game/modules/tome/data/talents/spells/arcane.lua index a84b7bda568e536901efd2e8305758926b4732f7..b533fdaf239bcbf0b6e0eeeffa9e578d565b7242 100644 --- a/game/modules/tome/data/talents/spells/arcane.lua +++ b/game/modules/tome/data/talents/spells/arcane.lua @@ -13,7 +13,6 @@ newTalent{ if self:getTalentLevel(t) >= 3 then tg.type = "beam" end local x, y = self:getTarget(tg) if not x or not y then return nil end - print("lvel", self:getTalentLevel(t)) self:project(tg, x, y, DamageType.ARCANE, self:spellCrit(10 + self:combatSpellpower(0.5) * self:getTalentLevel(t))) return true end, @@ -54,13 +53,13 @@ newTalent{ points = 5, require = { stat = { mag=28 }, }, on_learn = function(self, t) - self.combat_spellpower = self.combat_spellpower + 3 + self.combat_spellpower = self.combat_spellpower + 5 end, on_unlearn = function(self, t) - self.combat_spellpower = self.combat_spellpower - 3 + self.combat_spellpower = self.combat_spellpower - 5 end, info = function(self, t) - return [[Your mastery of magic allows your to permanently increase your spellpower by 3.]] + return [[Your mastery of magic allows your to permanently increase your spellpower by 5.]] end, } @@ -74,12 +73,18 @@ newTalent{ DEFEND = 10, }, activate = function(self, t) - game.log("IMPLEMENT ME!") + local power = 3 - (self:combatSpellpower(1) * self:getTalentLevel(t)) / 280 + return { + shield = self:addTemporaryValue("mana_shield", power), + } + end, + deactivate = function(self, t, p) + self:removeTemporaryValue("mana_shield", p.shield) return true end, - require = { stat = { mag=60 }, level=40 }, + require = { stat = { mag=40 }, level=20 }, info = function(self, t) - return ([[Uses mana instead of life to take damage - The damage to mana ratio increases with the Magic stat]]):format(10 + self:combatSpellpower()) + return ([[Uses mana instead of life to take damage. Uses %0.2f mana per damage taken. + The damage to mana ratio increases with the Magic stat]]):format(3 - (self:combatSpellpower(1) * self:getTalentLevel(t)) / 280) end, }