-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathfn_FrmChnge.sqf
More file actions
122 lines (92 loc) · 2.61 KB
/
Copy pathfn_FrmChnge.sqf
File metadata and controls
122 lines (92 loc) · 2.61 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
/*
Author: Genesis
Description:
Changes group formation dependent on surroundings and behaviour
Parameter(s):
0: OBJECT - Unit whose group to change formation
Returns:
BOOL
*/
private ["_unit", "_nearestCity", "_locationPos", "_nearestVillage", "_locationPos2", "_nearestHill", "_locationPos4", "_nearestLocal", "_locationPos3"];
//Pull the unit
_unit = _this;
//Grab the group of the unit
_group = group _unit;
//Vehicular groups in "SAFE" behaviour will move in convoys
if (!isNull objectParent _unit && {behaviour _unit == "SAFE"}) exitWith
{
_group setFormation "FILE";
//Set the units variable so they dont try changing formations too frequently.
_VCOM_CHANGEDFORMATION = true;
_VCOM_CHANGEDFORMATION
};
//Grab the nearest "City" from the unit
_nearestCity = nearestLocation [getPosASL _unit, "nameCity"];
//Lets grab the location position
_locationPos = locationPosition _nearestCity;
//If the unit is less than 500 meters from the location exit with the following code
if ((_locationPos distance _unit) < 500) exitWith
{
//Check if the unit is in a vehicle or not
if (!isNull objectParent _unit) then
{
_group setFormation "COLUMN";
}
else
{
_group setFormation "STAG COLUMN";
};
//Set the units variable so they dont try changing formations too frequently.
_VCOM_CHANGEDFORMATION = true;
_VCOM_CHANGEDFORMATION
};
//The rest of the commands follow the same logic. Commenting where necessary.
_nearestVillage = nearestLocation [getPosASL _unit, "NameVillage"];
_locationPos2 = locationPosition _nearestVillage;
if ((_locationPos2 distance _unit) < 500) exitWith
{
if ((vehicle _unit) != _unit) then
{
_group setFormation "COLUMN";
}
else
{
_group setFormation "STAG COLUMN";
};
_VCOM_CHANGEDFORMATION = true;
_VCOM_CHANGEDFORMATION
};
_nearestHill = nearestLocation [getPosASL _unit, "Hill"];
_locationPos4 = locationPosition _nearestHill;
if ((_locationPos4 distance _unit) < 500) exitWith
{
if ((vehicle _unit) != _unit) then
{
_group setFormation "LINE";
}
else
{
_group setFormation "LINE";
};
_VCOM_CHANGEDFORMATION = true;
_VCOM_CHANGEDFORMATION
};
_nearestLocal = nearestLocation [getPosASL _unit, "NameLocal"];
_locationPos3 = locationPosition _nearestLocal;
if ((_locationPos3 distance _unit) < 300) exitWith
{
if ((vehicle _unit) != _unit) then
{
_group setFormation "COLUMN";
}
else
{
_group setFormation "COLUMN";
};
_VCOM_CHANGEDFORMATION = true;
_VCOM_CHANGEDFORMATION
};
//Execute this code only when all the above were NOT true. Return to wedge formation
_group setFormation "WEDGE";
_VCOM_CHANGEDFORMATION = true;
_VCOM_CHANGEDFORMATION