Here is a simple script I wrote for a 'nam mission I'm working on. It uses a function called "find units" that is extremely simple and just finds units within a certain distance of another unit. You'll notice I execute an artillery strike script, but that line could easily be replaced by a call for UA to fire (actually I'm going to replace that line soon).
Basically it looks for an enemy target with no friendlies nearby (that the observer knows about), then it calls for fire, waits, and repeats. Simple but it works decently. One major problem with it though (and please, somebody tell me how to fix this!), is that the AI will call for fire as it is retreating, on targets it can no longer see. In some ways this is realistic (calling for arty to cover the retreat), but the problem is even if the target moves while the spotter is running away, each new barrage is still centered on his position.
The code:
_observer = _this
#Loop
;//wait until enemy detected
@("Land" countType ([_observer, west_units] call knownUnits) > 0 && allow_Earty) OR !(alive _observer)
?!(alive _observer) : exit
_knownEnemies = [_observer, west_units] call knownUnits
_i = 0
_max = count _knownEnemies
;//loop until target is found with no friendlies nearby
#FindTarget
_unit = _knownEnemies select _i
? count ([_unit, 100, east_units] call findUnits) == 0 AND "Land" countType [_unit] == 1 AND (_observer knowsabout _unit) > 3 : goto "CallStrike"
_i = _i + 1
? _i < _max : goto "FindTarget"
;//if no safe targets, wait, then back to beginning
~20
goto "Loop"
#CallStrike
_observer dofire _unit
_observer switchmove "combattomedic"
~4
?!(alive _observer) : exit
allow_Earty = FALSE
[getpos _unit, "sebgren", 150, 1, [1,3] call randInt, 0, 0, 5, 75 + ((4 - (_observer knowsabout _unit)) * 30)] exec "scripts\g_arty.sqs"
~10 + random 5
allow_Earty = TRUE
goto "Loop"