Thread Tools Display Modes
11-09-07, 03:22 PM   #1
Tatheltek
A Cyclonian
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 43
Checking if abilites are in CD

Do I need to use GetSpellCooldown or GetActionCooldown if I want to check if Overpower is in cooldown?

I have an addon that alerts me when my target dodges my attack, thus notifying me to Overpower. However I don’t want it to alert me to use the ability if it’s on cooldown.

If I need to use GetActionCooldown, how do I find out what action bar slot # a player has Overpower in? If I can use GetSpellCooldown, I can reference the ability by name (“Overpower”) correct?

I’m also wondering if I could use one of these to alert me to use Victory Rush or Revenge? As long as either of these would return >0, then the ability is ready for use I believe…

I guess lastly, is there a list somewhere of what is considered an Action vs. what is considered a Spell?
  Reply With Quote
11-09-07, 03:51 PM   #2
Eidolarr
An Aku'mai Servant
 
Eidolarr's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 34
An action is something that is bound to a slot on your action bars. A spell is something in your spellbook. Use
Code:
GetSpellCooldown("Overpower", BOOKTYPE_SPELL) > 0
and let me know how it works.
  Reply With Quote
11-09-07, 03:55 PM   #3
Tatheltek
A Cyclonian
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 43
I'll try this tonight when I'm home from work...

Should I have this run as a second conditional statement to checking if the target dodged? or just run this by itself?

also, should this be in myaddon_OnEvent() or myaddon_OnUpdate()? Right now i check for the dodge in event, but onupdate would check if the ability was in cooldown every frame...

Last edited by Tatheltek : 11-09-07 at 03:58 PM.
  Reply With Quote
11-09-07, 04:41 PM   #4
Eidolarr
An Aku'mai Servant
 
Eidolarr's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 34
Your logic should look like
Code:
On (target dodge)
  if (not overpower on cooldown)
    notify me
Make it a second condition after the onevent.

Think: why would you care if it's on cooldown at every second? Only when the target dodges do you need to know whether overpower is on cooldown so you can decide whether to notify. I don't think you should need onupdate at all for this addon.
  Reply With Quote
11-09-07, 04:55 PM   #5
Tatheltek
A Cyclonian
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 43
Good point. I'll have an update for this later tonight.

Mind you I'm sitting here at work and can't try anything but I have one last question.

If I:
Code:
local start, duration, enabled = GetSpellCooldown("Overpower", BOOKTYPE_SPELL);
with the logic
Code:
If target dodges then
if enabled == 0 then
alert
then if i want to do this for revenge as well can i just add:
Code:
local start, duration, enabled = GetSpellCooldown("Revenge", BOOKTYPE_SPELL);
or will that create an error because the addon is checking for something thats registered twice?

Last edited by Tatheltek : 11-09-07 at 05:50 PM.
  Reply With Quote
11-09-07, 11:35 PM   #6
Eidolarr
An Aku'mai Servant
 
Eidolarr's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 34
I'm not sure exactly what you're asking. This code
Code:
local start, duration, enabled = GetSpellCooldown("Overpower", BOOKTYPE_SPELL);
-- <... some code... >
local start, duration, enabled = GetSpellCooldown("Revenge", BOOKTYPE_SPELL);
won't generate an error, but it will overwrite the old values of start, duration, and enabled, so be sure you're done with them. If you want to make multiple calls with the same variable name, you'd want to do
Code:
local start, duration, enabled = GetSpellCooldown("Overpower", BOOKTYPE_SPELL);
-- code to handle overpower
start, duration, enabled = GetSpellCooldown("Revenge", BOOKTYPE_SPELL);
-- code to handle revenge
-- etc
although if you'll see below, you don't even need the , duration, enabled part.

I'm not certain enabled means what you think it means. Make sure you always read the documentation on functions you use so that you don't spend hours chasing down what you think is a bug but what is actually you grabbing the wrong argument.
enabled
Number - 0 if the spell is active (Stealth, Shadowmeld, Presence of Mind, etc) and the cooldown will begin as soon as the spell is used/cancelled; 1 otherwise.
It sounds like enabled marks when a 'buff' is active whose termination will result in a cooldown. Just check startTime - if it's '0', the spell has no cooldown.
  Reply With Quote
11-10-07, 12:09 PM   #7
Tatheltek
A Cyclonian
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 43
Code:
local	start, duration, enabled = GetSpellCooldown("Overpower", BOOKTYPE_SPELL);
and
Code:
	
	if (strfind(msg,"(.+) attack. (.+) dodges.") ) then
		if start == 0 then
			ProcAlertSplashFrame:SetTimeVisible(0)
			ProcAlertSplashFrame:AddMessage("|CFFFFFF33Overpower");
			PlaySoundFile("Interface\\Addons\\ProcAlert\\Sounds\\expalert.wav");
		end
	end
	if (strfind(msg,"Your (.+) was dodged by (.+).") ) then
		if start == 0 then
			ProcAlertSplashFrame:SetTimeVisible(0)
			ProcAlertSplashFrame:AddMessage("|CFFFFFF33Overpower");
			PlaySoundFile("Interface\\Addons\\ProcAlert\\Sounds\\expalert.wav");
		end
	end
causes this error

Interface\AddOns\ProcAlert\ProcAlert.lua:581: attempt to compare number with nil
Count: 1
  Reply With Quote
11-10-07, 12:24 PM   #8
Eidolarr
An Aku'mai Servant
 
Eidolarr's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 34
I need to see the surrounding code.

www.pastey.net

[e] find line 581 and highlight it on the pastey.

Last edited by Eidolarr : 11-10-07 at 12:26 PM.
  Reply With Quote
11-10-07, 12:39 PM   #9
Tatheltek
A Cyclonian
AddOn Author - Click to view addons
Join Date: Dec 2006
Posts: 43
Code:
	if (strfind(msg,"(.+) attack. (.+) dodges.") ) then
		if start == 0 then
			ProcAlertSplashFrame:SetTimeVisible(0)
			ProcAlertSplashFrame:AddMessage("|CFFFFFF33Overpower");
			PlaySoundFile("Interface\\Addons\\ProcAlert\\Sounds\\expalert.wav");
		end
	end
	if (strfind(msg,"Your (.+) was dodged by (.+).") ) then
		if start == 0 then
			ProcAlertSplashFrame:SetTimeVisible(0)
			ProcAlertSplashFrame:AddMessage("|CFFFFFF33Overpower");
			PlaySoundFile("Interface\\Addons\\ProcAlert\\Sounds\\expalert.wav");
		end
	end
the lines that are erroring are highlighted yellow

should it read startTime instead of start? cause im trying that now

also i tried duration == 0 because :
duration
Number - Cooldown duration in seconds, 0 if spell is ready to be cast.

but that does nothing at all

i also tried if start > 0 then return, else send the alert thinking that if it found a number > 0 it could stopthe alert and if not that meant the spell was ready but that did the same as duration and did nothing at all

Last edited by Tatheltek : 11-10-07 at 01:20 PM.
  Reply With Quote
11-10-07, 10:31 PM   #10
Eidolarr
An Aku'mai Servant
 
Eidolarr's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2006
Posts: 34
I need to see the entire context, particularly the function call. Post it here or use Pastey.
  Reply With Quote
11-10-07, 10:36 PM   #11
Mikord
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 61
When you call GetSpellCooldown with a spell name as opposed to an id you can't have the BOOKTYPE_SPELL parameter. The variable start is getting nil because the call is failing.

You are getting the error message telling you that you are comparing a number with nil because you are in fact doing that.

local start, duration, enabled = GetSpellCooldown("Overpower")
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Checking if abilites are in CD


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