Since OFP came out, I'm aching for a searchlight addon...
Meanwhile we have to do it with scripted searclhights and the best script I found was Sui's mgspot.sqs
The problem with mgspot is that you can still run through the lichtbeam undetected, because the unit does'nt look in the same direction the light does. That's the part I've changed, I create a gamelogic an move him in as gunner, so the lights turned on. Then I place a lookout very close to the mg and setdir him the same direction as the light. The best lookout is a sniper (with Nv goggles), without any other weapons and a this setunitpos "up" in the init.
When the lookout detects the player and the lichtbeam is directed to him ,the gamelogic disembark the mg (yeah, weird it works,
gamelogic don't have AI, deletevehicle Gamelogic doesn't work!) and the lookout moves in & start firing / searching the player
When the lookout is hit, he moves in directly.
When the lookout dies before the player's detected, the script exit and the light stays on (the gamelogic is still there)
Here's the script
; -- MG Searchlight Script --
; Written by Sui (reworked by Blanco)
_mg = _this select 0
_llimit = _this select 1
_rlimit = _this select 2
_lookout = _this select 3
; -- Create a tempgunner and move it in as gunner, so the script can start
_mgg = "logic" camcreate getpos _mg
_mgg moveingunner _mg
; -- Set the variable that calls the 2nd loop (to track the player)
detected = false
; -- sets the initial direction of the MG inbetween the two limits
_newhdg = (_rlimit + _llimit)/2
; -- First loop... random searchlight movements
; -- finds the direction of the MG relative to a random heading between the arc limits
; -- If the MG's heading is within 10 degrees of the random heading, it chooses a new random heading
? (getdir _mg - _newhdg) < 10 and (getdir _mg - _newhdg) > - 10: _newhdg = ((random (_rlimit - 90)) + _llimit)
? (getdir _mg - _newhdg) > 0: _mg setdir ((getdir _mg) - 1)
? (getdir _mg - _newhdg) < 0: _mg setdir ((getdir _mg) + 1)
; -- find the direction of the player relitive to the MG
_dirplr = ((getpos player Select 0) - (getpos _mg Select 0)) ATan2 ((getpos player Select 1) - (getpos _mg Select 1))
? _dirplr < 0: _dirplr = _dirplr + 360
? _dirplr > 360: _dirplr = _dirplr - 360
;;turn the lookout to the same direction as the lightbeam, so the lookout can spot the player when he runs through the lightbeam
_lookout setdir getdir _mg
; -- If the player is within 5 degrees of the MG's heading (in the searchlight) and the MG knows the player
; -- is there, the alarm is tripped
? (getdir _mg - _dirplr) < 5 and (getdir _mg - _dirplr) > - 5 and (_lookout knowsabout player > 0): detected = true
;exit the script when the lookout's dead, the light stay on, but it doesn't move anymore
?!alive _lookout : exit
;exit the searchloop when the lookout has been hit, and move in directly, an EH "hit" should be better here
?getdammage _lookout > 0.01 : goto "movein"
; -- If the player hasn't been detected the loop repeats
? not (detected) : goto "searchloop"
; The player is detected, the tempgunner ejects (deletehicle _mgg doesn't work! ) and the lookout is the new gunner
_Mgg action ["eject",_mg]
_lookout assignasgunner _mg
_lookout moveingunner _mg
; -- Second loop... tracks the player with the searchlight
; -- finds the bearing from the MG to the player, and makes sure it is within range (0 - 360)
_newhdg = ((getpos player Select 0) - (getpos _mg Select 0)) ATan2 ((getpos player Select 1) - (getpos _mg Select 1))
? _newhdg < 0: _newhdg = _newhdg + 360
? _newhdg > 360: _newhdg = _newhdg - 360
; -- Moves the direction of the MG depending on the bearing to the player
? (getdir _mg - _newhdg) > 0 and (_lookout knowsabout player > 1): _mg setdir ((getdir _mg) - 2)
? (getdir _mg - _newhdg) < 0 and (_lookout knowsabout player > 1): _mg setdir ((getdir _mg) + 2)
; -- If there is still a live gunner manning the MG the loop goes around again
? (east countside (crew _mg) > 0): goto "detectedloop"
; when the lookout dies, the temp gunner is the new gunner, the light stays on but it won't move
_mgg assignasgunner _mg
_mgg moveingunner _mg
1) Place an empty M2 machinegun (probably in a tower)
2) Place a lookout very close to the mg, right behind the mg works best.
the arguments: [Machinegun, left limit of search arc, right limit of search arc,name of the lookout]
eg. [mg1,90,270,lookout]] exec "SL.sqs"
If you like stealth missions Project IGI style, give it a try.
I also have another version where the lookout reacts when he spots dead bodies, but it's not very user friendly. I need help
I wouild like to know how I can add and 5th argument : an array of the names of potential bodies, something like :
[mg1,90,270,lookout,[unit1,unit2,unit3]] exec "SL.sqs"
When he spots a corps he'll bring his light in position and sound the alarm and continue searching the player...
Searchlights are scary!