How to loop a trigger ?

Progesterone

New Member
Reaction score
0
Hi all, I have created this trigger to let a building train a unit(eg. grunt) and move the trained unit to a particular area (eg. region A), with the condition being that "the player owns less than 8 grunts in region A".
i want this trigger to LOOP, ie, the training of units continue on and on, unless of course the "condition" as stated above is not fulfilled. How do i do that ? Thanks !!
 

denmax

You can change this now in User CP.
Reaction score
155
Create 2 variables, 1 Unit Group and 1 Point

Code:
Events
    Time - Every [...] seconds of the game
Conditions
    (Units in (GruntGroup) Less than or Equal to 8
Actions
    Set LocA = (Random Point in (Region A))
    Unit - Create 1 Grunt for (Player) at (*LocA) facing Default facing degrees
    Unit Group - Add (Last Created Unit) in GruntGroup
    *Unit - Order (Last Created Unit) to Attack - Move to (LocA)
    Custom Script: call RemoveLocation(udg_LocA)

Code:
Event
    Unit - A unit dies
Conditions
    (Unit type of (Triggering Unit)) Equal to Grunt
Actions
    Unit - Remove (Triggering Unit) from GruntGroup

In this kind of triggering, even though the unit isn't in the GruntGroup and is removed, the GruntGroup value will still not get reduction..

If you are looking for Training Type then use these.

Create 2 variables, 1 point and 1 integer
Code:
Events
    The same in first trigger
Conditions
    (TotalGrunt) Less than or equal to 8
Actions
    Unit - Order [Barracks] to train/upgrade [Grunt]
    Set TotalGrunt = (TotalGrunt + 1)

Code:
Event
    Unit - A unit dies
Conditions
    (Unit type of (Triggering Unit)) Equal to Grunt
Actions
    Set TotalGrunt = (TotalGrunt - 1)

The only thing here is that even though the Grunts that were trained but aren't suppose to be with the TotalGrunt then it will also - the integer value...
 
S

shadowvzs

Guest
Create 2 variables, 1 Unit Group and 1 Point

Code:
Events
    Time - Every [...] seconds of the game
Conditions
    (Units in (GruntGroup) Less than or Equal to 8
Actions
    Set LocA = (Random Point in (Region A))
    Unit - Create 1 Grunt for (Player) at (*LocA) facing Default facing degrees
    Unit Group - Add (Last Created Unit) in GruntGroup
    *Unit - Order (Last Created Unit) to Attack - Move to (LocA)
    Custom Script: call RemoveLocation(udg_LocA)

Code:
Event
    Unit - A unit dies
Conditions
    (Unit type of (Triggering Unit)) Equal to Grunt
Actions
    Unit - Remove (Triggering Unit) from GruntGroup

In this kind of triggering, even though the unit isn't in the GruntGroup and is removed, the GruntGroup value will still not get reduction..

If you are looking for Training Type then use these.

Create 2 variables, 1 point and 1 integer
Code:
Events
    The same in first trigger
Conditions
    (TotalGrunt) Less than or equal to 8
Actions
    Unit - Order [Barracks] to train/upgrade [Grunt]
    Set TotalGrunt = (TotalGrunt + 1)

Code:
Event
    Unit - A unit dies
Conditions
    (Unit type of (Triggering Unit)) Equal to Grunt
Actions
    Set TotalGrunt = (TotalGrunt - 1)

The only thing here is that even though the Grunts that were trained but aren't suppose to be with the TotalGrunt then it will also - the integer value...

and this....

Code:
move unit to region after trained
    Events
        Unit - A unit Finishes training a unit
    Conditions
        (Unit-type of (Trained unit)) Equal to Grunt
    Actions
        Set LocA = (Random point in Region A <gen>)
        Unit - Order (Trained unit) to Move To LocA
        Custom script:   call RemoveLocation(udg_LocA)
 

Progesterone

New Member
Reaction score
0
Hi all, thanks for all the help, let me summarise again what i need to do : i need the enemy barracks to start training orcs once the human player sends a unit to a particular area, then, the training will CONTINUE continuously regardless of whether the human player has any units in that area. I have created my trigger as such :

Trigger 1
Events
Unit in area = 1
Conditions
Unit belongs to Player 1 (human player)
Actions
activates trigger 2

Trigger 2 (ENABLED, INITIALLY OFF)
Events
Time - Every [...] seconds of the game
Conditions
(TotalGrunt) Less than or equal to 8
Actions
Unit - Order [Barracks] to train/upgrade [Grunt]

Trigger 3
Events
Unit - A unit Finishes training a unit
Conditions
(Unit-type of (Trained unit)) Equal to Grunt
Actions
Unit - Order (Trained unit) to Move To LocA

HOWEVER, the problem that i have is that the comupter barracks will stop training orcs when player 1 no longer has any unit in that specified area, and the training will start again when player 1 sends a unit to that area. What I want is for the training to start ONCE player 1 has a unit in that area, BUT it should continue to fire endlessly(provided that the condition of <8 orcs in area) once it is started. Please help me !! thanks !!
 

Progesterone

New Member
Reaction score
0
Help needed plz !

Hi all, let me summarise what i need to do : i need the enemy barracks to start training orcs once the human player sends a unit to a particular area, then, the training will CONTINUE continuously regardless of whether the human player has any units in that area. I have created my trigger as such :

Trigger 1
Events
Unit in area = 1
Conditions
Unit belongs to Player 1 (human player)
Actions
activates trigger 2

Trigger 2 (ENABLED, INITIALLY OFF)
Events
Time - Every [...] seconds of the game
Conditions
(TotalGrunt) Less than or equal to 8
Actions
Unit - Order [Barracks] to train/upgrade [Grunt]

Trigger 3
Events
Unit - A unit Finishes training a unit
Conditions
(Unit-type of (Trained unit)) Equal to Grunt
Actions
Unit - Order (Trained unit) to Move To LocA

HOWEVER, the problem that i have is that the comupter barracks will stop training orcs when player 1 no longer has any unit in that specified area, and the training will start again when player 1 sends a unit to that area. What I want is for the training to start ONCE player 1 has a unit in that area, BUT it should continue to fire endlessly(provided that the condition of <8 orcs in area) once it is started. Please help me !! thanks !!
 

denmax

You can change this now in User CP.
Reaction score
155
Try this, don't make it Initially Off, make the first trigger create the event for the 2nd trigger..

Adding the event is somewhere in the (Trigger -) column
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top