Jump to content
Reeveli

EnableSimulationGlobal on vehicle crew

Recommended Posts

So I am making a mission with a lot of hidden ambush sites. These sites work by hiding all units and fortifications inside an area. Once the player(s) enter the ambush site a trigger reveals all units and objects.

This is code I use for hiding stuff:

_thismarker = _this select 0;

_position = getMarkerPos _thismarker;

_list = ["Land_HBarrier_large","Land_BagFenceCorner","Land_CamoNet_NATO","BagBunker_base_F","Wire","Thing","HBarrier_base_F","Stall_base_F","Military_Item_NoInteractive","Man","LandVehicle"];

{ _x hideObjectGlobal true } foreach (nearestObjects [_position, _list, (getMarkerSize _thismarker) select 0]);
{ _x enableSimulationGlobal false } foreach (nearestObjects [_position, _list, (getMarkerSize _thismarker) select 0]);

And this is is the similar code for revealing them upon trigger activation:

_thismarker = _this select 0;

_position = getMarkerPos _thismarker;

_list = ["Land_HBarrier_large","Land_BagFenceCorner","Land_CamoNet_NATO","BagBunker_base_F","Wire","Thing","HBarrier_base_F","Stall_base_F","Military_Item_NoInteractive","Man","LandVehicle"];

{ _x hideObjectGlobal false } foreach (nearestObjects [_position, _list, (getMarkerSize _thismarker) select 0]);
{ _x enableSimulationGlobal true} foreach (nearestObjects [_position, _list, (getMarkerSize _thismarker) select 0]);

The problem is that any vehicle crews will stay invisible and their simulation disabled. Does anyone have any ideas how to go around that?

Share this post


Link to post
Share on other sites

They remain hidden but are returning fire and following waypoints when reveald but the crew are invisible in my tests.

any how a 3am solution and there's probably a better one out there is this.

 

{ _x hideObjectGlobal false;if (_x iskindof "LandVehicle") then {{_x hideObjectGlobal false} foreach crew _x}  } foreach (nearestObjects [_position, _list, (getMarkerSize _thismarker) select 0]);

Share this post


Link to post
Share on other sites
TAG_fnc_hideAmbush = {
	///Make sure we are executing on the server
	//as the commands hideObjectGlobal & enableSimulationGlobal are SE( Server Exec ) 
	if !( isServer ) exitWith {
		_this remoteExec[ "TAG_fnc_hideAmbush", 2 ];
	};
	
	params[ "_marker", "_hide" ];
	
	_position = getMarkerPos _marker;
	_radius = ( getMarkerSize _marker ) select 0;
	_list = ["Land_HBarrier_large","Land_BagFenceCorner","Land_CamoNet_NATO","BagBunker_base_F","Wire","Thing","HBarrier_base_F","Stall_base_F","Military_Item_NoInteractive","Man","LandVehicle"];
	
	_objects = nearestObjects [_position, _list, _radius];
	
	{
		{
			_x hideObjectGlobal _hide;
			_x enableSimulationGlobal !_hide;
		}forEach ( [_x] + ( units _x - [_x] )); 
	} foreach _objects;
};

[ "marker_0", true ] call TAG_fnc_hideAmbush;

Units of a static object (Land_HBarrier_large etc) is an empty array. Units of a vehicle is the crew. Units of a Man is the units of its group.

This is the same as what the show/hide module does for synced objects, of which you could just use that instead of your own solution but either will do.

  • Like 4

Share this post


Link to post
Share on other sites

Thanks for you function Larrow, it works as intended. The reason not to use the show/hide module is that I would have to apply the modules manually. Instead I can automate the hiding process in the init.sqf to apply for all ambush sites saving time in the editor.

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

×