Thread Tools Display Modes
05-27-11, 08:47 PM   #1
jurundo
Banned
Join Date: May 2011
Posts: 9
Ask of help so as to create complex targeting macros

Hi,

Should you know I tried everything I could to this myself, unfortunately, I guess I don't know enough to succeed it.

I tried many scripts made by me or found on some forums which didn't work on 3.3.5 and that I didn't test on 4.0.0 +

I figured 3 extremly helpful targeting macros, made them half working since 2.4.3, and now aim to make them fully work with your help.

Here they are.

Should we firstly assume these as variables, if I can say so...

FOCUS = fact of focusing; TARGET = fact of targeting; focus = focused unit; target = targeted unit; player = unit nature;

lasttarget = previous target;

Macro 1: focus current target then change target

Action 1:

if "target" exists and "target" is hostile and "target" is player then FOCUS (target)

if "target" = "focus" then FOCUS ("lasttarget) or [if unit = "currenttarget" then "DO NOT TARGET")

-- so to avoid my focus to go on the current target when spamming the macro while no other unit is in the targeting range

Action 2:

if unit is hostile and unit is player then TARGET (unit)


Macro 2: focus current target then target lasttarget

Action 1:

if "target" exists and "target" is hostile and "target" is player then FOCUS (target)

if "target" = "focus" then FOCUS ("lasttarget") or [if unit = "currenttarget" then "DO NOT TARGET")

-- so to avoid my focus to go on the current target when spamming the macro while no other unit is in the targeting range

Action 2:

TARGET ("lasttarget")

Macro 3: target only Non Player Units

if unit is not player and is hostile then TARGET (unit)

What I managed to do:

macro 1: incomplete
/focus [harm, exists]
/targetenemyplayer

macro 2: incomplete
/focus [harm, exists]
/targetlasttarget

macro 3: not working on 3.3.5 but not tested on 4.0.0 +
/target pet, totem

Thank you for whoever takes the time to read this and eventually helps or tries me or tries to.
  Reply With Quote
05-28-11, 02:36 PM   #2
Jynks
A Frostmaul Preserver
Join Date: Oct 2006
Posts: 264
might be easyer for peopel to help if in stead yo udescribed what your macro is meant to do... rather than all that broken code and short hand...

Just describe what you want the macros to do
  Reply With Quote
05-28-11, 04:11 PM   #3
jurundo
Banned
Join Date: May 2011
Posts: 9
Hi,
In my view, if you can't take the time to read it all and/or don't understand what I mean, you won't be able to help me (no offense, just saying).

Anyway, if you insist, here is what I "clearly" want:

Macro 1: focus only PLAYER targets which exist and are hostile, then target new unit which is PLAYER and hostile.
+ do not focus if target doesn't change

Macro 2: same as one except it targets lasttarget
Macro 3: targets only NON PLAYER units

Still, I think my post was very clear, if only you took the time to read it.
  Reply With Quote
05-28-11, 06:12 PM   #4
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Originally Posted by jurundo View Post
Macro 1: focus only PLAYER targets which exist and are hostile, then target new unit which is PLAYER and hostile.
...
Macro 3: targets only NON PLAYER units
1. Not possible. Macros cannot check whether a unit is a player or an NPC.

2. Everyone who posts here is a volunteer. Not everyone who posts here speaks English as a first language. If someone takes the time to ask you to clarify what you want, that means that they want to help you. Most likely, they already have "taken the time" to read your whole post (which is fairly painful, by the way) but don't understand all of it. Rather than being a condescending ass, why don't you just try to phrase your request in another way so that this person who wants to help you can help you?
  Reply With Quote
05-28-11, 07:53 PM   #5
jurundo
Banned
Join Date: May 2011
Posts: 9
Checking if a unit is player or npc isn't the only way to make this work.
We may make it someway like /targetenemyplayer with a script.
I know someone made this work on 2.4.3 so one sure thing is this is possible.
Also, should you know I didn't mean to hurt anyone by me previous post, so if I did hurt you Jynks, I'm sorry.
  Reply With Quote
05-28-11, 07:59 PM   #6
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
In addition to what Phanx said, macros cannot compare two targets to see if your current target is the same unit as your focus.

Originally Posted by jurundo View Post
Checking if a unit is player or npc isn't the only way to make this work.
We may make it someway like /targetenemyplayer with a script.
I know someone made this work on 2.4.3 so one sure thing is this is possible.
Also, should you know I didn't mean to hurt anyone by me previous post, so if I did hurt you Jynks, I'm sorry.
What do you mean "with a script"? Targeting is a protected action and addons have not been able to do this since the 2.0 patch. And perhaps what you're thinking of from 2.4.3 either is a) not exactly what you're wanting to do above, or b) something that was fixed in the 3 years since.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
05-29-11, 01:57 AM   #7
Crissa
A Flamescale Wyrmkin
 
Crissa's Avatar
Join Date: May 2008
Posts: 136
Yeah, you totally can't select targets based upon if they're player or not via code.

You can target based upon name, so if you knew the name of your target, you could save that name and check that.

But that only works if you know the name and they're within 'sight'.

-Crissa
  Reply With Quote
05-29-11, 11:13 AM   #8
Lily.Petal
A Molten Giant
 
Lily.Petal's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2010
Posts: 540
This? Not exactly sure if this is remotely close to what you were looking for though :<
__________________

Aggro Color to KG Panels Borders - Nibelheim
Lua Based UI Hider - Nibelheim
Custom LUA PowerText - Stuf - Nibelheim, Seerah
  Reply With Quote
05-31-11, 08:57 AM   #9
jurundo
Banned
Join Date: May 2011
Posts: 9
Hi,

You almost made me lose faith. Hopefully, I have found a way to make this FULLY work (that's actually what I meant by scripts, the wow API). However, I would need someone who's good at manipulating LUA to explain how some functions work TOGETHER.

If anyone is interested at doing this, please email me at [email protected]

Of course, if this ever works, I will let you know; also, if you are interested in this macro/addon, email me and I will send it to you once it's been released.

Anyway, thank you for trying to help me.
  Reply With Quote
05-31-11, 09:17 AM   #10
Ketho
A Pyroguard Emberseer
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 1,026
Uhmm these responses are from the most knowledgeable Lua addon authors you will ever find ...

if they say you can't do something particular, then you probably can't
  Reply With Quote
05-31-11, 10:17 AM   #11
jurundo
Banned
Join Date: May 2011
Posts: 9
I don't pretend I am good at that, but here is what I found.
TargetLastEnemy() - Selects the last targetted enemy as the current target.
TargetLastTarget() - Selects the last target as the current target.
TargetNearestEnemy([reverseFlag]) - Selects the nearest enemy as the current target.
TargetNearestEnemyPlayer([reverseFlag]) - Selects the nearest enemy player as the current target.
TargetUnit("unit") - Selects the specified unit as the current target.
UnitExists("unit") - Returns 1 if the specified unit exists, nil otherwise. UnitIsEnemy("unit", "otherUnit") - Returns true if the specified units are enemies, false otherwise.
UnitIsFriend("unit", "otherUnit") - Returns true if the specified units are friends (PC of same faction or friendly NPC), false otherwise.
UnitIsUnit("unit", "otherUnit") - Determine if two units are the same unit.
UnitPlayerControlled("unit") - Returns true if the specified unit is controlled by a player, false otherwise.

If we use these together we can make my macros work.

All I wonder now is if there is something which focus instead of targeting; even if it happens to not be the case, I am sure we can use the /focus command in some other way instead.

Yes, since I am editing, please find below what the macro could look like (note that there must be some huge scripting mistakes since I don't know much about that; all I want is to give an idea of what I am conceiving).

/script target = t, focus = f, if UnitPlayerControlled(t) and UnitExists(t) and UnitIsUnit(t, f) = false then runmacro "/focus" end
/targetenemyplayer

Last edited by jurundo : 05-31-11 at 10:43 AM.
  Reply With Quote
05-31-11, 12:06 PM   #12
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Originally Posted by Seerah View Post
What do you mean "with a script"? Targeting is a protected action and addons have not been able to do this since the 2.0 patch. And perhaps what you're thinking of from 2.4.3 either is a) not exactly what you're wanting to do above, or b) something that was fixed in the 3 years since.
I'm quoting myself here in case you skimmed past it before.

Addons and macros cannot make intelligent decisions for you to perform secure actions (targeting, casting spells, movement, etc.). It has been this way since 2.0 when Blizzard got rid of addons that took decision-making away from the player. Blizzard's stance is "UI, not AI".

The answer to your question is still that it is not possible.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
05-31-11, 01:11 PM   #13
jurundo
Banned
Join Date: May 2011
Posts: 9
I've checked and it seems you are right, the targeting functions are protected but the functions dealing with units are not.
UnitExists("unit") - Returns 1 if the specified unit exists, nil otherwise. UnitIsEnemy("unit", "otherUnit") - Returns true if the specified units are enemies, false otherwise.
UnitIsFriend("unit", "otherUnit") - Returns true if the specified units are friends (PC of same faction or friendly NPC), false otherwise.
UnitIsUnit("unit", "otherUnit") - Determine if two units are the same unit.
UnitPlayerControlled("unit") - Returns true if the specified unit is controlled by a player, false otherwise.
Is there some way to use them?
Something which would look like what is below:
/script "s" target=t, focus=f, UnitIsUnit(t, f) = true, end
/focus [s]
  Reply With Quote
05-31-11, 01:23 PM   #14
Crissa
A Flamescale Wyrmkin
 
Crissa's Avatar
Join Date: May 2008
Posts: 136
Those won't really help unless you have a function target("unit")

-Crissa
  Reply With Quote
05-31-11, 02:51 PM   #15
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Because you can't do /focus [s]. /focus (and /target, etc.) only take valid unitIDs and the macro parser won't work with a variable.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
05-31-11, 04:53 PM   #16
Nobgul
A Molten Giant
 
Nobgul's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2009
Posts: 693
No matter which way you look at it or try to work around it you will always end up back at the same point. The macro functionality you are looking for is not possible.
__________________
[SIGPIC][/SIGPIC]
  Reply With Quote
05-31-11, 05:11 PM   #17
jurundo
Banned
Join Date: May 2011
Posts: 9
Well, I am very disapointed to hear that, but well, playing with my old ones is still very useful.
Anyway thank you for your help everyone.
And here are the macros I used to use.

/focus [harm, exists]
/targetenemy or targetenemyplayer, depend on what you like

and

/focus [harm, exists]
/targetlasttarget

It limits the possibilies but it's still very useful in 2v2 and also in 3v3.
I use these with tab and capslock (replaced with keytweak to avoid the Caps).

Regards,
  Reply With Quote
05-31-11, 06:31 PM   #18
Crissa
A Flamescale Wyrmkin
 
Crissa's Avatar
Join Date: May 2008
Posts: 136
However, the request to check if something is your focus or target is perfectly reasonable. It doesn't violate any of their stated rules for making code. So putting the request on the WorldofWarcraft macro/addon forum might generate some interest.

I can definitely see a use in being able to make a macro say, 'I don't want to hit my target with this effect' or vice versa for focus; certainly as my last big hurrah was as a tank and there's nothing more annoying than aiming at an add and accidentally wasting the effect on the target I'm already targeted upon! (Which is why they moved all those effects to non-targeted, non-facing, AoEs. Which I kinda deplored as being a very boring solution.)

-Crissa

PS, if you are checking for 'exists', do it first. I know most of the bugs have been cut out, but if something doesn't exist in your range, then you don't want to bother with the other checks at all. It means the macro will return faster and create less lag.
  Reply With Quote
05-31-11, 11:16 PM   #19
Seerah
Fishing Trainer
 
Seerah's Avatar
WoWInterface Super Mod
Featured
Join Date: Oct 2006
Posts: 10,860
Actually, exists is redundant. If [harm] or [help] return true, the target of the macro obviously exists.
__________________
"You'd be surprised how many people violate this simple principle every day of their lives and try to fit square pegs into round holes, ignoring the clear reality that Things Are As They Are." -Benjamin Hoff, The Tao of Pooh

  Reply With Quote
06-01-11, 08:28 AM   #20
jurundo
Banned
Join Date: May 2011
Posts: 9
Hi,

If I added the "exists" condition, it was only to avoid my focus to disappear when I clear my target. I wanted to avoid as many targeting/focusing complications as I could. If there is no "exists" condition, when you have no target, the focus action will make your focused unit get cleared.
I also added the "harm" condition to avoid focusing friendly units.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » Macro Help » Ask of help so as to create complex targeting macros

Thread Tools
Display Modes

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