Currently I have a system that spawns waves units from an array, It will spawn x amount of random selection from array. This is nice but isnt enough luxury for me.
What I would like it to do is , spawn a random amount of random selected units to equal a total of units that are supposed to be spawned.
For example Instead of wave 1 = spawn 10 zerglings
Could be wave 1 = spawn 2 zerglings 5 marines 1 roach 2 hydras 2 fire bats.
well, you will need an array with 2 indicies: Spawn[X][Y]. whereas X is the tier of the unit and Y are the different unit types.
or you do basically the same thing with user types in data
You will need a struct with both unit type and spawn weight. You then make this into an array featuring all the spawns you want. To spawn you then loop until a total weight variable is less than or equal to zero, choosing a random index from the array to create the unit and subtract its weight from the total weight. This spawning will allow you more control over balance since you can assign weak units like zerglings less weight than heavy units like marauders. Another approach to weight would be to alter the chance of a spawn occurring but this would need a sorted binary tree.
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Currently I have a system that spawns waves units from an array, It will spawn x amount of random selection from array. This is nice but isnt enough luxury for me.
What I would like it to do is , spawn a random amount of random selected units to equal a total of units that are supposed to be spawned.
For example Instead of wave 1 = spawn 10 zerglings
Could be wave 1 = spawn 2 zerglings 5 marines 1 roach 2 hydras 2 fire bats.
Could some one give an trigger example?
well, you will need an array with 2 indicies: Spawn[X][Y]. whereas X is the tier of the unit and Y are the different unit types.
or you do basically the same thing with user types in data
Here look at this, not optimal, but works similar to what you want.
Still alive and kicking, just busy.
My guide to the trigger editor (still a work in progress)
You will need a struct with both unit type and spawn weight. You then make this into an array featuring all the spawns you want. To spawn you then loop until a total weight variable is less than or equal to zero, choosing a random index from the array to create the unit and subtract its weight from the total weight. This spawning will allow you more control over balance since you can assign weak units like zerglings less weight than heavy units like marauders. Another approach to weight would be to alter the chance of a spawn occurring but this would need a sorted binary tree.