Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Description:
- Freeze's/UnFreeze's units and makes em invincible while frozen.
- (Function saves last targets)
- Parameter(s):
- _Mode - Mode to run function in. (Bool)
- True: Freeze the Units.
- False: UnFreeze the Units.
- _TargetUnits - (Array, Number, String).
- Array of Units: Units to be Frozen/UnFrozen.
- Number: Gets all units that are not within given distance from player.
- String: Gets Variable from Missionnamespace.
- (Last Targets are automaticly saved, to use Last Targets use "LastTargets")
- Return Value:
- Boolean
- */
- params
- [
- ["_Mode", True, [True]],
- ["_TargetUnits", 150, [[], 0, ""]]
- ];
- //--- Selects correct _TargetUnits.
- _CheckTargetUnits =
- {
- switch (TypeName _TargetUnits) do
- {
- Case "SCALAR": //--- Get Units that are not within given distance.
- {
- _Distance = _TargetUnits;
- _TargetUnits = [];
- {
- _Unit = _x;
- {
- if (_Unit Distance _x > _Distance) then
- {
- _TargetUnits pushback _Unit;
- };
- } foreach Playableunits;
- } foreach (Allunits select {!(_x in Playableunits)});
- };
- Case "STRING":
- {
- if (_TargetUnits in ["LASTTARGETS","LastTargets","Lasttargets","lastTargets","lasttargets"]) then //in is used instead of isequalto to make it case insensitive.
- {
- _TargetUnits = (Missionnamespace GetVariable ["ETO_Fnc_FreezeUnits_TargetUnits", []]); //--- Get last Targets.
- } else {
- _TargetUnits = (Missionnamespace GetVariable [_TargetUnits, []]); //--- Get given Variable.
- Call _CheckTargetUnits; //--- ChecksValue again in case _TargetUnits is a number.
- };
- };
- };
- };
- Call _CheckTargetUnits;
- //--- Make sure _TargetUnits is an array.
- if ((_TargetUnits isequalto [])||!(_TargetUnits isequaltype [])) exitWith {False};
- //--- Saves Targets.
- Missionnamespace Setvariable ["ETO_Fnc_FreezeUnits_TargetUnits", _TargetUnits];
- //--- Freeze's or UnFreeze's _TargetUnits depended on (!_Mode).
- {
- _Unit = _x;
- _VehicleUnit = (vehicle _Unit);
- _Unit enableSimulationGlobal (!_Mode);
- _VehicleUnit enableSimulationGlobal (!_Mode);
- [_Unit, (!_Mode)] remoteExec ["Allowdamage", 0, True];
- [_VehicleUnit, (!_Mode)] remoteExec ["Allowdamage", 0, True];
- } foreach _TargetUnits;
- True
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement