Funny... I've just tried to make my own spotting device, yet a realistic one. All I did was scanning for enemy units along the direction which the unit is scanning (You don't want your enemy to detect you while you're aproaching behind him, right?).
The scripts and funtions contained:
- A maximum sight range for the unit, according to its weapon's settings, behaviour and skill. For example, a sniper can see up to 900 meters away, while in stealth or combat modes;
- A terrain obstacle detector (HARD TRIGNOMETRY!), which wouldn't include buildings, unless you detect them through the following process:
- An enemy list provider, such as a function which detects several nearestObjects of the enemy types (The one's that were specified in this thread);
- A looping device, wich would apply the revealing function every X+50meters along the direction the unit's facing, until the predefined distance was reached;
- An unit's direction update (setFormDir), to improve the detecting skill;
- A few other settings.
About the "HARD TRIGNOMETRY" issue: It's not as hard as I say, all you must do is getting the terrain declivity (straight line) between the Scanning unit and the ToBeRevealed unit, and check if there's any terrain height (sea level detector needed) higher than the maximum specified by the declivity function (it's like checking if there's a hill between you and the ToBerevealed unit - of course, you won't be able to see him). If the maximum is breaked, the unit won't be revealed.
I also tried to defined the maximum sight range according to the terrain configuration.
HOWEVER, this script got really wierd on my 400MHz, as you may guess... I just don't recomend it because of the lag...
My solution? Simple. Just create several addons with new settings specified for the units, such as higher eye sensivity, ear sensivity, less camouflage and higher weapon sight range for AI. They'll look like deadly commandos (For veterans only).