Step to reproduce:
* Try fighting Linaniil.
The callbackOnHit code is wrong and this shield will only explode at 50% mana.
What's more, its damage log is wrong upon exploding.
The following code shows an experimental fix, I am not sured if it is correct or can fix all the bugs.
Code: Select all
callbackOnHit = function(self, t, cb, src, dt)
local p = self:isTalentActive(t.id)
if not p then return end
if cb.value <= 0 then return end
if self:getMana() / self:getMaxMana() < 0.5 then
self:forceUseTalent(self.T_DISRUPTION_SHIELD, {ignore_energy=true})
return
end
-- if self:reactionToward(src) > 0 then return end
self.disruption_shield_power = self.disruption_shield_power or 0
self.disruption_shield_storage = self.disruption_shield_storage or 0
local absorbed = 0
if cb.value <= self.disruption_shield_power then
self.disruption_shield_power = self.disruption_shield_power - cb.value
absorbed = cb.value
cb.value = 0
game:delayedLogDamage(src, self, 0, ("#SLATE#(%d absorbed)#LAST#"):tformat(absorbed), false)
return true
else
cb.value = cb.value - self.disruption_shield_power
absorbed = self.disruption_shield_power
self.disruption_shield_power = 0
end
local do_explode = false
local ratio = t.getManaRatio(self, t)
local mana_usage = cb.value * ratio
local store = cb.value
if self.disruption_shield_storage + store >= t.getMaxDamage(self, t) then
do_explode = true
store = t.getMaxDamage(self, t) - self.disruption_shield_storage
mana_usage = store * ratio
end
if (self:getMana() - mana_usage) / self:getMaxMana() < 0.5 then
do_explode = true
local mana_limit = self:getMaxMana() * 0.3
mana_usage = self:getMana() - mana_limit
store = mana_usage / ratio
end
cb.value = cb.value - store
absorbed = absorbed + store
self:incMana(-mana_usage)
self.disruption_shield_storage = math.min(self.disruption_shield_storage + store, t.getMaxDamage(self, t))
game:delayedLogDamage(src, self, 0, ("#SLATE#(%d absorbed)#LAST#"):tformat(absorbed), false)
game:delayedLogDamage(src, self, 0, ("#PURPLE#(%d mana)#LAST#"):tformat(store), false)
if do_explode then
-- Deactivate without losing energy
self:forceUseTalent(self.T_DISRUPTION_SHIELD, {ignore_energy=true})
end
return true
end,