Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix group assaults #420

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions addons/danger/functions/fnc_tacticsAssault.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*
* Public: No
*/
params ["_group", "_target", ["_units", []], ["_cycle", 18], ["_delay", 70]];
params ["_group", "_target", ["_units", []], ["_cycle", 18], ["_delay", 85]];

// group is missing
if (isNull _group) exitWith {false};
Expand Down Expand Up @@ -70,20 +70,16 @@ if (_units isEqualTo []) then {
if (_units isEqualTo []) exitWith {false};

// sort potential targets
private _buildings = [_target, 28, false, false] call EFUNC(main,findBuildings);
private _buildings = [_target, 28, true, false, true] call EFUNC(main,findBuildings);
_buildings = _buildings apply { [_unit distanceSqr _x, _x] };
_buildings sort true;
_buildings = _buildings apply { _x select 1 };
private _housePos = [];
{
_housePos append (_x buildingPos -1);
} forEach _buildings;

// add building positions to group memory
_group setVariable [QEGVAR(main,groupMemory), _housePos];
_group setVariable [QEGVAR(main,groupMemory), _buildings];

// add base position
if (_housePos isEqualTo []) then {_housePos pushBack _target;};
if (_buildings isEqualTo []) then {_buildings pushBack _target;};

// find vehicles
private _vehicles = [_unit] call EFUNC(main,findReadyVehicles);
Expand All @@ -93,7 +89,7 @@ if (_overwatch isNotEqualTo []) then {
private _roads = _overwatch nearRoads 30;
if (_roads isNotEqualTo []) then {_overwatch = ASLToAGL (getPosASL (selectRandom _roads))};
_x doMove _overwatch;
_x doWatch (selectRandom _housePos);
_x doWatch (selectRandom _buildings);
} forEach _vehicles;
};

Expand Down Expand Up @@ -125,14 +121,15 @@ if (!GVAR(disableAutonomousSmokeGrenades)) then {
_group setFormDir (_unit getDir _target);
_group enableIRLasers true;
_units doWatch objNull;
doStop _units;

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

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

// debug
if (EGVAR(main,debug_functions)) then {
Expand Down
14 changes: 11 additions & 3 deletions addons/main/functions/GroupAction/fnc_doGroupAssault.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ if (_units isEqualTo [] || {_pos isEqualTo []}) exitWith {
// get targetPos
private _targetPos = _pos select 0;

// reorder positions
_pos = _pos apply {[_targetPos isEqualTo (round (_x select 2)), _targetPos distanceSqr _x, _x]};
_pos sort true;
_pos = _pos apply {_x select 2};

{
// get unit
private _unit = _x;
Expand All @@ -42,7 +47,7 @@ private _targetPos = _pos select 0;
// manoeuvre
_unit forceSpeed 3;
_unit setUnitPos (["UP", "MIDDLE"] select ((getSuppression _x) isNotEqualTo 0 || {_unit distance2D _assaultPos > 8}));
_unit setVariable [QGVAR(currentTask), format ["Group Assault (%1c - %2p)", _cycle, count _pos], GVAR(debug_functions)];
_unit setVariable [QGVAR(currentTask), format ["Group Assault @ %1m", round (_unit distance _assaultPos)], GVAR(debug_functions)];
_unit setVariable [QEGVAR(danger,forceMove), true];

// modify movement (if far)
Expand All @@ -51,14 +56,17 @@ private _targetPos = _pos select 0;
};
// set movement
if (((expectedDestination _unit) select 0) distanceSqr _assaultPos > 1) then {

_unit doMove _assaultPos;
_unit setDestination [_assaultPos, "LEADER PLANNED", true];
};

// remove positions
_pos = _pos select {[objNull, "VIEW", objNull] checkVisibility [eyePos _unit, (AGLToASL _x) vectorAdd [0, 0, 0.5]] < 0.01};
} forEach _units;

// update group variable
(group _unit) setVariable [QGVAR(groupMemory), _pos, false];

} forEach (_units select {!((getUnitState _x) in ["PLANNING", "BUSY"])});

// remove positions
_pos = _pos select {(_units select 0) distance _x > 3};
Expand Down
Loading