Skip to content

Commit f4cc1d5

Browse files
authored
Fix group assaults (#420)
* Fix group assaults Fix tacticsAssaults were bugged potentially leaving units with FSM switched off Improve Take advantage of "getUnitState" Improve sort building positions to ensure nearest spots are always used Improve use groupMemory as function goes along -- to prevent rechecking cleared positions * Update fnc_doGroupAssault.sqf Harsh criticism from the German league.
1 parent 0b3d053 commit f4cc1d5

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

addons/danger/functions/fnc_tacticsAssault.sqf

+7-10
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
*
1919
* Public: No
2020
*/
21-
params ["_group", "_target", ["_units", []], ["_cycle", 18], ["_delay", 70]];
21+
params ["_group", "_target", ["_units", []], ["_cycle", 18], ["_delay", 85]];
2222

2323
// group is missing
2424
if (isNull _group) exitWith {false};
@@ -70,20 +70,16 @@ if (_units isEqualTo []) then {
7070
if (_units isEqualTo []) exitWith {false};
7171

7272
// sort potential targets
73-
private _buildings = [_target, 28, false, false] call EFUNC(main,findBuildings);
73+
private _buildings = [_target, 28, true, false, true] call EFUNC(main,findBuildings);
7474
_buildings = _buildings apply { [_unit distanceSqr _x, _x] };
7575
_buildings sort true;
7676
_buildings = _buildings apply { _x select 1 };
77-
private _housePos = [];
78-
{
79-
_housePos append (_x buildingPos -1);
80-
} forEach _buildings;
8177

8278
// add building positions to group memory
83-
_group setVariable [QEGVAR(main,groupMemory), _housePos];
79+
_group setVariable [QEGVAR(main,groupMemory), _buildings];
8480

8581
// add base position
86-
if (_housePos isEqualTo []) then {_housePos pushBack _target;};
82+
if (_buildings isEqualTo []) then {_buildings pushBack _target;};
8783

8884
// find vehicles
8985
private _vehicles = [_unit] call EFUNC(main,findReadyVehicles);
@@ -93,7 +89,7 @@ if (_overwatch isNotEqualTo []) then {
9389
private _roads = _overwatch nearRoads 30;
9490
if (_roads isNotEqualTo []) then {_overwatch = ASLToAGL (getPosASL (selectRandom _roads))};
9591
_x doMove _overwatch;
96-
_x doWatch (selectRandom _housePos);
92+
_x doWatch (selectRandom _buildings);
9793
} forEach _vehicles;
9894
};
9995

@@ -125,14 +121,15 @@ if (!GVAR(disableAutonomousSmokeGrenades)) then {
125121
_group setFormDir (_unit getDir _target);
126122
_group enableIRLasers true;
127123
_units doWatch objNull;
124+
doStop _units;
128125

129126
// check for reload
130127
{
131128
reload _x;
132129
} forEach (_units select {getSuppression _x < 0.7 && {needReload _x > 0.6}});
133130

134131
// execute function
135-
[{_this call EFUNC(main,doGroupAssault)}, [_cycle, _units + [_unit], _housePos], 2 + random 3] call CBA_fnc_waitAndExecute;
132+
[{_this call EFUNC(main,doGroupAssault)}, [_cycle, _units + [_unit], _buildings], 2 + random 3] call CBA_fnc_waitAndExecute;
136133

137134
// debug
138135
if (EGVAR(main,debug_functions)) then {

addons/main/functions/GroupAction/fnc_doGroupAssault.sqf

+11-3
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ if (_units isEqualTo [] || {_pos isEqualTo []}) exitWith {
3333
// get targetPos
3434
private _targetPos = _pos select 0;
3535

36+
// reorder positions
37+
_pos = _pos apply {[_targetPos isEqualTo (round (_x select 2)), _targetPos distanceSqr _x, _x]};
38+
_pos sort true;
39+
_pos = _pos apply {_x select 2};
40+
3641
{
3742
// get unit
3843
private _unit = _x;
@@ -42,7 +47,7 @@ private _targetPos = _pos select 0;
4247
// manoeuvre
4348
_unit forceSpeed 3;
4449
_unit setUnitPos (["UP", "MIDDLE"] select ((getSuppression _x) isNotEqualTo 0 || {_unit distance2D _assaultPos > 8}));
45-
_unit setVariable [QGVAR(currentTask), format ["Group Assault (%1c - %2p)", _cycle, count _pos], GVAR(debug_functions)];
50+
_unit setVariable [QGVAR(currentTask), format ["Group Assault @ %1m", round (_unit distance _assaultPos)], GVAR(debug_functions)];
4651
_unit setVariable [QEGVAR(danger,forceMove), true];
4752

4853
// modify movement (if far)
@@ -51,14 +56,17 @@ private _targetPos = _pos select 0;
5156
};
5257
// set movement
5358
if (((expectedDestination _unit) select 0) distanceSqr _assaultPos > 1) then {
54-
5559
_unit doMove _assaultPos;
5660
_unit setDestination [_assaultPos, "LEADER PLANNED", true];
5761
};
5862

5963
// remove positions
6064
_pos = _pos select {[objNull, "VIEW", objNull] checkVisibility [eyePos _unit, (AGLToASL _x) vectorAdd [0, 0, 0.5]] < 0.01};
61-
} forEach _units;
65+
66+
} forEach (_units select {!((getUnitState _x) in ["PLANNING", "BUSY"])});
67+
68+
// update group variable
69+
(group (_units select 0)) setVariable [QGVAR(groupMemory), _pos, false];
6270

6371
// remove positions
6472
_pos = _pos select {(_units select 0) distance _x > 3};

0 commit comments

Comments
 (0)