Lealla's Comprehensive Focus Macro Collection

Forum for mod & macro requests and discussion

Moderator: Demon Hunters

User avatar
100
Lealla
Class Leader
Posts: 3797
Contact:

Lealla's Comprehensive Focus Macro Collection

Post#1 » Thu Jan 17, 2008 6:30 pm

Lealla's Comprehensive Focus Macro Collection*

*Not responsible for eyestrain, mental confusion, brain oozing out ears, urge to rape sheep.

What is Focus?

Ordinarily, you can only cast spells on or retrieve information (such as health, mana, spellcasting, buff/debuff info) about a unit that you're targeting, or that is being targeted by someone in your party or raid. Focus is an extra target that you can tell the game to keep track of for you. You can work with your focus just like you would with your target, except that you aren't actually targeting it. This is done through macros (and sometimes addons).

Put another way, focus is like telling the game, "Save this target. I want to do stuff with it later."

You only get one focus at a time. Note: pet classes may use their pet's target as a kind of secondary focus, although this has some limitations - mainly that it only works on hostile targets and your pet has to be actually attacking them. Although all of the examples below use macros, you can bind keys in the keybinding menu to set and clear your focus.

Viewing your focus
In the default UI, you can't see which unit you're focusing on, but if you target the unit you have focused, the target frame has a glowy white border around it. You can get an addon that provides a separate unit frame for your focus. The simplest is FocusFrame, which looks the same as the default target frame. Just about every unit frame replacement addon, however (such as xPerl) will provide a focus frame option that you can set. This can get your screen very cluttered if not managed properly.

You can do anything to your focus that you could to your target. You can cast spells on it, see who it's targeting, see its buffs and debuffs, track durations, etc. In fact, many addons (such as NECB) that track things like CC duration and cooldowns do so for your focus automatically.

It is important to note, however, that if you are not currently targeting anything, and you perform an action on your focus that would ordinarily activate your autoattack, the game will force you to target and autoattack that unit. This is built-in behavior and cannot be changed.

Unlike your target, your focus is not cleared automatically when the unit dies. In fact, your focus will persist until the unit no longer exists (e.g., despawns or, in the case of players, logs out). See below for some tricks to deal with this.


Setting, clearing, and manipulating Focus

This section demonstrates how to set your focus, clear it, and manipulate it in various ways.

Set Focus
This sets focus to your current target. You can also bind a key to Focus.

Code: Select all

/focus


Clear Focus
This clears your focus. It can also be bound to a key.

Code: Select all

/clearfocus


Target your Focus
Again, a no brainer.

Code: Select all

/target focus


Focus only if focus is not already set
The [target=focus] conditional has a special meaning for /focus, allowing you to test it without affecting what focus actually targets.

Code: Select all

/focus [target=focus,noexists]


Toggle focus
Set focus if not set; clear otherwise.

Code: Select all

/focus [target=focus,noexists];none


Focus hostile
Focus on a hostile, living target only. For a friendly, change harm to help. Note: help/harm imply exists.

Code: Select all

/focus [harm,nodead]


Focus on current target if focus is not hostile or is dead
If you are focusing for a beneficial spell, change "noharm" to "nohelp".

Code: Select all

/focus [target=focus,noharm] [target=focus,dead]


Focus on hostile target only
This is like the one above, but if your current target is also not valid, it will clear your focus instead.

Code: Select all

/focus [target=focus,noharm] [target=focus,dead]
/clearfocus [target=focus,noharm] [target=focus,dead]


Swap target and focus
This will make your focus your target and your target your focus. As a bonus, it stops if you don't have both a focus and a target.

Code: Select all

/stopmacro [noexists] [target=focus,noexists]
/target focus
/targetlasttarget
/focus
/targetlasttarget


Focus on modifier key
Valid modifier keys are shift, ctrl, and alt.

Code: Select all

/focus [mod:shift]



Casting a spell on your Focus

This section covers how to cast spells on your focus, as opposed to your nomal target.

Cast spell on focus
This will cast the spell only on your focus.

Code: Select all

/cast [target=focus] Spell


Cast spell on focus or target
This will cast the spell on your focus if it exists and your current target otherwise.

Code: Select all

/cast [target=focus,exists] [] Spell


Cast spell on hostile focus/target only
This will cast the spell on your focus if it is hostile (and alive), then make the same determination for your current target. Lacking a valid hostile target, it does nothing.

Code: Select all

/cast [target=focus,harm,nodead] [harm,nodead] Spell


Cast spell on friendly focus/target
This will cast the spell on your focus if it is friendly (and alive), then make the same determination for your current target. It will then give you the targeting cursor if it is unable to find a target normally.

Code: Select all

/cast [target=focus,help,nodead] [help,nodead] [] Spell


Cast spell on focus with modifier
This will cast the spell on your focus if it is valid and you hold a modifier key; your target otherwise. Sub help for harm for a friendly target.

Code: Select all

/cast [mod:shift,target=focus,harm,nodead] [harm,nodead] Spell



Combined Focus and Spellcast Macros

Now let's put everything together. The below macro examples use Polymorph but you may substitute your spell of choice. Remember that you only get one focus, so if you're a class with multiple CC abilities, you will have to compromise a bit.

Focus w/shift, Polymorph focus
The below macro will set focus if you hold shift, and cast Polymorph on your focus if set and your current target if not. The good thing about it is that you won't try to cast on a dead unit, even if you forgot to change your focus.

Code: Select all

#showtooltip Polymorph
/focus [mod:shift]
/cast [target=focus,harm,nodead] [harm,nodead] Polymorph


Focus automatically, Polymorph focus
The below macro will focus on your current target if you don't have a valid hostile focus. It will then cast Polymorph on your focus. With this macro, you will always have either a hostile focus or no hostile target, so there's no need for a check of your current target.

Code: Select all

#showtooltip Polymorph
/focus [target=focus,noharm][target=focus,dead]
/clearfocus [target=focus,noharm] [target=focus,dead]
/cast [target=focus,exists] Polymorph


Focus automatically, Polymorph focus, clear on Ctrl
This is identical to the above, except that if you hold the Ctrl key while activating it, it clears your focus instead of setting it or casting Polymorph. If you want it to cast Polymorph regardless, add [mod:ctrl] as a casting condition to the Polymorph line.

Code: Select all

#showtooltip Polymorph
/focus [target=focus,noharm][target=focus,dead]
/clearfocus [target=focus,noharm] [target=focus,dead] [mod:ctrl]
/cast [target=focus,exists] Polymorph


Do you want any other examples? Just post.

Edit: Fixed the /clearfocus lines.
Last edited by Lealla on Tue Jan 29, 2008 9:11 am, edited 2 times in total.
Image
Image

User avatar
110
Elvenbane
Leader
Posts: 4481
Contact:

Post#2 » Sun Jan 20, 2008 1:40 am

Woot thanks Lealla!
I have my new fear macro:

Code: Select all

#showtooltip Fear
/focus [mod:alt,target=focus,noharm][mod:alt,target=focus,dead]
/clearfocus [target=focus,noharm][target=focus,dead][mod:shift]
/cast [mod:alt,target=focus,exists] Fear; [nomod] [harm,nodead][target=targettarget,harm,nodead] Fear

For those of you who can't read code here's what happens.
Alt-Click (with no focus): sets the focus to my current target and fears focus
Alt-Click (with focus): fears focus
Shift-Click: clears focus
Click: fears current target if hostile or target's target if hostile while still maintaining focus.

The sexyness: alternating alt:click and click with let me chain fear 2 targets simultaneously.
Last edited by Elvenbane on Mon Jan 21, 2008 12:26 pm, edited 2 times in total.
It's the thought that counts, not how many people die because of it.
Elvenbane#1520

User avatar
100
Lealla
Class Leader
Posts: 3797
Contact:

Post#3 » Sun Jan 20, 2008 9:17 am

EB, I made a correction to the /clearfocus line - you should change it to this:

/clearfocus [target=focus,noharm] [target=focus,dead] [mod:shift]
Image

Image

User avatar
110
Elvenbane
Leader
Posts: 4481
Contact:

Post#4 » Sun Jan 20, 2008 6:00 pm

updated
It's the thought that counts, not how many people die because of it.
Elvenbane#1520

User avatar
110
Elvenbane
Leader
Posts: 4481
Contact:

Post#5 » Mon Jan 21, 2008 12:58 pm

Well, just noticed with the addition of your fixes Fear and Banish are about the only two spells that fit within the 255 character limit with that macro.

If you're having trouble making it fit change it as follows:

Code: Select all

#showtooltip SPELL
/focus [mod:alt,target=focus,noharm][mod:alt,target=focus,dead]
/clearfocus [target=focus,noharm][target=focus,dead][mod:shift]
/cast [mod:alt,target=focus,exists] SPELL; [nomod] SPELL


The only fuctionality you'll lose is casting on the target's target with a regular click.

Also, if you want to stopcast it add the following above the /cast

Code: Select all

/stopcasting [mod:alt][nomod]

That way if you just want to clear your focus while casting another spell you wont stopcast by accident.
It's the thought that counts, not how many people die because of it.
Elvenbane#1520

User avatar
100
Lealla
Class Leader
Posts: 3797
Contact:

Post#6 » Tue Jan 22, 2008 9:03 am

The macro can be written even more compactly, EB.

Code: Select all

#showtooltip
/focus [mod:alt,target=focus,noharm][mod:alt,target=focus,dead]
/clearfocus [target=focus,noharm][target=focus,dead][mod:shift]
/cast [mod:alt,target=focus,exists][]SPELL
Image

Image

User avatar
110
Elvenbane
Leader
Posts: 4481
Contact:

Post#7 » Tue Jan 22, 2008 11:27 am

ooh of course, however in that instance if you shift-click to clear focus while targeting another mod it will still attempt to cast on your current target. Would chanting [] to [nomod] resolve that?
It's the thought that counts, not how many people die because of it.
Elvenbane#1520

User avatar
100
Lealla
Class Leader
Posts: 3797
Contact:

Post#8 » Tue Jan 22, 2008 2:16 pm

Oh, yeah, right. I forgot about that reason for it.
Image

Image

User avatar
100
Lealla
Class Leader
Posts: 3797
Contact:

Post#9 » Tue Jan 29, 2008 11:24 am

Edited to add explanation of what focus is and how it's used.
Image

Image

User avatar
110
Elvenbane
Leader
Posts: 4481
Contact:

Post#10 » Mon Feb 11, 2008 3:14 am

Found out tonight that my macro doesn't work with mind control due to the noharm clause in the focus string, it therefore needs to be changed from noharm to noexists for it to work with mc:

Code: Select all

#showtooltip Polymorph
/focus [mod:alt,target=focus,noharm][mod:alt,target=focus,dead]
/clearfocus [target=focus,noharm][target=focus,dead][mod:shift]
/cast [mod:alt,target=focus,exists] Polymorph; [nomod] Polymorph


reverted back to noharm
Last edited by Elvenbane on Fri Mar 07, 2008 12:04 am, edited 4 times in total.
It's the thought that counts, not how many people die because of it.
Elvenbane#1520

User avatar
100
Lealla
Class Leader
Posts: 3797
Contact:

Post#11 » Mon Feb 11, 2008 9:12 am

The last time I checked, CC'd mobs (including Polymorph, Fear, Banish, Freezing Trap, Hibernate, Shackle Undead, etc.) are still considered hostile targets and the [noharm] clause should work properly with them. A very cursory test macro could easily reveal this:

Code: Select all

/script local m if UnitIsEnemy("player","target") then m="hostile" elseif UnitIsFriend("player","target") then m="friendly" else m="neutral" end DEFAULT_CHAT_FRAME:AddMessage("Target is "..m..".")


The only case in which a target would no longer be considered hostile is if it is Mind Controlled.
Image

Image

User avatar
110
Elvenbane
Leader
Posts: 4481
Contact:

Post#12 » Tue Feb 12, 2008 9:19 pm

They don't, I ran into the issue the night I posted the updated macro because we were running H-SL and I was using my original version and when I went to re-mc (before the initial mc broke) and it cleared my focus becasue it wasn't hostile.
It's the thought that counts, not how many people die because of it.
Elvenbane#1520

User avatar
100
Lealla
Class Leader
Posts: 3797
Contact:

Post#13 » Tue Feb 12, 2008 10:16 pm

I ran my test macro on a sheeped mob in SSC and it reported hostile. I'll do some more testing on this later.
Image

Image

User avatar
Heartwood
Posts: 1670

Post#14 » Wed Feb 13, 2008 11:16 am

Ok.... So to those of us who are new-ish at this... With Lemondrop I want to sheep my current target if I'm not sheeping anything else and I want to be able to monitor a focus target for the remaining duration of sheep and be able to resheep when the timer is low.

Do I want the last macro in Lealla's original post?

Btw, thanks for this thread and discussion.

-Heart
Image
At the brink of danger I stand. Clad in armour, shield and sword in hand.

Kendalh
Demon Hunter
Posts: 738

Post#15 » Wed Feb 13, 2008 11:31 am

You want Elven's last post of coding.

Return to “WoW Addon & Macro Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest