• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Smooth spawning

Status
Not open for further replies.
Greeting everyone

I have more or less 30 tipes of animals in my map but I have trouble spawning them without a lag.
  • Natural spawn Copy
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • bNaturalSwitch Equal to True
        • Then - Actions
          • For each (Integer Temp_Int) from 1 to 13, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in (Units of type uNatural[Temp_Int])) Less than 11
                • Then - Actions
                  • Set Temp_Point = (pCenter offset by (Random real number between 700.00 and 7000.00) towards (Random real number between 0.00 and 360.00) degrees)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Distance between Temp_Point and pRoshan) Greater than or equal to 600.00
                      • (Terrain pathing at Temp_Point of type Walkability is off) Equal to False
                    • Then - Actions
                      • Unit - Create 1 uNatural[Temp_Int] for Neutral Passive at Temp_Point facing (Random real number between 0.00 and 360.00) degrees
                    • Else - Actions
                  • Custom script: call RemoveLocation(udg_Temp_Point)
                • Else - Actions
          • Set bNaturalSwitch = False
        • Else - Actions
          • For each (Integer Temp_Int) from 14 to 27, do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in (Units of type uNatural[Temp_Int])) Less than 3
                • Then - Actions
                  • Set Temp_Point = (pCenter offset by (Random real number between 700.00 and 7000.00) towards (Random real number between 0.00 and 360.00) degrees)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Distance between Temp_Point and pRoshan) Greater than or equal to 600.00
                      • (Terrain pathing at Temp_Point of type Walkability is off) Equal to False
                    • Then - Actions
                      • Unit - Create 1 uNatural[Temp_Int] for Neutral Passive at Temp_Point facing (Random real number between 0.00 and 360.00) degrees
                    • Else - Actions
                  • Custom script: call RemoveLocation(udg_Temp_Point)
                • Else - Actions
          • Set bNaturalSwitch = True
As you can see, I used a switch to separate the the preditors from the herbifores and also reduces lag in this process. I've also preloded the models in the ini. The lag is extremely small on my computer but is visible if you know it's there. However it might be a problem on computers with less preformance than mine.

Help will be appreciated.
 
You can create a unitgroup from default of all neutral unit, and always add/remove from this group.
Or yes, you could also create alway a temporary Unitgroup and destroy it afterwerds.

Also once the condition "(Number of units in (Units of type uNatural[Temp_Int])) Less than 11" doesnt match --> you can set Temp_Int = LoopLimit +1, so it doesnt do more check in this loop.
 
Status
Not open for further replies.
Top