Progesterone
New Member
- Reaction score
- 0
Trigger:
- Barracks Defense
- Events
- Time - Every 3.00 seconds of game time
- Conditions
- Actions
- For each (Integer A) from 1 to 3, do (Actions)
- Loop - Actions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- NumberOfKnights[(Integer A)] Less than or equal to 1
- Then - Actions
- Unit - Order Barracks[(Integer A)] to train/upgrade to a Knight
- Set NumberOfKnights[(Integer A)] = (NumberOfKnights[(Integer A)] + 1)
- Else - Actions
- Barracks Defense Assign
- Events
- Unit - A unit Finishes training a unit
- Conditions
- (Unit-type of (Trained unit)) Equal to Knight
- Actions
- Unit - Set the custom value of (Trained unit) to (Custom value of (Triggering unit))
- Unit - Order (Trained unit) to Attack-Move To (Center of RegionToDefend[(Custom Value of (Triggering Unit))])
- -------- The Triggering Unit is the Barracks, as far as I can tell. --------
- Barracks Defense Reduce
- Events
- Unit - A unit owned by Player 5 (Yellow) Dies
- Conditions
- (Unit-type of (Triggering unit)) Equal to Knight
- Actions
- Set NumberOfKnights[(Custom value of (Triggering unit))] = ((Custom value of (Triggering unit)) - 1)
At the start assign each of your barracks a custom value to be used as the index for Arrays. Assign all the regions the same way. The first trigger is the one that begins training, then increases the number of Knights currently existing (regardless of whether it is trained or not). The second one assigns all Knights the custom value of their Barracks, which tells you which Barracks should train another Knight when one dies. The last trigger will reduce the number of Knights of one Barracks currently existing when one Knight dies. This will allow the first trigger to make that Barracks train a new knight. I hope this helped - it used up all 24.2% of my laptop's remaining power.
Hi Kaerf, I have tried your trigger, but it was unable to work as I could not figure out how to "set my newly created variable 'Barracks 1' to be that particular Barracks" (ie, I just created the variables and named them, select type as unit, and click Array, then put '3', but how does the editor recognise that Barracks 1 is one particular barracks ?)
Please help ! Thanks !