Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. /*
  2. Description:
  3. Freeze's/UnFreeze's units and makes em invincible while frozen.
  4. (Function saves last targets)
  5.  
  6. Parameter(s):
  7. _Mode - Mode to run function in. (Bool)
  8. True: Freeze the Units.
  9. False: UnFreeze the Units.
  10. _TargetUnits - (Array, Number, String).
  11. Array of Units: Units to be Frozen/UnFrozen.
  12. Number: Gets all units that are not within given distance from player.
  13. String: Gets Variable from Missionnamespace.
  14. (Last Targets are automaticly saved, to use Last Targets use "LastTargets")
  15.  
  16. Return Value:
  17. Boolean
  18. */
  19.  
  20. params
  21. [
  22. ["_Mode", True, [True]],
  23. ["_TargetUnits", 150, [[], 0, ""]]
  24. ];
  25.  
  26. //--- Selects correct _TargetUnits.
  27. _CheckTargetUnits =
  28. {
  29. switch (TypeName _TargetUnits) do
  30. {
  31. Case "SCALAR": //--- Get Units that are not within given distance.
  32. {
  33. _Distance = _TargetUnits;
  34. _TargetUnits = [];
  35. {
  36. _Unit = _x;
  37. {
  38. if (_Unit Distance _x > _Distance) then
  39. {
  40. _TargetUnits pushback _Unit;
  41. };
  42. } foreach Playableunits;
  43. } foreach (Allunits select {!(_x in Playableunits)});
  44. };
  45. Case "STRING":
  46. {
  47. if (_TargetUnits in ["LASTTARGETS","LastTargets","Lasttargets","lastTargets","lasttargets"]) then //in is used instead of isequalto to make it case insensitive.
  48. {
  49. _TargetUnits = (Missionnamespace GetVariable ["ETO_Fnc_FreezeUnits_TargetUnits", []]); //--- Get last Targets.
  50. } else {
  51. _TargetUnits = (Missionnamespace GetVariable [_TargetUnits, []]); //--- Get given Variable.
  52. Call _CheckTargetUnits; //--- ChecksValue again in case _TargetUnits is a number.
  53. };
  54. };
  55. };
  56. };
  57. Call _CheckTargetUnits;
  58.  
  59. //--- Make sure _TargetUnits is an array.
  60. if ((_TargetUnits isequalto [])||!(_TargetUnits isequaltype [])) exitWith {False};
  61.  
  62. //--- Saves Targets.
  63. Missionnamespace Setvariable ["ETO_Fnc_FreezeUnits_TargetUnits", _TargetUnits];
  64.  
  65. //--- Freeze's or UnFreeze's _TargetUnits depended on (!_Mode).
  66. {
  67. _Unit = _x;
  68. _VehicleUnit = (vehicle _Unit);
  69.  
  70. _Unit enableSimulationGlobal (!_Mode);
  71. _VehicleUnit enableSimulationGlobal (!_Mode);
  72.  
  73. [_Unit, (!_Mode)] remoteExec ["Allowdamage", 0, True];
  74. [_VehicleUnit, (!_Mode)] remoteExec ["Allowdamage", 0, True];
  75. } foreach _TargetUnits;
  76.  
  77. True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement