WoWInterface

WoWInterface (http://www.wowinterface.com/forums/index.php)
-   Macro Help (http://www.wowinterface.com/forums/forumdisplay.php?f=140)
-   -   Ask of help so as to create complex targeting macros (http://www.wowinterface.com/forums/showthread.php?t=40316)

jurundo 05-27-11 08:47 PM

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.

Jynks 05-28-11 02:36 PM

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

jurundo 05-28-11 04:11 PM

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.

Phanx 05-28-11 06:12 PM

Quote:

Originally Posted by jurundo (Post 238307)
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?

jurundo 05-28-11 07:53 PM

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.

Seerah 05-28-11 07:59 PM

In addition to what Phanx said, macros cannot compare two targets to see if your current target is the same unit as your focus.

Quote:

Originally Posted by jurundo (Post 238319)
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.

Crissa 05-29-11 01:57 AM

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

Lily.Petal 05-29-11 11:13 AM

This? Not exactly sure if this is remotely close to what you were looking for though :<

jurundo 05-31-11 08:57 AM

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 izemmouri@hotmail.fr

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.

Ketho 05-31-11 09:17 AM

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 :(

jurundo 05-31-11 10:17 AM

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

Seerah 05-31-11 12:06 PM

Quote:

Originally Posted by Seerah (Post 238320)
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.

jurundo 05-31-11 01:11 PM

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]

Crissa 05-31-11 01:23 PM

Those won't really help unless you have a function target("unit")

-Crissa

Seerah 05-31-11 02:51 PM

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.

Nobgul 05-31-11 04:53 PM

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.

jurundo 05-31-11 05:11 PM

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,

Crissa 05-31-11 06:31 PM

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.

Seerah 05-31-11 11:16 PM

Actually, exists is redundant. If [harm] or [help] return true, the target of the macro obviously exists. ;)

jurundo 06-01-11 08:28 AM

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.


All times are GMT -6. The time now is 06:27 AM.

vBulletin © 2014, Jelsoft Enterprises Ltd
©2012 ZAM Network LLC