- Joined
- Jul 10, 2007
- Messages
- 6,306
Yes... I'm working on a new Spawn : O.
For those of you who don't know what Spawn was, it was a system that allowed one to periodically spawn units (the original system was incredibly complicated, was 2000+ lines of code, and had a 15 page manual to go with it).
The new Spawn is much simpler. In fact, it is split into two different systems, these being SimpleSpawns and Spawns.
The normal method for spawning is enumerating every x seconds and creating a unit if a unit type id is right (like create a footmen at all barracks on the map ('hfoo' at 'hbar')).
The next method that people use, which is more optimal, is using timer loops and unit indexing to iterate through all units on a list (iterate through list rather than enumerate).
The problem with the above is that spawns start at different periods. Furthermore, it disallows tech upgrades for players and specific units.
SimpleSpawn creates a timer for each specific spawn so that the timers can be paused and modified. It also uses elapsed times when a time is changed so that the timer isn't simply reset. This means that if a timer went for 15 seconds out of 30 and had 15 seconds left, changing it to 18 seconds will make it have 3 seconds left instead. A normal system would make it have 18 seconds remaining (reset).
SimpleSpawn uses a combination of unit type id properties, player unit type id properties, and specific spawn properties to manipulate spawns. Properties that reals/integers (like count and time) are stacked upon each other (unit type id time + player unit type id time + spawn time = total time).
Updating spawn time on a global level updates the spawn time of all spawns matching its criteria. For example, modifying the spawn time of barracks owned by player 0 will iterate through all spawners owned by player 0 of type barracks and modify their spawn time.
For example
Updating a value like a boolean on a global level will only apply itself to spawns that derive itself from the same level. For example, if the player enabled value for barracks is not set (meaning barracks don't spawn), enabled for barracks will apply itself to all barracks owned by that player that don't have their specific values set.
For example
Custom code works the same way. If code is null, it uses default spawning, which just places x spawns at a spawner.
Advanced Spawning works in a very different fashion. With Advanced Spawning, each spawn is specifically created and given a position (a position being any agent with coordinates). Advanced Spawning also has stacked fields, meaning that changes to its properties like time can be undone. This is useful when transferring a spawn from one position to another and then wanting to undo the change (like a stealing spawn ability).
The stacked fields are grouped into two different stacks-
Position Stack (x, y, z, etc)
Stat Stack (time, count, spawn type, etc)
Spawns can also have multiple positions and positions can have multiple spawns.
Advanced Spawning also has special macros for the intense spawning loops involved.
Both Advanced Spawning and Simple Spawning keep track of all spawns via a set of groups.
1. Global spawn group, split by types
2. Global spawn group 2, split by types and players
3. Specific spawn group, split by spawners/positions
4. Instantaneous spawn groups, descending by time and organized by specific spawners/positions, types and players, and types
In this way, spawned units can be manipulated at any point in the game (for example, tracking a group of unit's ages for possible life/death or giving units of a base bonuses when that base is upgraded, or etc, who knows)
Archiving and Spawn Tracking are extra features and can be disabled.
I am simply posting these designs up to see what people think (what they want me to add, etc) : ). The code for the two systems should be done soon.
Woo, now I have 60000 projects going + end of the semester exams/projects : D.
/muahahahahas
edit
Can actually merge advanced and simple spawning ; O.
edit
further ideas for API (while background code may be coded to a degree, the API hasn't been set ^^)
For those of you who don't know what Spawn was, it was a system that allowed one to periodically spawn units (the original system was incredibly complicated, was 2000+ lines of code, and had a 15 page manual to go with it).
The new Spawn is much simpler. In fact, it is split into two different systems, these being SimpleSpawns and Spawns.
The normal method for spawning is enumerating every x seconds and creating a unit if a unit type id is right (like create a footmen at all barracks on the map ('hfoo' at 'hbar')).
The next method that people use, which is more optimal, is using timer loops and unit indexing to iterate through all units on a list (iterate through list rather than enumerate).
The problem with the above is that spawns start at different periods. Furthermore, it disallows tech upgrades for players and specific units.
SimpleSpawn creates a timer for each specific spawn so that the timers can be paused and modified. It also uses elapsed times when a time is changed so that the timer isn't simply reset. This means that if a timer went for 15 seconds out of 30 and had 15 seconds left, changing it to 18 seconds will make it have 3 seconds left instead. A normal system would make it have 18 seconds remaining (reset).
SimpleSpawn uses a combination of unit type id properties, player unit type id properties, and specific spawn properties to manipulate spawns. Properties that reals/integers (like count and time) are stacked upon each other (unit type id time + player unit type id time + spawn time = total time).
Updating spawn time on a global level updates the spawn time of all spawns matching its criteria. For example, modifying the spawn time of barracks owned by player 0 will iterate through all spawners owned by player 0 of type barracks and modify their spawn time.
For example
JASS:
set Spawn['hbar'].time = 10
set Spawn['hbar'].spawns['hfoo'].count = 3 //add footman x3
set Spawn['hbar'].spawns['ewsp'].count = 1 //add wisp x1
set Spawn['hbar'].spawns['hfoo'].count = 0 //remove footman
set Spawn['hbar'].player[0].spawns['hfoo'].count = 2 //add two footmen to player 0 only
set Player[0].spawns.time = 5 //add 5 seconds to all spawns of player 0
//actual spawn time
time = Spawn['hbar']+Player['hbar']+SpecificSpawn['hbar']
//time is updated on initial set
local real t = SpecificSpawn['hbar']+Spawn['hbar'].time+Player['hbar'].time
set t = t-TimerGetElapsed(timer)
if (t < 0) then
set t = 0
endif
call TimerStart(timer, t, false, function DoSpawn)
if (not enabled)
call PauseTimer(timer)
endif
For example
JASS:
set Spawn['hbar'].enabled = true
//background if statements in enumeration
if (player['hbar'].enabled.used == false) then
if (specificSpawn.enabled.used == false) then
set specificSpawn.enabled = true
endif
endif
Custom code works the same way. If code is null, it uses default spawning, which just places x spawns at a spawner.
Advanced Spawning works in a very different fashion. With Advanced Spawning, each spawn is specifically created and given a position (a position being any agent with coordinates). Advanced Spawning also has stacked fields, meaning that changes to its properties like time can be undone. This is useful when transferring a spawn from one position to another and then wanting to undo the change (like a stealing spawn ability).
The stacked fields are grouped into two different stacks-
Position Stack (x, y, z, etc)
Stat Stack (time, count, spawn type, etc)
Spawns can also have multiple positions and positions can have multiple spawns.
Advanced Spawning also has special macros for the intense spawning loops involved.
Both Advanced Spawning and Simple Spawning keep track of all spawns via a set of groups.
1. Global spawn group, split by types
2. Global spawn group 2, split by types and players
3. Specific spawn group, split by spawners/positions
4. Instantaneous spawn groups, descending by time and organized by specific spawners/positions, types and players, and types
In this way, spawned units can be manipulated at any point in the game (for example, tracking a group of unit's ages for possible life/death or giving units of a base bonuses when that base is upgraded, or etc, who knows)
Archiving and Spawn Tracking are extra features and can be disabled.
I am simply posting these designs up to see what people think (what they want me to add, etc) : ). The code for the two systems should be done soon.
Woo, now I have 60000 projects going + end of the semester exams/projects : D.
/muahahahahas
edit
Can actually merge advanced and simple spawning ; O.
edit
further ideas for API (while background code may be coded to a degree, the API hasn't been set ^^)
JASS:
//Global Spawning Manipulation that spawns may or may not use
origin['hbar'].spawn['hfoo'].count = 3
origin['hbar'].player[0].spawn['hfoo'].count = 3
player[0].spawn['hfoo'].count = 3
spawn['hfoo'].count = 3
origin['hbar'].player[0].spawn['hfoo'].count = 3
origin.spawn[0].count = 3 //set spawn via origin
//Specific Spawn Manipulation
spawn.position[position] = 3
spawn.type['hfoo'].count = 2
spawn.type['hfoo'].share(spawn2)
//soft/hard is when a spawn shares its stats with another spawn (may be specific stats)
//this is like spawn1 giving a spawntype to another spawn, or increasing another spawn's spawn count
//soft relies on spawn1 position integrity
//hard does not rely on spawn1 position integrity
spawn.soft[spawn2] = 1 //soft, x1
spawn.soft.position[position] = 1 //soft, x1
spawn.soft[spawn2] = 0
spawn.hard[spawn3] = 2 //hard, x2
//Lending
spawn.lend.position = pos //stack position
spawn.lend.position.revert()
spawn.lend.position.base()
//Mimicing
spawn.mimic = spawnToMimic
spawn.mimic.count = spawnToMimic.count
spawn.mimic.revert() //undo mimic
spawn.mimic.base() //stop mimicing
Last edited: