Jump to content

Recommended Posts

 

HI.

Maybe someone can find this usable.

This script adds/removes NVG's at all units besides players according to day/night cycle.

ACE3 compatible.

/*
file: autonvg.sqf
by DaVidoSS

description:
adds/removes nvg according to daytime for each unit
included ace3 nvgs:
"ACE_NVG_Gen1"
"ACE_NVG_Gen2"
"ACE_NVG_Gen4" 
"ACE_NVG_Wide" 

parameters:
none
return:
VOID
usage:
//init.sqf
if (isServer) then {
	0 = [] execVM "autonvg.sqf";
};

*/
private _autonvgOn = createTrigger ["EmptyDetector", [0, 0, 0], false];
_autonvgOn setTriggerActivation ["NONE", "PRESENT", true];
_autonvgOn setTriggerStatements [
"(sunOrMoon < 0.45)",
"
private ['_nvgsw', '_nvgse', '_nvgsi', '_nvgSide', '_itemsUnit', '_commonItemsArray', '_nvg', '_isACE'];
_nvgsw = ['NVGoggles','NVGogglesB_blk_F','NVGogglesB_grn_F','NVGogglesB_gry_F'];
_nvgse = ['NVGoggles_OPFOR','O_NVGoggles_ghex_F','O_NVGoggles_hex_F','O_NVGoggles_urb_F'];
_nvgsi = ['NVGoggles_INDEP','NVGoggles_tna_F'];

_isACE = !isnull (configfile >> 'CfgPatches' >> 'ace_main');
if (_isACE) then {
	_nvgsw = _nvgsw + ['ACE_NVG_Gen4', 'ACE_NVG_Wide'];
	_nvgse = _nvgse + ['ACE_NVG_Gen1'];
	_nvgsi = _nvgsi + ['ACE_NVG_Gen2'];
};
{
	_nvgSide = switch (str (side _x)) do {
		case 'WEST': { _nvgsw };
		case 'EAST': { _nvgse };
		case 'GUER': { _nvgsi };
		default { [] };
    };

	if(alive _x) then	{
		_itemsUnit = (items _x + assignedItems _x);
		_commonItemsArray = _nvgSide arrayIntersect _itemsUnit;
		_nvg = _commonItemsArray select 0;
								
		if (!isNil '_nvg') then	{
			if !(_nvg in (assignedItems _x)) then {
				_x assignItem _nvg;
			};	
		} else {
			_x linkitem (selectRandom _nvgSide);
		};
	};			
} forEach (allUnits select {!isPlayer _x});
",""];

private _autonvgOf = createTrigger ["EmptyDetector", [0, 0, 0], false];
_autonvgOf setTriggerActivation ["NONE", "PRESENT", true];
_autonvgOf setTriggerStatements [
"(sunOrMoon >= 0.45)",
"
private ['_nvgsw', '_nvgse', '_nvgsi', '_itemsUnit', '_commonItemsArray', '_nvg','_isACE'];
_nvgsw = ['NVGoggles','NVGogglesB_blk_F','NVGogglesB_grn_F','NVGogglesB_gry_F'];
_nvgse = ['NVGoggles_OPFOR','O_NVGoggles_ghex_F','O_NVGoggles_hex_F','O_NVGoggles_urb_F'];
_nvgsi = ['NVGoggles_INDEP','NVGoggles_tna_F'];

_isACE = !isnull (configfile >> 'CfgPatches' >> 'ace_main');
if (_isACE) then {
	_nvgsw = _nvgsw + ['ACE_NVG_Gen4', 'ACE_NVG_Wide'];
	_nvgse = _nvgse + ['ACE_NVG_Gen1'];
	_nvgsi = _nvgsi + ['ACE_NVG_Gen2'];
};
{
									
	if(alive _x) then {
				
		_itemsUnit = assignedItems _x;
		_commonItemsArray = ((_nvgsw + _nvgse + _nvgsi) arrayIntersect _itemsUnit);
		_nvg = _commonItemsArray select 0;
					
		if(!isNil '_nvg') then {
			_x unassignItem _nvg;
		};
	};

} forEach (allUnits select {!isPlayer _x});
",""];

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Hi,

 

cool release! One small thing though, NVGoggles_tna_F is a "BluFor" item if I'm not mistaken. At least worn by BluFor NATO Tanoa units.

 

Thanks!

Share this post


Link to post
Share on other sites

Well its not very important  i added it to guer because there are many NVGs on blufor and NVGoggles_tna_F is green colour.

Anyway anyone can easily change this behaviour on wish

Share this post


Link to post
Share on other sites

Suggestion: I see a lot of duplicate code. You can use switch for only array NVG instead of whole code of selecting and assigning. :) 

Share this post


Link to post
Share on other sites

Had a very quick look, wasn't really attention though lol but am I missing something or? Why not just add the NV in first place? Don't players/AI self control their NVG?

Share this post


Link to post
Share on other sites

Sure, but some might find it odd for units to have NVGs mounted on their helmets or clipping trough caps, hats and whatnot during daytime. It also adds weight. I suppose it's useful for more realistic looking type scenarios. :)

  • Like 1

Share this post


Link to post
Share on other sites

Of course you right. You cant see any soldier keeping his NVG on helmet during daytime combat. Its optic an expensive stuff and not durable.

@M1ke_SK: I tried to keep as possible side selected assign for NVGs

Share this post


Link to post
Share on other sites

@davidoss

{
        _nvgSide = switch (str (side _x)) do
        {
            case 'WEST': { _nvgsw };
            case 'EAST': { _nvgse };
            case 'GUER': { _nvgsi };
            default { [] };
    };

        if(alive _x) then
        {
            _itemsUnit = (items _x + assignedItems _x);
            _commonItemsArray = _nvgSide arrayIntersect _itemsUnit;
            _nvg = _commonItemsArray select 0;
            _nvgri = selectRandom _nvgSide;
            if(!isNil '_nvg') then
            {
                if !(_nvg in (assignedItems _x)) then
                {
                    _x assignItem _nvg;
                };
            }
            else
            {
                _x linkitem _nvgri;
            };
        };
} forEach (allUnits select {!isPlayer _x});

 

  • Like 1
  • Thanks 2

Share this post


Link to post
Share on other sites

I wanted to change this up some to suit my mission. yada yada yada and I broke it. ideas on why its broken?

private _autonvgOn = createTrigger ["EmptyDetector", [0, 0, 0], false];
_autonvgOn setTriggerActivation ["NONE", "PRESENT", true];
_autonvgOn setTriggerStatements [
"(sunOrMoon < 0.45)",
"
private ['_nvgsi','_itemsUnit','_nvg'];
_nvgsi = ['NVGoggles_OPFOR'];

{	
	if(alive _x && side isEqualto independent) then	{
		_itemsUnit = (items _x + assignedItems _x);
		_commonItems = _nvgsi Intersect _itemsUnit;
		_nvg = select 0;
								
		if (!isNil '_nvg') then	{
			if !(_nvg in (assignedItems _x)) then {
				_x assignItem _nvg;
			};	
		} else {
			_x linkitem _nvg;
		};
	};			
} forEach (allUnits);
",""];

private _autonvgOf = createTrigger ["EmptyDetector", [0, 0, 0], false];
_autonvgOff setTriggerActivation ["NONE", "PRESENT", true];
_autonvgOff setTriggerStatements [
"(sunOrMoon >= 0.45)",
"
private ['_nvgsi','_itemsUnit', '_nvg'];
_nvgsi = ['NVGoggles_OPFOR'];

{
	if(alive _x && side isEqualto independent) then {
				
		_itemsUnit = assignedItems _x;
		_commonItems = _nvgsi Intersect _itemsUnit);
		_nvg = select 0;
					
		if(!isNil '_nvg') then {
			_x unassignItem _nvg;
		};
	};

} forEach (allUnits);
",""];

 

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

×