Once I create a group of 20 units with hitboxes no bigger than small biters and send them off to do anything, a whole host of seemingly random (though entirely predictable in the sense that they happen every time) things can happen:
- Units, with or without being in a unitgroup, simply randomly vanish from the game if they are bumping into either eachother, or trees, or anything else that blocks their path - not all the time, but with a unit group of 20, it happens every play test session
- LuaUnitGroups are sometimes just destroy()'d if for example (this seems to be the most common thing) units in the group are "too far" apart - and I can't quantify "too far", but certainly a maximum zoomed screen-width away seems to be enough
- Units that are given compound commands, either with or without a luaunitgroup, will in all cases I have observed simply stop executing commands after 5-6 of them.
- LuaEntity/UnitGroup.has_command isn't very useful, because there's no way to remove commands. Can you make .set_command() simply accept nil to make an entity stop immediately what it's doing?
#1 and #2 would not be so bad if the engine told me in some way that it had happened.
I mean, for LuaEntity I can track on_entity_died and check on_tick if my units are no longer valid. And if one is invalid, and has not been catched by on_entity_died, it was probably randomly vanished by the game - but I don't know in which edge cases this way of tracking it will NOT work. And it also seems like it shouldn't be necessary.
#1 would not be so bad if the pathing engine didn't give all units the exact same path to get to the destination. In all cases when I send a group (with or without a luaunitgroup) of units going, they immediately go into "duckling mode" and path directly behind eachother, and this is causing most of the problem simply because they crash into eachother wanting to get to the "line" from where they are wandering.
I just think of ducklings and "Walk the Line" when I watch this behavior every single play test.
To work around this, I've started giving each unit their own random destination positions within a radius of where I want them to end up as a group. But obviously this isn't doable if I use a LuaUnitGroup, and also it adds a lot of complexity, and the further away you are from the destination the less chance that it will do any good, because the given path calculated by the engine smooths out into the same path the further away you are.
I can give you my rewrite of robotarmy if you want to check out this stuff for yourselves, but frankly setting up the test scenario would be nontrivial - I presume it'll be easier and faster for you to spawn groups of biters in game and test this some other way.