WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Help getting cooldown duration on spells with recharges (https://www.wowinterface.com/forums/showthread.php?t=46123)

Brusalk 03-26-13 06:09 PM

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 :)

Phanx 03-26-13 09:35 PM

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.

semlar 03-26-13 10:14 PM

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)

Brusalk 03-26-13 11:59 PM

@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.

semlar 03-27-13 12:06 AM

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.

Brusalk 03-27-13 12:13 AM

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)

semlar 03-27-13 12:15 AM

The time until the first charge comes back is 12 seconds from the first cast.

I tested this in-game before I wrote the example.

Brusalk 03-27-13 12:31 AM

I guess I'll have to include more logic then.

I was hoping there was a way to get the value not from when the recharge first starts but when it first hits 0 charges.

semlar 03-27-13 12:43 AM

I am very confused about what you're trying to do.

I thought you wanted to know how much time before conflagrate was usable again after it hit 0 charges, but you don't need to know the timestamp of when it hit 0 charges for that.

The main reason for knowing when it hit 0 would be to determine when the second charge is going to come back.

I guess the other reason would be if you needed the start time for a cooldown spinner or something.

If you know when it went on cooldown then you know when it hit 0 charges. The most efficient way to determine that really depends on how this is being implemented.

If this is for an action button there are much simpler ways to get the cooldown information.

Brusalk 03-27-13 01:16 AM

Basically I'm trying to implement some old functionality into a rewritten version of the addon (for various reasons)

The old behavior was that it would show a timer starting when Conflag would hit 0 charges, and end when it went up to 1 charge.

semlar 03-27-13 01:30 AM

Isn't that what the script I posted does?

Brusalk 03-27-13 01:40 AM

Yeah. You're completely correct.


I was in the middle of raiding and between pulls responding, and I totally made an assumption about what your code was doing. I didn't look close enough at it. My bad.


I was totally overcomplicating it.


Thanks for the help!

semlar 03-27-13 01:49 AM

Ah, well that explains the confusion.

If you have any more questions don't hesitate to ask.


All times are GMT -6. The time now is 12:07 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI