by DDDX » 17 May 2020, 00:10
sure. easy to do.
There are a couple of ways to do this
You could do it with the map script, make the map scan through all your units, or just the unique category of that unit (you can put anything in its category list), or you can list the unit by blueprint id. This is more CPU intensive, but works nicely.
Then if it is found, you can add restrictions to building it into your ACU, or whatever. if it's not there, nothing happens life goes on
Another way would be with a mod, to modify that unit's script file so that it kills any specific units that are over a total number (of 1, in your case)
Third way, again through a mod, with that unit's script file, would be to use the units OnStartBeingBuilt and OnCreate functions to immediately restrict further building when you start or when you complete building that unit.
2 things though, if you use OnStartBeingBuilt function, then you need to finish the unit completely, if you stop constructing or if it gets killed before being finished, you will not be able to make another one, or continue constructing that one. That's because SupCom does not even allow you to assist building of units you don't have available for building...
And if you use OnCreate function then nothing prevents you to start making 20 before you finish the 1.st one.
But that can be contered with the script that kills any unit over a total number (of 1). or you could make the build time 1 second, but require to have insane mass and energy in storages in order to build it instantly.
Check my mod called "Survival Mayhem&BO balance".
In it there is a series of hero units that can build limited numbers of improved turrets, and some OP minibosses. For example, check the unit XSL9905, that's a final level (out of 5) Seraphim hero, and check xac1101 or sxslew0001u (both are very OP units, max 1 allowed of either one of the other, you cannot have both). Those 2 are not in the units folder, but in the hook folder, find them there.
And if you have any questions, let me know.
Check out my 2 maps: "Survival_Mayhem&BO_3d_v1" "Survival_Mayhem&BO_3d_RPG"
as well as my mod: "Survival Mayhem&BO balance"
-- let me know of any bugs or issues regarding those 3.