WoW:Useful patterns in macros: Difference between revisions

No edit summary
 
Line 8: Line 8:


== Sheep/Monitor/Resheep Pattern ==
== Sheep/Monitor/Resheep Pattern ==
  /focus [target=focus,exists,nodead] focus;
  /focus [target=focus,exists,nodead] focus; target
  /cast [target=focus,harm,nodead] Polymorph
  /cast [target=focus,harm,nodead] Polymorph
This will leave your current focus as-is if there is a focused unit and it's alive; otherwise your focus will be set to your current target. (The ';' is not a line terminator -- means that if [target=focus,exists,nodead] did not evaluate true, then attempt to execute a /focus command with no arguments.) Then, once your focus has been set, if it is an enemy, Polymorph it.
If you have a focus, and it exists and is not dead, then your focus is set to your focus (in other words it remains unchanged). Otherwise, focus is set to your current target. Then, now that you have a focus set, if it is an enemy, Polymorph it.


As a result, this macro can be placed on the action bar, and be used as a single-button solution to sheep an initial target (as long as you have no focus, or it's dead), to be able to monitor the status (i.e., to know when it should be resheeped), and to resheep as necessary.
As a result, this macro can be placed on the action bar, and be used as a single-button solution to sheep an initial target (as long as you have no focus, or the one from the previous fight has died already), and to resheep as necessary.


== Last Pet Target Pattern ==
== Last Pet Target Pattern ==
''Keep in mind that this may or may not have any usefulness in combat.  The following work is presented only as an exercise.''
Because there's no petlasttarget function, we use the player's abilities instead.  Thankfully we can accomplish this without actually altering the player's target in the end.  There are really only two steps that we want to accomplish:
1. Send the pet to attack the focus. 
2. Set the focus to your pet's old target. 
These two steps will allow us to mash a single macro and have the pet go back and forth between two targets.
Since the following macro will use the focus ability to do that, you won't want to try it if you're using the focus ability for your own evil deeds, like keeping track of a seduction target, or what-have-you.
Here's the simple version.  We assume that your pet is attacking someone, and that you want to send it to attack the target that you focused.
/target pettarget
/petattack focus
/focus target
/targetlasttarget
Rinse and repeat.  If you met all the prerequisites, then your pet will bounce back and forth between the two targets each time you press the macro.
Now let's try adding a small amount of error correction:
/focus [target=focus,exists,harm,nodead] focus; [exists,harm,nodead] target; [target=mouseover,exists,harm,nodead] target
/bonk [target=focus,noexists] player
/stopmacro [target=focus,noexists]
/target pettarget
/petattack focus
/focus target
/targetlasttarget
Step 1: if you don't have a focus, set it to your current target, or failing that, to whomever you are mousing over.
Step 2: if you STILL don't have a focus, bonk yourself on the noggin' and stop.
And then back to the meat and potatoes of the macro:
Step 3: send your pet to attack the focus.
Step 4: switch the focus to your pet's previous target.
Steps 1 & 2 make it so that you don't have to take time out of your busy schedule to focus a target before you send your pet to attack it.  You just target it or mouseover it, then hit the macro, and the focusing is done for you.  That's the point of macros anyway.
That takes care of the possibility of no focus when you start.  But, what if your pet doesn't have a target at first?  Oh, my.  Well it's actually alright.  A quick look shows us what will happen: your target will be set to None, the pet will attack the shiny new focus, the focus will be set to None, and your target will revert to what it was before the macro started.
So, at this point that's about as much functionality as we can reasonably ask for, but you may have noticed that we're pushing the 255 character limit.  We can eliminate a few extra words that are implied by context, get rid of the bonks, and keep the same functionality:
/focus [target=focus,exists,harm,nodead] ; [exists,harm,nodead] ; [target=mouseover,harm,nodead]
/stopmacro [target=focus,noexists]
/target pettarget
/petattack focus
/focus target
/targetlasttarget
That's 193 characters if I count correctly.


[[Category:Macros]]
[[Category:Macros]]
Anonymous user