diff --git a/Description.ext b/Description.ext index d4c44a3..5b41cd2 100644 --- a/Description.ext +++ b/Description.ext @@ -14,6 +14,19 @@ class Header maxPlayers = 22; // maximum number of players the mission supports }; +class CfgFunctions +{ + class CLRK + { + tag = "CLRK"; + class Layers + { + file = "functions"; + class toggleLayerSim {}; + }; + }; +}; + respawnTemplates[] = {"MenuPosition"}; respawnOnStart = 0; respawnDialog = 1; diff --git a/functions/fn_toggleLayerSim.sqf b/functions/fn_toggleLayerSim.sqf new file mode 100644 index 0000000..3421ee7 --- /dev/null +++ b/functions/fn_toggleLayerSim.sqf @@ -0,0 +1,43 @@ +/* + Author: + Clarky + + Last Updated: + 06-05-2026 + + Description: + This function mimics the default functionality of the Show/Hide editor module, with the addition of allowing or disallowing damage. + Show/Hide does NOT toggle damage states on affected units, meaning you can hide a unit but it will still be affected by nearby explosions or vehicle collisions once un-hidden. Suboptimal for densely packed and layered instances where you may be hiding a number of different units/objects across different stages of an op. + This functionality can be applied to an entire layer of entities, making it easy to set up layers of units that will remain hidden, not simulating, and not processing any damage event until such a time as you are ready. + + Paramters: + 0: STRING - Name of the layer you wish to enable/disable + 1: BOOLEAN - true = enable layer, false = disable layer + + Returns: + BOOLEAN + + Examples: + ["Objective01-Assault", true] call TAG_fnc_toggleLayerSim; +*/ + +// Define variables. _layerName is the input parameter for the name of the layer, _show is the true/false value to turn the named layer on or off +params ["_layerName", "_show"]; + +// Import data based on provided parameters +private _layerEntities = getMissionLayerEntities _layerName; +private _objects = _layerEntities select 0; + +private _allowDamage = _show; +private _enableSim = _show; +private _hideObj = !_show; + +// Run the code based on provided input. +// First brackets input the current looped object (_x) and the toggle on/off for the relevant simulation requirement as set in the params +// The second bracket of params lists the desired variable to update based on the input (e.g allowDamage = _allowDamage, the locality of the remoteExec (0 = Server + Client), and if the call should be persistent or not (true = JIP users will also run this code, ensuring state parity) +{ + [_x, _allowDamage] remoteExec ["allowDamage", 0, true]; + [_x, _enableSim] remoteExec ["enableSimulationGlobal", 0, true]; + [_x, _hideObj] remoteExec ["hideObjectGlobal", 0, true]; +} forEach _objects; +true; \ No newline at end of file diff --git a/initServer.sqf b/initServer.sqf new file mode 100644 index 0000000..3037499 --- /dev/null +++ b/initServer.sqf @@ -0,0 +1,2 @@ +// Declare mission state variables +missionNameSpace setVariable ["mission_01_hvtDead", false, true]; diff --git a/mission.sqm b/mission.sqm index 4e406f9..52b92d4 100644 Binary files a/mission.sqm and b/mission.sqm differ