-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathfn_ClstWarn.sqf
More file actions
136 lines (96 loc) · 4.26 KB
/
Copy pathfn_ClstWarn.sqf
File metadata and controls
136 lines (96 loc) · 4.26 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*
Author: Genesis
Description:
Function for squads being able to warn their closest teammates about combat.
Parameter(s):
0: OBJECT - Unit whose group will call for help
1: OBJECT - Unit who killed above unit
Returns:
NOTHING
*/
params ["_unit","_killer"];
if !(alive _killer ) exitWith {};
private _unitGroup = (group _unit);
//If the squad is a TOUGH SQUAD, we just exit here.
if (_unitGroup getVariable ["VCM_TOUGHSQUAD",false] || _unitGroup getVariable ["Vcm_Disable",false] || _unitGroup getVariable ["VCM_NOFLANK",false]) exitWith {};
//If the squad is already calling for help, don't do anything further.
if (_unitGroup getVariable ["VCM_RQSTHELP",false]) exitWith {};
_unitGroup setVariable ["VCM_RQSTHELP",true];
_unitGroup spawn {sleep 300;_this setVariable ["VCM_RQSTHELP",false];};
private _trgtPos = getpos _killer;
//If this gets attached to a player, then exit before doing anything
if (isPlayer _unit) exitWith {};
//Check to see if this unit should be moving to support others or not
//Check to see if this unit is garrisoned. If so, don't do anything
//Check to see if unit has radio. If the unit does not have a radio, then it will not move to support
private _checkStatus = assignedItems _unit;
if (isNil "_checkStatus" || {(_unit getVariable ["Vcm_Disable",false])} || {!("ItemRadio" in _checkStatus)}) exitWith {};
private _arrayOrg = _unit call VCM_fnc_FriendlyArray;
_arrayOrg = _arrayOrg - VCM_ARTYLST;
//Remove players
{if (isPlayer _x) then {_arrayOrg deleteAt _foreachIndex;};} foreach _arrayOrg;
private _array2 = _killer call VCM_fnc_FriendlyArray;
_array2 = _array2 - VCM_ARTYLST;
{
if (_x distance _killer > 501) then {_array2 = _array2 - [_x];};
} foreach _array2;
sleep VCM_WARNDELAY;
private _EnemyCount = count _array2;
private _RespondCount = 0;
private _aliveCount = {alive _x} count (units _unitGroup);
if (_aliveCount > 0) then
{
{
if (_RespondCount < _EnemyCount) then
{
private _checkStatus2 = assignedItems _x;
if (!(isNil "_checkStatus2") && {!(_x getVariable ["Vcm_Disable",false])} && {!(_x getVariable ["VCM_NOFLANK",false])} && {!(_x getVariable ["VCM_NORESCUE",false])} && {!(_x getVariable ["VCM_MOVE2SUP",false])} && {"ItemRadio" in _checkStatus2}) then
{
private _group = group _x;
if ((count (waypoints _group)) < 2) then
{
private _WaypointCheck = _group call VCM_fnc_WyptChk;
if (count _WaypointCheck < 1) then
{
if ((_x distance2D _unit) <= VCM_WARNDIST) then
{
_x setbehaviour "AWARE";
(group _x) setVariable ["VCM_MOVE2SUP",true];
if !(vehicle _x isEqualTo _x) then
{
_RespondCount = _RespondCount + count (crew (vehicle _x));
private _Driver = (driver (vehicle _x));
//systemchat format ["_RespondCountDRIVER %1 GROUP: %2",[_EnemyCount,_RespondCount],(group _x)];
_waypoint2 = (group _Driver) addwaypoint[_trgtPos,15,150];
_waypoint2 setwaypointtype "MOVE";
_waypoint2 setWaypointSpeed "NORMAL";
//_waypoint2 setWaypointBehaviour "AWARE";
[(group _Driver), (_waypoint2 select 1)] setWaypointCompletionRadius 25;
}
else
{
_RespondCount = _RespondCount + (count (units (group _x)));
//systemchat format ["_RespondCount %1 GROUP: %2",[_EnemyCount,_RespondCount],(group _x)];
_waypoint2 = (group _x) addwaypoint[_trgtPos,15,150];
_waypoint2 setwaypointtype "MOVE";
_waypoint2 setWaypointSpeed "NORMAL";
//_waypoint2 setWaypointBehaviour "AWARE";
[(group _x), (_waypoint2 select 1)] setWaypointCompletionRadius 25;
_waypoint2 = (group _x) addwaypoint[_trgtPos,15,150];
_waypoint2 setwaypointtype "MOVE";
_waypoint2 setWaypointSpeed "NORMAL";
//_waypoint2 setWaypointBehaviour "AWARE";
[(group _x), (_waypoint2 select 1)] setWaypointCompletionRadius 25;
};
(group _x) spawn
{
sleep 300;
_this setVariable ["VCM_MOVE2SUP",false];
};
};
};
};
};
};
} foreach _arrayOrg;
};