Jump to content
Sign in to follow this  
Blitzen88

Applying NVG Settings to all units of side

Recommended Posts

I know this is a heavily discussed issue but I can't piece it together despite searching and trying for several hours.  Im trying to setup a script which will remove or add NVG goggles to each side based upon how the script is called via init.  The idea is to setup an easy and fast way to quickly configure NVG settings for each side.

 

This is what I have but I cant get it to work:

 

/*==========================================================================================
				Arma III AI NightVision Settings
===========================================================================================*/
//	1) East NVG Setting - "True" to Add NVGs for all East Units, "False" to Remove NVGs for all East Units
//	2) West NVG Setting - "True" to Add NVGs for all West Units, "False" to Remove NVGs for all West Units
//	3) Independent NVG Setting - "True" to Add NVGs for all Independent Units, "False" to Remove NVGs for all Independent Units
//	4) IR Laser Setting - "True" to enable IR Lasers for all units equipped with NVGs, "False" to disable IR Lasers for all units with NVGs
//	5) Amount of time (in seconds) that will pass before the script loops
		
_EastNVG = _this select 0;
_WestNVG = _this select 1;
_AAFNVG = _this select 2;
_IRLaser = _this select 3;
_Time = _this select 4;

if (_EastNVG) then {
		{
			if ((side _x) == East) then {			
			_x linkitem "NV_Goggles_Opfor";			
			_x action ["nvGoggles", _x];			
			_x EnableIRLasers _LaserSetting;			
			};			
		} forEach allUnits;
	} else {
		{
			if ((side _x) == East) then {			
			_x unlinkItem hmd _x;			
			_x EnableIRLasers False;
			};		
		} forEach allUnits;
	};

Systemchat "AI NightVision Settings Loaded";
sleep _time;
[] execvm Script.sqf

 

My goal is do something like that for each side (East, West, Indep).  If the input from init is "True" then the unit is given NVGs and they can operate their IR laser.  If the setting is set to "False" then the NVGs are removed and their IR laser is turned off.  The script is not complete but I cant get it to work for one side so I havent attempted to make it work for all the other sides.

 

 

Share this post


Link to post
Share on other sites

I got it to work if anyone wants to check it out.

 

/*==========================================================================================

				Arma III AI NightVision Settings

===========================================================================================

* Applies or removes nightvision goggles to all units of a particular side based upon the settings defined in Init

* Runs on initialization and will apply nightvision settings to units placed by the mission maker at the start of the mission

* Script loops in intervarls to account for units spawned after the start of the mission

* Captive units (setcaptive true) will not be effected by this script

* Call with: Called via Init.sqf

===========================================================================================*/

//Define Variables/Input Selection

_EastNVG = _this select 0;

_WestNVG = _this select 1;

_IndependentNVG = _this select 2;

_LaserSetting = _this select 3;

_Time = _this select 4;

//START
While {True} do {

//Create Arrays

_AllEastUnits = [];

_AllWestUnits = [];

_AllIndependentUnits = [];

//"Filter" Units into their respective Arrays

{If ((side _x) == East) then {_AllEastUnits pushBack _x}} forEach allUnits;

{If ((side _x) == West) then {_AllWestUnits pushBack _x}} forEach allUnits;

{If ((side _x) == Independent) then {_AllIndependentUnits pushBack _x}} forEach allUnits;

//East
//---------------------------------------

if (_EastNVG) then {
	
	{_x linkitem "NVGoggles_Opfor"; _x action ["nvGoggles", _x]; _x EnableIRLasers _LaserSetting} foreach _AllEastUnits;
	
} else {

	{_x unlinkItem hmd _x; _x EnableIRLasers False} foreach _AllEastUnits;

	};
//West
//---------------------------------------

if (_WestNVG) then {
	
	{_x linkitem "NVGoggles"; _x action ["nvGoggles", _x]; _x EnableIRLasers _LaserSetting} foreach _AllWestUnits;
	
} else {

	{_x unlinkItem hmd _x; _x EnableIRLasers False} foreach _AllWestUnits;

	};

//Independent
//---------------------------------------

if (_IndependentNVG) then {
	
	{_x linkitem "NVGoggles_Opfor"; _x action ["nvGoggles", _x]; _x EnableIRLasers _LaserSetting} foreach _AllIndependentUnits;
	
} else {

	{_x unlinkItem hmd _x; _x EnableIRLasers False} foreach _AllIndependentUnits;

	};

Systemchat "AI NVG Settings Loaded";

Sleep _Time;

//END
};

 

  • Like 1

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  

×