diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua index a6dbe4ec44b0599e77f2f06cae9c0c1d0da77cfc..2fe00870385fde7a26835fae5d7b6cc243cdbf9e 100644 --- a/game/modules/tome/class/Actor.lua +++ b/game/modules/tome/class/Actor.lua @@ -5513,10 +5513,9 @@ function _M:worthExp(target) end end ---- Remove all effects based on a filter -function _M:removeEffectsFilter(t, nb, silent, force) +--- Find effects based on a filter, up to nb. +function _M:effectsFilter(t, nb) local effs = {} - local removed = 0 for eff_id, p in pairs(self.tmp) do local e = self.tempeffect_def[eff_id] @@ -5540,19 +5539,28 @@ function _M:removeEffectsFilter(t, nb, silent, force) end if nb then + local found = {} while #effs > 0 and nb > 0 do local eff = rng.tableRemove(effs) - self:removeEffect(eff, silent, force) + found[#found + 1] = eff nb = nb - 1 - removed = removed + 1 end + return found else - removed = #effs - for i = 1,#effs do - self:removeEffect(effs[i], silent, force) - end + return effs + end +end + +function _M:removeEffects(effs, silent, force) + for _, eff_id in ipairs(effs) do + self:removeEffect(eff_id, silent, force) end - return removed +end + +function _M:removeEffectsFilter(t, nb, silent, force) + local eff_ids = self:effectsFilter(t, nb) + self:removeEffects(eff_ids, silent, force) + return #eff_ids end --- Randomly reduce talent cooldowns based on a filter diff --git a/game/modules/tome/data/talents/misc/inscriptions.lua b/game/modules/tome/data/talents/misc/inscriptions.lua index fd9143b3fa562625b8482abf9c9fb7c08b936833..21749275b63f9a33bee3e9d75be26ce9e73822ed 100644 --- a/game/modules/tome/data/talents/misc/inscriptions.lua +++ b/game/modules/tome/data/talents/misc/inscriptions.lua @@ -126,15 +126,8 @@ newInscription{ tactical = { DEFEND = 3, CURE = function(self, t, target) - local nb = 0 local data = self:getInscriptionData(t.short_name) - for eff_id, p in pairs(self.tmp) do - local e = self.tempeffect_def[eff_id] - if data.what[e.type] and e.status == "detrimental" then - nb = nb + 1 - end - end - return nb + return #self:effectsFilter({types=data.what, status="detrimental"}) end }, action = function(self, t) @@ -178,15 +171,8 @@ newInscription{ tactical = { DEFEND = 3, CURE = function(self, t, target) - local nb = 0 local data = self:getInscriptionData(t.short_name) - for eff_id, p in pairs(self.tmp) do - local e = self.tempeffect_def[eff_id] - if data.what[e.type] and e.status == "detrimental" then - nb = nb + 1 - end - end - return nb + return #self:effectsFilter({types=data.what, status="detrimental"}) end }, action = function(self, t)