Jump to content
Sign in to follow this  
[lol]clan killer bee

Searchlight & Mg post !

Recommended Posts

Now this is really strange and it happened last time with my own test.

When I place the recorded data into the data folder the game can't see the recorded data.

I have to place it in the main folder and change the code accordingly

Anyway it's the only way I can get it to work..

Then it probably doesn't work for me since mine is in the data folder. ;)

Perhaps we can change the code to make it see the data folder?

Share this post


Link to post
Share on other sites

I'm not sure what you guys are doing wrong, but if you look at the UnitCapture and UnitPlay thread there are plenty of examples there. This script is basically a modification of those functions; the basic concepts of how to use them is the same.

If you recorded the data correctly, it should look something like this:

[[0,[0.513916,29.9929,-0.36095]],[0.0679998,[0.513916,29.9929,-0.36095]],[0.112,[0.513916,29.9929,-0.36095]],...]

One big array with subarrays containing a time and a position.

Calling it is simply a matter of spawning the function on the searchlight vehicle (preferably while it's manned) and passing the recorded data. You can pass the data however you want; you could even paste the whole array into the call arguments. I just used txt files to make it more organized. To do this I used loadFile. LoadFile will load any text based file into a single long string. You need to pass it the relative path and filename. Once loaded as a string, the compile command will parse it into code; in this case back into an array.

If this method doesn't work for you, you could instead paste the recorded data into the init.sqf and assign a global variable to it. Ex:

myData = [[0,[0.513916,29.9929,-0.36095]],[0.0679998,[0.513916,29.9929,-0.36095]],[0.112,[0.513916,29.9929,-0.36095]],...]

Then just pass myData to the play function.

Share this post


Link to post
Share on other sites

Something odd is going on, the supplied data does not work in my tests but works in the example, my data did not work in the example I provided, captured in another map BTW, seems like it is map and or position dependent?

Edited by callihn

Share this post


Link to post
Share on other sites
Something odd is going on, the supplied data does not work in my tests but works in the example, my data did not work in the example I provided, captured in another map BTW, seems like it is map and or position dependent?

It depends on how you are capturing and playing it. There are two versions of each function:

Relative and Normal (Absolute). The relative functions will capture and play data relative to the position and orientation of the searchlight, while absolute functions will record positions on the map: so moving your light will cause the scan pattern to change relatively.

Another thing you should be aware of is initialization. If you are using the initialization from the example init.sqf, you will need to ensure that the functions have initialized before you call them. Adding a slight delay to your trigger should ensure this.

Edited by Big Dawg KS

Share this post


Link to post
Share on other sites

What about using multiple lights, can we just add them to that trigger?

Share this post


Link to post
Share on other sites

In the example I posted above it has two lights using the same data, one on an empty gun and the other on a radio call.

You could have them on the same trigger as well.

Share this post


Link to post
Share on other sites

Or I suppose you could add all that to a script and call it from the trigger with execvm too huh?

Probably be easier than working in the init box in the editor.

I don't guess there is a smoother way to do it like button to rotate left and right?

If not I think we could use that, the choppers have it and I think it would be great in the gunner seats too, I keep my axis turned down fairly slow on my mouse.

I have that other script which I could use for just capturing a basic left to right and back type of scaning, but i do not know how to get the light to point up more, tried setVector on the light but it just turned the light over.

Edited by callihn

Share this post


Link to post
Share on other sites

It's not a problem putting it into a script after all code placed in an init or trigger is just script anyway.

If your using script though you may and well just script do operate the searchlight any way.

All though you can't do as complicated a pattern and it may be more difficult to apply to a gunner of a chopper.

;// nul=[name,degofrotation] execVM "movesearchlight.sqf";
;// nul=[unitsname,90] execVM "movesearchlight.sqf";
_unit = _this select 0;
_deg  = _this select 1;

_face = getdir _unit;
_gman = (gunner (vehicle _unit));

while {(alive _gman) &&  (alive _unit)} do
{
_gman setformdir _face+((random -(_deg)+(_deg/2)));

sleep (random 6)+2;
};

I just tried recording the gunner of a vehicle but it doesn't work very well, using a stationary vehicle it's fine but if the vehicle moves and it didn't in the recording is fails.

I tried both methods of recording the data.

Edited by F2k Sel

Share this post


Link to post
Share on other sites
It's not a problem putting it into a script after all code placed in an init or trigger is just script anyway.

If your using script though you may and well just script do operate the searchlight any way.

All though you can't do as complicated a pattern and it may be more difficult to apply to a gunner of a chopper.

;// nul=[name,degofrotation] execVM "movesearchlight.sqf";
;// nul=[unitsname,90] execVM "movesearchlight.sqf";
_unit = _this select 0;
_deg  = _this select 1;

_face = getdir _unit;
_gman = (gunner (vehicle _unit));

while {(alive _gman) &&  (alive _unit)} do
{
_gman setformdir _face+((random -(_deg)+(_deg/2)));

sleep (random 6)+2;
};

I just tried recording the gunner of a vehicle but it doesn't work very well, using a stationary vehicle it's fine but if the vehicle moves and it didn't in the recording is fails.

I tried both methods of recording the data.

Yea I already have a script but it does not do anything when it spots enemies, so.

Did you try the relative capture and playback?

Share this post


Link to post
Share on other sites
Yea I already have a script but it does not do anything when it spots enemies, so.

Did you try the relative capture and playback?

Yes I tried them both.

Share this post


Link to post
Share on other sites

Something else I think I've found, it seems like after a certain amount of time recording say 60 seconds and I can not get it to work, it moves some, but nothing like it is suppose to.

Tried in the same trigger and a separate trigger.

Have you tried longer data recordings?

I think this might work better if it just recorded the degrees and the Z axis.

Edited by callihn

Share this post


Link to post
Share on other sites

I've just tried a couple at about 90 seconds and it seemed ok, I also tried to record the gunner of a vehicle again but that always messes up. It only works correctly while stationary.

Share this post


Link to post
Share on other sites

So that mean a empty searchlight than you let someone step in ?

I just asked for some help and I got lost after my last post !:eek:

This don't make no sense at all ?

Edited by [LOL]clan Killer Bee

Share this post


Link to post
Share on other sites

If you are trying to record/play on a moving vehicle, keep in mind the following:

- Using a Relative capture/playback, the captured data is relative to the vehicle itself, not the gunner. However, the unit you pass to the play function can specifically be the gunner. If the vehicle moves or rotates, the search pattern will move/rotate with it. For example, if you record a pattern that sweeps about 90 degrees left and right, it will always be 90 degrees from the direction of the vehicle. Also, since the scripts use doWatch, the playback may not be 100% accurate, but when I tested it seemed to be pretty close.

- Using an Absolute capture/playback, the function captures world positions that are approximately 30m in the direction you are aiming. When playing it back, the gunner will attempt to watch those exact positions. For gunners with limited traverse, it obviously may not always be possible to aim at those spots.

Share this post


Link to post
Share on other sites

I can't seem to get two to play back at the same time for some reason.

I also noticed that the Z axis is off when recording from a height like a building you have to aim a higher than you want it played back at.

Share this post


Link to post
Share on other sites
If you are trying to record/play on a moving vehicle, keep in mind the following:

- Using a Relative capture/playback, the captured data is relative to the vehicle itself, not the gunner. However, the unit you pass to the play function can specifically be the gunner. If the vehicle moves or rotates, the search pattern will move/rotate with it. For example, if you record a pattern that sweeps about 90 degrees left and right, it will always be 90 degrees from the direction of the vehicle. Also, since the scripts use doWatch, the playback may not be 100% accurate, but when I tested it seemed to be pretty close.

- Using an Absolute capture/playback, the function captures world positions that are approximately 30m in the direction you are aiming. When playing it back, the gunner will attempt to watch those exact positions. For gunners with limited traverse, it obviously may not always be possible to aim at those spots.

This is what I did to capture the gunner of a vehicle, I put myself in the gunner position and recorded the data relative and saved the data then repeated with absolute. The vehicle was stationary. If I later start the vehicle moving which one should I use if it can be done that way.

When I try it it either just turns in one direction and stop or I get a very limited search pattern nothing like the one recorded.

Share this post


Link to post
Share on other sites
I put myself in the gunner position and recorded the data relative and saved the data then repeated with absolute.

The recorded data is different, you should not record with one method and play with the other.

---------- Post added at 08:55 AM ---------- Previous post was at 08:51 AM ----------

I also noticed that the Z axis is off when recording from a height like a building you have to aim a higher than you want it played back at.

That seems odd. The record function should definately capture the correct height.

Share this post


Link to post
Share on other sites

I decided I've had enough of the mystery so I went with something that works consistently:

/*
SEARCHLIGHT AIMING SCRIPT WITH ENEMY TARGETING
By Deathcon5 && Big Dawg KS && Modified By SoNumb
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 directions, and so on. If an enemy is spotted the 
light will target the enemy and if configured alert a gunner to the enemy.
obj - The unit searching, use this in editor or the unit name.
face1-10 - The 10 directions you select that the unit will randomly face.
randomdelay+5 - The random element of the delay between positions to which 5 seconds will be added.
gunnerName ( optional ) - The name of a gunnner you want to have alerted to the enemy.
Unit init line:
null=[obj,face1,face2,face3,face4,face5,face6,face7,face8,face9,face10,randomdelay+5,[gunnerName]] execVM "randomSearchlight.sqf"
*/
private ["_selectedface","_unit","_deg1","_deg2","_deg3","_deg4","_deg5","_deg6","_deg7","_deg8","_deg9","_deg10","_delay","_list","_gman","_additionalGuns","_enemy","_grp"];
_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;
_additionalGuns = [];
if(count _this > 12)then{_additionalGuns = _this select 12};
_list = [_deg1, _deg2, _deg3, _deg4, _deg5, _deg6, _deg7, _deg8, _deg9, _deg10];
_gman = (gunner (vehicle _unit));
_grp = group _gman;
while {(alive _gman) &&  (alive _unit)} do {
waitUntil{
 _enemy = _gman findNearestEnemy _gman;
 _gman doWatch _enemy;
 _gman doTarget _enemy;
 {_X doWatch _enemy; _X doTarget _enemy} forEach _additionalGuns;
 sleep random 5;
 !({(_grp knowsAbout (vehicle _X) >= 1) && (_unit countEnemy [vehicle _X] > 0)} count allUnits > 0) || (isNull _enemy);
};
_selectedface = _list select (round(random(count _list)));
_gman setformdir _selectedface;
sleep (random _delay)+5;
};

Light version which only requires three directions:

/*
SEARCHLIGHT AIMING SCRIPT WITH ENEMY TARGETING -LIGHT
By Deathcon5 && Big Dawg KS && Modified By SoNumb
This script picks at random 1 of 3 facings you want it to scan, looks that direction for several 
seconds, then randomly picks another 1 of your 10 directions, and so on. If an enemy is spotted the 
light will target the enemy and if configured alert a gunner to the enemy.
obj - The unit searching, use this in editor or the unit name.
face1-3 - The 3 directions you select that the unit will randomly face.
randomdelay+5 - The random element of the delay between positions to which 5 seconds will be added.
gunnerName ( optional ) - The name of a gunnner you want to have alerted to the enemy.
Unit init line:
null=[obj,face1,face2,face3,randomdelay+5,[gunnerName]] execVM "randomSearchlightLight.sqf"
*/
private ["_selectedface","_unit","_deg1","_deg2","_deg3","_delay","_list","_gman","_additionalGuns","_enemy","_grp"];
_unit = _this select 0;
_deg1 = _this select 1;
_deg2 = _this select 2;
_deg3 = _this select 3;
_delay = _this select 4;
_additionalGuns = [];
if(count _this > 5)then{_additionalGuns = _this select 5};
_list = [_deg1, _deg2, _deg3];
_gman = (gunner (vehicle _unit));
_grp = group _gman;
while {(alive _gman) &&  (alive _unit)} do {
waitUntil{
 _enemy = _gman findNearestEnemy _gman;
 _gman doWatch _enemy;
 _gman doTarget _enemy;
 {_X doWatch _enemy; _X doTarget _enemy} forEach _additionalGuns;
 sleep random 5;
 !({(_grp knowsAbout (vehicle _X) >= 1) && (_unit countEnemy [vehicle _X] > 0)} count allUnits > 0) || (isNull _enemy);
};
_selectedface = _list select (round(random(count _list)));
_gman setformdir _selectedface;
sleep (random _delay)+5;
};

Edited by callihn

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  

×