Jump to content
Sign in to follow this  
tmortensen

Helicopter Spotlight (AI, Night mission)

Recommended Posts

I have spent the past several hours trying to make an AI chopper on my night mission patrol WITH its spotlight on.

I have tried script such as:

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

however this only beats the pilot to turning the headlights off every 0.01 seconds. And epileptic fits is not what I want for my teammates.

I have also tried

if (isServer) then {0=[this]spawn{while{alive driver (_this select 0)}do{driver (_this select 0) action ["LightOn", (_this select 0)]}}};

again this flickers the light.

Several other scripts have only seen collision lights. lightOn function in a vehicle (i.e. Ifrit) will set the headlights on, but not in a heli. does the lightOn function only turn collision lights on or is it actually the headlight/spotlight?

Alternative methods:

I have come across scripts such as #lightpoint

light = "#lightpoint" createVehicleLocal position this; light setLightBrightness 0.05; light setLightAmbient[0.0, 0.0, 0.0]; light setLightColor[1.0, 1.0, 1.0]; light lightAttachObject [this, [0,0,-10]];light = "#lightpoint" createVehicleLocal position this; light setLightBrightness 0.9; light setLightAmbient[0.0, 0.0, 0.0]; light setLightColor[0.7, 0.7, 1.0]; light lightAttachObject [this, [0,30,-20]];

this I have attempted to move the light point to 20 below and 30 in front of the chopper. However it is unfocused and it doesn't reach the ground at certain points of heli flight. (unless someone can amalgamate the script to see the light object at ground level as a constant?)

And yes I understand careless, seek and destroy, and safe patrol techniques turn the collisions lights on.

Main question:

Is there a way of setting an AI helicopters FRONT lights on constant?

Cheers

Share this post


Link to post
Share on other sites

"if (isServer) then {0=[this]spawn{while{alive driver (_this select 0)}do{driver (_this select 0) action ["LightOn", (_this select 0)]}}};" plop that right into the heli's init (without quotes) and it will work.

Share this post


Link to post
Share on other sites

This is currently a huge problem with every vehicles that have additional collision lights.

Instead of using the main lights the AI will always turn on/off the collision lights, depending of the combat behavior.

So no matter which behavior is set, AI will completely ignore the main lights on all vehicles with collision lights, currently all choppers, SDVs and speedboats.

I made a feedback tracker entry and hope you guys can help me to upvote this issue.

http://feedback.arma3.com/view.php?id=15487

I hope BIS will look into this and fix it soon, since it's probably one of the biggest immersion breakers right now.

With all that new lighting going on it's a pity that this issue is still in the game.

Share this post


Link to post
Share on other sites

@kunsa gunlights dont function. Dont think gunlights are included in A3

@mangler I believe I have tried this, ill give it a second bash later today. My mid somewhat melted lastnight.

@Grumpy Voted. You say you updated a mission file? What config did you tweak? As im looking to set up a repo on PWS for clan use, will it need to be distriutable? Also I feel im turning into a Grumpy Old Man mk.2

Cheers gents

Share this post


Link to post
Share on other sites

@tmortensen

don't know anything about play with six since I'm not using it myself.

I didn't tweak any settings, just removed some addon dependencies from the mission.sqm that would throw some errors

thanks for the vote, hope others will chime in

Share this post


Link to post
Share on other sites
"if (isServer) then {0=[this]spawn{while{alive driver (_this select 0)}do{driver (_this select 0) action ["LightOn", (_this select 0)]}}};" plop that right into the heli's init (without quotes) and it will work.

Again this flickers (at a lower rate as previous 0.01 script, granted).

I believe as it is forcing the driver to perform such an action over and over.

Close though

Share this post


Link to post
Share on other sites

I'm using this code and I don't have any flickering.

this setBehaviour "SAFE";   this setCombatMode "RED";   player action ["lightOn", this]; this setBehaviour "SAFE";   null=[] spawn { while {true} do {  player action ["lightOn", nameofyourheli];sleep 0.01};};  

It's a bit confusing and stuff, but it's working, at least for me.

Share this post


Link to post
Share on other sites
I'm using this code and I don't have any flickering.

this setBehaviour "SAFE";   this setCombatMode "RED";   player action ["lightOn", this]; this setBehaviour "SAFE";   null=[] spawn { while {true} do {  player action ["lightOn", nameofyourheli];sleep 0.01};};  

It's a bit confusing and stuff, but it's working, at least for me.

Beautiful.

Shame there isn't just a function to set to force on constant, rather than going all boolean on it.

Cheers brah

Share this post


Link to post
Share on other sites

Glad that it's working for you too, anyway this code is not mine, I found it in the forum time ago.

Share this post


Link to post
Share on other sites

Hi everyone,

 

I had tried all of the suggested work-arounds but still got the flickering. However, I had heard about attaching a vehicle with lights to a helicopter with attachTo command and then turning the lights of the attached vehicle on. This results in no flicker at all.

 

I eventually discovered that the remote controlled drone (AR-2 Darter) is ideal for this purpose as its light is very similar to, for example, the Pawnee search light. It is also very small and so can be virtually hidden in the body of the Pawnee etc. So this is the resulting code:

 

(I created a script called YB_enemyHeliSearchLight.sqf containing the following code and then put it in mission root direcotry and then executed it using: null = _enemyHeliDriver execVM "YB_enemyHeliSearchLight.sqf";  where a driver / pilot of an enemy (i.e. AI) helicopter (of Pawnee body type) has been made equal to _enemyHeliDriver):

if (isServer) then
	{	private ["_driver", "_enHeli"];
		//Prepare variables:
		_driver = _this;
		_enHeli = vehicle _this;

		while {sleep 60; true} do
			{
				//Wait until it is night time:
				waitUntil {sleep 30; (dayTime > 20 || dayTime < 4)};

				//Create "search light" (UAV) and attach it to the helicopter:	
				_uav = "B_UAV_01_F" createVehicle getPos _enHeli; 
				_uav attachTo [_enHeli, [0,1.5,-0.5]]; _uav setVectorUp [0, 0.5, 1];	
				
				//Wait until helicopter takes off:
				waitUntil {sleep random 30; (getPosATL _enHeli select 2) > 5};
					
				//If still night time, turn the search light on:
				if (dayTime > 18 || dayTime < 7) then
					{
						_driver action ["lightOn", _uav];
					};
						
				//Wait until helicopter lands, is destroyed, or it is day time:
				waitUntil {sleep 3; (getPosATL _enHeli select 2) < 5 || damage _enHeli == 1 || (dayTime < 20 && dayTime > 4)};
				
				//Delete search light:
				_driver action ["lightOff", _uav];
				deleteVehicle _uav;
				
				//Rinse, repeat via the while-do loop, in case helicopter takes off again / it becomes night again etc.		
			};
	};

 Hope this helps.

 

Cheers from Far North Queensland, Australia

 

PS: If you want this enemy helicopter to "stalk" / "hunt" a player, you can set a way point such as this on a regular basis:

//NB: curTargP1 needs to be first set as a player you are wanting the helicopter to pursue
//NB: _driver needs to be first set as the enemy (AI) unit piloting the helicopter

curTargPos = [	((getPos curTargP1 select 0) + (_enSpreadDist - (random _enSpreadDist * 2))), 
		((getPos curTargP1 select 1) + (_enSpreadDist - (random _enSpreadDist * 2))), 
		(getPos curTargP1 select 2)];	
			
deleteWaypoint [group _driver, 0]; //Ensure previous waypoint deleted
_heliWaypoint = group _driver addWaypoint [curTargPos, 0, 0];
_heliWaypoint setWaypointType "LOITER";
_heliWaypoint setWaypointLoiterType "CIRCLE_S";
_heliWaypoint setWaypointLoiterRadius 100;
//Make sure helicopter moves slowly and scarily!:
_heliWaypoint setWaypointSpeed "LIMITED";
_heliWaypoint setWaypointBehaviour "COMBAT";
_heliWaypoint setWaypointCombatMode "RED";
group _driver setCurrentWaypoint _heliWaypoint;

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  

×