-
Notifications
You must be signed in to change notification settings - Fork 149
/
fnc_moduleDefend.sqf
75 lines (60 loc) · 2.13 KB
/
fnc_moduleDefend.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
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
#include "script_component.hpp"
/* ----------------------------------------------------------------------------
Function: CBA_fnc_moduleDefend
Description:
A function for commanding a group to defend a location with information
parsed from a module.
Parameters:
- Logic (Object)
- Group Leader(s) (Array)
Optional:
Logic Parameters (Must be passed associated with Object using "setVariable")
- Location Type (String)
setVariable ["defendLocType", value]
- Defend Position (XYZ, Object, Location, Group, Marker, or Task)
setVariable ["defendPosition", value]
- Building Threshold (Scalar)
setVariable ["threshold", value]
- Can Patrol (Bool)
setVariable ["canPatrol", vaule]
Example:
(begin example)
[Logic, [group1, group2,..., groupN]] call CBA_fnc_moduleDefend
(end)
Returns:
Nil
Author:
WiredTiger
---------------------------------------------------------------------------- */
params [
["_logic", objNull, [objNull]],
["_groups", [], [[]]],
"_localGroups",
"_defendPos",
"_defendLocType",
"_defendRadius",
"_defendSetPos",
"_threshold",
"_canPatrol"
];
// Only server, dedicated, or headless beyond this point
if (hasInterface && !isServer) exitWith {};
_localGroups = _groups select {local _x};
if (_localGroups isEqualTo []) exitWith {};
// Define variables
_defendLocType = _logic getVariable ["defendLocType", ""];
_defendPos = _logic getVariable ["defendPosition", objNull];
_defendSetPos = false;
// Parse defend position from string
_defendPos = [_defendLocType, _defendPos] call CBA_fnc_getPosFromString;
if (isNil "_defendPos") then {_defendSetPos = true;};
// Define if allowed to patrol
_canPatrol = _logic getVariable ["canPatrol", 0.1];
_shouldHold = _logic getVariable ["shouldHold", 0];
// Command local group leaders to defend area
_defendRadius = _logic getVariable ["defendRadius", 25];
_threshold = _logic getVariable ["threshold", 2];
{
if (_defendSetPos) then {_defendPos = getPos _x;};
[_x, _defendPos, _defendRadius, _threshold, _canPatrol, _shouldHold] call CBA_fnc_taskDefend;
} forEach _localGroups;