Sorry for the late sign of life from me, I was quite busy today and in the evening had an arrangement with a couple of friends for map testing in-game ... somehow the times when you're not at work are always the ones when you have the least time
First of all: thanks for all the replies!
Second, just to make the goal clear: it's for a gadget included in -up to now- two maps that optionally alters the game goal to "king of the hill": go in a defined zone of the map -> occupy it for a certain amount of time -> win (==when time is up for this team, all other teams are destroyed).
This should work pretty much independent of the mod, as long as it can be played on the maps.
Trying to go through the replies:
I am aware that not all mods have commanders; and for some KotH probably makes no sense at all - with or without com. Maybe I should have phrased this better in my first post.
But I was under the impression, that many mods besides BA have a com unit, too. But I might be wrong and it's only a few other (*A?!).
Why a commander for KotH: the easiest answer is that the script from Alchemist, which is the base of my additions/fixes, had this in...
And I have to say, needing a commander to occupy the hill zone makes the game play more fun than just having to get
any unit in the zone to activate it (from that point on, any unit counts until control is lost == all units removed from zone).
This argument holds obviously only for mods, that have only a single com unit per team. If you can have/build more than one com, it fails mostly... maybe not completely.
Since the current gadget version works probably only for BA correctly, and in the
map thread it was mentioned as one of the things that could be improved, I wanted to try so (among other fixes).
And I had hoped there would be a standard way to test for com.. which would have been an easy way to adjust it for more mods than just BA.
After reading all replies, I agree that catching the first spawned unit is a bad idea. Thinking about it, I tend to do it -at least partly- mod wise. This way, there would also be a way to just stop the script if a mod is played that has no com. Maybe check for the mod in a separate function.
A list of units per mod would be more foolproof, but I agree that a single list could be better in other respects.
Testing for supported mods could also be used to accept any unit in the zone if the mod has no com... but this would be a quite different game play and I am not sure it it is worth it.
Probably, not too many players are interested in this modification anyway
(*)
All the hints how to find a com in different mods and pointers to code are very helpful! Thanks a lot, big help!
I surely also learned a bit more about other games. I guess I have to do some research now and have a look at several mods and see how games/things work there in detail.
Thanks again, qray.
---
footnote
(*) but me and a couple of friends had much fun playing this mode in a non-public BA mutator I had packed. So I improved the original script step by step and in the end thought I might share it publicly in the form of a map gadget