• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] Requesting a spawning trigger that wont Lag up my map.

Status
Not open for further replies.
Level 8
Joined
Nov 21, 2008
Messages
316
My map isnt even half way done but the spawning trigger i make lags it up every spawn.

This part just sets regions
  • Events
    • Map initialization
  • Conditions
  • Actions
    • Set SpawnRegions2[1] = Orc Spawn <gen>
    • Set SpawnRegions2[2] = Orc spawn 2 <gen>
This one is the spawn
  • Events
    • Time - Every 300.00 seconds of game time
  • Conditions
  • Actions
    • For each (Integer A) from 1 to 30, do (Actions)
      • Loop - Actions
        • Set Spawn_Point2[1] = (Random point in SpawnRegions2[(Random integer number between 1 and 2)])
        • Unit - Create 1 Grunt for Player 12 (Brown) at Spawn_Point2[1] facing Default building facing degrees
        • Unit - Order (Last created unit) to Attack (Random unit from (Units owned by (Random player from (All enemies of Player 12 (Brown)))))
        • Unit - Create 1 Grunt for Player 11 (Dark Green) at Spawn_Point2[1] facing Default building facing degrees
        • Unit - Order (Last created unit) to Attack (Random unit from (Units owned by (Random player from (All enemies of Player 12 (Brown)))))
        • Custom script: call RemoveLocation (udg_Spawn_Point2[1])
Plz give me one that doesnt make my map lag as bad as this does
 
The "Units owned by (All enemies of (Player 12 (Brown)))" is a unit group and a player group actually, so they should be variable-d.
Let's see:
  • Trigger
  • Actions
    • For each (Integer A) from 1 to 30, do (Actions)
      • Loop - Actions
        • Set Spawn_Point2[1] = (Random point in SpawnRegions2[(Random integer number between 1 and 2)])
        • Unit - Create 1 Grunt for Player 12 (Brown) at Spawn_Point2[1] facing Default building facing degrees
        • Set Players_Group = (All enemies of Player 12 (Brown))
        • Set Unit_Group = (Units owned by (Random Player from (Players_Group))
        • Unit - Order (Last created unit) to Attack (Random unit from Unit_Group)
        • Custom script: call RemoveLocation (udg_Spawn_Point2[1])
        • Custom script: call DestroyForce (udg_Players_Group)
        • Custom script: call DestroyGroup (udg_Unit_Group)
If it won't work for the second 30.00's seconds, meaning in 60.00 seconds, then it is because i should not use the custom script "call DestroyForce (udg_Players_Group)", but, since the enemies of Player 12 (Brown) are defined through the Forces, the enemies of his are still enemies, even after destroying the group. Still, notice that.
 
Level 6
Joined
Mar 20, 2008
Messages
208
Random unit from (Units owned by.....

That leaks a group. Basically that trigger is created 30 groups and then leaving them to float around in memory.
Same thing with the locations.

Pharaoh pretty much has the cleanup for ya.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
The larger problem is most likely that the game needs to load the unit types when you first create the units (ie preload the units), assuming you change the unit type every spawn. If not, it's that you're constantly reloading the unit group. Leaks are not as big of an issue—they take a lot of buildup to cause lag, and don't cause spikes. That isn't to say you shouldn't clean up your leaks, it's just to say that they wouldn't be causing spikes here.

Note that the solution provided above would not fix the lag in this case. Also note that this solution is hand-written and thus may appear slightly different than the actual GUI text.

  • Actions
    • Set TheGroup = (Units in (Playable Map Area) Matching (((Matching Unit) belongs to an enemy of Player 12 (Brown)) Equal to True))
    • For Each (Integer A) from 1 to 30, do (Actions)
      • Loop - Actions
        • Set TempPoint = (Random point in SpawnRegions2[(Random integer number between 1 and 2)])
        • Unit - Create 1 Grunt for Player 11 (Dark Green) at TempPoint facing Default building facing degrees
        • Unit - Order (Last Created Unit) to Attack (Random unit in TheGroup)
        • Unit - Create 1 Grunt for Player 12 (Brown) at TempPoint facing Default building facing degrees
        • Unit - Order (Last Created Unit) to Attack (Random unit in TheGroup)
        • Custom script: call RemoveLocation(udg_TempPoint)
    • Custom script: call DestroyGroup(udg_TheGroup)
 
Level 6
Joined
Mar 20, 2008
Messages
208
Wouldn't it just spike once though? Anyway, I guess he could pop down a grunt unit somewhere off of the map to get around that.
 
Level 8
Joined
Nov 21, 2008
Messages
316
  • Actions
    • Set TheGroup = (Units in (Playable Map Area) Matching (((Matching Unit) belongs to an enemy of Player 12 (Brown)) Equal to True))
    • For Each (Integer A) from 1 to 30, do (Actions)
      • Loop - Actions
        • Set TempPoint = (Random point in SpawnRegions2[(Random integer number between 1 and 2)])
        • Unit - Create 1 Grunt for Player 11 (Dark Green) at TempPoint facing Default building facing degrees
        • Unit - Order (Last Created Unit) to Attack (Random unit in TheGroup)
        • Unit - Create 1 Grunt for Player 12 (Brown) at TempPoint facing Default building facing degrees
        • Unit - Order (Last Created Unit) to Attack (Random unit in TheGroup)
        • Custom script: call RemoveLocation(udg_TempPoint)
    • Custom script: call DestroyGroup(udg_TheGroup)

In the part of the trigger that says
  • Set TheGroup = (Units in (Playable Map Area) Matching (((Matching Unit) belongs to an enemy of Player 12 (Brown)) Equal to True))
why is TheGroup set to belong to enemies of brown, brown and dg are the spawners and players will kill them. shouldnt it belong to enemy of one of the user players such as red.
 
Level 6
Joined
Mar 20, 2008
Messages
208
Are the spawned units suppose to stand there? If not, then that should send them out to go fight.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Wouldn't it just spike once though? Anyway, I guess he could pop down a grunt unit somewhere off of the map to get around that.
Yeah, hence why I said preloading would only be a problem if the unit type changed every round.

why is TheGroup set to belong to enemies of brown, brown and dg are the spawners and players will kill them. shouldnt it belong to enemy of one of the user players such as red.
Because that's how you had it in your trigger. Read my code again.
 
Level 8
Joined
Jun 1, 2008
Messages
341
Don't know if this helps. But i made this system the other day and I think it works pretty well. Leak free, + unless you can see the whole map you won't see any dodgy units spawning out of nowhere.

  • Creeps
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Set TempGroup = (Units owned by Player 12 (Brown) matching (((Matching unit) is alive) Equal to True))
      • Set TempGroup3 = (Units in (Playable map area) matching ((((Matching unit) is A Hero) Equal to True) and ((((Matching unit) is alive) Equal to True) and (((Owner of (Matching unit)) is an enemy of Player 12 (Brown)) Equal to True))))
      • Set TempUnit = (Random unit from TempGroup3)
      • Set TempPoint2 = (Position of TempUnit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in TempGroup) Less than 15
        • Then - Actions
          • Set TempPoint = (Random point in (Playable map area))
          • Set TempGroup2 = (Units in (Region centered at TempPoint with size (1800.00, 1800.00)) matching ((Owner of (Matching unit)) Not equal to Player 12 (Brown)))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • (Number of units in TempGroup2) Equal to 0
                  • (Terrain pathing at TempPoint of type Walkability is off) Equal to False
            • Then - Actions
              • Set TempInteger = (Random integer number between 1 and 8)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • TempInteger Greater than 7
                • Then - Actions
                  • Unit - Create 1 Gnoll Overseer for Player 12 (Brown) at TempPoint facing Default building facing degrees
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • TempInteger Greater than 5
                    • Then - Actions
                      • Unit - Create 1 Gnoll Brute for Player 12 (Brown) at TempPoint facing Default building facing degrees
                    • Else - Actions
                      • Unit - Create 1 Gnoll for Player 12 (Brown) at TempPoint facing Default building facing degrees
            • Else - Actions
              • Trigger - Run (This trigger) (checking conditions)
        • Else - Actions
      • Unit Group - Pick every unit in TempGroup and do (Actions)
        • Loop - Actions
          • Set TempUnit = (Random unit from TempGroup3)
          • Set TempPoint2 = (Position of TempUnit)
          • Unit - Order (Picked unit) to Attack-Move To TempPoint2
Quick Guide

[-] Basicaly it will spawn creeps at least 1800 (warcraft Distance Units) away from all units every 5 seconds providing the number of creeps has not gone over a limit.
[-] Therefore as the maximum sight range of units is 1800 they 'should' never see units spawn.
[-] Also there are three different types of creeps spawning in this system, that can easily be changed by adding more if statements that follow the same structure as those provided by me.
[-] If it suits your needs you can however just remove the if statements
  • Set TempInteger = (Random integer number between 1 and 8)
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • TempInteger Greater than 7
    • Then - Actions
      • Unit - Create 1 Gnoll Overseer for Player 12 (Brown) at TempPoint facing Default building facing degrees
    • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TempInteger Greater than 5
        • Then - Actions
          • Unit - Create 1 Gnoll Brute for Player 12 (Brown) at TempPoint facing Default building facing degrees
        • Else - Actions
          • Unit - Create 1 Gnoll for Player 12 (Brown) at TempPoint facing Default building facing degrees
and spawn random units by inserting the lines
  • Set TempInteger = (Random integer number between 1 and 10)
  • Unit - Create 1 (Random level TempInteger creep unit-type) for Player 12 (Brown) at TempPoint facing Default building facing degrees
[-] It is best to consider using an empty player spot than Neutral Hostile as Neutral Hostile will not follow move order fully before the AI kicks in.
[-] Finaly... If you want to change the rate. (I know.. Its obvious) change teh event line.
P.S if you do use it, i'm not demanding credits as i recon someone has already made a very similar system as its so simple. However i'm not saying credits will be unappreciated. xD

Hope this helped :)

Below is the Map demonstrating this method..
 

Attachments

  • Spells Test Map.w3x
    136 KB · Views: 26
Last edited:
Status
Not open for further replies.
Top