System Lag-free line-spawning system

LightChaosma

New Member
Reaction score
60
features of this system:
- only spawns creeps at active players
- each player gets thier creeps at the same time
- adds recources to active players at end of a wave.
- units wont get stuck
- lag free
- leak free
- easy to use
- extra features to make it look nice (optional)
- requires only GUI, no fancy world editor

for this system to work, you will need a few variables
- spawnint > an integer array size 2
- playeractive > an integer array size (amount of defenders)
- wave > integer with start value 0
- angle > real array size (ammount of defenders)
- wave_type > unit-type array with size (amount of waves)
- next_wave > timer
- living > real
- Temp_UnitG > tempory unit group (leak prevention)
- custom > integer array with size ( amount of defenders) (extra feature only)
- Temp_point > point array for leak prevention
- spawn_region > region array size (number of defenders)

extra features:
- all creeps will explode on death (choose a nice animation in the object editor under art - special)
- creeps are collored to the color of the player they "attack" (enable allow custom team color in object editor)
- set the custom value of the spwaned units (for eventual route issues)


this trigger will detect if a player is active or not: (map init)
Code:
active player
    Events
        Map initialization
    Conditions
    Actions
        For each (Integer A) from 1 to 8, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        ((Player((Integer A))) slot status) Equal to Is playing
                    Then - Actions
                        Set player_active[(Integer A)] = 1
                    Else - Actions
                        Set player_active[(Integer A)] = 0
        Trigger - Turn off (This trigger)

the floowing trigger will define your what creeps will spawn, creep 1 is the creep that will be spaned at level 1, creep 2 at level 2, etc.
Code:
    Events
        Map initialization
    Conditions
    Actions
        Set Wave_type[1] = creep 1
        Set Wave_type[2] = creep 2
        Set Wave_type[3] = creep 3
        Set Wave_type[4] = creep 4
        Set Wave_type[5] = creep 5
        Set Wave_type[6] = creep 6
        ---go on like this---
        Trigger - Turn off (This trigger)

this is the trigger to spawn the units: (the underlined parts are the extra features:

Code:
wave
    Events
        Time - Next_wave expires
    Conditions
    Actions
        Set wave = (wave + 1)
        Game - Display to (All players) the text: (Wave  + (String(wave)))
 [U]       Set costum[1] = 1
        Set costum[2] = 1
        Set costum[3] = 2
        Set costum[4] = 2
        Set costum[5] = 3
        Set costum[6] = 3
        Set costum[7] = 4
        Set costum[8] = 4[/U]
        Set angle[1] = 0.00
        Set angle[2] = 180.00
        Set angle[3] = 270.00
        Set angle[4] = 90.00
        Set angle[5] = 180.00
        Set angle[6] = 0.00
        Set angle[7] = 90.00
        Set angle[8] = 270.00
        For each (Integer spawn_int[1]) from 1 to <amount of creeps>, do (Actions)
            Loop - Actions
                Wait <time between units> game-time seconds
                For each (Integer spawn_int[2]) from 1 to <amount of players here>, do (Actions)
                    Loop - Actions
                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            If - Conditions
                                player_active[spawn_int[2]] Equal to 1
                            Then - Actions
                                Set temp_point[1] = (Center of spawn_region[spawn_int[2]])
                                Unit - Create 1 Wave_type[wave] for <owner of creeps (player 12 for instance)> at temp_point[1] facing angle[spawn_int[2]] degrees
                                Custom script:   call RemoveLocation(udg_temp_point[1])
                                Set temp_unitG[1] = (Units in spawn_region[spawn_int[2]] owned by Player 9 (Gray))
                                Unit Group - Pick every unit in temp_unitG[1] and do (Actions)
                                    Loop - Actions
                 [U]                       Unit - Set the custom value of (Picked unit) to costum[spawn_int[2]][/U]
                                        Unit - Turn collision for (Picked unit) Off
 [U]                                       Unit - Change color of (Picked unit) to (Color of (Player(spawn_int[2])))[/U]                                        Unit - [U]Make (Picked unit) Explode on death[/U]
                                       
                                Custom script:   call DestroyGroup (udg_temp_unitG[1])
                            Else - Actions


in that example i had 8 players.
now, all we need to do now is detect when the next wave begins.

we use the following triggers, they are pretty straight forward, and need no further explenation:
Code:
start timer
    Events
        Game - living becomes Equal to 0.00
    Conditions
    Actions
        Countdown Timer - Start Next_wave as a One-shot timer that will expire in 20.00 seconds
        For each (Integer A) from 1 to 8, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        player_active[(Integer A)] Equal to 1
                    Then - Actions
                        Player - Add (wave x 100) to (Player((Integer A))) Current gold
                        Player - Add 1 to (Player((Integer A))) Current lumber
                    Else - Actions
        Game - Display to (All players) the text: (You have completed wave  + ((String(wave)) + ( so you get  + (|cff00aa001|r  + ( lumber and  + (((|cffffff00 + (String((100 x wave)))) + |r ) + gold !!))))))

Code:
count living units
    Events
        Unit - A unit Dies
    Conditions
        (Owner of (Dying unit)) Equal to <creep owner>
    Actions
        Set temp_unitG[1] = (Units owned by <creep owner> matching (((Matching unit) is alive) Equal to True))
        Set living = (Real((Number of units in temp_unitG[1])))
        Custom script:   call DestroyGroup (udg_temp_unitG[1])

all that is left is to make a start window:

Code:
next wave timer
    Events
        Time - Elapsed game time is 20.00 seconds
    Conditions
    Actions
        Countdown Timer - Start Next_wave as a One-shot timer that will expire in 60.00 seconds
        Countdown Timer - Create a timer window for Next_wave with title Next Wave
        Trigger - Turn off (This trigger)

for as far as i know this system is leak free.
i hope it may help someone someday

feel free to use it, you dont have to credit me

here is a picture:
spawnsystemlh4.jpg
 

dannyboydude

Ultra Cool Member
Reaction score
33
Code:
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    Events
        Map initialization
    Conditions
    Actions
        Set Wave_type[1] = creep 1
        Set Wave_type[2] = creep 2
        Set Wave_type[3] = creep 3
        Set Wave_type[4] = creep 4
        Set Wave_type[5] = creep 5
        Set Wave_type[6] = creep 6
        ---go on like this---
        Trigger - Turn off (This trigger)

What the heck ?
If then else , then an event ?
What world do you live in dude ?

Other than that i like this basic guide to people who dont know hwo to spawn creeps in a TD
 

LightChaosma

New Member
Reaction score
60
i had an if amount of units in map is greater then 0 condition, to keep track of what i set in that trigger, j coppied this from my own map, that pwart was in a trigger where i set 50 or so vars, if not more

ill reomve it, thx
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
This is prolly too much to ask, but can you make a Jass version?
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
I can duplicate this in Jass for him if he wants.
 

dannyboydude

Ultra Cool Member
Reaction score
33
I remember when you was a gui noob adn now look at you renendaru

Your a learning jass pro :D

Im still a noobish gui-er


Ontopic: Why would he want this in jass if he doesnt know jass ?
 

LightChaosma

New Member
Reaction score
60
they only thing i know in jass in leak removal :eek: i might, just might make a start on jass in a few weeks, when i comletely mastered GUI (lightning eff, ubersplat, gamecashe, the rest i already master), since as far as i know, i will need JASS to make MUI spells, dont i?
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
Jass is pretty easy to use once you get how it runs. I used to program in Visual Basic, and Assembly Language on a calculator, so it's easy to figure it out from that.
 

LightChaosma

New Member
Reaction score
60
assemly language on a calculator, i can relate to that :D used to do that in math and physics class:p had nothing to do, and it was fun:p
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
Yea, I did some fun things with those in High school. I had put a funny mod on my teacher's calculator making any answer on it always equal 0.
 

LightChaosma

New Member
Reaction score
60
back to the topic > you said you could change it to JASS for me. currently i dont understand a word from jass, why would that be beneficial? (for me, or my map)
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
Well Jass runs faster than GUI in most cases, since it's the raw language of the triggers basically. Converting it into Jass will be easy. Want me to do it, and put in some documentation to show you how it works?
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
Gotta fix something on it, hold on.
 

LightChaosma

New Member
Reaction score
60
WE crashes when i use that... just coppied and pasted in a custom text trigger, and disabled the GUI one.

it crashes when i test it
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
I know, messed up on something. Accidentally forgot I couldn't carry the integer i across, so I'm putting the Forloop's back in.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top