Thread Tools Display Modes
03-26-13, 06:09 PM   #1
Brusalk
An Aku'mai Servant
 
Brusalk's Avatar
AddOn Author - Click to view addons
Join Date: May 2010
Posts: 32
Help getting cooldown duration on spells with recharges

Hello!

I've been looking high and low and I haven't been able to find any information on this. (Probably because it's kind of obscure, and the only reason I'm looking for it is for backwards compatibility reasons)

Anyway, what I'm looking for is a way to determine the amount of time until a spell that has charges (conflag for example) will hit 1 charge when it first hits 0 charges.

So, for example, take conflag with 2 max charges and a recharge time of 12 seconds. If the player was to cast 2 conflags back to back, I would expect GetSpellCooldown() or GetSpellCharges() to return a duration of 12-GCDDuration, because it took 1 GCD to cast the first GCD, so you've already recharged 1 GCDDuration before the chgarges first hit 0 charges.


Both GetSpellCooldown and GetSpellCharges return 12 seconds as the duration, and the start is the same for both.


I'm looking for a way to determine how much time there is until a spell with charges goes from 0 charges to 1 from the time when it hits 0 charges.


Any help you can give me would be very appreciated! Thanks
  Reply With Quote
03-26-13, 09:35 PM   #2
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
I'm not entirely clear on what you're trying to do, but if you're having trouble displaying the correct cooldown on spells with charges, I'd suggest looking at OmniCC, as it shows the correct time remaining until I can cast the spell again once I hit 0 charges.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote
03-26-13, 10:14 PM   #3
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
GetSpellCooldown returns the timestamp of when you first cast it and its duration. All you need to do is subtract the current time from that to get how much time is left.

Here's a complete example.
Lua Code:
  1. local text = UIParent:CreateFontString(nil, nil, 'GameFontNormal')
  2. text:SetPoint('CENTER')
  3. CreateFrame('frame'):SetScript('OnUpdate', function()
  4.  local start, duration = GetSpellCooldown('conflagrate')
  5.  if duration > 2 then
  6.   local timeLeft = start + duration - GetTime() -- time until it recharges the first charge, in seconds
  7.   text:SetFormattedText('%d seconds until conflagrate', timeLeft)
  8.  else
  9.   text:SetText('Conflagrate not on cooldown')
  10.  end
  11. end)

Last edited by semlar : 03-26-13 at 10:23 PM.
  Reply With Quote
03-26-13, 11:59 PM   #4
Brusalk
An Aku'mai Servant
 
Brusalk's Avatar
AddOn Author - Click to view addons
Join Date: May 2010
Posts: 32
@Semlar,

That's not the problem I'm having.

The problem is that the duration for recharge spells (namely Conflag) is ALWAYS 12 seconds, regardless of how much actual time there is left.
  Reply With Quote
03-27-13, 12:06 AM   #5
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
The duration is 12 seconds. The duration of the cooldown doesn't change.

The time left is determined by adding the duration to the start time and subtracting the current time.
  Reply With Quote
03-27-13, 12:13 AM   #6
Brusalk
An Aku'mai Servant
 
Brusalk's Avatar
AddOn Author - Click to view addons
Join Date: May 2010
Posts: 32
Okay, so for an example of what I'm trying to describe:

Normal CD (12 second Cooldown):

Cast @ 10
Start = 10
Duration = 12
Start + Duration = 22


Recharge CD (12 second recharge):

Cast 1 @ 10
Cast 2 @ 12
Duration = 12
Start + Duration = 24

However, the expected time for the charges to actually hit 1 is @22sec. (As 2 seconds of recharge have already happened at the time you casted the spell a second time and it's charges hit 0)
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Help getting cooldown duration on spells with recharges


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off