Progesterone
New Member
- Reaction score
- 0
Dear all,
I need to create a trigger for a computer player which will ask his Barracks to IMMEDIATELY train a particular unit (knight), and MOVE that unit to a particular region (Region X) WHENEVER there are less than 2 of that unit(knights) in Region X; AND most importantly STOP the training when there are 2 or more knights in Region X. (ie, my goal is that I do not want more than 3 knights in Region X at any one time)
1)Trigger A
Event
Time - Every 3.00 seconds of game time
Condition
(Number of units in (Units in RegionX <gen> matching ((Unit-type of (Matching unit)) Equal to Knight))) Less than 2
Action
Unit - Order Barracks 0108 <gen> to train/upgrade to a Knight
3)Trigger B
Event
Unit - Barracks 0108 <gen> Finishes training a unit
Condition
(Unit-type of (Trained unit)) Equal to Knight
Action
Unit - Order (Trained unit) to Attack-Move To (Center of RegionX <gen>)
The problem I have: even though there were already more than TWO knights in Region X, the barracks KEPT ON TRAINING MORE KNIGHTS.
The reason for this, which I understood, was due to the BUILD ORDER phenomenon: ie, it takes time for the training of the knight to be completed and the knight to reach Region X; during this period, my trigger as above will cause the Barracks to ADD A KNIGHT IN THE BUILD ORDER every 3 seconds, and therefore, even though eventually my trained knights reached Region X and now the condition(that there are less than 2 knights in Region X) is not "true" anymore, the Barracks will just keep on training as there are still knights left in the Build Order.
I have tried increasing the "every x seconds" in Trigger A, but the effect is very inconsistent.
Can someone help me to overcome this problem to accomplish my goal as stated above?
Thanks a lot !
I need to create a trigger for a computer player which will ask his Barracks to IMMEDIATELY train a particular unit (knight), and MOVE that unit to a particular region (Region X) WHENEVER there are less than 2 of that unit(knights) in Region X; AND most importantly STOP the training when there are 2 or more knights in Region X. (ie, my goal is that I do not want more than 3 knights in Region X at any one time)
1)Trigger A
Event
Time - Every 3.00 seconds of game time
Condition
(Number of units in (Units in RegionX <gen> matching ((Unit-type of (Matching unit)) Equal to Knight))) Less than 2
Action
Unit - Order Barracks 0108 <gen> to train/upgrade to a Knight
3)Trigger B
Event
Unit - Barracks 0108 <gen> Finishes training a unit
Condition
(Unit-type of (Trained unit)) Equal to Knight
Action
Unit - Order (Trained unit) to Attack-Move To (Center of RegionX <gen>)
The problem I have: even though there were already more than TWO knights in Region X, the barracks KEPT ON TRAINING MORE KNIGHTS.
The reason for this, which I understood, was due to the BUILD ORDER phenomenon: ie, it takes time for the training of the knight to be completed and the knight to reach Region X; during this period, my trigger as above will cause the Barracks to ADD A KNIGHT IN THE BUILD ORDER every 3 seconds, and therefore, even though eventually my trained knights reached Region X and now the condition(that there are less than 2 knights in Region X) is not "true" anymore, the Barracks will just keep on training as there are still knights left in the Build Order.
I have tried increasing the "every x seconds" in Trigger A, but the effect is very inconsistent.
Can someone help me to overcome this problem to accomplish my goal as stated above?
Thanks a lot !