• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Action not working inside the Unit Group Units within Range

Status
Not open for further replies.
Level 4
Joined
Apr 30, 2012
Messages
59
Anyone please help.
Can anyone correct my triggers.
  • GUNS21
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units within 300.00 of (Position of UnitSphere[12])) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is A Hero) Equal to True
            • Then - Actions
              • Unit - Order UnitSphere[12] to Move To (Position of (Picked unit))
              • Unit Group - Pick every unit in (Units within 25.00 of (Position of (Picked unit))) and do (Actions)
                • Loop - Actions
                  • Unit - Remove UnitSphere[12] from the game
                  • Unit - Set life of (Picked unit) to 10.00
            • Else - Actions
              • Do nothing
  • Unit Check Initializations
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 0
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 1
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 2
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 3
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 4
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 5
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 6
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 7
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 8
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 9
    • Actions
      • Trigger - Run Unit Check Trigger <gen> (ignoring conditions)
  • Unit Check OFF
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
      • (Number of living Health Sphere units owned by Neutral Passive) Equal to 10
    • Actions
      • Trigger - Turn off Unit Check Initializations <gen>
  • Unit Check Trigger
    • Events
    • Conditions
    • Actions
      • Unit - Create 1 Health Sphere for Neutral Passive at (Random point in (Playable map area)) facing Default building facing degrees
      • Set UnitSphere[12] = (Last created unit)
Map is Provided.
Map.w3x

Reward: Reputation
 

Attachments

  • SphereMPHP.w3x
    18.4 KB · Views: 136
the UnitSphere[12] is changing everytime you run the Unit Check Trigger, so you need
to create a global group and add the UnitSphere[12], then in the GUNS21, you need
to...
  • Unit Group - Pick every unit in (YOUR_GROUP) and do (Actions)
    • Set UnitSphere[12] = PickedUnit
    • Unit Group - Pick every unit in (Units within 300.00 of (Position of UnitSphere[12])) and do (Actions)
you leak position btw...
 
Level 4
Joined
Apr 30, 2012
Messages
59
I want
  • Set UnitSphere[12] = PickedUnit
to follow the
  • Actions
    • Unit Group - Pick every unit in (Units within 300.00 of (Position of UnitSphere[12])) and do (Actions)
    • Loop - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • ((Picked unit) is A Hero) Equal to True
    • Then - Actions
    • Unit - Order UnitSphere[12] to Move To (Position of (Picked unit))
    • Unit Group - Pick every unit in (Units within 25.00 of (Position of (Picked unit))) and do (Actions)
    • Loop - Actions
    • Unit - Remove UnitSphere[12] from the game
    • Unit - Set life of (Picked unit) to 10.00
 
Level 4
Joined
Oct 20, 2011
Messages
129
I think he want to make 9 Heath Spheres around the map, and everytime a hero moves near to one of them, that sphere flies to the hero and gives him 10HP.

  • Events
    • Time - Every 1.00 seconds of game time
  • Conditions
    • (Number of living Health Sphere units owned by Neutral Passive) Less than 10
  • Actions
    • Unit - Create 1 Health Sphere for Neutral Passive at (Random point in (Playable map area)) facing Default building facing degrees
    • Unit Group - Add Last created unit to (HeathSphereGroup)
  • GUNS21
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (HeathSphereGroup) and do (Actions)
        • Loop - Actions
          • Set u = (Picked unit)
          • Unit Group - Pick every unit in (Units within 300.00 of (Position of u)) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is A Hero) Equal to True
                • Then - Actions
                  • Unit - Order u to Move To (Position of (Picked unit))
                  • Unit Group - Pick every unit in (Units within 25.00 of (Position of (Picked unit))) and do (Actions)
                    • Loop - Actions
                      • Unit - Remove u from the game
                      • Unit - Set life of (Picked unit) to (Life of (Picket unit) + 10)
                • Else - Actions
                  • Do nothing
 
Last edited:
Level 4
Joined
Apr 30, 2012
Messages
59
I think he want to make 9 Heath Spheres around the map, and everytime a hero moves near to one of them, that sphere flies to the hero and gives him 10HP.
  • Unit - Set life of (Picked unit) to (Life of (Picket unit) + 10)
Merge these too trigger into one.

  • Events
    • Time - Every 1.00 seconds of game time
  • Conditions
    • (Number of living Health Sphere units owned by Neutral Passive) Equal to 10
  • Actions
    • Unit - Create 1 Health Sphere for Neutral Passive at (Random point in (Playable map area)) facing Default building facing degrees
I don't have problems with that. What the problem is the Unit Group that leaks and the spheres wont move.
 
This is suppose your trigger should look like without leaks

  • Unit Check Trigger
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 0
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 1
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 2
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 3
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 4
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 5
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 6
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 7
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 8
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 9
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 10
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • Set Loc1 = (Random point in (Playable map area))
          • Unit - Create 1 Health Sphere for Neutral Passive at Loc1 facing Default building facing degrees
          • Unit Group - Add (Last created unit) to Grp
          • Custom script: call RemoveLocation(udg_Loc1)
  • GUNS21
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Grp and do (Actions)
        • Loop - Actions
          • Set UnitSphere[12] = (Picked unit)
          • Set Loc1 = (Position of UnitSphere[12])
          • Custom script: set bj_wantDestroyGroup=true
          • Unit Group - Pick every unit in (Units within 300.00 of Loc1) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is A Hero) Equal to True
                • Then - Actions
                  • Custom script: call RemoveLocation(udg_Loc1)
                  • Set Loc1 = (Position of (Picked unit))
                  • Unit - Order UnitSphere[12] to Move To Loc1
                  • Custom script: set bj_wantDestroyGroup=true
                  • Unit Group - Pick every unit in (Units within 25.00 of Loc1) and do (Actions)
                    • Loop - Actions
                      • Unit - Remove UnitSphere[12] from the game
                      • Unit - Set life of (Picked unit) to 10.00
                      • Custom script: call RemoveLocation(udg_Loc1)
                • Else - Actions

But truth to be told I really dont understand why you pick every unit in 25AOE and removes it, strange...
 
Level 4
Joined
Apr 30, 2012
Messages
59
Yes I followed your triggers bro but the sphere wont move.
Here is your trigger that I modified.
  • Unit Check Trigger
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 0
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 1
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 2
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 3
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 4
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 5
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 6
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 7
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 8
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 9
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 10
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • Set Loc1 = (Random point in (Playable map area))
          • Unit - Create 1 Health Sphere for Neutral Passive at Loc1 facing Default building facing degrees
          • Unit Group - Add (Last created unit) to Group
          • Custom script: call RemoveLocation(udg_Loc1)
  • Sphere
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Group and do (Actions)
        • Loop - Actions
          • Set HeroSphere[12] = (Picked unit)
          • Set Loc1 = (Position of UnitSphere[12])
          • Custom script: set bj_wantDestroyGroup=true
      • Unit Group - Pick every unit in (Units within 350.00 of Loc1) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is A Hero) Equal to True
            • Then - Actions
              • Custom script: call RemoveLocation(udg_Loc1)
              • Set Loc1 = (Position of (Picked unit))
              • Unit - Order UnitSphere[12] to Move To Loc1
              • Custom script: set bj_wantDestroyGroup=true
              • Unit Group - Pick every unit in (Units within 25.00 of Loc1) and do (Actions)
                • Loop - Actions
                  • Unit - Remove UnitSphere[12] from the game
                  • Unit - Set life of (Picked unit) to ((Percentage life of (Picked unit)) + 20.00)
                  • Custom script: call RemoveLocation(udg_Loc1)
            • Else - Actions
 
Level 4
Joined
Oct 20, 2011
Messages
129
This is suppose your trigger should look like without leaks

  • Unit Check Trigger
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 0
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 1
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 2
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 3
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 4
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 5
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 6
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 7
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 8
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 9
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of living Health Sphere units owned by Neutral Passive) Equal to 10
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • Set Loc1 = (Random point in (Playable map area))
          • Unit - Create 1 Health Sphere for Neutral Passive at Loc1 facing Default building facing degrees
          • Unit Group - Add (Last created unit) to Grp
          • Custom script: call RemoveLocation(udg_Loc1)
  • GUNS21
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Grp and do (Actions)
        • Loop - Actions
          • Set UnitSphere[12] = (Picked unit)
          • Set Loc1 = (Position of UnitSphere[12])
          • Custom script: set bj_wantDestroyGroup=true
          • Unit Group - Pick every unit in (Units within 300.00 of Loc1) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is A Hero) Equal to True
                • Then - Actions
                  • Custom script: call RemoveLocation(udg_Loc1)
                  • Set Loc1 = (Position of (Picked unit))
                  • Unit - Order UnitSphere[12] to Move To Loc1
                  • Custom script: set bj_wantDestroyGroup=true
                  • Unit Group - Pick every unit in (Units within 25.00 of Loc1) and do (Actions)
                    • Loop - Actions
                      • Unit - Remove UnitSphere[12] from the game
                      • Unit - Set life of (Picked unit) to 10.00
                      • Custom script: call RemoveLocation(udg_Loc1)
                • Else - Actions

But truth to be told I really dont understand why you pick every unit in 25AOE and removes it, strange...

Your triggers ruin his idea.
You should read the page 1 of this thread to see what other people have done.

Hmm.. in your second trigger, if there is no unit to be picked, this will leak.

@Dr. Brewery Ale: You got one mistake...
  • Custom script: set bj_wantDestroyGroup=true
  • Unit Group - Pick every unit in (Units within 350.00 of Loc1) and do (Actions)
to
  • Custom script: set bj_wantDestroyGroup=true
  • Unit Group - Pick every unit in (Units within 350.00 of Loc1) and do (Actions)
 
im just combining tre triggers he made coz the Unit Check Initializations runs the
Unit Check Trigger per second, that's why I put a condition that if Health Sphere equals 10
then off the trigger that is running the loop (this trigger)...
Hmm.. in your second trigger, if there is no unit to be picked, this will leak.
if there's no unit picked, then Loc1 has a null instance coz there's no unit, however,
the Custom script: call RemoveLocation(udg_Loc1) should be placed under the group enumeration
not in the 'then' part...
 
Level 4
Joined
Apr 30, 2012
Messages
59
I found the solution to the problem.
  • Initialization Sphere
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • Set TempLoc = (Random point in (Playable map area))
          • Unit - Create 1 Health Sphere for Neutral Passive at TempLoc facing Default building facing degrees
          • Set UnitSphere[(Integer A)] = (Last created unit)
          • Custom script: call RemoveLocation(udg_TempLoc)
  • Sphere
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • Set TempLoc = (Position of UnitSphere[(Integer A)])
          • Custom script: set bj_wantDestroyGroup = true
          • Unit Group - Pick every unit in (Units within 300.00 of (Position of UnitSphere[(Integer A)])) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is A Hero) Equal to True
                • Then - Actions
                  • Set TargetHero[(Integer A)] = (Picked unit)
                  • Unit - Order UnitSphere[(Integer A)] to Move To (Position of (Picked unit))
                • Else - Actions
          • Unit Group - Pick every unit in (Units within 50.00 of (Position of UnitSphere[(Integer A)])) and do (Actions)
            • Loop - Actions
              • Set TargetHero[(Integer A)] = No unit
              • Unit - Move UnitSphere[(Integer A)] instantly to (Random point in (Playable map area))
              • Unit - Set life of TargetHero[(Integer A)] to ((Life of TargetHero[(Integer A)]) + 10.00)
              • Set TempLoc2 = (Random point in (Playable map area))
              • Custom script: call RemoveLocation(udg_TempLoc2)
          • Custom script: call RemoveLocation(udg_TempLoc)
I just did not kill the unit but instead move it to another place.
If i want to put it in 7 Random locations what trigger should I use?
 
Status
Not open for further replies.
Top