Thread: Searchlights
View Single Post
Old 01-17-2010, 11:44 PM   #5
Deathcon5
Private First Class
 
Join Date: Jul 2009
Posts: 37
aiming the search light

I needed to have the search light aim only in a certain arc. (Imagine the man with the light standing in front of a wall and randomly turning and shining it into the wall, not very realistic looking) So, I came up with a script to overcome the whole mathematical issue of 90, 0, 270 etc.. All you have to do is pick 10 possible directions that you would like the searchlight to scan and the script randomly picks one to look at then randomly picks another and another, pausing between scans. It's great for focusing scans on likely avenues of attack, but occasionally scanning elsewhere.

randomSearchlight.sqf
Code:
// SEARCHLIGHT AIMING SCRIPT
// this script picks at random 1 of 10 facings you want it to scan;
// looks that direction for several seconds, then randomly picks another 1 of your 10, and so on;

// obj, the unit searching, use <this> in editor or the unit name;
// face1-10 are the 10 directions you select that the unit will randomly face;
// randomdelay+6 is the random element of the delay; 
// between positions to which 6 seconds will be added;
// put in unit init line:;
// null=[obj,face1,face2,face3,face4,face5,face6,face7,face8,face9,face10,randomdelay+6] execVM "randomSearchlight.sqf";

// randomSearchlight.sqf;



_unit = _this select 0;
_deg1 = _this select 1;
_deg2 = _this select 2;
_deg3 = _this select 3;
_deg4 = _this select 4;
_deg5 = _this select 5;
_deg6 = _this select 6;
_deg7 = _this select 7;
_deg8 = _this select 8;
_deg9 = _this select 9;
_deg10 = _this select 10;
_delay = _this select 11;

_list = [_deg1, _deg2, _deg3, _deg4, _deg5, _deg6, _deg7, _deg8, _deg9, _deg10];
_gman = (gunner (vehicle _unit));

while {(alive _gman) &&  (alive _unit)} do
{
_selectedface = _list select (floor(random(count _list)));

_gman setformdir _selectedface;

sleep (random _delay)+6;

};
Enjoy!

Thanks to F2k Sel for his rotating weapon script to which I added the randomization of the 10 facings, and a timing setting.
Deathcon5 is offline   Reply With Quote