OK then,
I had originally solved this topic, but when I tested it with my MOD, the OverWater.sqf only seemed to work about 25% of the time.
I have since found a much more reliable method of ensuring units do not spawn in the water (among other uses; it could easily be configured to ensure boats DO spawn only in the water, I'm even using it to add water splashes to scripted arty without all the addon/config.cpp tomfoolery)
The answer was right under my nose the whole time. The getheightASL.sqf will reliably get an objects height above sea level in meters. Due to some idiosyncrosies of water in OFP, the height ASL for water can be 0 (duh), -1# something or other, or (maybe due to tide/waves) as much as 7m ASL (usually but not always around shorelines).
SOooooo after some trial and error I came up with this snippet in conjunctin with a patrol spawn script that spawns patrols around a randomly placed invisible"H"...
Note: you must have the getheightASL.sqf properly set up first of course...
;find spawn center (gamelogic)
_pos=getpos spawncentergamelogic
_xpos=_pos select 0
_ypos=_pos select 1
;Check to see if it is around sea level by moving an invis"h" to random spawn location first
#checkwater
~.01
_randomx=_xpos+random(100)-50
_randomy=_ypos+random(100)-50
patrolspawn setpos [_randomx,_randomy]
_heightASL=[patrolspawn] call getheightASL
?!(_heightASL>7): goto "checkwater"
;If spawn is above 7m ASL then spawn patrol around the invis"h"
"_x setpos [_randomx+random(10)-5,_randomy+random(10)-5]" foreach units enemypatrolgroup
I have tried to make this alot easier to follow than my usual cryptic shorthand code with no comments...so hopefully this makes sense.
This will run a loop to find another random spot that is over 7m ASL. It works pretty much all the time (so far at least), and creates a "buffer" around pretty much any coastline.
I will leave this unsolved in case anyone has any questions/comments or finds anything wrong with the code (going off of memory here)...Then maybe it should go to the FAQ (?).
-Grendel