From 430713bc10c9fe99c8d333714235625e4e8fdf43 Mon Sep 17 00:00:00 2001 From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54> Date: Wed, 6 Oct 2010 20:27:10 +0000 Subject: [PATCH] Fixed time passing when learning talents git-svn-id: http://svn.net-core.org/repos/t-engine4@1442 51575b47-30f0-44d4-a5cc-537603b46e54 --- game/modules/tome/class/Actor.lua | 29 +++++++++++-------- game/modules/tome/class/NPC.lua | 5 +--- game/modules/tome/class/interface/Combat.lua | 15 ++-------- .../tome/data/general/objects/egos/gloves.lua | 2 +- .../tome/data/talents/corruptions/bone.lua | 5 +--- .../tome/data/talents/divine/chants.lua | 5 +--- .../tome/data/talents/divine/hymns.lua | 5 +--- game/modules/tome/data/talents/spells/air.lua | 5 +--- .../tome/data/talents/spells/fire-alchemy.lua | 5 +--- .../tome/data/talents/spells/infusion.lua | 5 +--- .../modules/tome/data/talents/spells/meta.lua | 5 +--- game/modules/tome/dialogs/DeathDialog.lua | 5 +--- .../tome/dialogs/LevelupStatsDialog.lua | 8 ++--- .../tome/dialogs/LevelupTalentsDialog.lua | 8 ++--- 14 files changed, 34 insertions(+), 73 deletions(-) diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua index e7e9c2aae2..856c9cec8f 100644 --- a/game/modules/tome/class/Actor.lua +++ b/game/modules/tome/class/Actor.lua @@ -176,10 +176,7 @@ function _M:act() for tid, _ in pairs(self.sustain_talents) do local t = self:getTalentFromId(tid) if (t.sustain_mana and self.mana < 1) or (t.sustain_stamina and self.stamina < 1) then - local old = self.energy.value - self.energy.value = 100000 - self:useTalent(tid) - self.energy.value = old + self:forceUseTalent(tid, {ignore_energy=true}) end end end @@ -559,10 +556,7 @@ function _M:onTakeHit(value, src) local dam = self.disruption_shield_absorb -- Deactivate without loosing energy - local old = self.energy.value - self.energy.value = 10000 - self:useTalent(self.T_DISRUPTION_SHIELD) - self.energy.value = old + self:forceUseTalent(t.T_DISRUPTION_SHIELD, {ignore_energy=true}) -- Explode! game.logSeen(self, "%s disruption shield collapses and then explodes in a powerful manastorm!", self.name:capitalize()) @@ -1311,6 +1305,20 @@ function _M:postUseTalent(ab, ret) return true end +--- Force a talent to activate without using energy or such +function _M:forceUseTalent(t, def) + local oldpause = game.paused + local oldenergy = self.energy.value + if def.ignore_energy then self.energy.value = 10000 end + + self:useTalent(t, nil, def.force_level, def.ignore_cd, def.force_target) + + if def.ignore_energy then + game.paused = oldpause + self.energy.value = oldenergy + end +end + --- Breaks stealth if active function _M:breakStealth() if self:isTalentActive(self.T_STEALTH) then @@ -1322,10 +1330,7 @@ function _M:breakStealth() -- Do not break stealth if rng.percent(chance) then return end - local old = self.energy.value - self.energy.value = 100000 - self:useTalent(self.T_STEALTH) - self.energy.value = old + self:forceUseTalent(self.T_STEALTH, {ignore_energy=true}) self.changed = true end end diff --git a/game/modules/tome/class/NPC.lua b/game/modules/tome/class/NPC.lua index 823562db3c..69affff6a7 100644 --- a/game/modules/tome/class/NPC.lua +++ b/game/modules/tome/class/NPC.lua @@ -118,10 +118,7 @@ function _M:die(src) if eff[1] == "effect" then self:removeEffect(eff[2]) else - local old = self.energy.value - self:useTalent(eff[2]) - -- Prevent using energy - self.energy.value = old + self:forceUseTalent(eff[2], {ignore_energy=true}) end end self.life = self.max_life diff --git a/game/modules/tome/class/interface/Combat.lua b/game/modules/tome/class/interface/Combat.lua index 7349a8aea6..a71cc2be7d 100644 --- a/game/modules/tome/class/interface/Combat.lua +++ b/game/modules/tome/class/interface/Combat.lua @@ -246,10 +246,7 @@ function _M:attackTargetWith(target, weapon, damtype, mult) DamageType:get(DamageType.LIGHT).projector(self, target.x, target.y, DamageType.LIGHT, dam) self:incPositive(-3) if self:getPositive() <= 0 then - local old = self.energy.value - self.energy.value = 100000 - self:useTalent(self.T_WEAPON_OF_LIGHT) - self.energy.value = old + self:forceUseTalent(self.T_WEAPON_OF_LIGHT, {ignore_energy=true}) end end @@ -272,10 +269,7 @@ function _M:attackTargetWith(target, weapon, damtype, mult) if tid then print("[ARCANE COMBAT] autocast ",self:getTalentFromId(tid).name) local old_cd = self:isTalentCoolingDown(self:getTalentFromId(tid)) - local old = self.energy.value - self.energy.value = 100000 - self:useTalent(tid, nil, nil, nil, target) - self.energy.value = old + self:forceUseTalent(tid, {ignore_energy=true, force_target=target}) -- Do not setup a cooldown if not old_cd then self.talents_cd[tid] = nil @@ -288,10 +282,7 @@ function _M:attackTargetWith(target, weapon, damtype, mult) if hitted and not target.dead and weapon.talent_on_hit and next(weapon.talent_on_hit) then for tid, data in pairs(weapon.talent_on_hit) do if rng.percent(data.chance) then - local old = self.energy.value - self.energy.value = 100000 - self:useTalent(tid, nil, data.level, true, target) - self.energy.value = old + self:forceUseTalent(tid, {ignore_energy=true, force_target=target, force_level=data.level}) end end end diff --git a/game/modules/tome/data/general/objects/egos/gloves.lua b/game/modules/tome/data/general/objects/egos/gloves.lua index d95a9cf341..7f7a048a41 100644 --- a/game/modules/tome/data/general/objects/egos/gloves.lua +++ b/game/modules/tome/data/general/objects/egos/gloves.lua @@ -177,6 +177,6 @@ newEntity{ cost = 15, wielder = { inc_stats = { [Stats.STAT_STR] = resolvers.mbonus_material(2, 2, function(e, v) return v * 3 end) }, - disarm_immune = 0.7,, + disarm_immune = 0.7, }, } diff --git a/game/modules/tome/data/talents/corruptions/bone.lua b/game/modules/tome/data/talents/corruptions/bone.lua index 195b2684c9..812fa7f101 100644 --- a/game/modules/tome/data/talents/corruptions/bone.lua +++ b/game/modules/tome/data/talents/corruptions/bone.lua @@ -123,10 +123,7 @@ newTalent{ game.logPlayer(self, "Your bone shield absorbs the damage!") self:removeParticles(table.remove(p.particles)) if #p.particles <= 0 then - local old = self.energy.value - self.energy.value = 100000 - self:useTalent(t.id) - self.energy.value = old + self:forceUseTalent(t.id, {ignore_energy=true}) end end, activate = function(self, t) diff --git a/game/modules/tome/data/talents/divine/chants.lua b/game/modules/tome/data/talents/divine/chants.lua index a0b71bdbc4..cb18a1be73 100644 --- a/game/modules/tome/data/talents/divine/chants.lua +++ b/game/modules/tome/data/talents/divine/chants.lua @@ -21,10 +21,7 @@ local function cancelChants(self) local chants = {self.T_CHANT_OF_FORTITUDE, self.T_CHANT_OF_FORTRESS, self.T_CHANT_OF_RESISTANCE, self.T_CHANT_OF_LIGHT} for i, t in ipairs(chants) do if self:isTalentActive(t) then - local old = self.energy.value - self.energy.value = 100000 - self:useTalent(t) - self.energy.value = old + self:forceUseTalent(t, {ignore_energy=true}) end end end diff --git a/game/modules/tome/data/talents/divine/hymns.lua b/game/modules/tome/data/talents/divine/hymns.lua index f70b761b98..dc6a26d3eb 100644 --- a/game/modules/tome/data/talents/divine/hymns.lua +++ b/game/modules/tome/data/talents/divine/hymns.lua @@ -21,10 +21,7 @@ local function cancelHymns(self) local hymns = {self.T_HYMN_OF_SHADOWS, self.T_HYMN_OF_DETECTION, self.T_HYMN_OF_PERSEVERANCE, self.T_HYMN_OF_MOONLIGHT} for i, t in ipairs(hymns) do if self:isTalentActive(t) then - local old = self.energy.value - self.energy.value = 100000 - self:useTalent(t) - self.energy.value = old + self:forceUseTalent(t, {ignore_energy=true}) end end end diff --git a/game/modules/tome/data/talents/spells/air.lua b/game/modules/tome/data/talents/spells/air.lua index 3c89b88bb9..30cc85d6e8 100644 --- a/game/modules/tome/data/talents/spells/air.lua +++ b/game/modules/tome/data/talents/spells/air.lua @@ -180,10 +180,7 @@ newTalent{ direct_hit = true, do_storm = function(self, t) if self:getMana() <= 0 then - local old = self.energy.value - self.energy.value = 100000 - self:useTalent(self.T_THUNDERSTORM) - self.energy.value = old + self:forceUseTalent(t.id, {ignore_energy=true}) return end diff --git a/game/modules/tome/data/talents/spells/fire-alchemy.lua b/game/modules/tome/data/talents/spells/fire-alchemy.lua index 1c873f619c..8fb68dd86e 100644 --- a/game/modules/tome/data/talents/spells/fire-alchemy.lua +++ b/game/modules/tome/data/talents/spells/fire-alchemy.lua @@ -140,10 +140,7 @@ newTalent{ range = 12, do_fire = function(self, t) if self:getMana() <= 0 then - local old = self.energy.value - self.energy.value = 100000 - self:useTalent(self.T_BODY_OF_FIRE) - self.energy.value = old + self:forceUseTalent(t.id, {ignore_energy=true}) return end diff --git a/game/modules/tome/data/talents/spells/infusion.lua b/game/modules/tome/data/talents/spells/infusion.lua index 8b94ee1ffa..9bb07480a8 100644 --- a/game/modules/tome/data/talents/spells/infusion.lua +++ b/game/modules/tome/data/talents/spells/infusion.lua @@ -21,10 +21,7 @@ local function cancelInfusions(self) local chants = {self.T_ACID_INFUSION, self.T_LIGHTNING_INFUSION, self.T_FROST_INFUSION} for i, t in ipairs(chants) do if self:isTalentActive(t) then - local old = self.energy.value - self.energy.value = 100000 - self:useTalent(t) - self.energy.value = old + self:forceUseTalent(t, {ignore_energy=true}) end end end diff --git a/game/modules/tome/data/talents/spells/meta.lua b/game/modules/tome/data/talents/spells/meta.lua index b540ff3ea4..e337039f95 100644 --- a/game/modules/tome/data/talents/spells/meta.lua +++ b/game/modules/tome/data/talents/spells/meta.lua @@ -61,10 +61,7 @@ newTalent{ if eff[1] == "effect" then target:removeEffect(eff[2]) else - local old = target.energy.value - target:useTalent(eff[2]) - -- Prevent using energy - target.energy.value = old + target:forceUseTalent(eff[2], {ignore_energy=true}) end end game:playSoundNear(self, "talents/spell_generic") diff --git a/game/modules/tome/dialogs/DeathDialog.lua b/game/modules/tome/dialogs/DeathDialog.lua index ac2e8ad2b8..4020fd4a10 100644 --- a/game/modules/tome/dialogs/DeathDialog.lua +++ b/game/modules/tome/dialogs/DeathDialog.lua @@ -72,10 +72,7 @@ function _M:cleanActor(actor) if eff[1] == "effect" then actor:removeEffect(eff[2]) else - local old = actor.energy.value - actor:useTalent(eff[2]) - -- Prevent using energy - actor.energy.value = old + actor:forceUseTalent(eff[2], {ignore_energy=true}) end end end diff --git a/game/modules/tome/dialogs/LevelupStatsDialog.lua b/game/modules/tome/dialogs/LevelupStatsDialog.lua index 3bd82492bb..aaccd1b413 100644 --- a/game/modules/tome/dialogs/LevelupStatsDialog.lua +++ b/game/modules/tome/dialogs/LevelupStatsDialog.lua @@ -103,12 +103,8 @@ function _M:finish() end end for i, tid in ipairs(reset) do - local old = self.actor.energy.value - self.actor:useTalent(tid) - self.actor.energy.value = old - self.actor.talents_cd[tid] = nil - self.actor:useTalent(tid) - self.actor.energy.value = old + self.actor:forceUseTalent(tid, {ignore_energy=true, ingore_cd=true}) + self.actor:forceUseTalent(tid, {ignore_energy=true, ingore_cd=true}) end end diff --git a/game/modules/tome/dialogs/LevelupTalentsDialog.lua b/game/modules/tome/dialogs/LevelupTalentsDialog.lua index 3ada6cdd34..8724d9f61a 100644 --- a/game/modules/tome/dialogs/LevelupTalentsDialog.lua +++ b/game/modules/tome/dialogs/LevelupTalentsDialog.lua @@ -210,12 +210,8 @@ function _M:finish() end end for i, tid in ipairs(reset) do - local old = self.actor.energy.value - self.actor:useTalent(tid) - self.actor.energy.value = old - self.actor.talents_cd[tid] = nil - self.actor:useTalent(tid) - self.actor.energy.value = old + self.actor:forceUseTalent(tid, {ignore_energy=true, ingore_cd=true}) + self.actor:forceUseTalent(tid, {ignore_energy=true, ingore_cd=true}) end end -- GitLab