Jump to content
Sign in to follow this  
mestoth

Helicopter Search Lights (AI) without sleep command (post 1.34)

Recommended Posts

Even in 1.34 (with the 'helicopters DLC') AI Helicopters at night wont use search lights. Many people have suggested

  null=[] spawn { while {true} do {  player action ["lightOn", heli]; player action ["collisionlightOn", heli]; sleep 0.01};}; 

After much testing with Lecks from ASOR http://www.armaholic.com/page.php?id=26181\ www.asor.com.au) we have found a solution that does not require a sleep 0.01 loop (which destroys MP missions due to lag). Full credit to Lecks for coming up with the code.

this is a copy paste from my mission script where I want the choppers to surround (but not shoot) for a "capture" mission. Hence the careless and captive true. They also started as simulation disabled, so remove this if your choppers are active to start with. I wait 30 seconds so they can take off the ground prior to the clone thing - sometimes in uneven terrain they will blow up if you dont wait for them to take off and be airborne.

HINT "Lights SCRIPT RUNNING";
(driver _this) setCaptive true;
(group driver _this) setBehaviour "Careless";
(driver _this) setBehaviour "Careless";
_this enablesimulation true; _this enablesimulationglobal true;
sleep 30;
_type = typeOf _this;
_copy = _type createVehicle getPos _this;
_copy setHit [getText(configFile >> "cfgVehicles" >> (typeof _copy) >> "HitPoints" >> "HitHRotor" >> "name"), 1];
_copy attachTo [_this, [0,0,0]];
_copy setPilotLight true;
_copy setCollisionLight true;
_copy engineOn true;
(driver _this) setCaptive true;

This should allow you to have choppers fly with search lights without a sleep command (and the resultant lag!). I suggest for uneven terrain you set the helicopter as non simulated, then enable the simulation so it can take off BEFORE you clone it. It may explode:

Known Issue: Roter blades may look a bit messed up, but at night with a Searchlight on, you cant see it anyway :)

Edited by mestoth

Share this post


Link to post
Share on other sites

Just want to mention side effects of this..

-It probably won't work when you destroy the chopper (not sure what would happen.. didn't matter for our mission).

-As mestoth mentioned, you can see the still rotor blades of the copy of the chopper. the setHit was an attempt to break them but didn't work.

-Might look weird close up.

The relevant parts of the code for forcing the lights on are (assuming _this == the chopper):

_type = typeOf _this;
_copy = _type createVehicle getPos _this;
_copy attachTo [_this, [0,0,0]];
_copy setPilotLight true;
_copy setCollisionLight true;

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  

×