I've been looking at trying to learn how to remove leaks. I decided to start with unit groups, I don't think that's gone too bad. But then I saw things like location leaks and player group leaks. And there are loads of different variables needed? I'm confused. The main trigger I want shown to me is posted below (it's an AI system I made for my map).
-
AI Train
-
Events
- Time - Every 15.00 seconds of game time
- Conditions
-
Actions
-
Player Group - Pick every player in (All players controlled by a Computer player) and do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
Or - Any (Conditions) are true
-
Conditions
- ((Number of units in (Units owned by (Picked player) of type Plantation)) x 15) Greater than or equal to ((Picked player) Food used)
- ((Picked player) Current lumber) Greater than or equal to (((Picked player) Food used) - 1)
-
Conditions
-
Or - Any (Conditions) are true
-
Then - Actions
- -------- Train Monk --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ((Picked player) Current gold) Greater than or equal to 300
- ((Picked player) Food used) Less than ((Picked player) Food cap)
- ((Picked player) Food used) Greater than or equal to ((Number of units in (Units owned by (Picked player) of type Monk)) x 10)
-
Then - Actions
- Unit - Order (Random unit from (Units owned by (Picked player) of type Church)) to train/upgrade to a Monk
- Else - Actions
-
If - Conditions
- -------- Train Balista, Catapult or Cannon --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Number of units in (Units owned by (Picked player) matching (((Unit-type of (Matching unit)) Equal to Ballista) or (((Unit-type of (Matching unit)) Equal to Catapult) or ((Unit-type of (Matching unit)) Equal to Cannon))))) Less than or equal to (Integer(((Real(((Picked player) Food cap))) x 0.05)))
-
Then - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ((Picked player) Current gold) Greater than or equal to 800
- (Number of units in (Units owned by (Picked player) of type Mine)) Greater than or equal to 3
- (Current research level of Chemistry for (Picked player)) Equal to 0
- (Current research level of Age 2 for (Picked player)) Greater than or equal to 2
- (Random integer number between 1 and 2) Equal to 1
- ((Picked player) Food used) Less than ((Picked player) Food cap)
-
Then - Actions
- Unit - Order (Random unit from (Units owned by (Picked player) of type Workshop)) to train/upgrade to a Ballista
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ((Picked player) Current gold) Greater than or equal to 760
- (Number of units in (Units owned by (Picked player) of type Mine)) Greater than or equal to 3
- (Current research level of Chemistry for (Picked player)) Equal to 0
- (Current research level of Age 2 for (Picked player)) Greater than or equal to 2
- ((Picked player) Food used) Less than ((Picked player) Food cap)
-
Then - Actions
- Unit - Order (Random unit from (Units owned by (Picked player) of type Workshop)) to train/upgrade to a Catapult
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ((Picked player) Current gold) Greater than or equal to 1160
- (Number of units in (Units owned by (Picked player) of type Mine)) Greater than or equal to 5
- (Current research level of Chemistry for (Picked player)) Equal to 1
- (Current research level of Age 2 for (Picked player)) Equal to 3
- ((Picked player) Food used) Less than ((Picked player) Food cap)
-
Then - Actions
- Unit - Order (Random unit from (Units owned by (Picked player) of type Workshop)) to train/upgrade to a Cannon
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Else - Actions
-
If - Conditions
- -------- Train Light Cavalry, Mounted Skirmisher, Heavy Cavalry or Paladin. --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Number of units in (Units owned by (Picked player) matching (((Unit-type of (Matching unit)) Equal to Light Cavalry) or (((Unit-type of (Matching unit)) Equal to Mounted Skirmisher) or (((Unit-type of (Matching unit)) Equal to Heavy Cavalry) or ((Unit-type o Less than or equal to (Integer(((Real(((Picked player) Food cap))) x 0.10)))
-
Then - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ((Picked player) Current gold) Greater than or equal to 275
- (Number of units in (Units owned by (Picked player) of type Mine)) Greater than or equal to 2
- (Current research level of Age 2 for (Picked player)) Less than or equal to 1
- (Random integer number between 1 and 2) Equal to 1
- ((Picked player) Food used) Less than ((Picked player) Food cap)
-
Then - Actions
- Unit - Order (Random unit from (Units owned by (Picked player) of type Stables)) to train/upgrade to a Light Cavalry
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ((Picked player) Current gold) Greater than or equal to 280
- (Number of units in (Units owned by (Picked player) of type Mine)) Greater than or equal to 2
- (Current research level of Age 2 for (Picked player)) Less than or equal to 1
- ((Picked player) Food used) Less than ((Picked player) Food cap)
-
Then - Actions
- Unit - Order (Random unit from (Units owned by (Picked player) of type Stables)) to train/upgrade to a Mounted Skirmisher
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ((Picked player) Current gold) Greater than or equal to 340
- (Number of units in (Units owned by (Picked player) of type Mine)) Greater than or equal to 3
- (Current research level of Age 2 for (Picked player)) Greater than or equal to 3
- (Current research level of Squires for (Picked player)) Not equal to 1
- ((Picked player) Food used) Less than ((Picked player) Food cap)
-
Then - Actions
- Unit - Order (Random unit from (Units owned by (Picked player) of type Stables)) to train/upgrade to a Heavy Cavalry
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ((Picked player) Current gold) Greater than or equal to 450
- (Number of units in (Units owned by (Picked player) of type Mine)) Greater than or equal to 4
- (Current research level of Age 2 for (Picked player)) Greater than or equal to 3
- (Current research level of Squires for (Picked player)) Equal to 1
- ((Picked player) Food used) Less than ((Picked player) Food cap)
-
Then - Actions
- Unit - Order (Random unit from (Units owned by (Picked player) of type Stables)) to train/upgrade to a Paladin
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Else - Actions
-
If - Conditions
- -------- Train Archer, Skirmisher or Crossbowman --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Number of units in (Units owned by (Picked player) matching (((Unit-type of (Matching unit)) Equal to Archer) or (((Unit-type of (Matching unit)) Equal to Skirmisher) or ((Unit-type of (Matching unit)) Equal to Crossbowman))))) Less than or equal to (Integer(((Real(((Picked player) Food cap))) x 0.15)))
-
Then - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ((Picked player) Current gold) Greater than or equal to 270
- (Number of units in (Units owned by (Picked player) of type Mine)) Greater than or equal to 2
- (Current research level of Age 2 for (Picked player)) Equal to 1
- ((Picked player) Food used) Less than ((Picked player) Food cap)
-
Then - Actions
- Unit - Order (Random unit from (Units owned by (Picked player) of type Archery)) to train/upgrade to a Archer
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ((Picked player) Current gold) Greater than or equal to 270
- (Number of units in (Units owned by (Picked player) of type Mine)) Greater than or equal to 2
- (Current research level of Age 2 for (Picked player)) Equal to 1
- ((Picked player) Food used) Less than ((Picked player) Food cap)
-
Then - Actions
- Unit - Order (Random unit from (Units owned by (Picked player) of type Archery)) to train/upgrade to a Skirmisher
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ((Picked player) Current gold) Greater than or equal to 255
- (Number of units in (Units owned by (Picked player) of type Mine)) Greater than or equal to 4
- (Current research level of Age 2 for (Picked player)) Equal to 2
- ((Picked player) Food used) Less than ((Picked player) Food cap)
-
Then - Actions
- Unit - Order (Random unit from (Units owned by (Picked player) of type Archery)) to train/upgrade to a Crossbowman
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ((Picked player) Current gold) Greater than or equal to 320
- (Number of units in (Units owned by (Picked player) of type Mine)) Greater than or equal to 4
- (Current research level of Age 2 for (Picked player)) Greater than or equal to 3
- (Current research level of Fire Arrows for (Picked player)) Equal to 0
- ((Picked player) Food used) Less than ((Picked player) Food cap)
-
Then - Actions
- Unit - Order (Random unit from (Units owned by (Picked player) of type Archery)) to train/upgrade to a Crossbowman
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ((Picked player) Current gold) Greater than or equal to 320
- (Number of units in (Units owned by (Picked player) of type Mine)) Greater than or equal to 4
- (Current research level of Age 2 for (Picked player)) Greater than or equal to 3
- (Current research level of Fire Arrows for (Picked player)) Equal to 1
- (Random integer number between 1 and 2) Equal to 1
- ((Picked player) Food used) Less than ((Picked player) Food cap)
-
Then - Actions
- Unit - Order (Random unit from (Units owned by (Picked player) of type Archery)) to train/upgrade to a Crossbowman
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ((Picked player) Current gold) Greater than or equal to 270
- (Current research level of Age 2 for (Picked player)) Greater than or equal to 3
- (Current research level of Fire Arrows for (Picked player)) Equal to 1
- ((Picked player) Food used) Less than ((Picked player) Food cap)
-
Then - Actions
- Unit - Order (Random unit from (Units owned by (Picked player) of type Archery)) to train/upgrade to a Archer
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Else - Actions
-
If - Conditions
- -------- Train Man-at-Arms, Footman, Spearman, Swordsman or Templar --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Number of units in (Units owned by (Picked player) matching (((Unit-type of (Matching unit)) Equal to Man-at-Arms) or (((Unit-type of (Matching unit)) Equal to Footman) or (((Unit-type of (Matching unit)) Equal to Pikeman) or (((Unit-type of (Matching unit)) Less than or equal to (Integer(((Real(((Picked player) Food cap))) x 0.60)))
-
Then - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ((Picked player) Current gold) Greater than or equal to 120
- (Current research level of Age 2 for (Picked player)) Equal to 0
- ((Picked player) Food used) Less than or equal to ((Picked player) Food cap)
-
Then - Actions
- Unit - Order (Random unit from (Units owned by (Picked player) of type Barracks)) to train/upgrade to a Man-at-Arms
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ((Picked player) Current gold) Greater than or equal to 230
- ((Picked player) Current gold) Less than 280
- (Number of units in (Units owned by (Picked player) of type Mine)) Greater than or equal to 2
- (Current research level of Age 2 for (Picked player)) Equal to 1
- ((Picked player) Food used) Less than ((Picked player) Food cap)
-
Then - Actions
- Unit - Order (Random unit from (Units owned by (Picked player) of type Barracks)) to train/upgrade to a Footman
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ((Picked player) Current gold) Greater than or equal to 280
- (Number of units in (Units owned by (Picked player) of type Mine)) Greater than or equal to 2
- (Current research level of Age 2 for (Picked player)) Equal to 1
- ((Picked player) Food used) Less than ((Picked player) Food cap)
-
Then - Actions
- Unit - Order (Random unit from (Units owned by (Picked player) of type Barracks)) to train/upgrade to a Footman
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ((Picked player) Current gold) Greater than or equal to 300
- (Number of units in (Units owned by (Picked player) of type Mine)) Greater than or equal to 3
- (Current research level of Age 2 for (Picked player)) Greater than or equal to 2
- (Current research level of Arenas for (Picked player)) Equal to 0
- ((Picked player) Food used) Less than ((Picked player) Food cap)
-
Then - Actions
- Unit - Order (Random unit from (Units owned by (Picked player) of type Barracks)) to train/upgrade to a Swordsman
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ((Picked player) Current gold) Greater than or equal to 420
- (Number of units in (Units owned by (Picked player) of type Mine)) Greater than or equal to 4
- (Current research level of Age 2 for (Picked player)) Equal to 3
- (Current research level of Arenas for (Picked player)) Equal to 1
- ((Picked player) Food used) Less than ((Picked player) Food cap)
-
Then - Actions
- Unit - Order (Random unit from (Units owned by (Picked player) of type Barracks)) to train/upgrade to a Templar
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Else - Actions
-
If - Conditions
- Else - Actions
-
If - Conditions
- -------- Train Villager or Peasant --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ((Picked player) Current gold) Greater than or equal to 40
- ((Picked player) Food cap) Greater than or equal to ((Number of units in (Units owned by (Picked player) of type Villager)) x 50)
-
Then - Actions
- Unit - Order (Random unit from (Units owned by (Picked player) of type Town Center)) to train/upgrade to a Villager
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ((Picked player) Current gold) Greater than or equal to 65
- ((Picked player) Food cap) Greater than or equal to ((Number of units in (Units owned by (Picked player) of type Peasant)) x 50)
-
Then - Actions
- Unit - Order (Random unit from (Units owned by (Picked player) of type Town Center)) to train/upgrade to a Peasant
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
-
Player Group - Pick every player in (All players controlled by a Computer player) and do (Actions)
-
Events