[Solved] Triggers: Unit probably not recognized as a part of "Unit Group"

Status
Not open for further replies.
Level 5
Joined
Dec 27, 2014
Messages
96
Good day to you, again!

Please, can someone help me with the following problem I have? In one trigger, which is run without "event" and "conditions" (it is run by "Run trigger" function) and only has "actions", I have created actions where units are being created. It is about 15 units in total. After each "Unit - Create units" I have placed an "action" "Add last created unit to unit group", while at the case of one specific unit, it is meant to be added to two groups (I have this pictured in the image I have attached to this message).

Then, there is an another trigger, which means to recognize if all units in the respective unit groups are dead (if the unit group is empty). If they are, then respective actions should take place.

Problem is that those actions in the second trigger are not working, while everything else is. I have tried to replace the condition in the second trigger by "Unit-type comparison", and set it to "Unit-type of dying unit is Quilboar Brute", in which case it is working. Therefore, I think that the triggers are not recognizing the existence of the units in my unit groups.


  • Release Quillboar Brute Wave
    • Events
    • Conditions
    • Actions
      • Trigger - Turn off (This trigger)
      • -------- 1 --------
      • Unit - Create 1 Quillboar Scout for Player 12 (Brown) at (Center of Northern Spawn <gen>) facing 270.00 degrees
      • Unit Group - Add (Last created unit) to Current_Wave
      • Unit Group - Add (Last created unit) to Fleeing_Enemies
      • Unit - Create 1 Quillboar Scout for Player 12 (Brown) at (Center of Eastern Spawn <gen>) facing 180.00 degrees
      • Unit Group - Add (Last created unit) to Current_Wave
      • Unit Group - Add (Last created unit) to Fleeing_Enemies
      • Unit - Create 1 Quillboar Scout for Player 12 (Brown) at (Center of Western Spawn <gen>) facing 0.00 degrees
      • Unit Group - Add (Last created unit) to Current_Wave
      • Unit Group - Add (Last created unit) to Fleeing_Enemies
      • Wait 0.50 seconds
      • -------- 2 --------
      • Unit - Create 1 Quillboar Scout for Player 12 (Brown) at (Center of Northern Spawn <gen>) facing 270.00 degrees
      • Unit Group - Add (Last created unit) to Current_Wave
      • Unit Group - Add (Last created unit) to Fleeing_Enemies
      • Unit - Create 1 Quillboar Scout for Player 12 (Brown) at (Center of Eastern Spawn <gen>) facing 180.00 degrees
      • Unit Group - Add (Last created unit) to Current_Wave
      • Unit Group - Add (Last created unit) to Fleeing_Enemies
      • Unit - Create 1 Quillboar Scout for Player 12 (Brown) at (Center of Western Spawn <gen>) facing 0.00 degrees
      • Unit Group - Add (Last created unit) to Current_Wave
      • Unit Group - Add (Last created unit) to Fleeing_Enemies
      • Wait 0.50 seconds
      • -------- 3 --------
      • Unit - Create 1 Quillboar Brute for Player 12 (Brown) at (Center of Northern Spawn <gen>) facing 270.00 degrees
      • Unit Group - Add (Last created unit) to Boss_Unit_Group
      • Unit Group - Add (Last created unit) to Current_Wave
      • Unit - Create 1 Quillboar Thrower for Player 12 (Brown) at (Center of Eastern Spawn <gen>) facing 180.00 degrees
      • Unit Group - Add (Last created unit) to Current_Wave
      • Unit Group - Add (Last created unit) to Fleeing_Enemies
      • Unit - Create 1 Quillboar Thrower for Player 12 (Brown) at (Center of Western Spawn <gen>) facing 0.00 degrees
      • Unit Group - Add (Last created unit) to Current_Wave
      • Unit Group - Add (Last created unit) to Fleeing_Enemies
      • -------- Other --------
      • Trigger - Turn on Boss Sound <gen>

  • Victory Cheer Boss
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Dying unit) is in Boss_Unit_Group) Equal to True
    • Actions
      • Unit Group - Remove (Dying unit) from Boss_Unit_Group
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in Boss_Unit_Group) Equal to 0
        • Then - Actions
          • Item - Create Rune of Lesser Healing at (Position of (Dying unit))
          • Wait 0.50 seconds
          • Sound - Play OgreEventCheerUnique <gen> at 100.00% volume, located at (Center of Orc Cheer NE <gen>) with Z offset 0.00
          • Sound - Play OgreEventCheerUnique <gen> at 100.00% volume, located at (Center of Orc Cheer NW <gen>) with Z offset 0.00
          • Sound - Play OgreEventCheerUnique <gen> at 100.00% volume, located at (Center of Orc Cheer SE <gen>) with Z offset 0.00
          • Sound - Play OgreEventCheerUnique <gen> at 100.00% volume, located at (Center of Orc Cheer SW <gen>) with Z offset 0.00
        • Else - Actions
          • Do nothing

I am looking forward to your replies.


P.S.: My apologies, all creatures are being added to two Unit Groups.
 
Last edited:
Level 25
Joined
May 11, 2007
Messages
4,650
Don't take screenshots of your triggers, instead post them:
How To Post Your Trigger

Place some game text messages as the first action in the 2nd trigger, so you can see that it actually triggers.
Print out how many units that are in the Boss_Unit_Group too.

And remove the Do Nothing fuction, it doesn't do anything.
 
Level 5
Joined
Dec 27, 2014
Messages
96
Thank you for your ideas, LordDz.

In the case of the second trigger I have, for now, only tried to remove the condition and replace it by "Unit-type of dying unit = Quilboar Brute", and then it was working. That is the reason why I think that the problem is with the recognition of the Unit Group (the Quilboar Brute of the first trigger is probably not being added to the Unit Group).

Regarding the number of units in Boss_Unit_Group: There should by none prior to this events, as this is the first wave and Quilboar Brute is the first unit added to this group.

Here I repost the triggers:


Release Quillboar Brute Wave
Events
Conditions
Actions
Trigger - Turn off (This trigger)
-------- 1 --------
Unit - Create 1 Quillboar Scout for Player 12 (Brown) at (Center of Northern Spawn <gen>) facing 270.00 degrees
Unit Group - Add (Last created unit) to Current_Wave
Unit Group - Add (Last created unit) to Fleeing_Enemies
Unit - Create 1 Quillboar Scout for Player 12 (Brown) at (Center of Eastern Spawn <gen>) facing 180.00 degrees
Unit Group - Add (Last created unit) to Current_Wave
Unit Group - Add (Last created unit) to Fleeing_Enemies
Unit - Create 1 Quillboar Scout for Player 12 (Brown) at (Center of Western Spawn <gen>) facing 0.00 degrees
Unit Group - Add (Last created unit) to Current_Wave
Unit Group - Add (Last created unit) to Fleeing_Enemies
Wait 0.50 seconds
-------- 2 --------
Unit - Create 1 Quillboar Scout for Player 12 (Brown) at (Center of Northern Spawn <gen>) facing 270.00 degrees
Unit Group - Add (Last created unit) to Current_Wave
Unit Group - Add (Last created unit) to Fleeing_Enemies
Unit - Create 1 Quillboar Scout for Player 12 (Brown) at (Center of Eastern Spawn <gen>) facing 180.00 degrees
Unit Group - Add (Last created unit) to Current_Wave
Unit Group - Add (Last created unit) to Fleeing_Enemies
Unit - Create 1 Quillboar Scout for Player 12 (Brown) at (Center of Western Spawn <gen>) facing 0.00 degrees
Unit Group - Add (Last created unit) to Current_Wave
Unit Group - Add (Last created unit) to Fleeing_Enemies
Wait 0.50 seconds
-------- 3 --------
Unit - Create 1 Quillboar Brute for Player 12 (Brown) at (Center of Northern Spawn <gen>) facing 270.00 degrees
Unit Group - Add (Last created unit) to Boss_Unit_Group
Unit Group - Add (Last created unit) to Current_Wave
Unit - Create 1 Quillboar Thrower for Player 12 (Brown) at (Center of Eastern Spawn <gen>) facing 180.00 degrees
Unit Group - Add (Last created unit) to Current_Wave
Unit Group - Add (Last created unit) to Fleeing_Enemies
Unit - Create 1 Quillboar Thrower for Player 12 (Brown) at (Center of Western Spawn <gen>) facing 0.00 degrees
Unit Group - Add (Last created unit) to Current_Wave
Unit Group - Add (Last created unit) to Fleeing_Enemies
-------- Other --------
Trigger - Turn on Boss Sound <gen>



Victory Cheer Boss
Events
Unit - A unit Dies
Conditions
((Dying unit) is in Boss_Unit_Group) Equal to True
Actions
Unit Group - Remove (Dying unit) from Boss_Unit_Group
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Number of units in Boss_Unit_Group) Equal to 0
Then - Actions
Item - Create Rune of Lesser Healing at (Position of (Dying unit))
Wait 0.50 seconds
Sound - Play OgreEventCheerUnique <gen> at 100.00% volume, located at (Center of Orc Cheer NE <gen>) with Z offset 0.00
Sound - Play OgreEventCheerUnique <gen> at 100.00% volume, located at (Center of Orc Cheer NW <gen>) with Z offset 0.00
Sound - Play OgreEventCheerUnique <gen> at 100.00% volume, located at (Center of Orc Cheer SE <gen>) with Z offset 0.00
Sound - Play OgreEventCheerUnique <gen> at 100.00% volume, located at (Center of Orc Cheer SW <gen>) with Z offset 0.00
Else - Actions
Do nothing
 
Level 25
Joined
May 11, 2007
Messages
4,650
Use the game text messages and see if they work with the trigger you first posted.
One of the most general things in programming is to use debug tools, printing out stuff is one of them.

And you didn't post your trigger properly =/
 
Level 5
Joined
Dec 27, 2014
Messages
96
And you didn't post your trigger properly =/

Please, explain.

P. S.: I am about to try those text messages. I will be informing you about the results.

Edit. 1: It appears to be working, now, but I do not know what might have solved it. I have only deleted those "Add to unit group" and then added it there anew it it is perfectly fine now.
 
Last edited:
Level 5
Joined
Dec 27, 2014
Messages
96
I consider it to be the explanation in LordDz´s behalf, or in his stead; thank you, Pyrogasm, and especially for this insight regarding the fixation of the trigger. I have never thought that there might be such problems like that Editor or game is malfunctioned in these regards. I have never experienced this (that editor or game is not able to read the functions or recognize them) before, and I am using editor for about 12 years (but for last 10 years only sporadically).

I am still trying to figure out if there is not something that I am doing wrong, because I can not believe it due to the fact I have written just above, but everything seems to me set-up right. As this trigger is now working, I am experiencing the same problems with the other ones based on the same "Unit group function" idea/principle. I will post those triggers here, if anyone would like to look upon them what might be wrong.

Again, thank you for your entry, Pyrogasm.

Edit. 1: Here is one of those other trigger-related issue. The first trigger is the same as the one in my aforementioned case, as it is related to this issue. The other trigger is the one onto which it is related in this problem:

  • Release Quillboar Brute Wave
    • Events
    • Conditions
    • Actions
      • Trigger - Turn off (This trigger)
      • -------- 1 --------
      • Unit - Create 1 Quillboar Scout for Player 12 (Brown) at (Center of Northern Spawn <gen>) facing 270.00 degrees
      • Unit Group - Add (Last created unit) to Current_Wave
      • Unit Group - Add (Last created unit) to Fleeing_Enemies
      • Unit - Create 1 Quillboar Scout for Player 12 (Brown) at (Center of Eastern Spawn <gen>) facing 180.00 degrees
      • Unit Group - Add (Last created unit) to Current_Wave
      • Unit Group - Add (Last created unit) to Fleeing_Enemies
      • Unit - Create 1 Quillboar Scout for Player 12 (Brown) at (Center of Western Spawn <gen>) facing 0.00 degrees
      • Unit Group - Add (Last created unit) to Current_Wave
      • Unit Group - Add (Last created unit) to Fleeing_Enemies
      • Wait 0.50 seconds
      • -------- 2 --------
      • Unit - Create 1 Quillboar Scout for Player 12 (Brown) at (Center of Northern Spawn <gen>) facing 270.00 degrees
      • Unit Group - Add (Last created unit) to Current_Wave
      • Unit Group - Add (Last created unit) to Fleeing_Enemies
      • Unit - Create 1 Quillboar Scout for Player 12 (Brown) at (Center of Eastern Spawn <gen>) facing 180.00 degrees
      • Unit Group - Add (Last created unit) to Current_Wave
      • Unit Group - Add (Last created unit) to Fleeing_Enemies
      • Unit - Create 1 Quillboar Scout for Player 12 (Brown) at (Center of Western Spawn <gen>) facing 0.00 degrees
      • Unit Group - Add (Last created unit) to Current_Wave
      • Unit Group - Add (Last created unit) to Fleeing_Enemies
      • Wait 0.50 seconds
      • -------- 3 --------
      • Unit - Create 1 Quillboar Brute for Player 12 (Brown) at (Center of Northern Spawn <gen>) facing 270.00 degrees
      • Unit Group - Add (Last created unit) to Boss_Unit_Group
      • Unit Group - Add (Last created unit) to Current_Wave
      • Unit - Create 1 Quillboar Thrower for Player 12 (Brown) at (Center of Eastern Spawn <gen>) facing 180.00 degrees
      • Unit Group - Add (Last created unit) to Current_Wave
      • Unit Group - Add (Last created unit) to Fleeing_Enemies
      • Unit - Create 1 Quillboar Thrower for Player 12 (Brown) at (Center of Western Spawn <gen>) facing 0.00 degrees
      • Unit Group - Add (Last created unit) to Current_Wave
      • Unit Group - Add (Last created unit) to Fleeing_Enemies
      • -------- Other --------
      • Trigger - Turn on Boss Sound <gen>

  • Fleeing enemies
    • Events
      • Unit - A unit owned by Player 12 (Brown) Is attacked
    • Conditions
      • ((Attacked unit) is in Fleeing_Enemies) Equal to True
      • (Life of (Attacked unit)) Less than (Random real number between 400.00 and 250.00)
    • Actions
      • Unit Group - Remove (Attacked unit) from Fleeing_Enemies
      • Unit - Add Wander (Neutral) to (Attacked unit)
      • Wait 4.00 seconds
      • Unit - Remove Wander (Neutral) from (Attacked unit)
      • Wait 1.00 seconds
      • Unit - Order (Attacked unit) to Attack-Move To (Position of (Random unit from UG_Heroes))
 
Last edited:
Level 45
Joined
Feb 27, 2007
Messages
5,578
Some things, like "Attacked Unit", don't work after a wait action. Triggering Unit always does, though, so in this case you can just use it instead. In cases where there isn't a wait-safe event response to use you can use custom scripts to add local variables to your GUI triggers to temporarily store a reference to the object. There should be a tutorial for this somewhere in the tutorials section, but I'm on mobile so I don't want to try to find it.

Not entirely sure if this is correct, but the order might matter for "Random real between 400 and 250." Try switching the order of the numbers.

Did you forget to readd the unit to Fleeing Enemies after it stops wandering, or should units only flee once?

The "turn off this trigger" action is unnecessary since the trigger has no events. It won't prevent the trigger from being run by a "Trigger - Run SomeTrigger <gen>" action, and since it has no events it can't run on its own anyway.
 
Last edited:
Level 5
Joined
Dec 27, 2014
Messages
96
Pyrogasm, I have tried these things (changing from "Attacked" to "Triggering unit" and changing "the order of numbers"), but it was not working. However, the unit is not even given that "Wander" ability, which is before the "wait" action. And in my other triggers, the creature is given an ability, and it is being recognized as "Attacked unit" and there is a "wait" action after the "Add ability" action. But that creature is being recognized in "conditions" by "Unit-type of attacked unit" and not as "Unit is in Unit group" condition. Here is the working trigger, in comparison to the not working one (Third Trigger):

  • Quillboar Brute Roar
    • Events
      • Unit - A unit owned by Player 12 (Brown) Is attacked
    • Conditions
      • (Unit-type of (Attacked unit)) Equal to Quillboar Brute
      • (Life of (Attacked unit)) Less than (Random real number between 1500.00 and 2000.00)
    • Actions
      • Trigger - Turn off (This trigger)
      • Unit - Add Roar (Quilboar Brute) to (Attacked unit)
      • Wait (Random real number between 5.00 and 10.00) seconds
      • Unit - Order (Attacked unit) to Night Elf Druid Of The Claw - Roar
... So, I think that the problem is with unit groups, or so.

The fleeing action should take place only once at each unit, so not re-adding the "Wander" is intentional. And thank you for the "turn off this trigger" notion, I have not realized it.
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
Oh okay I guess Attacked Unit does work. Sorry for the misinformation, but to be clear there are a few that don't work after waits. If the Fourth trigger works and switching the order of the 400 and 250 didn't fix it, then it must be that the units aren't getting added to the group. Given that you were having some problems before that were fixed by deleting and re-adding the actions, maybe you should try that again. Or try adding to a different group variable. Or copy the trigger and delete the old version (this might achieve the same thing as re-making the actions).

Does every unit flee if you disable all the conditions in the Third trigger? You can use some "Display text to player..." actions to count and show the number of units in Fleeing_Enemies after each new unit should be added to it in your spawn triggers. If the number doesn't go up or magically resets to 0 then something is removing them from the group or clearing the group. Do you ever call DestroyGroup(udg_Fleeing_Enemies) in a custom script somewhere to clean up a group leak with that group? I don't see why you would have since it appears that group never needs to be destroyed, but if you did that would cause units not to be added to it any more since the group doesn't technically exist.
 
Level 5
Joined
Dec 27, 2014
Messages
96
That is all right, Pyrogasm. I was trying that, but it does not seem to work. I just do not understand that, and can not believe that Editor and game are not able to read those triggers properly, as I have never experienced such a problem before.

Would someone be interested in looking into that map? It is for about 80 % completed (at least from a playability perspective).
 
Level 5
Joined
Dec 27, 2014
Messages
96
Good day, Killcide!

The relation between the "First Trigger" and the "Third Trigger" is being problematic, because the "Third Trigger" is not working, as if the units created in the "First Trigger" are not parts of the "Fleeing_Enemies" unit group despite being added to it in the "First Trigger".
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
If you post your map I'll look at it. Otherwise I would suggest you do something like this:
  • Events
    • Player 1 (Red) skips a cinematic sequence
  • Conditions
  • Actions
    • Game - Display to (All players) the text: String(Number of units in Fleeing_Enemies)
Press Escape as the wave is spawning and a few times before/after that to see how many units are in the group. That might help identify if there's a real problem or an editor bug.
 
Level 5
Joined
Dec 27, 2014
Messages
96
I have reproduced the triggers in a new plain map. It is not working even here.
 

Attachments

  • Test.w3x
    18.3 KB · Views: 76
Level 45
Joined
Feb 27, 2007
Messages
5,578
Figured it out! Wander was apparently never designed to be used on units that are able to attack, so if you give it to a unit with attacks and there are nearby enemies for it to attack it will do that instead of wandering. So to fix it, you just need to disable the units' attacks for the duration of the flee. The easist way to do that is to give them the Cargo Hold ability, which renders units unable to attack unless they have something loaded into them (which can't happen without the load/unload abilities)-- in your case disabling attacks entirely. The trigger below works for me:

  • Fleeing Quillboars
    • Events
      • Unit - A unit owned by Player 12 (Brown) Is attacked
    • Conditions
      • ((Attacked unit) is in Fleeing_Quillboars) Not equal to True
      • (Life of (Attacked unit)) Less than (Random real number between 150.00 and 250.00)
    • Actions
      • Game - Display to (All players) for 30.00 seconds the text: Flee!
      • Unit Group - Add (Attacked unit) to Fleeing_Quillboars
      • Unit - Add Wander (Neutral) to (Attacked unit)
      • Unit - Add Cargo Hold (Orc Burrow) to (Attacked unit)
      • Wait 4.00 seconds
      • Unit - Remove Wander (Neutral) from (Attacked unit)
      • Unit - Remove Cargo Hold (Orc Burrow) from (Attacked unit)
      • Wait 1.00 seconds
      • Unit - Order (Attacked unit) to Attack-Move To (Position of (Random unit from (Units owned by Player 1 (Red))))
      • Wait 15.00 seconds
      • Unit Group - Remove (Attacked unit) from Fleeing_Quillboars
You will, however, probably want to change some of the OE fields for Wander so the units have the behavior you want. Check out the "Tornado Wander (Tornado)" for an idea what the different fields modify. As I understand the cast range determines how far away the chosen wander point can be, area of effect is how far the tornado can move towards that location before it stops, and duration controls how often it picks a new point to wander to.
 
Level 5
Joined
Dec 27, 2014
Messages
96
Pyrogasm, I have also tried to add Wander ability to a unit (Footman, while testing it before, and now, in this test map, Centaur, to verify it) in Object Editor, so that unit will start with the Wander ability, and the Wander ability is working. In the case of this test map, the Centaur (owned by the same player as the quillboars - brown) was running away if his allies were attacked. Also, when I have attacked the Centaur, he was running away. It appears that the Wander ability is not working only if added by a trigger or something like that.

Edit. 1:

I have started to think that it might be required that the Wander effect must precede the "Attack" order the unit issues by itself. I have tried to make it, therefore, break the current attack of the unit by ordering it to move away and adding the Wander ability while it is moving away, and it appears to be working. It is looking, now, like this:


  • Fleeing Quillboars
    • Events
      • Unit - A unit owned by Player 12 (Brown) Is attacked
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Attacked unit)) Equal to Quillboar Scout
          • (Unit-type of (Attacked unit)) Equal to Quillboar Thrower
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Life of (Attacked unit)) Less than 200.00
        • Then - Actions
          • Unit Group - Add (Attacked unit) to Fleeing_Enemies
          • Unit - Order (Attacked unit) to Move To ((Position of (Attacking unit)) offset by 500.00 towards 180.00 degrees)
          • Unit - Add Wander (Neutral) to (Attacked unit)
          • Wait 4.00 seconds
          • Unit - Remove Wander (Neutral) from (Attacked unit)
          • Wait 1.00 seconds
          • Unit - Order (Attacked unit) to Attack-Move To (Position of (Random unit from UG_Heroes))
          • Wait 30.00 seconds
          • Unit Group - Remove (Attacked unit) from Fleeing_Enemies
        • Else - Actions
          • Do nothing
 
Last edited:
Level 45
Joined
Feb 27, 2007
Messages
5,578
You're currently leaking 2 points with that method (position of..) and (<that point> offset by...) and the 180 degrees is a static direction so they will always go left.

You're totally right that wander only takes over after the unit has no active order. I didn't realize it but that's how it works for Naga Witch's Tornado ultimate (you can order it to move places and it won't wander until it gets there). Since you ordered the spawned Quillboars to attack-move when created, that order is effectively always 'active' until they reach the point and there are no enemies. Therefore I think a simpler solution would be to order the unit to "stop" instead of moving to a point.
 
Level 5
Joined
Dec 27, 2014
Messages
96
Thank you for your notions, Pyrogasm. This is, actually, only the second time I am operating with the "offset" triggering. I have forgot, in this case, to add there that 180° is to be calculated from the current facing angle of the intented fleeing unit (Quillboar).

Also I was considering an option of using a "stop" order, but I have wanted to make sure that there will be enough time for a fleeing unit to be affected by the Wander effect before it decides to take an another attack order by itself (for I do not know what might be faster: if the transition time between individual trigger-actions, or an independent artificial intelligence of the unit, so I have resorted to this option to get some time before the unit decides to take some action). And I have already changed it to move only 100 points away instead of 500, which was only for testing purposes.
 
Status
Not open for further replies.
Top