wownerds
New Member
- Joined
- Feb 15, 2011
- Messages
- 1,385
- Reaction score
- 30
Hey there,
I'm trying to get the exact cooldown left for a spell that's been cast.
The basic idea is to have a timer increase an int by 1 every second after the spell was cast and subtracting that int from the base cd of the spell.
Here's the code I got:
I'm castin the spell with this code:
I'm calling CSCD()
in the initialization part of the cc.
I added the logging code for checking where it gets stuck. Until now, all I get is:
each time the spell was cast.
Does anyone have an idea why this does not work?
Thanks in advance!
I'm trying to get the exact cooldown left for a spell that's been cast.
The basic idea is to have a timer increase an int by 1 every second after the spell was cast and subtracting that int from the base cd of the spell.
Here's the code I got:
Code:
public static System.Timers.Timer CSCDTimer;
public int CurrentCSCD = 0;
public int RanCS = 0;
uint basecd = SpellManager.Spells["Colossus Smash"].BaseCooldown;
public void CSCD()
{
CSCDTimer.Interval = 1000;
CSCDTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
}
public void CalcCD()
{
RanCS = RanCS + 1;
CurrentCSCD = (int)basecd - RanCS;
Logging.Write(Color.GreenYellow, "CSCD: "+ CurrentCSCD + " !");
}
public void ResetCD()
{
Logging.Write(Color.GreenYellow, "Reset CSCD");
if (CSCDTimer.Enabled == true)
{
CSCDTimer.Enabled = false;
}
RanCS = 0;
CSCDTimer.Enabled = true;
}
public void OnTimedEvent(object source, ElapsedEventArgs e)
{
Logging.Write(Color.GreenYellow, "Calculating CSCD");
CalcCD();
}
I'm castin the spell with this code:
Code:
public Composite CastCS()
{
return new Decorator(ret => SpellManager.CanCast("Colossus Smash"),
new Action(delegate
{
SpellManager.Cast("Colossus Smash");
Logging.Write(Color.Red, "!!--> Colossus Smash <--!!");
ResetCD();
return RunStatus.Success;
}
));
}
I'm calling CSCD()
Code:
public void CSCD()
{
CSCDTimer.Interval = 1000;
CSCDTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
}
in the initialization part of the cc.
I added the logging code for checking where it gets stuck. Until now, all I get is:
Code:
Reset CSCD
each time the spell was cast.
Does anyone have an idea why this does not work?
Thanks in advance!