-
Notifications
You must be signed in to change notification settings - Fork 0
/
fnc_cleanMissionResources.sqf
45 lines (39 loc) · 1.59 KB
/
fnc_cleanMissionResources.sqf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Cleans up unneeded resources once they are far from any BLUFOR.
#include "macros.hpp"
params ["_groups", "_vehicles", "_markers"];
{
deleteMarker _x;
} forEach _markers;
{
private _group = _x;
private _units = (units _group) select {alive _x};
{
[_x] spawn {
params ["_unit"];
private _rand = random 5;
private _group = group _unit;
waitUntil {sleep (5 + _rand); not([_unit, AS_P("spawnDistance")] call AS_fnc_friendlyNearby)};
//If already dead and in despawner, exit:
if (_unit getVariable ["inDespawner", false]) exitWith {};
if ({alive _x} count units _group == 1) then {
// clean group after last unit
_unit call AS_fnc_safeDelete;
deleteGroup _group;
} else {
_unit call AS_fnc_safeDelete;
};
};
} forEach _units;
} forEach _groups;
{
//[_x] spawn AS_fnc_activateVehicleCleanup;
//Addition why wait if cleanResources is triggered only after away for spawn distance?
//ReammoBox_F changed to supplycrate class: location objects such as barrels on pallet had also ReammoBox_F parent class
if (!(_x isKindOf "AllVehicles") and {!(_x isKindof "B_supplyCrate_F")}) then {
[_x] remoteExecCall ["deletevehicle", _x];
} else {
//Sleep to avoid despawn while players are spawning
//vehicle cleanup where vehicle is local to avoid possible bug where remote veh is not detected as same vehicle
[_x] remoteExec ["AS_fnc_activateVehicleCleanup", _x];
};
} forEach _vehicles;