Jump to content
Sign in to follow this  
Ronin[NR]

Searchlights

Recommended Posts

Hi All,

I've been working on a script to make searchlights... well, search :D. Ideal for those blackop style missions to add atmosphere. I searched the forum and couldn't find one. This is based on an old SQS script (Sorry, cant remember the author, you know who you are :)) to do the same thing, have just updated it to SQF.

Real simple and easy thing, thought I'd post it here for peeps to use and comment on and hopefully improve if poss.

I'd like to change the angle at which the light is searching, make it a little more close to the search light as opposed to searching the countryside :)

This would involve vectors I believe, but, not sure how these work, wiki doesn't give any examples of how I should use them.

if ( isServer ) then
{
searcher = "true";

while {searcher == "true"} do
{
	_unit = _this select 0;
	_left = _this select 1;
	_right = _this select 2;

	_dir = getDir _unit;

	while {( alive _unit ) && ( _dir <= _right )} do 
	{
		sleep 0.5;
		_dir = _dir+1;
		_unit setformdir _dir;
	};

	sleep 2;

	while {( alive _unit ) && ( _dir >= _left )} do 
	{
		sleep 0.5;
		_dir = _dir-1;
		_unit setformdir _dir;
	};

	sleep 2;
};

} else 
{};

This should work on locally hosted and dedicated servers.

Only one limitation at the moment:

The script uses GetDir. Now, because of the way this is set up, if you have a searchlight set at 0 azimuth and you want the light to search left to say 270, then right to 90, it won't work. If you flip this around however and set it to search left to 90 and right to 270, it would work okie.

Also, if the light spots someone, it will lookat it, but then, continue to search. Kinda like 'Haha, found you, but, it doesn't matter that your a spec op and going to kill my friends, I'll just carry on searching' :D

Would like a way for the light to stop searching when it does find an enemy.

Anyways, hope you like.

Example:

Searchlight Example

Share this post


Link to post
Share on other sites
You want to download the following file:

http://rapidshare.com/files/326593338/searchlight_test.utes.rar | 1 KB

This file can only be downloaded by becoming a Premium member

There are no more download slots available for free users right now. If you don't want to become a premium member, you might want to try again later.

Any chance of using a better upload site? rapidshare and megaupload are terrible. Take a look at filesmelt.

Share this post


Link to post
Share on other sites

I use a script along the lines of your script Ronin =ASP=, one thing I do differently is to check for both the unit and the gunners alive status as I like to group several men to searchlight or machinegun.

The only way I've seen searchlights looking up is to rotate an object infont of the searchlight and have them dowatch target.

Share this post


Link to post
Share on other sites

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

// 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.

Share this post


Link to post
Share on other sites

An example mission would be greatly appreciated! :)

Please use file front as rapidshare is as good as a three legged horse!

Share this post


Link to post
Share on other sites
An example mission would be greatly appreciated! :)

Please use file front as rapidshare is as good as a three legged horse!

Here is an example mission for the searchlight. There are 2 searchlights on the roof of the utes control tower. You will see how they only scan their respective sides. The delay seems to work in their "default" facing anyway. Not sure what that's about. But it looks much better than them doing nothing or pointing directions that don't make sense.

Share this post


Link to post
Share on other sites

Very nice nice script, thx for your work!

Put it on our scripts section at Assault Mission Studio. I made also a little movie to show the script in action.

dlicon.gif

Searchlight Aiming Script by Deathcon5

FxNOxxopGp0

@Ronin =ASP=: I wait for uploading your script. But Rapidshare don't like me atm :)

Edited by Imutep

Share this post


Link to post
Share on other sites

Why is it that it seems they refuse to work after 2-3 turns in OA.

Nm got it working.

Edited by SGTIce

Share this post


Link to post
Share on other sites

Cool ronin! Works fine :)

But! It could be so much cooler! ;) If the searchlight operator sees a enemy unit he stops the search and follows the unit. Then activating something we could use in a trigger for an alarm or a search-team etc. And if he looses sight of the unit he returns to the searching.

Im not good at scripting, so I have no idea if its possible. But it would be so sweet ;)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×