Reducing Unit Lag with multiple players. Need Help!

Level 7
Joined
Sep 10, 2023
Messages
112
Ive tried making a trigger for to reduce unit lag.

For context this is what I have:

I have 4 tiers of units (t1, t2, t3 and t4)
I have 2 undead players (both control 4 more computer players)

I have these triggers:

  • Map Ini Zombie Interget Variables
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set VariableSet ZombieTotal = 0
      • Set VariableSet ZombieLimit = 300

  • CREATION DG T1
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • (Unit-type of (Trained unit)) Equal to Zombie (T1)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ZombieP1T1 Less than 40
        • Then - Actions
          • Set VariableSet ZombieP1T1 = (ZombieP1T1 + 1)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ZombieP2T1 Less than 40
            • Then - Actions
              • Set VariableSet ZombieP2T1 = (ZombieP2T1 + 1)
              • Unit - Change ownership of (Trained unit) to Player 17 (Wheat) and Retain color
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ZombieP3T1 Less than 40
                • Then - Actions
                  • Set VariableSet ZombieP3T1 = (ZombieP3T1 + 1)
                  • Unit - Change ownership of (Trained unit) to Player 18 (Peach) and Retain color
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ZombieP4T1 Less than 40
                    • Then - Actions
                      • Set VariableSet ZombieP4T1 = (ZombieP4T1 + 1)
                      • Unit - Change ownership of (Trained unit) to Player 19 (Mint) and Retain color
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • ZombieP5T1 Less than 40
                        • Then - Actions
                          • Set VariableSet ZombieP5T1 = (ZombieP5T1 + 1)
                          • Unit - Change ownership of (Trained unit) to Player 20 (Lavender) and Retain color
                        • Else - Actions
                          • Unit - Kill (Trained unit)

  • [SPOILER="Players lose a unit and reduce count"]
  • Decrease DG T1
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Zombie (T1)
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 11 (Dark Green)
        • Then - Actions
          • Set VariableSet ZombieP1T1 = (ZombieP1T1 - 1)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Triggering unit)) Equal to Player 17 (Wheat)
            • Then - Actions
              • Set VariableSet ZombieP2T1 = (ZombieP2T1 - 1)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Owner of (Triggering unit)) Equal to Player 18 (Peach)
                • Then - Actions
                  • Set VariableSet ZombieP3T1 = (ZombieP3T1 - 1)
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Owner of (Triggering unit)) Equal to Player 19 (Mint)
                    • Then - Actions
                      • Set VariableSet ZombieP4T1 = (ZombieP4T1 - 1)
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Owner of (Triggering unit)) Equal to Player 20 (Lavender)
                        • Then - Actions
                          • Set VariableSet ZombieP5T1 = (ZombieP5T1 - 1)
                        • Else - Actions
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • ZombieP1T1 Less than 0
                            • Then - Actions
                              • Set VariableSet ZombieP1T1 = 0
                            • Else - Actions
                              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                • If - Conditions
                                  • ZombieP2T1 Less than 0
                                • Then - Actions
                                  • Set VariableSet ZombieP2T1 = 0
                                • Else - Actions
                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    • If - Conditions
                                      • ZombieP3T1 Less than 0
                                    • Then - Actions
                                      • Set VariableSet ZombieP3T1 = 0
                                    • Else - Actions
                                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                        • If - Conditions
                                          • ZombieP4T1 Less than 0
                                        • Then - Actions
                                          • Set VariableSet ZombieP4T1 = 0
                                        • Else - Actions
                                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                            • If - Conditions
                                              • ZombieP5T1 Less than 0
                                            • Then - Actions
                                              • Set VariableSet ZombieP5T1 = 0
                                            • Else - Actions
  • [/SPOILER]
  • Increase Zombie Count
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Trained unit)) Equal to Zombie (T1)
          • Or - Any (Conditions) are true
            • Conditions
              • (Unit-type of (Trained unit)) Equal to Ravenous Zombie (T2)
              • Or - Any (Conditions) are true
                • Conditions
                  • (Unit-type of (Trained unit)) Equal to Mutated Zombie (T3)
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Unit-type of (Trained unit)) Equal to Ghoul (T4)
    • Actions
      • Set VariableSet ZombieTotal = (ZombieTotal + 1)


  • Decrease Zombie Count
    • Events
      • Unit - A unit Dies
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Trained unit)) Equal to Zombie (T1)
          • Or - Any (Conditions) are true
            • Conditions
              • (Unit-type of (Trained unit)) Equal to Ravenous Zombie (T2)
              • Or - Any (Conditions) are true
                • Conditions
                  • (Unit-type of (Trained unit)) Equal to Mutated Zombie (T3)
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Unit-type of (Trained unit)) Equal to Ghoul (T4)
    • Actions
      • Set VariableSet ZombieTotal = (ZombieTotal - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ZombieTotal Equal to (ZombieTotal - 1)
        • Then - Actions
          • Player - Make Zombie (T1) Available for training/construction by Player 11 (Dark Green)
          • Player - Make Zombie (T1) Available for training/construction by Player 12 (Brown)
        • Else - Actions


  • Enable Zombies
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
      • ZombieTotal Less than ZombieLimit
    • Actions
      • Player - Make Zombie (T1) Available for training/construction by Player 11 (Dark Green)
      • Player - Make Zombie (T1) Available for training/construction by Player 12 (Brown)

  • Disable Zombies
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
      • ZombieTotal Greater than or equal to ZombieLimit
    • Actions
      • Player - Make Zombie (T1) Unavailable for training/construction by Player 11 (Dark Green)
      • Player - Make Zombie (T1) Unavailable for training/construction by Player 12 (Brown)

Ive tried to make it work, It seems to work fine but when I reach 300 units I cant make more units, even when I kill all the units.
 
You're not using "Or" correctly. It should look like this:
  • Increase Zombie Count
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Trained unit)) Equal to Zombie (T1)
          • (Unit-type of (Trained unit)) Equal to Ravenous Zombie (T2)
          • (Unit-type of (Trained unit)) Equal to Mutated Zombie (T3)
          • (Unit-type of (Trained unit)) Equal to Ghoul (T4)
Conditions all need to be true by default. By using "Or - Any (Conditions) are true" you change the behavior to "As long as one of these Conditions is true".

But I recommend using Abilities as custom "classifications" instead of these more complex checks:
  • Conditions
    • (Level of I AM A ZOMBIE for (Trained unit)) Greater than 0
Side note, Arrays would be useful for tracking these ZombieP1T1 integer variables.
 
Last edited:
Back
Top