Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function _M:postUseTalent(ab, ret, silent)
- if not ret then return end
- self.changed = true
- if self.talent_kind_log then
- if ab.is_spell then self.talent_kind_log.spell = (self.talent_kind_log.spell or 0) + 1 end
- if ab.is_summon then self.talent_kind_log.summon = (self.talent_kind_log.summon or 0) + 1 end
- if ab.is_mind then self.talent_kind_log.mind = (self.talent_kind_log.mind or 0) + 1 end
- if ab.is_nature then self.talent_kind_log.nature = (self.talent_kind_log.nature or 0) + 1 end
- end
- -- Handle inscriptions (delay it so it does not affect current inscription)
- game:onTickEnd(function()
- if ab.type[1] == "inscriptions/infusions" then
- self:setEffect(self.EFF_INFUSION_COOLDOWN, 10, {power=1})
- if self:knowTalent(self.T_FUNGAL_BLOOD) then self:triggerTalent(self.T_FUNGAL_BLOOD) end
- elseif ab.type[1] == "inscriptions/runes" then
- self:setEffect(self.EFF_RUNE_COOLDOWN, 10, {power=1})
- elseif ab.type[1] == "inscriptions/taints" then
- self:setEffect(self.EFF_TAINT_COOLDOWN, 10, {power=1})
- end
- end)
- if not ab.no_energy then
- if ab.is_spell then
- self:useEnergy(game.energy_to_act * self:combatSpellSpeed())
- elseif ab.is_summon then
- self:useEnergy(game.energy_to_act * self:combatSummonSpeed())
- elseif ab.type[1]:find("^technique/") then
- self:useEnergy(game.energy_to_act * self:combatSpeed())
- elseif ab.is_mind then
- self:useEnergy(game.energy_to_act * self:combatMindSpeed())
- else
- self:useEnergy()
- end
- -- Free melee blow
- if ab.is_spell and ab.mode ~= "sustained" and self:knowTalent(self.T_CORRUPTED_STRENGTH) and not self:attr("forbid_corrupted_strength_blow") and not self.turn_procs.corrupted_strength then
- local tgts = {}
- for _, c in pairs(util.adjacentCoords(self.x, self.y)) do
- local target = game.level.map(c[1], c[2], Map.ACTOR)
- if target and self:reactionToward(target) < 0 then tgts[#tgts+1] = target end
- end
- if #tgts > 0 then
- self.turn_procs.corrupted_strength = true
- DamageType:projectingFor(self, {project_type={talent=self:getTalentFromId(self.T_CORRUPTED_STRENGTH)}})
- self:attackTarget(rng.table(tgts), DamageType.BLIGHT, self:combatTalentWeaponDamage(self.T_CORRUPTED_STRENGTH, 0.5, 1.1), true)
- DamageType:projectingFor(self, nil)
- end
- end
- end
- local trigger = false
- if ab.mode == "sustained" then
- if not self:isTalentActive(ab.id) then
- if ab.sustain_mana then
- trigger = true; self:incMaxMana(-util.getval(ab.sustain_mana, self, ab))
- end
- if ab.sustain_stamina then
- trigger = true; self:incMaxStamina(-util.getval(ab.sustain_stamina, self, ab))
- end
- if ab.sustain_vim then
- trigger = true; self:incMaxVim(-util.getval(ab.sustain_vim, self, ab))
- end
- if ab.sustain_equilibrium then
- trigger = true; self:incMinEquilibrium(util.getval(ab.sustain_equilbrium, self, ab))
- end
- if ab.sustain_positive then
- trigger = true; self:incMaxPositive(-util.getval(ab.sustain_positive, self, ab))
- end
- if ab.sustain_negative then
- trigger = true; self:incMaxNegative(-util.getval(ab.sustain_negative, self, ab))
- end
- if ab.sustain_hate then
- trigger = true; self:incMaxHate(-util.getval(ab.sustain_hate, self, ab))
- end
- if ab.sustain_paradox then
- trigger = true; self:incMinParadox(util.getval(ab.sustain_paradox, self, ab));
- end
- if ab.sustain_psi then
- trigger = true; self:incMaxPsi(-util.getval(ab.sustain_psi, self, ab))
- end
- if ab.sustain_feedback then
- trigger = true; self:incMaxFeedback(-util.getval(ab.sustain_feedback, self, ab))
- end
- if ab.callbackOnAct then
- self.talents_on_act = self.talents_on_act or {}
- self.talents_on_act[ab.id] = true
- end
- if ab.callbackOnMove then
- self.talents_on_move = self.talents_on_move or {}
- self.talents_on_move[ab.id] = true
- end
- else
- if ab.sustain_mana then
- self:incMaxMana(util.getval(ab.sustain_mana, self, ab))
- end
- if ab.sustain_stamina then
- self:incMaxStamina(util.getval(ab.sustain_stamina, self, ab))
- end
- if ab.sustain_vim then
- self:incMaxVim(util.getval(ab.sustain_vim, self, ab))
- end
- if ab.sustain_equilibrium then
- self:incMinEquilibrium(-util.getval(ab.sustain_equilbrium, self, ab))
- end
- if ab.sustain_positive then
- self:incMaxPositive(util.getval(ab.sustain_positive, self, ab))
- end
- if ab.sustain_negative then
- self:incMaxNegative(util.getval(ab.sustain_negative, self, ab))
- end
- if ab.sustain_hate then
- self:incMaxHate(util.getval(ab.sustain_hate, self, ab))
- end
- if ab.sustain_paradox then
- self:incMinParadox(-util.getval(ab.sustain_paradox, self, ab));
- end
- if ab.sustain_psi then
- self:incMaxPsi(util.getval(ab.sustain_psi, self, ab))
- end
- if ab.sustain_feedback then
- self:incMaxFeedback(util.getval(ab.sustain_feedback, self, ab))
- end
- if ab.callbackOnAct then
- self.talents_on_act[ab.id] = nil
- if not next(self.talents_on_act) then self.talents_on_act = nil end
- end
- if ab.callbackOnMove then
- self.talents_on_move[ab.id] = nil
- if not next(self.talents_on_move) then self.talents_on_move = nil end
- end
- end
- elseif not self:attr("force_talent_ignore_ressources") then
- if ab.mana and not self:attr("zero_resource_cost") then
- trigger = true; self:incMana(-util.getval(ab.mana, self, ab) * (100 + 2 * self:combatFatigue()) / 100)
- end
- if ab.stamina and not self:attr("zero_resource_cost") then
- trigger = true; self:incStamina(-util.getval(ab.stamina, self, ab) * (100 + self:combatFatigue()) / 100)
- end
- -- Vim is not affected by fatigue
- if ab.vim and not self:attr("zero_resource_cost") then
- trigger = true; self:incVim(-util.getval(ab.vim, self, ab)) self:incEquilibrium(ab.vim * 5)
- end
- if ab.positive and not (self:attr("zero_resource_cost") and ab.positive > 0) then
- trigger = true; self:incPositive(-util.getval(ab.positive, self, ab) * (100 + self:combatFatigue()) / 100)
- end
- if ab.negative and not (self:attr("zero_resource_cost") and ab.negative > 0) then
- trigger = true; self:incNegative(-util.getval(ab.negative, self, ab) * (100 + self:combatFatigue()) / 100)
- end
- if ab.hate and not self:attr("zero_resource_cost") then
- trigger = true; self:incHate(-util.getval(ab.hate, self, ab) * (100 + self:combatFatigue()) / 100)
- end
- -- Equilibrium is not affected by fatigue
- if ab.equilibrium and not self:attr("zero_resource_cost") then
- trigger = true; self:incEquilibrium(util.getval(ab.equilibrium, self, ab))
- end
- -- Paradox is not affected by fatigue but it's cost does increase exponentially
- if ab.paradox and not (self:attr("zero_resource_cost") or game.zone.no_anomalies) then
- trigger = true; self:incParadox(util.getval(ab.paradox, self, ab) * (1 + (self.paradox / 300)))
- end
- if ab.psi and not self:attr("zero_resource_cost") then
- trigger = true; self:incPsi(-util.getval(ab.psi, self, ab) * (100 + 2 * self:combatFatigue()) / 100)
- end
- if ab.feedback and not self:attr("zero_resource_cost") then
- trigger = true; self:incFeedback(-util.getval(ab.feeedback, self, ab) * (100 + 2 * self:combatFatigue()) / 100)
- end
- if ab.fortress_energy and game:getPlayer(true):hasQuest("shertul-fortress") and not self:attr("zero_resource_cost") then
- trigger = true; game:getPlayer(true):hasQuest("shertul-fortress").shertul_energy = game:getPlayer(true):hasQuest("shertul-fortress").shertul_energy - ab.fortress_energy
- end
- end
- local hd = {"Actor:postUseTalent", t=ab, ret=ret, trigger=trigger}
- if self:triggerHook(hd) then
- trigger = hd.trigger
- end
- if trigger and self:hasEffect(self.EFF_BURNING_HEX) then
- local p = self:hasEffect(self.EFF_BURNING_HEX)
- DamageType:get(DamageType.FIRE).projector(p.src, self.x, self.y, DamageType.FIRE, p.dam)
- end
- -- Cancel stealth!
- if ab.id ~= self.T_STEALTH and ab.id ~= self.T_HIDE_IN_PLAIN_SIGHT and not ab.no_break_stealth then self:breakStealth() end
- if ab.id ~= self.T_LIGHTNING_SPEED then self:breakLightningSpeed() end
- if ab.id ~= self.T_GATHER_THE_THREADS and ab.id ~= self.T_SPACETIME_TUNING and ab.is_spell then self:breakChronoSpells() end
- if not ab.no_reload_break then self:breakReloading() end
- self:breakStepUp()
- if not (ab.no_energy or ab.no_break_channel) and not (ab.mode == "sustained" and self:isTalentActive(ab.id)) then self:breakPsionicChannel(ab.id) end
- for tid, _ in pairs(self.sustain_talents) do
- local t = self:getTalentFromId(tid)
- if t and t.callbackBreakOnTalent then
- self:callTalent(tid, "callbackBreakOnTalent", ab)
- end
- end
- if ab.id ~= self.T_REDUX and self:hasEffect(self.EFF_REDUX) and ab.type[1]:find("^chronomancy/") and ab.mode == "activated" and self:getTalentLevel(self.T_REDUX) >= self:getTalentLevel(ab.id) then
- self:removeEffect(self.EFF_REDUX)
- -- this still consumes energy but works as the talent suggests it does
- self:forceUseTalent(ab.id, {ignore_energy=true, ignore_cd = true})
- end
- if not ab.innate and self:hasEffect(self.EFF_RAMPAGE) and ab.id ~= self.T_RAMPAGE and ab.id ~= self.T_SLAM then
- local eff = self:hasEffect(self.EFF_RAMPAGE)
- value = self.tempeffect_def[self.EFF_RAMPAGE].do_postUseTalent(self, eff, value)
- end
- if ab.is_summon and ab.is_nature and self:attr("heal_on_nature_summon") then
- local tg = {type="ball", range=0, radius=3,}
- self:project(tg, self.x, self.y, function(px, py)
- local target = game.level.map(px, py, Map.ACTOR)
- if target and self:reactionToward(target) >= 0 then
- target:heal(self:attr("heal_on_nature_summon"))
- end
- end)
- end
- if not ab.innate and self:attr("random_talent_cooldown_on_use") and rng.percent(self:attr("random_talent_cooldown_on_use")) then
- local tids = {}
- for tid, lev in pairs(self.talents) do
- local t = self:getTalentFromId(tid)
- if tid ~= ab.id and t and not self.talents_cd[tid] and t.mode == "activated" and not t.innate then tids[#tids+1] = t end
- end
- for i = 1, self:attr("random_talent_cooldown_on_use_nb") do
- local t = rng.tableRemove(tids)
- if not t then break end
- self.talents_cd[t.id] = self:attr("random_talent_cooldown_on_use_turns")
- game.log("%s talent '%s%s' is disrupted by the mind parasite.", self.name:capitalize(), (t.display_entity and t.display_entity:getDisplayString() or ""), t.name)
- end
- end
- return true
- end
Advertisement
Add Comment
Please, Sign In to add comment