However, I wonder if it would be better to have a generic setDroidLimit(player, limit[, droidType]) function?
EDIT: Just realised there is already a setDroidLimit() function, but it doesn't have a param to define droid type.
With such a function, it would be possible to set limits for DROID_SENSOR, DROID_SUPERTRANSPORTER, etc. And, if DROID_ANY constant is used (also the default for droidType param if it's not specified), it would set the max number of droids that the player could have (irrespective of type).
Example use: In a campaign mission or challenge game, this could be used to create a mission whereby a player can research a certain type of droid (eg. super transport) but not build any until they've destroyed enemy AA defences at which point the limit for super transport is increased from 0 to 10 or whatever, thus allowing them to actually produce transports.
I think having a single function will be much cleaner - single point of access to setting droid limits, it would also tie up nicely with the existing getDroidLimit(player, droidType) function, and it would be less documentation for script devs to wade through
The C++ code could then have a 2D array:
Code: Select all
droidLimits[player][droidType] = limit
I imagine having something similar for structures would be worthwhile, keeping everything consistent and centralised wherever possible.
EDIT: Also it would be useful if the function returned the limit that's been set (eg. if DROID_ANY is limited to 40 and I try setting DROID_SENSOR to 50, I assume DROID_SENSOR will get limited down to 40, but without the return value my script won't know that). Also I believe there's max number of commanders the UI can deal with - something like 5 or 10 on the factory settings panel, so I guess trying to set more than that number of commanders should limit down to whatever the UI can deal with (and js needs to know that extra limiting has been applied via the function return val).