Hello All
I'm not sure whether this is a general query or an advanced query but here goes (PS - it's been a long time since my last post so be gentle !).
I am writing a script that provides a form of "morale" for the designated group. Basically, the group will try to close the range between itself and its assigned target (by way of setWPPos), unless the range to the nearest enemy is more than the "minimum allowable". If it is then the group will move directly away to the minimum allowable range. This starts at zero, but it goes up steeply to a maximum of 500m once the group takes casualties over its assigned morale rating.
Two neat things. First, you can make the target any named object, so that the group will try to to take (or defend) the target until its casualties get too high. Second, if you add a group respawn script (which I've written !) then the group will attack, take casualties, regroup, reform and attack again unless it is completely wiped out (which is tough, since it runs away if it takes too many casualties !).
Or so the theory goes. I am trying to find out the syntax to determine the range to the nearest enemy unit. I have OFP: Resistance so cI an use any set of commands up to 1.96. Any ideas ?
My guess so far is that I should somehow make an array out of all enemy units using the "countType" command and Type = soldierEast (not sure of syntax here). I am guessing that I then use the "distance" and "forEach" commands to work out the closest unit.
Am I on the right track ? Or is there something much simpler and easier (say, a "nearestEnemy" command ?)
Any help would be greatly appreciated. I am actually working on a number of variants to the basic script to represent random civilian scatterings, hunt and seek engagements, prison breakout missions and guerilla warfare operations. I will of course post the scripts as and when they are finished.
Cheers
Rags