Well, first of all some background information:
I am using version 1.46 since most of the people I know don't have RES (maybe I'll port that mission to 1.75 later). One of the mission's goals will be to arrest/capture a certain enemy officer. So I'll have to define and check conditions which will make the officer surrender and those should be:
1) None of his own guards/troops alive or within let's say a range of 300m
2) At least one member of the player's squad within 25m distance
Ok, I could put all guards into one array and check the distance for all array elements e.g. every 10 seconds (there will be more looping scripts so I don't want to make an interval shorter than neccessary) and do the same thing about the player's squad.
But I think that would be a very unflexible and static solution so I was wondering if I could handle the problem with a more dynamic script.
As far as I have tested it nearestObject does only take real objects as second parameter and does not work with unittypes (e.g. "SoldierWB") or vehicles (? actually I don't remember if I tested that though I would not help me in this case) accordingly. Is there any kind of workaround for that problem except for such things as attaching objects (e.g. gamelogic) to the desired units enabling the use of nearestObject (apparently that method would not really be more flexible than the unit-array)? And please don't tell me about that 1.75-bug with nearestObject since that does not concern me right now