-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinitPlatoonGroups.sqf
162 lines (140 loc) · 4.99 KB
/
initPlatoonGroups.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
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
// // File: functions\config\fn_initPlatoonGroups.sqf
// /*
// Author: Your Name
// Description: Initializes or replenishes a NATO infantry platoon
// Parameters:
// _spawnPos: Array/Object - Position to spawn units [x,y,z] or object
// _replenish: Boolean - True to check and replenish existing groups
// Returns: Array of groups created/replenished
// Example:
// [getMarkerPos "platoon_start", false] call DPC_fnc_initPlatoonGroups;
// */
// params [
// ["_spawnPos", [0,0,0], [[],objNull]],
// ["_replenish", false, [false]]
// ];
// // NATO Infantry unit types
// #define UNIT_OFFICER "B_officer_F"
// #define UNIT_SQL "B_Soldier_SL_F"
// #define UNIT_TL "B_Soldier_TL_F"
// #define UNIT_MEDIC "B_medic_F"
// #define UNIT_AR "B_soldier_AR_F"
// #define UNIT_GREN "B_Soldier_GL_F"
// #define UNIT_LAT "B_soldier_LAT_F"
// #define UNIT_RADIO "B_Soldier_lite_F"
// // Platoon structure definitions
// private _platoonStructure = [
// // HQ Squad - 4 men
// [
// "HQ", [
// [UNIT_OFFICER, "Platoon Commander"],
// [UNIT_MEDIC, "Platoon Medic"],
// [UNIT_RADIO, "Platoon RTO"],
// [UNIT_TL, "Platoon Sergeant"]
// ]
// ],
// // Three identical infantry squads - 8 men each
// [
// "Alpha", [
// [UNIT_SQL, "Squad Leader"],
// [UNIT_TL, "Team Leader"],
// [UNIT_AR, "Automatic Rifleman"],
// [UNIT_GREN, "Grenadier"],
// [UNIT_LAT, "AT Specialist"],
// [UNIT_TL, "Team Leader"],
// [UNIT_AR, "Automatic Rifleman"],
// [UNIT_MEDIC, "Squad Medic"]
// ]
// ],
// [
// "Bravo", [
// [UNIT_SQL, "Squad Leader"],
// [UNIT_TL, "Team Leader"],
// [UNIT_AR, "Automatic Rifleman"],
// [UNIT_GREN, "Grenadier"],
// [UNIT_LAT, "AT Specialist"],
// [UNIT_TL, "Team Leader"],
// [UNIT_AR, "Automatic Rifleman"],
// [UNIT_MEDIC, "Squad Medic"]
// ]
// ],
// [
// "Charlie", [
// [UNIT_SQL, "Squad Leader"],
// [UNIT_TL, "Team Leader"],
// [UNIT_AR, "Automatic Rifleman"],
// [UNIT_GREN, "Grenadier"],
// [UNIT_LAT, "AT Specialist"],
// [UNIT_TL, "Team Leader"],
// [UNIT_AR, "Automatic Rifleman"],
// [UNIT_MEDIC, "Squad Medic"]
// ]
// ]
// ];
// // Convert spawn position
// _spawnPos = if (_spawnPos isEqualType objNull) then {
// getPos _spawnPos
// } else {
// _spawnPos
// };
// // Initialize platoon groups array if needed
// if (isNil "PLATOON_GROUPS" && !_replenish) then {
// PLATOON_GROUPS = [];
// };
// // Function to create a single unit
// private _fnc_createUnit = {
// params ["_type", "_role", "_group", "_pos"];
// private _unit = _group createUnit [_type, _pos, [], 5, "NONE"];
// _unit setRank "PRIVATE";
// _unit setVariable ["DPC_Role", _role, true]; // Added true for global broadcast
// // Set ranks based on role
// switch (toLower _role) do {
// case "platoon commander": { _unit setRank "LIEUTENANT" };
// case "platoon sergeant": { _unit setRank "SERGEANT" };
// case "squad leader": { _unit setRank "SERGEANT" };
// case "team leader": { _unit setRank "CORPORAL" };
// default { _unit setRank "PRIVATE" };
// };
// _unit
// };
// // Process each squad in the platoon structure
// {
// _x params ["_squadName", "_composition"];
// private "_group";
// // Check if group exists when replenishing
// if (_replenish) then {
// {
// if ((_x getVariable ["DPC_SquadName", ""]) == _squadName) exitWith {
// _group = _x;
// };
// } forEach PLATOON_GROUPS;
// };
// // Create new group if needed
// if (isNil "_group" || {isNull _group}) then {
// _group = createGroup [west, true];
// _group setVariable ["DPC_SquadName", _squadName, true]; // Added true for global broadcast
// PLATOON_GROUPS pushBack _group;
// };
// // Create or replenish units
// {
// _x params ["_type", "_role"];
// // Check if we need this role when replenishing
// private _needUnit = true;
// if (_replenish) then {
// {
// if (alive _x && {_x getVariable ["DPC_Role", ""] == _role}) exitWith {
// _needUnit = false;
// };
// } forEach (units _group);
// };
// // Create unit if needed
// if (_needUnit) then {
// [_type, _role, _group, _spawnPos] call _fnc_createUnit;
// };
// } forEach _composition;
// // Basic group settings
// _group enableDynamicSimulation true;
// _group setFormation "WEDGE";
// } forEach _platoonStructure;
// // Return the groups array
// PLATOON_GROUPS