Essentially wondering if anyone has any good advice/experience with randomly populating units in a map.
I have a 512x512 map (probably overly ambitious in hindsight) and wanted to add some randomization to the unit spawns for the map. Started out with Random Groups (under the advanced menu in the world editor) but it seems like the sets only roll once per map. This led to me writing a more or less proof of concept for a Random Unit Spawn system using a similar approach. Unit Spawn groups made up of Unit Spawn Positions (each group has an arbitrary number of positions with an arbitrary number of units allowed to spawn in that position, or whatever lua's table size limit is). The system takes a Unit Spawn Group, an x,y coordinate pair to act as the center of the group, and a shape spawn function (e.g. Square, Polygon, Circle, Triangle) in which to arrange the units.
Anyway, everything with the system works fine so far, however, I've realized that this will likely require a lot of manual recording of my X, Y "unit group center coordinates"
Current thoughts are basically creating a bunch of tiny regions for my center cords and giving them a descriptive name and then matching that name in a lua script with the associated x/y values (Essentially an in memory db) and using those to create the spawn groups.
My question is more or less, is there a better way to go about this I'm not thinking of? Something to simplify/reduce the need for manually creating all these individual spawns. i.e. using convention over configuration? As well as if there are any concerns I should have with generating such a large number of units. My current assumption is that I'll have to use timers to do it over a longer period of time, and maybe have some initial delay at the beginning of the map load to ensure everything can spawn without any issues.
As far as I can tell theres no way to loop through all the regions and their names in the map or get them by name via the Lua api, but maybe having my "in memory db" be a table of descriptions (e.g. EasyBanditGroup# and x/y pairs) and looping over that would allow me to use covention somewhat at least.
Appreciate any feedback/advice.
I have a 512x512 map (probably overly ambitious in hindsight) and wanted to add some randomization to the unit spawns for the map. Started out with Random Groups (under the advanced menu in the world editor) but it seems like the sets only roll once per map. This led to me writing a more or less proof of concept for a Random Unit Spawn system using a similar approach. Unit Spawn groups made up of Unit Spawn Positions (each group has an arbitrary number of positions with an arbitrary number of units allowed to spawn in that position, or whatever lua's table size limit is). The system takes a Unit Spawn Group, an x,y coordinate pair to act as the center of the group, and a shape spawn function (e.g. Square, Polygon, Circle, Triangle) in which to arrange the units.
Anyway, everything with the system works fine so far, however, I've realized that this will likely require a lot of manual recording of my X, Y "unit group center coordinates"
Current thoughts are basically creating a bunch of tiny regions for my center cords and giving them a descriptive name and then matching that name in a lua script with the associated x/y values (Essentially an in memory db) and using those to create the spawn groups.
My question is more or less, is there a better way to go about this I'm not thinking of? Something to simplify/reduce the need for manually creating all these individual spawns. i.e. using convention over configuration? As well as if there are any concerns I should have with generating such a large number of units. My current assumption is that I'll have to use timers to do it over a longer period of time, and maybe have some initial delay at the beginning of the map load to ensure everything can spawn without any issues.
As far as I can tell theres no way to loop through all the regions and their names in the map or get them by name via the Lua api, but maybe having my "in memory db" be a table of descriptions (e.g. EasyBanditGroup# and x/y pairs) and looping over that would allow me to use covention somewhat at least.
Appreciate any feedback/advice.
Last edited: