EDIT: This article is a bit dated. There are at least two addons that were created after I built these macros that you should check out. Both Announce and GuardianSpirited do what I'm trying to do in these macros, only more elegantly and more reliably. The macros are still fine, and certainly more lightweight, but they're no longer your best choice.
At some point you realize that you can do more than just
/cast Power Infusion
Here are some upgrades to your PI macro, culminating in what I think is just about the best you can do in the limited space of a macro.
Round One: Adding a whisper
Before any raid, I’ll usually alert my intended victim of what’s about to happen. Getting PI’d is fantastic, but if you’re not ready for it, it can be a bit jarring. So I just let them know that they’ll be getting hit with it when it’s up.
Then, when I cast PI, I’ll send an automatic whisper to the target so they know what just happened. Of course, they can see the animation and feel the haste, but the whisper is generally appreciated.
/cast [target=mouseover] Power Infusion
/run SendChatMessage("You just got Power Infusion...haste it up!","WHISPER",nil,UnitName("mouseover"))
Round Two: Linking the spell, and adding a Quartz timer
Just because you can, doesn’t mean you should. But I like to anyway :) Here’s the same macro, but this time the spell is linked, rather than just named. Also, I’ve added a line that tells Quartz to put up a custom timer bar (enable the “mirror” function within Quartz, then play around with it). If you’re using other methods for managing your cooldowns, the Quartz timer can certainly be removed.
/cast [target=mouseover] Power Infusion
/run SendChatMessage("You just got "..GetSpellLink("Power
Infusion").."...haste it up!","WHISPER",nil,UnitName("mouseover"))
/quartztimer 96 Power Infusion
Round Three: Error checking
I used the above macro for a long time. Unfortunately, it does no error checking. So if my target is out of range, they of course won’t get hit with PI, but they’ll still get the whisper. Same if the spell is on cooldown; they get a message but no buff.
The two LUA functions we’re adding here are IsSpellInRange and GetSpellCooldown. I’ve removed the Quartz timer, because I can’t include it within the error check. (I.e., the timer will display when I click, even if the spell fails.)
This uses some handy programming shortcuts in order to minimize the number of characters in the macro. Still, it’s about as sophisticated as you can get within the 255 character limit. (This is 217 characters, so there’s a little wiggle room.)
/script local u,pi="mouseover","Power
Infusion";if IsSpellInRange(pi,u)==1 and GetSpellCooldown(pi)==0 then
SendChatMessage("You just got
"..GetSpellLink(pi).."!","WHISPER",nil,UnitName(u))
end
/cast [target=mouseover] Power Infusion
Briefly, what’s happening is this. In the first line, we’re sending the recipient a whisper, but only if the spell will land. To test if the spell will land, we’re checking to see if the target is in range and if the spell is off cooldown. (We’re not checking for line of sight, though that could probably be built in as well.)
Another difference with this version is that the spell itself is cast after the whisper. If we cast it before the whisper, the cooldown will of course be in effect and the whisper won’t be sent.
If you have any additions, corrections, or anything to improve upon in this macro, please send them along!
Addons
There are two addons that I know of that can be used for this sort of thing. CastYeller is made to order – it’s designed to let people know when a spell is cast successfully. It can whisper the target, post to a custom chat channel, or to the entire raid. I haven’t quite gotten it to do what I want, but YMMV of course. Definitely worth a look.
Aftercast is another option. It looks like it’s no longer in development, so I haven’t even downloaded it to try. I’d be curious if anyone has this working, or if there are other addons that are useful for spell announcements.
Bonus macro: Pain Suppression
What’s different here? Not much, to be honest. The only thing is that we’re no longer interested in sending a whisper to the target, but to the raid in general. This lets everyone know you’ve blown your cooldown to save the tank (most likely) or dps (shame on them!).
/script local u,ps,c="mouseover","Pain
Suppression",GetNumRaidMembers()>0 and "RAID" or
"PARTY";if IsSpellInRange(ps,u)==1 and GetSpellCooldown(ps)==0 then
SendChatMessage(ps.." on "..UnitName(u),c) end
/cast [target=mouseover] Pain Suppression
The chat channel will be set dynamically based on whether you're in a raid or a party; if you’re testing it out solo you’ll get an error message saying that you’re not in a party.
FYI macaroon let's you have way way longer macros.
*copy+paste*
Nice. I've been usings macros like your basic ones but its annoying announcing your ressing someone when they are out of range or similar. I'll have to try your LUA ones.
I've been looking for a macro like this for a while, and was unable to find it (and my LUA skills are sadly lacking), so thanks for that. Is there any way I can add a second message, in /s, to the whispered one? (Aside from concerns about macro length)
@Stripes: Macaroon is a great tip. It's not a macro addon per se, it's a full action-bar replacement addon. But if you do need longer macros, it's certainly a good option.
@Tsark: I don't know of any way to use a single "SendChatMessage" command to send to multiple channels at once. That said, you could chain two commands together inside the if statment.
if BLAH then SendChatMessage(...); SendChatMessage(...); end
Use the channel "SAY" in place of "WHISPER" in the code. You might have to work at it to keep the macro within its size limits.
Just stumbled on this, can't wait to try it out, I have been looking for this exact macro!
Thanks for posting!
Cloota
Nice! Been using this since yesterday and I love it.
Thanks :)
nice! i was using a macro like round 1 and i always thought it was flawed.
now just how to make him not whisper when gcd isnt ready :\
looking for my first Macro something simple to start with the "Macro for dummies that happen to be disc priest." version. lol c
can someone tell me where to start im no coder Just love DISC priest
This doesn't seem to work when you're trying to cast it on someone from a different realm in a cross-realm PuG. It will tell you player not found.
I would be a happy happy priest if I could figure out how to use this PI macro with VuhDo. I know for the spell I use [target=VuhDo], but can't figure out how to get it to whisper.
Thanks for this! Awesome macro!