ToME: the Tales of Maj'Eyal

Everything about ToME
It is currently Tue Sep 18, 2018 4:34 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Sun Sep 20, 2015 8:50 pm 
Offline
Uruivellas

Joined: Tue May 14, 2013 3:45 pm
Posts: 831
Perhaps there's a better way of doing this. I have a timed effect that is supposed to cause your next spell to have x% reduced cooldown and grant x% energy. The energy part works, but the problem is that callBackOnTalentPost seemingly runs before the talent goes on cooldown, causing cooldown modification to fail. Any ideas? Current code (I tried hacking it with CDR, but that doesn't work as there's no good way to remove the effect when you account for speed increases):

Code:
newEffect{
   name = "SOULBURN", image = "talents/soulburn.png",
   desc = "Soulburn",
   long_desc = function(self, eff) return ("Next spell has %d%% reduced cooldown and grants %d%% of a turn."):format(eff.cd, eff.turn) end,
   type = "magical",
   subtype = { darkness=true },
   status = "beneficial",
   parameters = { cd = 0.5, turn = 0.7 },
   activate = function(self, eff)
      eff.cdid = self:addTemporaryValue("spell_cooldown_reduction", eff.cd/100)
   end,
   deactivate = function(self, eff)
      self:removeTemporaryValue("spell_cooldown_reduction", eff.cdid)
   end,
   callbackOnTalentPost = function(self, t,  ab)
      if ab.type[1]:find("^spell/") and not ab.type[1]:find("^spell/soulforge") then
         local t = self:getTalentFromId(self.T_SOULBURN)
         local energy = (game.energy_to_act * t.getTurn(self,t))/100
         self.energy.value = self.energy.value + energy
      end
   end,
   callbackOnActBase = function(self, eff)
      self:removeEffect(self.EFF_SOULBURN)
   end,
}


Top
 Profile  
 
PostPosted: Mon Sep 21, 2015 1:13 am 
Offline
Perspiring Physicist

Joined: Sun Sep 09, 2012 7:43 am
Posts: 5752
I think the problem is actually you dividing by 100 on the spell_cooldown_reduction value, as I can't see any reason why it wouldn't work.
However, you might want to move the removeEffect onto the callbackOnTalentPost and delay it until end of tick. Unless you are intending for this effect to last for multiple spells?

_________________
My feedback meter decays into coding. Give me feedback and I make mods.


Top
 Profile  
 
PostPosted: Tue Sep 22, 2015 8:38 am 
Offline
Uruivellas

Joined: Tue May 14, 2013 3:45 pm
Posts: 831
All working now, used game:onTickEnd() to terminate the function after applying the effects. Thanks.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


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