Jump to content
Sign in to follow this  
shuko

SHK_searchlight

Recommended Posts

I was making a night raid mission and wasn't happy with static searchlights. Here is my try to improve them. This was done in a couple of hours, so I'm looking for brave people to test it out and report bugs etc.

You can specify a sector for a light to scan. It's also possible to define if the light should focus on specific target(s), the default is all players. It will follow the target until the target dies or light operator can't see it anymore. Either way, it will continue scanning the sector after that.

SHK_searchlight.rar

Parameters:

0: Object or Array   SearchLight to be used. If operator unit doesn't start
                    in the light, give the searchlight and the user in array.

1: Number or Array   Sector to scan can be given as width of the sector,
                    middle of the sector is the direction to which the
                    searchlight is facing at the start. Or the sector can be
                    given as an array containing the left and right borders
                    of the sector in compass directions.

2: Number            Optional. Knowsabout value. Stop scan when a target is
                    spotted, focus on the target. Default is 1. 0 is no focusing.

3: Array             Optional. Array of units the searchlight will focus
                    on once it detects them. Default is all playableunits.

Searchlight variables:

SHK_Searchlight_Knowsabout    Level of detection required for target focusing.
SHK_Searchlight_Sector        Scan sector. Use array only.
SHK_Searchlight_Targets       Array of units the light will focus on.

Read-only:
SHK_Searchlight_LightDamage   Level of damage done to the actual light.
SHK_Searchlight_Status        What is the light doing?
                               0: nothing, fsm stopped
                               1: fsm started
                               2: scanning sector
                               3: focusing on a target

Starting examples:

nul = [sl,180] execfsm "shk_searchlight.fsm"
nul = [sl,[90,180]] execfsm "shk_searchlight.fsm"
nul = [[sl,slOp],180] execfsm "shk_searchlight.fsm"
nul = [[sl,slOp],[90,180]] execfsm "shk_searchlight.fsm"
nul = [sl,180,0] execfsm "shk_searchlight.fsm"
nul = [sl,180,1,[trg1,trg2,trg3]] execfsm "shk_searchlight.fsm"

OUejsRRMUws

Edited by Shuko

Share this post


Link to post
Share on other sites

well done, i can forsee usage with Invasion 44 and similar (even on AntiAir searchlights tracking for planes, locking on it then flaks and mgs focus :) yay

and ofc area guarding ;)

Share this post


Link to post
Share on other sites

Updated

Changed so that you can change parameters with setvariable while a light is scanning, instead of living with the parameters given once at the start.

Changed the 3rd parameter so that with it you define the knowsabout value, which determines level of detection/identification required for focusing.

Share this post


Link to post
Share on other sites

Indeed very nice script mate!! i´ve got a question though, does the fact that the AI in the video is using NVG´s affects the way it recognizes the threads? by threads i mean the guys standing on the other side of the searchlight. Lookinf forward to test this script. Cheers

Share this post


Link to post
Share on other sites

Another very useful script, thanks! :)

Share this post


Link to post
Share on other sites
Indeed very nice script mate!! i´ve got a question though, does the fact that the AI in the video is using NVG´s affects the way it recognizes the threads? by threads i mean the guys standing on the other side of the searchlight. Lookinf forward to test this script. Cheers

NVGs improve detection ability a lot. The detection is based on knowsAbout.

Share this post


Link to post
Share on other sites

Is there anyway to either integrate this with BIN_taskdefend and/or run it by detecting if theres a searchlight? im trying to spawn a random composition, in a random location then detect if that composition has a searchlight, and if it does add a guy and execut this script on it?

Share this post


Link to post
Share on other sites

After creating comp.

1. Find searchlight (nearobjects etc commands for example)

2. Create a unit to operate it

3. Start the FSM

Share this post


Link to post
Share on other sites

i know nothing about nearobjects command, any way you can help me out with it, i can do the rest jsut not detect the searchlight :(

Share this post


Link to post
Share on other sites

Well, didn't bother testing this (have to leave something for you to do :P).

_pos = getmarkerpos "compCenter";
_objs = nearestObjects [_pos, ["Searchlight"], 200];
if (count _objs > 0) then {
 _o = (creategroup WEST) createunit ["USMC_Soldier",_pos,[],0,"none"];
 _sl = _objs select 0;
 _o moveingunner _sl;
 [_sl,[123,234]] execfsm "shk_searchlight.fsm";
};

Edited by Shuko

Share this post


Link to post
Share on other sites

will do, but arent there different kinds of searchlights? Like _RU and _USMC?

Share this post


Link to post
Share on other sites

Ah, so it will auto-jamatically grab all base searchlights, brilliant :)

Share this post


Link to post
Share on other sites

Yeah, the searchlight A.I. is completely retarded. You have to turn the skill level up all of the way to get anything approaching normal behavior, but they still don't scan that much. If, however, you move into their cone they will then aim the light at you and follow you with it.

The problem with turning their skill level up enough to get somewhat normal searchlight behavior is that if they dismount, you now have a super-human trooper to contend with.

Share this post


Link to post
Share on other sites

Updated

Added a variable to check what the light is currently doing.

SHK_Searchlight_Status

0: nothing, fsm stopped

1: fsm started

2: scanning sector

3: focusing on a target

Share this post


Link to post
Share on other sites

Great work Shuko!

Exactly what i need for my current mission...

Working very well. Thank you! :cool:

Share this post


Link to post
Share on other sites
well done, i can forsee usage with Invasion 44 and similar (even on AntiAir searchlights tracking for planes, locking on it then flaks and mgs focus :) yay

and ofc area guarding ;)

Did this ever happen? (The AntiAir searchlight I mean} I've been searching for a long while but never came up with anything that could throw out a powerful enough beam to simulate the'Blitz' WWII type cones of light? I don't have the know-how to put it together but I'd still like to see one - is it possible? If not A2 - A3?

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  

×