From 67c8ae176ab54ca90d12603aba3df7fc39217bbf Mon Sep 17 00:00:00 2001 From: Alexander Sedov <alex0player@gmail.com> Date: Sun, 19 Oct 2014 08:28:09 +0400 Subject: [PATCH] Callback-ified, however good was possible, Actor.actBase. A lot of it involved renaming a single method in a talent definition. Shrug. Also talents now cool down after sustains are broken. --- game/modules/tome/class/Actor.lua | 126 +----------------- .../tome/data/talents/celestial/eclipse.lua | 6 + .../tome/data/talents/celestial/hymns.lua | 2 +- .../tome/data/talents/chronomancy/matter.lua | 2 +- .../talents/chronomancy/speed-control.lua | 3 +- .../data/talents/cursed/force-of-will.lua | 5 +- .../tome/data/talents/cursed/gloom.lua | 4 +- .../tome/data/talents/cursed/shadows.lua | 2 +- .../tome/data/talents/psionic/discharge.lua | 4 +- .../tome/data/talents/psionic/dream-forge.lua | 3 +- .../tome/data/talents/psionic/mentalism.lua | 7 + .../tome/data/talents/psionic/other.lua | 2 +- .../tome/data/talents/psionic/projection.lua | 14 +- .../tome/data/talents/psionic/psi-archery.lua | 4 +- game/modules/tome/data/talents/spells/air.lua | 2 +- .../tome/data/talents/spells/fire-alchemy.lua | 2 +- .../tome/data/talents/techniques/2hweapon.lua | 2 +- .../talents/techniques/battle-tactics.lua | 2 +- .../data/talents/techniques/conditioning.lua | 7 +- 19 files changed, 53 insertions(+), 146 deletions(-) diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua index af39254883..35747ad479 100644 --- a/game/modules/tome/class/Actor.lua +++ b/game/modules/tome/class/Actor.lua @@ -474,21 +474,6 @@ function _M:actBase() self:useBuildOrder() end - -- Break darkest light - if self:isTalentActive (self.T_DARKEST_LIGHT) and self.positive > self.negative then - self:forceUseTalent(self.T_DARKEST_LIGHT, {ignore_energy=true}) - game.logSeen(self, "%s's darkness can no longer hold back the light!", self.name:capitalize()) - end - -- Break mind links - if self:isTalentActive(self.T_MIND_LINK) then - local p = self:isTalentActive(self.T_MIND_LINK) - if not p.target or p.target.dead or not p.target:hasEffect(p.target.EFF_MIND_LINK_TARGET) or not game.level:hasEntity(p.target) then - self:forceUseTalent(self.T_MIND_LINK, {ignore_energy=true}) - end - end - - -- Cooldown talents - if not self:attr("no_talents_cooldown") then self:cooldownTalents() end -- Regen resources self:regenLife() self:regenAmmo() @@ -549,118 +534,13 @@ function _M:actBase() -- Handle thunderstorm, even if the actor is stunned or incapacitated it still works if not game.zone.wilderness and not self.dead then - if self:isTalentActive(self.T_THUNDERSTORM) then - local t = self:getTalentFromId(self.T_THUNDERSTORM) - t.do_storm(self, t) - end - if self:isTalentActive(self.T_BODY_OF_FIRE) then - local t = self:getTalentFromId(self.T_BODY_OF_FIRE) - t.do_fire(self, t) - end - if self:isTalentActive(self.T_HYMN_OF_MOONLIGHT) then - local t = self:getTalentFromId(self.T_HYMN_OF_MOONLIGHT) - t.do_beams(self, t) - end - if self:isTalentActive(self.T_BLOOD_FRENZY) then - local t = self:getTalentFromId(self.T_BLOOD_FRENZY) - t.do_turn(self, t) - end - if self:isTalentActive(self.T_TRUE_GRIT) then - local t = self:getTalentFromId(self.T_TRUE_GRIT) - t.do_turn(self, t) - end - -- this handles cursed gloom turn based effects - if self:isTalentActive(self.T_GLOOM) then - local t = self:getTalentFromId(self.T_GLOOM) - t.do_gloom(self, t) - end - -- this handles cursed call shadows turn based effects - if self:isTalentActive(self.T_CALL_SHADOWS) then - local t = self:getTalentFromId(self.T_CALL_SHADOWS) - t.do_callShadows(self, t) - end - -- this handles cursed deflection turn based effects - if self:isTalentActive(self.T_DEFLECTION) then - local t = self:getTalentFromId(self.T_DEFLECTION) - t.do_act(self, t, self:isTalentActive(self.T_DEFLECTION)) - end - -- this handles doomed unseen force turn based effects - if self.unseenForce then - local t = self:getTalentFromId(self.T_UNSEEN_FORCE) - t.do_unseenForce(self, t) - end - -- Curse of Nightmares: Nightmare - if not self.dead and self:hasEffect(self.EFF_CURSE_OF_NIGHTMARES) then - local eff = self:hasEffect(self.EFF_CURSE_OF_NIGHTMARES) - if eff.isHit then - eff.isHit = false - self.tempeffect_def[self.EFF_CURSE_OF_NIGHTMARES].doNightmare(self, eff) - end - end - -- this handles Carbon Spike regrowth - if self:isTalentActive(self.T_CARBON_SPIKES) then - local t = self:getTalentFromId(self.T_CARBON_SPIKES) - t.do_carbonRegrowth(self, t) - end - -- this handles conditioning talents - if self:knowTalent(self.T_UNFLINCHING_RESOLVE) then - local t = self:getTalentFromId(self.T_UNFLINCHING_RESOLVE) - t.do_unflinching_resolve(self, t) - end - if self:isTalentActive(self.T_DAUNTING_PRESENCE) then - local t = self:getTalentFromId(self.T_DAUNTING_PRESENCE) - if self.life < t.getMinimumLife(self, t) then - self:forceUseTalent(self.T_DAUNTING_PRESENCE, {ignore_energy=true}) - end - end - -- this handles Mind Storm - if self:isTalentActive(self.T_MIND_STORM) then - local t, p = self:getTalentFromId(self.T_MIND_STORM), self:isTalentActive(self.T_MIND_STORM) - if self:getFeedback() >=5 or p.overcharge >=1 then - t.doMindStorm(self, t, p) - end - end - - if self:isTalentActive(self.T_DREAMFORGE) then - local t, p = self:getTalentFromId(self.T_DREAMFORGE), self:isTalentActive(self.T_DREAMFORGE) - t.doForgeStrike(self, t, p) - end - - if self:isTalentActive(self.T_TIME_DILATION) then - local t, p = self:getTalentFromId(self.T_TIME_DILATION), self:isTalentActive(self.T_TIME_DILATION) - t.doTimeDilation(self, t, p) - end - - local psiweapon = self:getInven("PSIONIC_FOCUS") and self:getInven("PSIONIC_FOCUS")[1] - if (psiweapon and ( not psiweapon.combat or psiweapon.subtype == "mindstar" )) or not psiweapon then - if self:isTalentActive(self.T_KINETIC_AURA) then - local t = self:getTalentFromId(self.T_KINETIC_AURA) - t.do_kineticaura(self, t) - end - if self:isTalentActive(self.T_THERMAL_AURA) then - local t = self:getTalentFromId(self.T_THERMAL_AURA) - t.do_thermalaura(self, t) - end - if self:isTalentActive(self.T_CHARGED_AURA) then - local t = self:getTalentFromId(self.T_CHARGED_AURA) - t.do_chargedaura(self, t) - end - end - - if self:isTalentActive(self.T_BEYOND_THE_FLESH) then - local t = self:getTalentFromId(self.T_BEYOND_THE_FLESH) - t.do_tkautoattack(self, t) - end - if self:hasEffect(self.EFF_MASTERFUL_TELEKINETIC_ARCHERY) then - local t = self:getTalentFromId(self.T_MASTERFUL_TELEKINETIC_ARCHERY) - t.do_tkautoshoot(self, t) - end - self:triggerHook{"Actor:actBase:Effects"} - self:fireTalentCheck("callbackOnActBase") end + -- Cooldown talents after effects, because some of them involve breaking sustains. + if not self:attr("no_talents_cooldown") then self:cooldownTalents() end + -- Suffocate ? local air_level, air_condition = game.level.map:checkEntity(self.x, self.y, Map.TERRAIN, "air_level"), game.level.map:checkEntity(self.x, self.y, Map.TERRAIN, "air_condition") if air_level then diff --git a/game/modules/tome/data/talents/celestial/eclipse.lua b/game/modules/tome/data/talents/celestial/eclipse.lua index b2a2b4f6c2..e91e623a21 100644 --- a/game/modules/tome/data/talents/celestial/eclipse.lua +++ b/game/modules/tome/data/talents/celestial/eclipse.lua @@ -146,6 +146,12 @@ newTalent{ getEnergyConvert = function(self, t) return math.max(0, 6 - self:getTalentLevelRaw(t)) end, getDamage = function(self, t) return self:combatTalentSpellDamage(t, 10, 100) end, getRadius = function(self, t) return math.floor(self:combatTalentScale(t, 2.5, 4.5)) end, + callbackOnActBase = function(self, t) + if self.positive > self.negative then + self:forceUseTalent(t.id, {ignore_energy=true}) + game.logSeen(self, "%s's darkness can no longer hold back the light!", self.name:capitalize()) + end + end, activate = function(self, t) local timer = t.getEnergyConvert(self, t) game:playSoundNear(self, "talents/heal") diff --git a/game/modules/tome/data/talents/celestial/hymns.lua b/game/modules/tome/data/talents/celestial/hymns.lua index 644fa2afae..05958da7aa 100644 --- a/game/modules/tome/data/talents/celestial/hymns.lua +++ b/game/modules/tome/data/talents/celestial/hymns.lua @@ -168,7 +168,7 @@ newTalent{ getDamage = function(self, t) return self:combatTalentSpellDamage(t, 7, 80) end, getTargetCount = function(self, t) return math.floor(self:combatTalentScale(t, 1, 5)) end, getNegativeDrain = function(self, t) return self:combatTalentLimit(t, 0, 8, 3) end, -- Limit > 0, no regen at high levels - do_beams = function(self, t) + callbackOnActBase = function(self, t) if self:getNegative() < t.getNegativeDrain(self, t) then return end local tgts = {} diff --git a/game/modules/tome/data/talents/chronomancy/matter.lua b/game/modules/tome/data/talents/chronomancy/matter.lua index 7d50b7ea94..ee417667ba 100644 --- a/game/modules/tome/data/talents/chronomancy/matter.lua +++ b/game/modules/tome/data/talents/chronomancy/matter.lua @@ -62,7 +62,7 @@ newTalent{ tactical = { BUFF =2, DEFEND = 2 }, getDamageOnMeleeHit = function(self, t) return self:combatTalentSpellDamage(t, 1, 150, getParadoxSpellpower(self, t)) end, getArmor = function(self, t) return math.ceil(self:combatTalentSpellDamage(t, 20, 50, getParadoxSpellpower(self, t))) end, - do_carbonRegrowth = function(self, t) + callbackOnActBase = function(self, t) local maxspikes = t.getArmor(self, t) if self.carbon_armor < maxspikes then self.carbon_armor = self.carbon_armor + 1 diff --git a/game/modules/tome/data/talents/chronomancy/speed-control.lua b/game/modules/tome/data/talents/chronomancy/speed-control.lua index acbd0d107c..ebd36b2c1d 100644 --- a/game/modules/tome/data/talents/chronomancy/speed-control.lua +++ b/game/modules/tome/data/talents/chronomancy/speed-control.lua @@ -62,7 +62,8 @@ newTalent{ local fnt = "buff_font" return tostring(math.ceil(val)), fnt end, - doTimeDilation = function(self, t, p) + callbackOnActBase = function(self, t) + local p = self:isTalentActive(t.id) -- If we moved lower the power if self.x ~= p.x or self.y ~= p.y then p.x = self.x; p.y=self.y; p.charges = math.max(0, p.charges - 1) diff --git a/game/modules/tome/data/talents/cursed/force-of-will.lua b/game/modules/tome/data/talents/cursed/force-of-will.lua index 3cd78c1a4c..2cdbbd1078 100644 --- a/game/modules/tome/data/talents/cursed/force-of-will.lua +++ b/game/modules/tome/data/talents/cursed/force-of-will.lua @@ -174,7 +174,8 @@ newTalent{ p.particles = nil return true end, - do_act = function(self, t, p) + callbackOnActBase = function(self, t) + local p = self:isTalentActive(t.id) local maxDamage = t.getMaxDamage(self, t) if p.value < maxDamage and self.hate >= 0.2 then self:incHate(-0.2) @@ -328,7 +329,7 @@ newTalent{ self.unseenForce = { duration = duration, particles = particles } return true end, - do_unseenForce = function(self, t) + callbackOnActBase = function(self, t) local targets = {} local grids = core.fov.circle_grids(self.x, self.y, 5, true) for x, yy in pairs(grids) do diff --git a/game/modules/tome/data/talents/cursed/gloom.lua b/game/modules/tome/data/talents/cursed/gloom.lua index ca1913455f..5016a2b99b 100644 --- a/game/modules/tome/data/talents/cursed/gloom.lua +++ b/game/modules/tome/data/talents/cursed/gloom.lua @@ -55,9 +55,7 @@ newTalent{ self:removeParticles(p.particle) return true end, - do_gloom = function(self, tGloom) - if game.zone.wilderness then return end - + callbackOnActBase = function(self, tGloom) -- all gloom effects are handled here local tWeakness = self:getTalentFromId(self.T_WEAKNESS) local tDismay = self:getTalentFromId(self.T_DISMAY) diff --git a/game/modules/tome/data/talents/cursed/shadows.lua b/game/modules/tome/data/talents/cursed/shadows.lua index f36b4799d0..e04e2c95b3 100644 --- a/game/modules/tome/data/talents/cursed/shadows.lua +++ b/game/modules/tome/data/talents/cursed/shadows.lua @@ -355,7 +355,7 @@ newTalent{ return true end, - do_callShadows = function(self, t) + callbackOnActBase = function(self, t) if not self.shadows then self.shadows = { remainingCooldown = 0 diff --git a/game/modules/tome/data/talents/psionic/discharge.lua b/game/modules/tome/data/talents/psionic/discharge.lua index 7548e0be70..d7cbdb76d6 100644 --- a/game/modules/tome/data/talents/psionic/discharge.lua +++ b/game/modules/tome/data/talents/psionic/discharge.lua @@ -35,7 +35,9 @@ newTalent{ getDamage = function(self, t) return self:combatTalentMindDamage(t, 10, 100) end, getTargetCount = function(self, t) return math.floor(self:combatTalentScale(t, 1, 5, "log")) end, getOverchargeRatio = function(self, t) return self:combatTalentLimit(t, 10, 19, 15) end, -- Limit >10 - doMindStorm = function(self, t, p) + callbackOnActBase = function(self, t) + local p = self:isTalentActive(t.id) + if not (self:getFeedback() >= 5 or p.overcharge >= 1) then return end local tgts = {} local tgts_oc = {} local grids = core.fov.circle_grids(self.x, self.y, self:getTalentRange(t), true) diff --git a/game/modules/tome/data/talents/psionic/dream-forge.lua b/game/modules/tome/data/talents/psionic/dream-forge.lua index 9e3782660f..5543191fd0 100644 --- a/game/modules/tome/data/talents/psionic/dream-forge.lua +++ b/game/modules/tome/data/talents/psionic/dream-forge.lua @@ -232,7 +232,8 @@ newTalent{ getChance = function(self, t) return self:combatTalentLimit(t, 100, 5, 25) end, --Limit < 100% getFailChance = function(self, t) return self:combatLimit(self:combatTalentMindDamage(t, 5, 25), 67, 0, 0, 16.34, 16.34) end, -- Limit to <67% - doForgeStrike = function(self, t, p) + callbackOnActBase = function(self, t, p) + local p = self:isTalentActive(t.id) -- If we moved reset the forge if self.x ~= p.x or self.y ~= p.y or p.new then p.x = self.x; p.y=self.y; p.radius=0; p.damage=0; p.power=0; p.new = nil; diff --git a/game/modules/tome/data/talents/psionic/mentalism.lua b/game/modules/tome/data/talents/psionic/mentalism.lua index cb83e99b96..dcf9f7445b 100644 --- a/game/modules/tome/data/talents/psionic/mentalism.lua +++ b/game/modules/tome/data/talents/psionic/mentalism.lua @@ -255,6 +255,13 @@ newTalent{ return {type="hit", range=self:getTalentRange(t), talent=t} end, getBonusDamage = function(self, t) return self:combatTalentMindDamage(t, 5, 30) end, + callbackOnActBase = function(self, t) + -- Break mind links + local p = self:isTalentActive(self.T_MIND_LINK) + if not p.target or p.target.dead or not p.target:hasEffect(p.target.EFF_MIND_LINK_TARGET) or not game.level:hasEntity(p.target) then + self:forceUseTalent(t.id, {ignore_energy=true}) + end + end, activate = function(self, t) local tg = self:getTalentTarget(t) local x, y = self:getTarget(tg) diff --git a/game/modules/tome/data/talents/psionic/other.lua b/game/modules/tome/data/talents/psionic/other.lua index 17e6880d9a..e8b7f21b30 100644 --- a/game/modules/tome/data/talents/psionic/other.lua +++ b/game/modules/tome/data/talents/psionic/other.lua @@ -93,7 +93,7 @@ newTalent{ no_energy = true, no_unlearn_last = true, tactical = { BUFF = 3 }, - do_tkautoattack = function(self, t) + callbackOnActBase = function(self, t) if game.zone.wilderness then return end local tkweapon = self:getInven("PSIONIC_FOCUS")[1] if type(tkweapon) == "boolean" then tkweapon = nil end diff --git a/game/modules/tome/data/talents/psionic/projection.lua b/game/modules/tome/data/talents/psionic/projection.lua index 093cc9e2de..2fe709edec 100644 --- a/game/modules/tome/data/talents/psionic/projection.lua +++ b/game/modules/tome/data/talents/psionic/projection.lua @@ -64,6 +64,11 @@ local function aura_target(self, t) end end +local function aura_should_proc(self, t) + local psiweapon = self:getInven("PSIONIC_FOCUS") and self:getInven("PSIONIC_FOCUS")[1] + return (psiweapon and ( not psiweapon.combat or psiweapon.subtype == "mindstar" )) or not psiweapon +end + newTalent{ name = "Kinetic Aura", type = {"psionic/projection", 1}, @@ -122,7 +127,8 @@ newTalent{ getKnockback = function(self, t) return 3 + math.floor(self:getTalentLevel(t)) end, - do_kineticaura = function(self, t) + callbackOnActBase = function(self, t) + if not aura_should_proc(self, t) then return end local mast = aura_mastery(self, t) local dam = t.getAuraStrength(self, t) local tg = t.getNormalTarget(self, t) @@ -246,7 +252,8 @@ newTalent{ getSpikeCost = function(self, t) return t.sustain_psi*2/3 end, - do_thermalaura = function(self, t) + callbackOnActBase = function(self, t) + if not aura_should_proc(self, t) then return end local mast = aura_mastery(self, t) local dam = t.getAuraStrength(self, t) local tg = t.getNormalTarget(self, t) @@ -374,7 +381,8 @@ newTalent{ getNumSpikeTargets = function(self, t) return 3 + math.floor(0.5*self:getTalentLevel(t)) end, - do_chargedaura = function(self, t) + callbackOnActBase = function(self, t) + if not aura_should_proc(self, t) then return end local mast = aura_mastery(self, t) local dam = t.getAuraStrength(self, t) local tg = t.getNormalTarget(self, t) diff --git a/game/modules/tome/data/talents/psionic/psi-archery.lua b/game/modules/tome/data/talents/psionic/psi-archery.lua index 9d667f88db..debb0dd05f 100644 --- a/game/modules/tome/data/talents/psionic/psi-archery.lua +++ b/game/modules/tome/data/talents/psionic/psi-archery.lua @@ -135,9 +135,7 @@ newTalent{ direct_hit = true, tactical = { BUFF = 3 }, duration = function(self, t) return math.floor(self:combatTalentScale(t, 4, 8)) end, - do_tkautoshoot = function(self, t) - if game.zone.wilderness then return end - + callbackOnActBase = function(self, t) local targnum = 1 if self:hasEffect(self.EFF_PSIFRENZY) then targnum = self:callTalent(self.T_FRENZIED_PSIFIGHTING, "getTargNum") end local speed, hit = nil, false diff --git a/game/modules/tome/data/talents/spells/air.lua b/game/modules/tome/data/talents/spells/air.lua index 3905349e67..2700f624f2 100644 --- a/game/modules/tome/data/talents/spells/air.lua +++ b/game/modules/tome/data/talents/spells/air.lua @@ -199,7 +199,7 @@ newTalent{ getDamage = function(self, t) return self:combatTalentSpellDamage(t, 15, 80) end, getTargetCount = function(self, t) return math.floor(self:getTalentLevel(t)) end, getManaDrain = function(self, t) return -1.5 * self:getTalentLevelRaw(t) end, - do_storm = function(self, t) + callbackOnActBase = function(self, t) local mana = t.getManaDrain(self, t) if self:getMana() <= mana + 1 then 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 068154f2f8..bef2597da6 100644 --- a/game/modules/tome/data/talents/spells/fire-alchemy.lua +++ b/game/modules/tome/data/talents/spells/fire-alchemy.lua @@ -172,7 +172,7 @@ newTalent{ getResistance = function(self, t) return self:combatTalentSpellDamage(t, 5, 45) end, getFireDamageInSight = function(self, t) return self:combatTalentSpellDamage(t, 15, 70) end, getManaDrain = function(self, t) return -0.1 * self:getTalentLevelRaw(t) end, - do_fire = function(self, t) + callbackOnActBase = function(self, t) if self:getMana() <= 0 then self:forceUseTalent(t.id, {ignore_energy=true}) return diff --git a/game/modules/tome/data/talents/techniques/2hweapon.lua b/game/modules/tome/data/talents/techniques/2hweapon.lua index ffd254f913..9fe0e5317c 100644 --- a/game/modules/tome/data/talents/techniques/2hweapon.lua +++ b/game/modules/tome/data/talents/techniques/2hweapon.lua @@ -363,7 +363,7 @@ newTalent{ sustain_stamina = 70, no_energy = true, tactical = { BUFF = 1 }, - do_turn = function(self, t) + callbackOnActBase = function(self, t) if self.blood_frenzy > 0 then self.blood_frenzy = math.max(self.blood_frenzy - 2, 0) end diff --git a/game/modules/tome/data/talents/techniques/battle-tactics.lua b/game/modules/tome/data/talents/techniques/battle-tactics.lua index 0168ddaa0e..cd879991e9 100644 --- a/game/modules/tome/data/talents/techniques/battle-tactics.lua +++ b/game/modules/tome/data/talents/techniques/battle-tactics.lua @@ -109,7 +109,7 @@ newTalent{ --Note: this can result in > 100% resistancs (before cap) at high talent levels to keep up with opposing resistance lowering talents resistCoeff = function(self, t) return self:combatTalentScale(t, 25, 45) end, getCapApproach = function(self, t) return self:combatTalentLimit(t, 1, 0.15, 0.5) end, - do_turn = function(self, t) --called by mod.class.Actor:actBase + callbackOnActBase = function(self, t) --called by mod.class.Actor:actBase local p = self:isTalentActive(t.id) if p.resid then self:removeTemporaryValue("resists", p.resid) end if p.cresid then self:removeTemporaryValue("resists_cap", p.cresid) end diff --git a/game/modules/tome/data/talents/techniques/conditioning.lua b/game/modules/tome/data/talents/techniques/conditioning.lua index c66aaa63e2..0613fafb66 100644 --- a/game/modules/tome/data/talents/techniques/conditioning.lua +++ b/game/modules/tome/data/talents/techniques/conditioning.lua @@ -54,7 +54,7 @@ newTalent{ mode = "passive", points = 5, getChance = function(self, t) return self:combatStatLimit("con", 1, .28, .745)*self:combatTalentLimit(t,100, 28,74.8) end, -- Limit < 100% - do_unflinching_resolve = function(self, t) + callbackOnActBase = function(self, t) local effs = {} -- Go through all spell effects for eff_id, p in pairs(self.tmp) do @@ -121,6 +121,11 @@ newTalent{ end end) end, + callbackOnActBase = function(self, t) + if self.life < t.getMinimumLife(self, t) then + self:forceUseTalent(t.id, {ignore_energy=true}) + end + end, activate = function(self, t) local ret = { } return ret -- GitLab