• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] How to Pick Enemy and Ally units, but not Own?

Status
Not open for further replies.
Level 5
Joined
Dec 31, 2013
Messages
121
Hello, I just can't figure it out, what I need to do, to make trigger pick enemy units, pick my ally units, but not my own units.

I can't use specific players for this trigger, because I can play as different players and others people too. Here is this trigger. If use "Picked unit belongs to ally of triggering player equal to true" or "Picked unit belongs to ally of owner of triggering unit equal to try" It will also pick my own units. So I kinda lost here.

4b8545d2cb.png
 
Level 3
Joined
Jun 18, 2016
Messages
68
Try to use pick every unit belongs to ally of triggering player and picked unit not equal to unit owned by trigger player and do actions
 
Level 22
Joined
Aug 27, 2013
Messages
3,973
Try this
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Owner of (Picked unit)) Not equal to (Owner of (Triggering unit))
      • Or - Any (Conditions) are true
        • Conditions
          • ((Picked unit) belongs to an ally of (Owner of (Triggering unit))) Equal to True
          • ((Picked unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True
    • Then - Actions
    • Else - Actions
 
Level 5
Joined
Dec 31, 2013
Messages
121
It seems that this trigger works, but I tried it before posting and nothing happened.

  • ((Picked unit) is owned by (Triggering player)) Equal to False[trigger]

Dunno how to make this one:

  • (Owner of (Picked unit)) Not equal to (Owner of (Triggering unit))
And tried and it looked like this:

  • ((Picked unit) is owned by (Owner of (Picked unit))) Not equal to ((Triggering unit) is owned by (Triggering player))
But thx any way for help
 
Level 3
Joined
Jun 18, 2016
Messages
68
Dunno how to make this one:

  • (Owner of (Picked unit)) Not equal to (Owner of (Triggering unit))
it can be found in Conditions > Player Comparison

EDIT: And, by the way, your meaning is to pick ally and enemy of caster within 400 AoE right? doesnt that equals to (Pick unit within 400 range of caster)? doesnt it same as Pick unit within 400 range and if (picked unit is ally of (X)) or (picked unit is enemy of (x))???

So basically, what your trigger do?

EDIT2: sorry if you dont get it, but my meaning is,
If you want to pick every ally and enemy of caster within 400 AoE, why you dont straight pick every unit within 400 range of caster? or you want to seperate them? like "Pick ally of (X) and do action" while "Pick enemy of (X) and do action"?
 
Last edited:
Level 5
Joined
Dec 31, 2013
Messages
121
I just wanted add units to group and do action, but this units should be enemys and my ally units. Didn't know how to do that and found this 2 conditions. But second condition picked my own units too. But now I can see that I need only this one condition "picked unit not equal to unit owned by trigger player"
 
Level 3
Joined
Jun 18, 2016
Messages
68
If you want to pick all enemy and ally unit within caster, then just simply use (Picked (every unit) within (400) range of (caster) matching ((matching uni) is alive) equal to true and do actions), unless you want to pick dying unit too :3
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Try to use pick every unit belongs to ally of triggering player and picked unit not equal to unit owned by trigger player and do actions
"unit owned by trigger player" there is no such thing.

  • ((Picked unit) is in (Units owned by (Triggering player))) Egal à FALSE
You are aware of how unit groups leak?
Better to compare the owner of the picked unit.

Try this
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Owner of (Picked unit)) Not equal to (Owner of (Triggering unit))
      • Or - Any (Conditions) are true
        • Conditions
          • ((Picked unit) belongs to an ally of (Owner of (Triggering unit))) Equal to True
          • ((Picked unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True
    • Then - Actions
    • Else - Actions
That is a bit too much, just the first condition is enough.

But now I can see that I need only this one condition "picked unit not equal to unit owned by trigger player"
Again, that action doesnt exist.
You probably mean "(Owner of (Picked unit)) Not equal to (Owner of (Triggering unit))".

If you want to pick all enemy and ally unit within caster, then just simply use (Picked (every unit) within (400) range of (caster) matching ((matching uni) is alive) equal to true and do actions), unless you want to pick dying unit too :3
Better to add it in the condition in the loop.
The mathing functionality loops through the group applying the condition you entered in the condition field.
If you loop through the group anyway (which you do 95% of the times) and you have a filter, you end up doing redundant work... and not the least cpu consuming work.
 
Level 3
Joined
Jun 18, 2016
Messages
68
"unit owned by trigger player" there is no such thing.

Better to add it in the condition in the loop.
The mathing functionality loops through the group applying the condition you entered in the condition field.
If you loop through the group anyway (which you do 95% of the times) and you have a filter, you end up doing redundant work... and not the least cpu consuming work.
well, okay xD.... since im also new from hive :3 i don't know much tho
 
Level 5
Joined
Dec 31, 2013
Messages
121
You are aware of how unit groups leak?
Better to compare the owner of the picked unit.

I mean this one:
  • ((Picked unit) is owned by (Triggering player)) Equal to False
I tested it and it works fine alone. But this one works too

  • (Owner of (Picked unit)) Not equal to (Owner of (Triggering unit))
So if I am right, I have 2 conditions and can choose any.

But I got another problem, to remove leaks I found that I need destroy group at the end of the trigger, but when I do it, this group will not work anymore when I start trigger again.
 
Last edited:
Level 4
Joined
Jul 26, 2016
Messages
88
I mean this one:
  • ((Picked unit) is owned by (Triggering player)) Equal to False
I tested it and it works fine alone. But this one works too

  • (Owner of (Picked unit)) Not equal to (Owner of (Triggering unit))
So if I am right, I have 2 conditions and can choose any.

But I got another problem, to remove leaks I found that I need destroy group at the end of the trigger, but when I do it, this group will not work anymore when I start trigger again.

Have your unit group global variable (top of trigger editor, variables)

You need to re-set the group every iteration of the trigger. For example your trigger should look like

every X seconds

some or no conditions

set tempGroup = units within range matching condition
pick every unit in tempGroup and do whatever
Custom Script: call DestroyGroup(udg_tempGroup)
 
Level 5
Joined
Dec 31, 2013
Messages
121
Well my trigger launches when unit starts effect of the ability, then it creates group, then I launch second trigger, second one uses group for 1 second, then first trigger turns of second trigger and then it destroys group. But If I do this ability again, units never added to group. It seems you can never use this group after you destroyed it, so you should not destroy it, but clear it. Am I right? I just saw some threads about leaks and people were saying you should destroy groups and etc, but it seems not work for my trigger if I want use it many times.

PS: Also sorry for offtop, just don't want create new thread. Is there way to use local variables if I use 2 triggers for my spell? The second trigger repeats like 5 or 20 times.
 
Level 4
Joined
Jul 26, 2016
Messages
88
Well my trigger launches when unit starts effect of the ability, then it creates group, then I launch second trigger, second one uses group for 1 second, then first trigger turns of second trigger and then it destroys group. But If I do this ability again, units never added to group. It seems you can never use this group after you destroyed it, so you should not destroy it, but clear it. Am I right? I just saw some threads about leaks and people were saying you should destroy groups and etc, but it seems not work for my trigger if I want use it many times.

PS: Also sorry for offtop, just don't want create new thread. Is there way to use local variables if I use 2 triggers for my spell? The second trigger repeats like 5 or 20 times.

For your casting trigger, do something like, have your temporary group every time you cast that you call DestroyGroup on, that will ADD all the picked units to a permanent unit group, which you will use for the looping trigger. When the loop is done for a specific unit remove it from the unit group.

Trigger 1:

Event - Unit casts whatever

Actions - Set tempGroup = units in X range matching Y condition
for every unit in tempGroup do add picked unit to loopGroup
Custom Script: call DestroyGroup(udg_tempGroup)


Trigger 2:

Event - Every x seconds of game time

Actions - do pick Every unit in loopGroup and do actions (i do not know if this causes a leak, I would not think since you're never instantiating a new group but maybe someone smarter can confirm/dis-confirm)

you need to track when your units will be removed from the group

I know what i wrote above isnt 100% accurate but I hope you get the idea. Don't hesitate to add further questions.
 
Status
Not open for further replies.
Top