Advertisement
Doggifast

Switch objects hidden within area of trigger

Feb 2nd, 2024 (edited)
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQF 2.11 KB | Source Code | 0 0
  1. /* DGF_fnc_SwitchObjectsHiddenInTriggerArea
  2.  
  3. Switch all objects in a trigger's area to a specified-hidden state.
  4.  
  5. PARAMS:
  6. 0: Triggers Affected [OBJECT.TRIGGER]
  7. 1: Apply restrictions [BOOL] (Optional, Default: true)
  8.     -Vehicles with units in them won't be hidden
  9.     -Units won't be hidden
  10. 2: Hidden switch type [SCALAR] (Optional, Default: 2)
  11.     0: hide all objects within trigger
  12.     1: un-hide all objects within trigger
  13.     2: auto-switch - if an object is hidden, unhide it; if not - hide it; per-object.
  14.  
  15. by Doggifast
  16. */
  17.  
  18. if !(isServer) exitWith {};
  19. params ["_triggers", "_applyRestrictions", "_typeSwitch"];
  20. private _triggers = param [0, [], [[]], []];
  21. private _applyRestrictions = param [1, true, [true]];
  22. private _typeSwitch = param [2, 2, [2]];
  23. private _appropriateObjects0 = (63 allObjects 0);
  24. private _appropriateObjects1 = (63 allObjects 1);
  25. {
  26.     private _arrayIncompatibleObjects = [];
  27.     private _appropriateObjects = [];
  28.     if (_applyRestrictions) then
  29.     {
  30.         _appropriateObjects = (((_appropriateObjects0 + _appropriateObjects1) - [_x]) - AllUnits) inAreaArray _x;
  31.         {
  32.             if !((crew _x) isEqualTo []) then //if vehicle holds crew...
  33.             {
  34.                 _arrayIncompatibleObjects pushBack _x;
  35.             };
  36.         } forEach _appropriateObjects;
  37.         _appropriateObjects = (_appropriateObjects - _arrayIncompatibleObjects);
  38.     } else
  39.     {
  40.         _appropriateObjects = (((_appropriateObjects0 + _appropriateObjects1) - [_x]) inAreaArray _x);
  41.     };
  42.  
  43.     switch (_typeSwitch) do
  44.     {
  45.         case 0: {
  46.             {_x hideObjectGlobal true;} forEach _appropriateObjects;
  47.         };
  48.         case 1: {
  49.             {_x hideObjectGlobal false;} forEach _appropriateObjects;
  50.         };
  51.         case 2:
  52.         {
  53.             {
  54.                 if (isObjectHidden _x) then
  55.                 {
  56.                     _x hideObjectGlobal false;
  57.                 }
  58.                 else
  59.                 {
  60.                     _x hideObjectGlobal true;
  61.                 };
  62.             } forEach _appropriateObjects;
  63.         };
  64.     };
  65. } forEach _triggers;
Tags: Arma 3 SQF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement