-
Active Member
[Macro][Request] How do I track debuff durations?
Looking for a lua script I can run to check if my target has corruption, if not cast corruption, if it does then if it has less than or equal to 5 seconds recast it.
I really suck at lua/scripting in general, so the way I was going to do it was as two parts.
/run if not UnitDebuff("target", "Corruption", unitCaster~="player") then CastSpellByName("Corruption") end
/run if UnitDebuff("target", "Corruption", unitCaster~="player") and expirationTime-GetTime()<6 then CastSpellByName("Corruption") end
First line works fine, second line doesn't work at all. Any help would be greatly appreciated!
-
change: expirationTime to expires and < 6 to < 600 (it's in milliseconds)
http://wowprogramming.com/docs/api/UnitDebuff
//edit, i can't test until i get home, i'm just looking at API calls from work
-
Active Member
Tried the following on a target with corruption at 4 seconds and it still didn't work Thanks for the input though!
/run if UnitDebuff("target", "Corruption", unitCaster~="player") and expires-GetTime()<600 then CastSpellByName("Corruption") end
-
I'll take a peek when i get home, another 2-3 hours.
-
Sergeant
dont you need to give expirationTime a value before you use it or am I missing something?
you need to add
name, rank, icon, count, dispelType, duration, expires = UnitDebuff(whatever)
into the macro before you can use expires
edit: try this
/run expires=select(7,UnitDebuff("target", "Corruption")) if not expires or (expires-GetTime())<6 then CastSpellByName("Corruption") end
Last edited by seasick; 05-20-2015 at 07:42 PM.
-
Contributor
Hello. No need to declare a variable. I will help.
You had this.
Code:
/run if not UnitDebuff("target", "Corruption", unitCaster~="player") then CastSpellByName("Corruption") end
/run if UnitDebuff("target", "Corruption", unitCaster~="player") and expirationTime-GetTime()<6 then CastSpellByName("Corruption") end
Switch it up to this.
Code:
/run if not UnitDebuff("target", "Corruption", "", "player") or (select(7,UnitDebuff("target","Corruption","","player")))-GetTime()<6 then CastSpellByName("Corruption") end
You forgot the 3rd argument in UnitDebuff, the spell's rank. It's a required argument if you want to filter the owner of the spell (the 4th argument). Most spell ranks are empty, hence the "". Also the 7th return can be directly compared to GetTime, both of which work in seconds and not milliseconds. The only useful return I know of that works in milliseconds and not seconds is unit casting/channel info's start/end/duration times.
Last edited by Ssateneth; 05-20-2015 at 08:03 PM.
KuRIoS is awesome!
-
Post Thanks / Like - 1 Thanks
fedelis (1 members gave Thanks to Ssateneth for this useful post)
-
Active Member
Thanks a lot for the help guys it works great now!