Jump to content
LarsAspra

Broken supports code after recent update, help fixing it

Recommended Posts

As you might already know, multiplayer functionality and BIS functions were not the only casualties of Update 1.86; the supports in the popular Dynamic Recon Ops scenario have stopped functioning since the update, with the sole exception of UAVs.
Even if you select the pertinent options in the Lobby, you won't get the support options when the mission starts. Everything else in the mission still works fine however.
Being an avid user of it and seeing how the author is on break currently, I took it upon myself to try and isolate the issue and fix it.

Here's the code in question:
addSupports.sqf

diag_log "DRO: Initiating supports";

// Define supports
centerSide = createCenter sideLogic;
_logicGroupRequester = createGroup centerSide;
requester = _logicGroupRequester createUnit ["SupportRequester", getPos (leader (grpNetId call BIS_fnc_groupFromNetId)), [], 0, "FORM"];

diag_log format ["DRO: requester = %1", requester];
//Setup requestor limit values
{
	[requester, _x, 0] remoteExec ["BIS_fnc_limitSupport", 0, true];
	//[requester, _x, 0] call BIS_fnc_limitSupport;
} forEach [
	"Artillery",
	"CAS_Heli",
	"CAS_Bombing",
	"UAV",
	"Drop",
	"Transport"
];

// Check whether supports are random or custom
_dropChance = random 1;
_artyChance = random 1;
_casChance = random 1;
_uavChance = random 1;
if (randomSupports == 1) then {
	if ("SUPPLY" in customSupports) then {_dropChance = 1;} else {_dropChance = 0;};
	if ("ARTY" in customSupports) then {_artyChance = 1;} else {_artyChance = 0;};
	if ("CAS" in customSupports) then {_casChance = 1;} else {_casChance = 0;};
	if ("UAV" in customSupports) then {_uavChance = 1;} else {_uavChance = 0;};	
};

// Supply drop
if (_dropChance > 0.7) then {
	diag_log "DRO: Support selected: Supply drop";
	providerDrop = nil;
	if (count pHeliClasses > 0) then {
		_logicGroupDrop = createGroup centerSide;		
		_suppPos = [getPos trgAOC,3000,4000,0,1,1,0] call BIS_fnc_findSafePos;
		diag_log format ["DRO: _suppPos = %1", _suppPos];			
		providerDrop = _logicGroupDrop createUnit ["SupportProvider_Virtual_Drop", _suppPos, [], 0, "FORM"];			
		diag_log format ["DRO: providerDrop = %1", providerDrop];		
		//Setup provider values
		{
			providerDrop setVariable [(_x select 0),(_x select 1),true];
		} forEach [
			["BIS_SUPP_crateInit",
				"
					clearWeaponCargoGlobal _this;
					clearMagazineCargoGlobal _this;
					clearItemCargoGlobal _this;
					_this addMagazineCargoGlobal ['SatchelCharge_Remote_Mag', 2];
					_this addMagazineCargoGlobal ['DemoCharge_Remote_Mag', 4];
					_this addItemCargoGlobal ['Medikit', 1];
					_this addItemCargoGlobal ['FirstAidKit', 10];
					{
						_magazines = magazinesAmmoFull _x;
						{
							_this addMagazineCargoGlobal [(_x select 0), 2];
						} forEach _magazines;
					} forEach (units (grpNetId call BIS_fnc_groupFromNetId));
					[_this] call sun_supplyBox;
				"],		
			["BIS_SUPP_vehicles",[(selectRandom pHeliClasses)]],		
			["BIS_SUPP_vehicleinit",""],	
			["BIS_SUPP_filter","FACTION"]		
		];
		
		[requester, "Drop", 1] remoteExec ["BIS_fnc_limitSupport", 0, true];
		//[requester, "Drop", 1] call BIS_fnc_limitSupport;
	
		{	
			//[_x, requester, providerDrop] call BIS_fnc_addSupportLink;
			[_x, requester, providerDrop] remoteExec ["BIS_fnc_addSupportLink", 0, true];
		} forEach (units (grpNetId call BIS_fnc_groupFromNetId));		
	};
};

// Artillery
if (_artyChance > 0.7) then {
	diag_log "DRO: Support selected: Artillery";
	providerArty = nil;
	_artyList = pMortarClasses + pArtyClasses;
	diag_log _artyList;
	if (count _artyList > 0) then {
		_availableArty = [];
		{
			_artyClass = (selectRandom _artyList);						
			_artyRanges = [_artyClass] call dro_getArtilleryRanges;
			_minRange = (_artyRanges select 0);
			_maxRange = (_artyRanges select 1);			
			_trgArea = triggerArea trgAOC;
			_largestSize = if ((_trgArea select 0) > (_trgArea select 1)) then {
				(_trgArea select 0)
			} else {
				(_trgArea select 1)
			};			
			_minPlacementDistance = (_largestSize + 500);			
			if (_minRange > 0) then {
				_minPlacementDistance = (_largestSize + _minRange);			
			};				
			_artyPos = [getPos trgAOC, _minPlacementDistance, _minPlacementDistance + 500, 5, 0, 0.25, 0, [trgAOC], [[0,0,0],[0,0,0]]] call BIS_fnc_findSafePos;
			if (!(_artyPos isEqualTo [0,0,0])) then {
				_availableArty pushBack [_artyClass, _artyPos];
			};
		} forEach _artyList;
		
		if (count _availableArty > 0) then {
			_logicGroupArty = createGroup centerSide;
			_artySelection = selectRandom _availableArty;
			_artyClass = _artySelection select 0;
			_artyPos = _artySelection select 1;
			_markerSupports = createMarker ["mkrSupports", _artyPos];
			_markerSupports setMarkerShape "ICON";
			_markerSupports setMarkerColor markerColorPlayers;
			_markerSupports setMarkerType "mil_marker";
			_markerSupports setMarkerText "Support Position";
			_markerSupports setMarkerSize [0.6, 0.6];
			diag_log format ["DRO: _artyPos = %1", _artyPos];	
			providerArty = _logicGroupArty createUnit ["SupportProvider_Artillery", _artyPos, [], 0, "FORM"];
			diag_log format ["DRO: providerArty = %1", providerArty];			
			_artyVeh = createVehicle [_artyClass, _artyPos, [], 0, "NONE"];
			_artyVeh setDir ([_artyPos, trgAOC] call BIS_fnc_dirTo);			
			diag_log format ["DRO: _artyVeh = %1", _artyVeh];
			
			[_artyVeh, playersSide, false] call sun_createVehicleCrew;
			_artyVeh disableAI "PATH";
			[requester, "Artillery", -1] remoteExec ["BIS_fnc_limitSupport", 0, true];			
			[providerArty, [_artyVeh]] remoteExec ["synchronizeObjectsAdd", 0, true];			
			{	
				[_x, requester, providerArty] remoteExec ["BIS_fnc_addSupportLink", 0, true];
			} forEach (units (grpNetId call BIS_fnc_groupFromNetId));					
		} else {
			diag_log "DRO: Valid artillery support position not found";
		};
	};
};

// CAS
if (_casChance > 0.7) then {
	diag_log "DRO: Support selected: CAS";
	if (count availableCASClasses > 0) then {		
		_availableCASClassesHeli = [];
		_availableCASClassesBomb = [];
		{
			_availableSupportTypes = (configfile >> "CfgVehicles" >> _x >> "availableForSupportTypes") call BIS_fnc_GetCfgData;	
			if ("CAS_Bombing" in _availableSupportTypes) then {
				_availableCASClassesBomb pushBack _x;				
			};
			if ("CAS_Heli" in _availableSupportTypes) then {
				_availableCASClassesHeli pushBack _x;				
			};
		} forEach availableCASClasses;		
		
		_chosenCASClasses = [];
		// Choose a random CAS type based on vehicles available
		_casType = "";
		_limitType = "";
		if ((count _availableCASClassesHeli > 0) && (count _availableCASClassesBomb > 0)) then {			
			_casTypeChance = [0,1] call BIS_fnc_randomInt;
			if (_casTypeChance == 0) then {
				_casType = "SupportProvider_Virtual_CAS_Heli";
				_chosenCASClasses = _availableCASClassesHeli;
				_limitType = "CAS_Heli";
			} else {
				_casType = "SupportProvider_Virtual_CAS_Bombing";
				_chosenCASClasses = _availableCASClassesBomb;
				_limitType = "CAS_Bombing";
			};
		} else {
			if (count _availableCASClassesHeli > 0) then {
				_casType = "SupportProvider_Virtual_CAS_Heli";
				_chosenCASClasses = _availableCASClassesHeli;
				_limitType = "CAS_Heli";
			} else {
				_casType = "SupportProvider_Virtual_CAS_Bombing";
				_chosenCASClasses = _availableCASClassesBomb;
				_limitType = "CAS_Bombing";
			};
		};
		
		_logicGroupCAS = createGroup centerSide;
		diag_log _chosenCASClasses;
		diag_log _casType;
		diag_log _limitType;
		
		_suppPos = [getPos trgAOC, 3000, 4000, 0, 1, 1, 0] call BIS_fnc_findSafePos;	
		diag_log format ["DRO: _suppPos = %1", _suppPos];
		providerCAS = _logicGroupCAS createUnit [_casType, _suppPos, [], 0, "FORM"];
		diag_log format ["DRO: providerCAS = %1", providerCAS];				
		//Setup provider values
		{
			providerCAS setVariable [(_x select 0),(_x select 1), true];
		} forEach [						
			["BIS_SUPP_vehicles",[(selectRandom _chosenCASClasses)]],		
			["BIS_SUPP_vehicleinit",""],	
			["BIS_SUPP_filter","FACTION"]		
		];
		
		[requester, _limitType, 1] remoteExec ["BIS_fnc_limitSupport", 0, true];
		//[requester, _limitType, 1] call BIS_fnc_limitSupport;
	
		{
			[_x, requester, providerCAS] remoteExec ["BIS_fnc_addSupportLink", 0, true];
			//[_x, requester, providerCAS] call BIS_fnc_addSupportLink;
		} forEach (units (grpNetId call BIS_fnc_groupFromNetId));		
				
	};
};

if (_uavChance > 0.7) then {
	[] execVM "sunday_system\player_setup\uavPatrol.sqf";
};	



The solution still eludes me, but this is what I know so far from my attempts:
Contrary to my initial suspicions, the multiplayer changes seemingly have nothing to do with it, since the issue still persists to 1.88, and according to the .rpt logs assignment of NetId and BIS_fnc_groupFromNetId work fine.
All the code relating to the setting up of the support modules works fine according to the .rpt logs and visual inspection of the spawned artillery position ingame. (which itself is marked correctly on the map)
{To make sure that the malfunction wasn't in that part of the code, on the advice of https://forums.bohemia.net/forums/topic/181264-sector-module-scripting/  I applied providerDrop/providerArty/providerCAS/requester setvariable ['BIS_fnc_initModules_disableAutoActivation',false]; after all bits of code with CreateUnit and tested it, to no avail.)

Basically, all the supports spawn successfully and as intended.

This leads me to believe that the issue lies with the supports somehow not being successfully linked to the player, but I'm kind of stumped since I haven't had problems with nor have I seen anyone have any issue with BIS_fnc_addSupportLink as a result of the recent updates except with this specific scenario. The syntax checks out, so why doesn't it work?
Can someone wiser than I in the realm of Arma 3 scripting shed light on this?

 

Share this post


Link to post
Share on other sites

Works fine for me once you apply the variable BIS_fnc_initModules_disableAutoActivation to each module. Tested from the initServer.sqf in SP, MP and dedicated.

 

Had to remove functions I dont have and defined the missing variables.

Spoiler

waitUntil { time > 0 };

//Missing vars
_player = allPlayers select 0;
grpNetID = group _player call BIS_fnc_netId;
pHeliClasses = [ "B_Heli_Transport_01_F" ];
pMortarClasses = [ "B_Mortar_01_F" ];
pArtyClasses = [ "B_MBT_01_arty_F" ];
availableCASClasses = [ "B_Plane_CAS_01_dynamicLoadout_F" ];

//Missing trigger
trgAOC = createTrigger [ "EmptyDetector", getPosATL _player, true ];
trgAOC setTriggerArea [ 100, 100, 0, false ];
trgAOC setTriggerActivation [ "ANY", "PRESENT", true ];
trgAOC setTriggerStatements ["this", "", ""];

diag_log "DRO: Initiating supports";

// Define supports
centerSide = createCenter sideLogic;
_logicGroupRequester = createGroup centerSide;
requester = _logicGroupRequester createUnit ["SupportRequester", getPos (leader (grpNetId call BIS_fnc_groupFromNetId)), [], 0, "FORM"];

diag_log format ["DRO: requester = %1", requester];
//Setup requestor limit values
{
	[requester, _x, 0] remoteExec ["BIS_fnc_limitSupport", 0, true];
	//[requester, _x, 0] call BIS_fnc_limitSupport;
} forEach [
	"Artillery",
	"CAS_Heli",
	"CAS_Bombing",
	"UAV",
	"Drop",
	"Transport"
];

//ENABLE ACTIVATION
requester setVariable[ "BIS_fnc_initModules_disableAutoActivation", false ];

// Check whether supports are random or custom
_dropChance = 1;
_artyChance = 1;
_casChance = 1;
_uavChance = 1;


// Supply drop
if (_dropChance > 0.7) then {
	diag_log "DRO: Support selected: Supply drop";
	providerDrop = nil;
	if (count pHeliClasses > 0) then {
		_logicGroupDrop = createGroup centerSide;
		_suppPos = [getPos trgAOC,3000,4000,0,1,1,0] call BIS_fnc_findSafePos;
		diag_log format ["DRO: _suppPos = %1", _suppPos];
		providerDrop = _logicGroupDrop createUnit ["SupportProvider_Virtual_Drop", _suppPos, [], 0, "FORM"];
		diag_log format ["DRO: providerDrop = %1", providerDrop];
		//Setup provider values
		{
			providerDrop setVariable [(_x select 0),(_x select 1),true];
		} forEach [
			["BIS_SUPP_crateInit",
				"
					clearWeaponCargoGlobal _this;
					clearMagazineCargoGlobal _this;
					clearItemCargoGlobal _this;
					_this addMagazineCargoGlobal ['SatchelCharge_Remote_Mag', 2];
					_this addMagazineCargoGlobal ['DemoCharge_Remote_Mag', 4];
					_this addItemCargoGlobal ['Medikit', 1];
					_this addItemCargoGlobal ['FirstAidKit', 10];
					{
						_magazines = magazinesAmmoFull _x;
						{
							_this addMagazineCargoGlobal [(_x select 0), 2];
						} forEach _magazines;
					} forEach (units (grpNetId call BIS_fnc_groupFromNetId));
				"],
			["BIS_SUPP_vehicles",[(selectRandom pHeliClasses)]],
			["BIS_SUPP_vehicleinit",""],
			["BIS_SUPP_filter","FACTION"]
		];

		//ENABLE ACTIVATION
		providerDrop setVariable[ "BIS_fnc_initModules_disableAutoActivation", false ];

		[requester, "Drop", 1] remoteExec ["BIS_fnc_limitSupport", 0, true];
		//[requester, "Drop", 1] call BIS_fnc_limitSupport;

		{
			//[_x, requester, providerDrop] call BIS_fnc_addSupportLink;
			[_x, requester, providerDrop] remoteExec ["BIS_fnc_addSupportLink", 0, true];
		} forEach (units (grpNetId call BIS_fnc_groupFromNetId));
	};
};

// Artillery
if (_artyChance > 0.7) then {
	diag_log "DRO: Support selected: Artillery";
	providerArty = nil;
	_artyList = pMortarClasses + pArtyClasses;
	diag_log _artyList;
	if (count _artyList > 0) then {
		_availableArty = [];
		{
			_artyClass = (selectRandom _artyList);
			_minRange = getNumber( configFile >> "CfgVehicles" >> _artyClass >> "htMin" );
			_maxRange = getNumber( configFile >> "CfgVehicles" >> _artyClass >> "htMax" );;
			_trgArea = triggerArea trgAOC;
			_largestSize = if ((_trgArea select 0) > (_trgArea select 1)) then {
				(_trgArea select 0)
			} else {
				(_trgArea select 1)
			};
			_minPlacementDistance = (_largestSize + 500);
			if (_minRange > 0) then {
				_minPlacementDistance = (_largestSize + _minRange);
			};
			_artyPos = [getPos trgAOC, _minPlacementDistance, _minPlacementDistance + 500, 5, 0, 0.25, 0, [trgAOC], [[0,0,0],[0,0,0]]] call BIS_fnc_findSafePos;
			if (!(_artyPos isEqualTo [0,0,0])) then {
				_availableArty pushBack [_artyClass, _artyPos];
			};
		} forEach _artyList;

		if (count _availableArty > 0) then {
			_logicGroupArty = createGroup centerSide;
			_artySelection = selectRandom _availableArty;
			_artyClass = _artySelection select 0;
			_artyPos = _artySelection select 1;
			_markerSupports = createMarker ["mkrSupports", _artyPos];
			_markerSupports setMarkerShape "ICON";
			_markerSupports setMarkerColor "ColorGreen";
			_markerSupports setMarkerType "mil_marker";
			_markerSupports setMarkerText "Support Position";
			_markerSupports setMarkerSize [0.6, 0.6];
			diag_log format ["DRO: _artyPos = %1", _artyPos];
			providerArty = _logicGroupArty createUnit ["SupportProvider_Artillery", _artyPos, [], 0, "FORM"];

			//ENABLE ACTIVATION
			providerArty setVariable[ "BIS_fnc_initModules_disableAutoActivation", false ];
          
			diag_log format ["DRO: providerArty = %1", providerArty];
			_artyVeh = createVehicle [_artyClass, _artyPos, [], 0, "NONE"];
			_artyVeh setDir ([_artyPos, trgAOC] call BIS_fnc_dirTo);
			diag_log format ["DRO: _artyVeh = %1", _artyVeh];

			createVehicleCrew _artyVeh;
			_artyVeh disableAI "PATH";
			[requester, "Artillery", -1] remoteExec ["BIS_fnc_limitSupport", 0, true];
			[providerArty, [_artyVeh]] remoteExec ["synchronizeObjectsAdd", 0, true];
			{
				[_x, requester, providerArty] remoteExec ["BIS_fnc_addSupportLink", 0, true];
			} forEach (units (grpNetId call BIS_fnc_groupFromNetId));
		} else {
			diag_log "DRO: Valid artillery support position not found";
		};
	};
};

// CAS
if (_casChance > 0.7) then {
	diag_log "DRO: Support selected: CAS";
	if (count availableCASClasses > 0) then {
		_availableCASClassesHeli = [];
		_availableCASClassesBomb = [];
		{
			_availableSupportTypes = (configfile >> "CfgVehicles" >> _x >> "availableForSupportTypes") call BIS_fnc_GetCfgData;
			if ("CAS_Bombing" in _availableSupportTypes) then {
				_availableCASClassesBomb pushBack _x;
			};
			if ("CAS_Heli" in _availableSupportTypes) then {
				_availableCASClassesHeli pushBack _x;
			};
		} forEach availableCASClasses;

		_chosenCASClasses = [];
		// Choose a random CAS type based on vehicles available
		_casType = "";
		_limitType = "";
		if ((count _availableCASClassesHeli > 0) && (count _availableCASClassesBomb > 0)) then {
			_casTypeChance = [0,1] call BIS_fnc_randomInt;
			if (_casTypeChance == 0) then {
				_casType = "SupportProvider_Virtual_CAS_Heli";
				_chosenCASClasses = _availableCASClassesHeli;
				_limitType = "CAS_Heli";
			} else {
				_casType = "SupportProvider_Virtual_CAS_Bombing";
				_chosenCASClasses = _availableCASClassesBomb;
				_limitType = "CAS_Bombing";
			};
		} else {
			if (count _availableCASClassesHeli > 0) then {
				_casType = "SupportProvider_Virtual_CAS_Heli";
				_chosenCASClasses = _availableCASClassesHeli;
				_limitType = "CAS_Heli";
			} else {
				_casType = "SupportProvider_Virtual_CAS_Bombing";
				_chosenCASClasses = _availableCASClassesBomb;
				_limitType = "CAS_Bombing";
			};
		};

		_logicGroupCAS = createGroup centerSide;
		diag_log _chosenCASClasses;
		diag_log _casType;
		diag_log _limitType;

		_suppPos = [getPos trgAOC, 3000, 4000, 0, 1, 1, 0] call BIS_fnc_findSafePos;
		diag_log format ["DRO: _suppPos = %1", _suppPos];
		providerCAS = _logicGroupCAS createUnit [_casType, _suppPos, [], 0, "FORM"];
		diag_log format ["DRO: providerCAS = %1", providerCAS];
		//Setup provider values
		{
			providerCAS setVariable [(_x select 0),(_x select 1), true];
		} forEach [
			["BIS_SUPP_vehicles",[(selectRandom _chosenCASClasses)]],
			["BIS_SUPP_vehicleinit",""],
			["BIS_SUPP_filter","FACTION"]
		];
      
		//ENABLE ACTIVATION
		providerCAS setVariable[ "BIS_fnc_initModules_disableAutoActivation", false ];
      
		[requester, _limitType, 1] remoteExec ["BIS_fnc_limitSupport", 0, true];
		//[requester, _limitType, 1] call BIS_fnc_limitSupport;

		{
			[_x, requester, providerCAS] remoteExec ["BIS_fnc_addSupportLink", 0, true];
			//[_x, requester, providerCAS] call BIS_fnc_addSupportLink;
		} forEach (units (grpNetId call BIS_fnc_groupFromNetId));

	};
};

 

Only thing that does not always show is supply drop, but that is just a timing issue. As soon as you redo...

requester, "Drop", 1] remoteExec ["BIS_fnc_limitSupport", 0, true];

...in the debug console the supply drop shows up and works fine.

  • Like 1

Share this post


Link to post
Share on other sites
8 hours ago, killzone_kid said:

grpNetId is undefined


It's defined in the preceding functions.

To Larrow, I did indeed apply BIS_fnc_initModules_disableAutoActivation to each module, and to make double sure I tested your version of the script in a clean scenario (it worked without a hitch) and copied your BIS_fnc_initModules_disableAutoActivation syntax, adapted and tested it for DRO but again with just DRO it doesn't want to work.
I don't know what to make of it.

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

×