I would call this a weekly exercise except that I expect that this may take a bit longer than a week, so I shall see how we go.
Trigger Exercise #3
This trigger exercise is going to be producing a tower defense spawning system for an actual map. The SC2Mapster Community Project. So in a way instead of getting you all to make a separate spawning system and end in a result of us only using one of them, we are going to attempt to build one together, and discuss ways of making it as efficient as possible.
This will be built in a map on its own, and i will copy the code into the final map at a later date.
What does this spawning system need to do?
If you have had a look at the terraining exercise you will see there are several different TD maps in one huge map, so firstly our system will need to adapt to the possible number of maps that will be use chosen at the beginning of the map.
There may be a possibilty of up to 5 different starting spawns for the "creeps" to start at, so it needs to be able to randomly chose a beginning starting spawn for each creep, but also a possibility to go to a random exit, Again this is depending on the map.
Each map will have separate paths the creeps will take, so once spawned it needs to be able to get the correct orders for that map so that the creep can make its way towards the end.
Waves will not be timer based, they will start based on player input, so there is a possiblity of players being on different levels during the game.
The game is going to have up to 8 people playing, so ideally the system is going to be working with a fair few variables as the 8 players will be on separate maps and on possible different levels
Examples
Player one chooses map 1 (which has one starting point and one finish and one path to take) - his creeps will not need to be random, will start at the same location will have the same path to take to the end.
Player two chooses map 2 (which has two starting points and two finishes and path to take) - his creeps will need to be randomly spawned at the two locations given their correct set of orders towards their finish.
Player three chooses map 3 (which has one starting point but four finishes) - his creeps will all start at the same point but be given a random finish location so the correct orders need to be given to get them to the correct finish.
If you have any questions regarding the system/aspects I have missed, bring it up and I will clarify and edit this post
random spawn even if there are 5 starting zones? if you are unlucky, 50% of the creeps spawn in one position and simply run by. don't know how far away the starting zones are from each other
I would do the path system on the map and not in the spawn trigger.
A combination of order unit move random point in region 1
unit enters region 1a move left
unit enters region 1b move right
with this method it would stay safe, dynamic and efficient
All maps the the paths will have areas where they cross, so if they all spawn in one location and get as you say unlucky, it won't matter. then it comes down to tower placement :)
if your going to do a path system on the map, there is a possibility of 20+ maps... there must be away to do it all with variables :)
as for the maps. take a look at the latest terraining exercise, just open the latest version of the map to get an idea
never done something like that before but wouldn't it be possible with multi-dimensional arrays?
eg. first dimension for the choosen map, second for the path and third for the point of the path.
Then you have to size the array only to the max values you need
I thought about saving the new path with a string, since you can change a point to two fixed and these to strings. Now I would add these strings together with a " " between the values. And the use StringWord( the string, n - (n-1) ).
okay this was far easier than I thought
if you use units without collision it should works well and it didn't take 16 hours ;)
very efficient and easy. should work with every possible grid
map 0 and 2 from the preview map are working
at some points regions are probably better than points, cross-ways for example
Typically for something like this I would need to see the terrain setup to get a better idea of how to do a pathing system. But, the basic spawn loop I use for Tower Defense Classic is extremely flexible and extensible (hell, I've already adapted it for 8 game modes), so I'm gonna throw mine in for this project. Now, I've never participated in one of these Trigger Exercises before, so do you want a video demonstrating it in action or something? Might be a bit difficult to do with my shitty computer but I can whip up a map later this week to show it off.
But as for the spawn loop, here you go:
Global Variables:
Map - Integer: # of Maps
Lives - Integer: 25 (Array for # of maps)
Level - Integer: 0 (Array for # of maps)
Wave Size - Integer: 25 (or Array [Levels])
Enemy Type - Unit Type Array: [Levels]
Command - Ability Command Array [2]: Move / Attack Move
Order - Integer: 1 / 2
Units In Wave - Unit Group (Array for # of maps)
Attack Wave - Unit Group (Array for # of maps)
Spawn Area - Region Array: [# of Spawns] [Maps]
Spawn Group - Unit Group Array: [# of Spawns] [Maps]
Intermission - Boolean: False
Intermission Timer - Timer
Intermission Duration - Real: 30
Intermission Timer Window - Timer Window
Lives Spent - Boolean: False
Game Difficulty - Real: 1.0 (Set from vote dialog, .5, .75, 1.0, 1.5, 2.0, 3.0)
EventsLocalVariables#ofUnitstoMake=0<Integer>Result=0.0<Real>TimeCounter=0<Integer>ConditionsLivesSpent==falseActionsVariable-SetIntermission=false-------CalculatehowmanyUnitstoSpawnVariable-SetResult=(Real(WaveSize[Level]))
Variable - Modify Result: * 4.0
Variable - Modify Result: * Game Difficulty
Variable - Modify Result: / 4.0
Variable - Set # of Units to Make = (Integer((Round(Result))))
Player Group - Pick each player in (All players) and do (Actions)
Actions
UI - Show help for Enemy Type[Level] for player (Picked player)
General - If (Conditions) then do multiple (Actions)
If Then Else
General - Else if (Conditions) then do (Actions)
Else If
Game Mode == 1
Then
01 - Classic(# of Units to Make)
Action Definition: 01 - Classic
Options:ActionReturnType:(None)ParametersUnitstoSpawn=0<Integer>GrammarText:01-Classic(UnitstoSpawn)HintText:(None)CustomScriptCodeLocalVariablesActionsGeneral-Pickeachintegerfrom1to4,anddo(Actions)ActionsUnit-CreateUnitstoSpawnEnemyType[Level] for player 15 at (Center of Spawn Areas[(Pickedinteger)]) using default facing (No Options)
Unit Group - Add all units in (Last created units) to Units in Wave
General - If (Conditions) then do (Actions) else do (Actions)
If
(Enemy Type[Level] has Heroic attribute) == true
Then
Variable - Set Order = 2
Unit Group - Add all units in (Last created units) to Attack Wave
Unit Group - Add all units in (Last created units) to Spawn Group[(Pickedinteger)]
Else
Variable - Set Order = 1
Unit Group - Add all units in (Last created units) to Spawn Group[(Pickedinteger)]
Unit - Order all units in Spawn Group[(Pickedinteger)] to (Command[Order] targeting Destination[(Pickedinteger)]) (Replace Existing Orders)
General - Wait 5.0 Real Time seconds
UI - Clears all current tip alerts for (All players)
There was a lot of extra hooks I had to remove from all of those and I didn't update them for use with multiple maps, but it should be pretty easy to figure out how to modify the code to use the multi-map variables I defined at the beginning. Overall though, you just loop through each map and each spawn zone in each map and that's what gets units spawning. If you want each map running on a separate clock, then you just put the intermission variables into an array to keep time per map. Play around with it and I'm sure you can do a vast array of things with this simple structure.
I'll try and get a working multi-map example done later this week, for now lunch and job hunting is in order.
I would call this a weekly exercise except that I expect that this may take a bit longer than a week, so I shall see how we go.
Trigger Exercise #3
This trigger exercise is going to be producing a tower defense spawning system for an actual map. The SC2Mapster Community Project. So in a way instead of getting you all to make a separate spawning system and end in a result of us only using one of them, we are going to attempt to build one together, and discuss ways of making it as efficient as possible.
This will be built in a map on its own, and i will copy the code into the final map at a later date.
What does this spawning system need to do?
Examples
If you have any questions regarding the system/aspects I have missed, bring it up and I will clarify and edit this post
it's still not complicated. some records for every possible map and then loop it and profit.
if two player choose the same map, they are always on the same level or do you want some kind of phasing?
going to look into it
@b0ne123: Go
It may not be over complicated, but it will need to be efficient.
Two players will not be able to choose the same map, that will be part of another exercise that will go up after this one
random spawn even if there are 5 starting zones? if you are unlucky, 50% of the creeps spawn in one position and simply run by. don't know how far away the starting zones are from each other
I would do the path system on the map and not in the spawn trigger.
A combination of order unit move random point in region 1
unit enters region 1a move left
unit enters region 1b move right
with this method it would stay safe, dynamic and efficient
@b0ne123: Go
All maps the the paths will have areas where they cross, so if they all spawn in one location and get as you say unlucky, it won't matter. then it comes down to tower placement :)
if your going to do a path system on the map, there is a possibility of 20+ maps... there must be away to do it all with variables :)
as for the maps. take a look at the latest terraining exercise, just open the latest version of the map to get an idea
going to do it when I'm back home
but still, the path system with variables? you have to limit to the number of path points
never done something like that before but wouldn't it be possible with multi-dimensional arrays?
eg. first dimension for the choosen map, second for the path and third for the point of the path.
Then you have to size the array only to the max values you need
Cheers Then
dynamic flexible spawn system
currently thinking about a flexible system to move the units
I thought about saving the new path with a string, since you can change a point to two fixed and these to strings. Now I would add these strings together with a " " between the values. And the use StringWord( the string, n - (n-1) ).
If you need an idea of how you get something like this to work check out
"Infinite TD" on US
As for how its done, thas a bit of a trade secret but if your pretty good and you watch the units closely Im sure you can figure it out.
I just spent 16 hours over the weekend writing such a dynamic pathing system. Tonight I will be implementing players being on different levels.
us, there we've got a problem ;)
if there wouldn't be so much limits in this editor...^^
okay this was far easier than I thought
if you use units without collision it should works well and it didn't take 16 hours ;)
very efficient and easy. should work with every possible grid
map 0 and 2 from the preview map are working
at some points regions are probably better than points, cross-ways for example
@b0ne123: Go
allrighty and what if the levels were not dynamic, not consiting of the same unit types and different times between each unit came out?
two clicks at the spawn trigger
and a periodic event instead of listen to something player-based
made the system open in every direction
@b0ne123: Go
mmmm what I'm saying is if level 1 was to consist of 5 zergling and 4 roaches, with different spawn intervals. (time before each one turns up)
you don't mean one after another?
something like:
ling ling roach ling roach ling roach ling roach
?
@b0ne123: Go
correct, if levels are fairly random as to what they spawn, and how long between each unit that spawns :)
so
ling wait 0.1 sec
ling wait 0.2 sec
roach wait 1 sec
ling wait 0.1 sec
ling wait 0.5 sec
if I was to preplan all the levels in such a way, is there a way to implement it to read each level as so
sure, I could change the waves record to contain 2 arrays. one containing the units, one the delay
but have to think about it later, it's 0 o clock here. have to sleep
edit: now I'm gone
Typically for something like this I would need to see the terrain setup to get a better idea of how to do a pathing system. But, the basic spawn loop I use for Tower Defense Classic is extremely flexible and extensible (hell, I've already adapted it for 8 game modes), so I'm gonna throw mine in for this project. Now, I've never participated in one of these Trigger Exercises before, so do you want a video demonstrating it in action or something? Might be a bit difficult to do with my shitty computer but I can whip up a map later this week to show it off.
But as for the spawn loop, here you go:
Global Variables:
Map - Integer: # of Maps
Lives - Integer: 25 (Array for # of maps)
Level - Integer: 0 (Array for # of maps)
Wave Size - Integer: 25 (or Array [Levels])
Enemy Type - Unit Type Array: [Levels]
Command - Ability Command Array [2]: Move / Attack Move
Order - Integer: 1 / 2
Units In Wave - Unit Group (Array for # of maps)
Attack Wave - Unit Group (Array for # of maps)
Spawn Area - Region Array: [# of Spawns] [Maps]
Spawn Group - Unit Group Array: [# of Spawns] [Maps]
Intermission - Boolean: False
Intermission Timer - Timer
Intermission Duration - Real: 30
Intermission Timer Window - Timer Window
Lives Spent - Boolean: False
Game Difficulty - Real: 1.0 (Set from vote dialog, .5, .75, 1.0, 1.5, 2.0, 3.0)
Triggers:
Start New Level
Run Level
Action Definition: 01 - Classic
End Level
Intermission
Update Lives
There was a lot of extra hooks I had to remove from all of those and I didn't update them for use with multiple maps, but it should be pretty easy to figure out how to modify the code to use the multi-map variables I defined at the beginning. Overall though, you just loop through each map and each spawn zone in each map and that's what gets units spawning. If you want each map running on a separate clock, then you just put the intermission variables into an array to keep time per map. Play around with it and I'm sure you can do a vast array of things with this simple structure.
I'll try and get a working multi-map example done later this week, for now lunch and job hunting is in order.
go to the main thread, there is a link to the terrain exercise . or download the map i linked above and read the whole description^^