ToME: the Tales of Maj'Eyal

Everything about ToME
It is currently Fri Apr 10, 2020 8:30 am

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Sun Feb 09, 2020 3:39 pm 
Offline
Halfling

Joined: Sat Sep 27, 2014 11:33 am
Posts: 113
Location: Irkkk
Disruption Shield won't explode reaching max energy storage.
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:
   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,


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group