The difference between removing buffs and debuffs
Posted: Wed Oct 28, 2015 8:49 pm
Maybe it's because work has left me tired and burn out, but for some reason I just can't seem to diagnose this bug. I'm getting bug reports that the following ability is removing negative effects, whereas it should only be stripping beneficial ones. Can anyone spot the issue?
Code: Select all
newTalent{
name = "Devour Soul",
type = {"spell/soul",2},
require = spells_req2,
points = 5,
random_ego = "attack",
mana = 30,
cooldown = 10,
direct_hit = true,
tactical = { ATTACKAREA = { DARKNESS = 2 }, DISABLE = { stun = 2 }, },
range = 0,
radius = function(self, t) return math.floor(self:combatTalentScale(t, 4, 8)) end,
getNb = function(self, t) return math.floor(self:combatTalentScale(t, 1, 3)) end,
requires_target = true,
target = function(self, t) return {type="cone", range=self:getTalentRange(t), radius=self:getTalentRadius(t), friendlyfire=false, talent=t} end,
getDamage = function(self, t) return self:combatTalentSpellDamage(t, 24, 240) end,
action = function(self, t)
local tg = self:getTalentTarget(t)
local x, y = self:getTarget(tg)
if not x or not y then return nil end
local chance = 50
local nb = t.getNb(self,t)
local p = self:getTalentFromId(self.T_SOULFORGE)
if self:hasEffect(self.EFF_SOULFORGE) and self:getSoul() >= 2 then
p.forge(self,2)
self:incSoul(-2)
chance = 100
nb = nb+1
end
self:project(tg, x, y, function(px, py)
local target = game.level.map(px, py, Map.ACTOR)
local dam = t.getDamage(self,t)
if target and target:hasEffect(target.EFF_SOUL_REND) then
target:removeEffect(target.EFF_SOUL_REND)
DamageType:get(DamageType.DARKNESS).projector(self, px, py, DamageType.DARKNESS, dam)
local effs = {}
-- Go through all spell effects
for eff_id, p in pairs(target.tmp) do
local e = target.tempeffect_def[eff_id]
if (e.type == "magical" or e.type == "physical") and e.status == "beneficial" then
effs[#effs+1] = {"effect", eff_id}
end
end
for i = 1, nb do
if #effs > 0 then
local eff = rng.tableRemove(effs)
if eff[1] == "effect" then
target:removeEffect(eff[2])
game.logSeen(self, "#CRIMSON#%s's beneficial effect was stripped!#LAST#", target.name:capitalize())
end
end
end
elseif target then
DamageType:get(DamageType.DARKNESS).projector(self, px, py, DamageType.DARKNESS, dam)
if rng.percent(chance) and self:knowTalent(self.T_SOUL_REND) then
local t = self:getTalentFromId(self.T_SOUL_REND)
t.do_rend(self, t, target, false)
end
end
end)
game.level.map:particleEmitter(self.x, self.y, tg.radius, "breath_dark", {radius=tg.radius, tx=x-self.x, ty=y-self.y})
game:playSoundNear(self, "talents/fire")
return true
end,
info = function(self, t)
local dam = t.getDamage(self, t)
local radius = self:getTalentRadius(t)
local nb =t.getNb(self,t)
return ([[Devours the souls of targets in a radius %d cone, dealing %0.2f darkness damage. This will consume Soul Rend to remove up to %d beneficial physical or magical effects from the target.
Against those unaffected by Soul Rend, this has a 50%% chance to inflict Soul Rend.
The damage will increase with your Spellpower.
#PURPLE#Soulforge 2: Increase the chance of Soul Rend to 100%% and increase the number of beneficial effects removed by 1.]]):
format(self:getTalentRadius(t), damDesc(self, DamageType.DARKNESS, dam), nb )
end,
}