Ok, so i deleted my original post, i am now editing because i was really tired when i made it. I fixed the problems now and cleaned it up, it now works but causes extreme delay after around 10 minutes.
What this trigger does is check every .15 seconds to make sure that each base (a base is a county and a CoP, with a tower) has a defender in its CoP. It loops through by baseDefender Unit group and if it is the only available defender owned by the owner of the base then the current defender will be moved to the center of the circle. If there is other units within range of the circle owned by the owner of the base it will change the defender to one of those units.
TLDR version: this trigger keeps a bases defender in its CoP.
Why does this trigger cause huge delay after about 10 minutes?
edited to fix the trigger.
What this trigger does is check every .15 seconds to make sure that each base (a base is a county and a CoP, with a tower) has a defender in its CoP. It loops through by baseDefender Unit group and if it is the only available defender owned by the owner of the base then the current defender will be moved to the center of the circle. If there is other units within range of the circle owned by the owner of the base it will change the defender to one of those units.
TLDR version: this trigger keeps a bases defender in its CoP.
-
Change Defender Range
-
Events
- Time - Every 0.15 seconds of game time
- Conditions
-
Actions
-
Unit Group - Pick every unit in baseDefenders and do (Actions)
-
Loop - Actions
- Set tempUnit1 = (Picked unit)
- Set tempPoint1 = (Position of tempUnit1)
- Set tempGroup1 = (Units within 300.00 of tempPoint1 matching ((Unit-type of (Matching unit)) Equal to Tower))
- Set tempUnit2 = (Random unit from tempGroup1)
- Set tempPoint2 = (Position of tempUnit2)
- Set tempPlayer1 = (Owner of tempUnit1)
- Set tempGroup2 = (Units within 175.00 of tempPoint2 matching ((((Matching unit) is A structure) Equal to False) and (((Owner of (Matching unit)) Equal to tempPlayer1) and ((Matching unit) Not equal to tempUnit1))))
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Distance between tempPoint1 and tempPoint2) Greater than or equal to 175.00
- (Number of units in tempGroup2) Equal to 0
-
Then - Actions
- -------- Move the defender back to the center of the CoP for his base, if he is the only unit around. --------
- Unit - Move tempUnit1 instantly to tempPoint2
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Distance between tempPoint1 and tempPoint2) Greater than or equal to 175.00
- (Number of units in tempGroup2) Greater than or equal to 1
-
Then - Actions
- -------- This will switch the defender is there is another in the range. --------
- Unit Group - Remove tempUnit1 from baseDefenders
- Set tempUnit3 = (Random unit from tempGroup2)
- Unit Group - Add tempUnit3 to baseDefenders
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- Custom script: set udg_tempUnit1 = null
- Custom script: set udg_tempUnit2 = null
- Custom script: set udg_tempUnit3 = null
- Custom script: set udg_tempPlayer1 = null
- Custom script: call DestroyGroup( udg_tempGroup1 )
- Custom script: set udg_tempGroup1 = null
- Custom script: call DestroyGroup( udg_tempGroup2 )
- Custom script: set udg_tempGroup2 = null
- Custom script: call RemoveLocation( udg_tempPoint1 )
- Custom script: set udg_tempPoint1 = null
- Custom script: call RemoveLocation( udg_tempPoint2 )
- Custom script: set udg_tempPoint2 = null
-
Loop - Actions
-
Unit Group - Pick every unit in baseDefenders and do (Actions)
-
Events
Why does this trigger cause huge delay after about 10 minutes?
edited to fix the trigger.
Last edited: