Skip to content

Commit

Permalink
Improve vehicle maneuverability and defenses
Browse files Browse the repository at this point in the history
Adds Vehicle smoke usage when dropping off troops, or Jinking/dodging danger
Adds road checks to Assault, Flank and VehicleJink (to improve manoeuvrability)
Adds pseudo-fire team based bounds to infantry flanking together with Vehicles.

Relies on #341
  • Loading branch information
nk3nny committed Mar 4, 2024
1 parent 618424f commit f8cf007
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 11 deletions.
9 changes: 8 additions & 1 deletion addons/danger/functions/fnc_brainVehicle.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,13 @@ if (_armored && {!isNull _dangerCausedBy}) exitWith {
&& {!(terrainIntersectASL [eyePos _vehicle, (eyePos _dangerCausedBy) vectorAdd [0, 0, 2]]) || {_distance < 200}}
) exitWith {

// use smoke if available
private _time = _vehicle getVariable [QEGVAR(main,smokescreenTime), 0];
if (RND(0.6) && {_time < time}) then {
(commander _vehicle) forceWeaponFire ["SmokeLauncher", "SmokeLauncher"];
_vehicle setVariable [QEGVAR(main,smokescreenTime), time + 30 + random 20];
};

// define enemy direction
_group setFormDir (_vehicle getDir _dangerCausedBy);
_cargo doMove _dangerPos;
Expand Down Expand Up @@ -203,7 +210,7 @@ if (_car) exitWith {
private _slow = speed _vehicle < 30;

// escape ~ if enemy within 15-50 meters or explosions are nearby!
if (_slow && {_cause isEqualTo DANGER_EXPLOSION || {_vehicle distanceSqr _dangerCausedBy < (225 + random 1225)}}) exitWith {
if (_slow && {(side _dangerCausedBy) isNotEqualTo (side _unit)} && {_cause isEqualTo DANGER_EXPLOSION || {_vehicle distanceSqr _dangerCausedBy < (225 + random 1225)}}) exitWith {
[_unit] call EFUNC(main,doVehicleJink);
[_timeout + 3] + _causeArray
};
Expand Down
14 changes: 13 additions & 1 deletion 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", 16], ["_delay", 70]];
params ["_group", "_target", ["_units", []], ["_cycle", 18], ["_delay", 70]];

// group is missing
if (isNull _group) exitWith {false};
Expand Down Expand Up @@ -82,6 +82,18 @@ _group setVariable [QEGVAR(main,groupMemory), _housePos];
// add base position
if (_housePos isEqualTo []) then {_housePos pushBack _target;};

// find vehicles
private _vehicles = [_unit] call EFUNC(main,findReadyVehicles);
private _overwatch = [POSITIONAGL(_unit), EGVAR(main,minSuppressionRange) * 2, EGVAR(main,minSuppressionRange), 4, _target] call EFUNC(main,findOverwatch);

Check failure on line 87 in addons/danger/functions/fnc_tacticsAssault.sqf

View workflow job for this annotation

GitHub Actions / build

unparseable syntax

unparseable syntax
if (_overwatch isNotEqualTo []) then {
{
private _roads = _overwatch nearRoads 30;
if (_roads isNotEqualTo []) then {_overwatch = POSITIONAGL(selectRandom _roads);};
_x doMove _overwatch;
_x doWatch (selectRandom _housePos);
} forEach _vehicles;
};

// set tasks
_unit setVariable [QEGVAR(main,currentTarget), _target, EGVAR(main,debug_functions)];
_unit setVariable [QEGVAR(main,currentTask), "Tactics Assault", EGVAR(main,debug_functions)];
Expand Down
20 changes: 12 additions & 8 deletions addons/main/functions/GroupAction/fnc_doGroupFlank.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@
*
* Public: No
*/
params ["_cycle", "_units", "_vehicles", "_pos", "_overwatch"];
params ["_cycle", "_units", "_vehicles", "_pos", "_overwatch", ["_teamAlpha", 0]];

// update
_units = _units select { _x call FUNC(isAlive) && { !isPlayer _x } && {_x distance2D _overwatch > 5}};
_vehicles = _vehicles select { canFire _x };

private _posASL = AGLtoASL (selectRandom _pos);

{
private _suppressed = (getSuppression _x) > 0.5;
_x setUnitPos (["MIDDLE", "DOWN"] select _suppressed);
Expand All @@ -36,31 +34,37 @@ private _posASL = AGLtoASL (selectRandom _pos);
_x setVariable [QEGVAR(danger,forceMove), !_suppressed];

// suppress
private _posASL = AGLtoASL (selectRandom _pos);
if (
RND(0.6)
&& {(leader _x) isNotEqualTo _x}
(_forEachIndex mod 2) isEqualTo _teamAlpha
&& {!(terrainIntersectASL [eyePos _x, _posASL vectorAdd [0, 0, 3]])}
) then {
[{_this call FUNC(doSuppress)}, [_x, _posASL vectorAdd [0, 0, random 1], true], random 3] call CBA_fnc_waitAndExecute;
[{_this call FUNC(doSuppress)}, [_x, _posASL vectorAdd [0, 0, random 1], true], 1 + random 3] call CBA_fnc_waitAndExecute;
};
} foreach _units;

// reset alpha status
_teamAlpha = [0, 1] select (_teamAlpha isEqualTo 0);

// vehicles
if (_cycle isEqualTo 1) then {
if ((_cycle mod 2) isEqualTo 0) then {
{
private _posAGL = selectRandom _pos;
_x doWatch _posAGL;
[_x, _posAGL] call FUNC(doVehicleSuppress);
} foreach _vehicles;
} else {
// check for roads
private _roads = _overwatch nearRoads 50;
if (_roads isNotEqualTo []) exitWith {_vehicles doMove (POSITIONAGL(selectRandom _roads));};

Check failure on line 59 in addons/main/functions/GroupAction/fnc_doGroupFlank.sqf

View workflow job for this annotation

GitHub Actions / build

unparseable syntax

unparseable syntax
_vehicles doMove _overwatch;
};

// recursive cyclic
if !(_cycle <= 1 || {_units isEqualTo []}) then {
[
{_this call FUNC(doGroupFlank)},
[_cycle - 1, _units, _vehicles, _pos, _overwatch],
[_cycle - 1, _units, _vehicles, _pos, _overwatch, _teamAlpha],
10 + random 8
] call CBA_fnc_waitAndExecute;
};
Expand Down
10 changes: 9 additions & 1 deletion addons/main/functions/VehicleAction/fnc_doVehicleJink.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,16 @@ _destination = _destination select {(_x isNotEqualTo []) && {!(surfaceIsWater _x
if (_destination isEqualTo []) exitWith { getPosASL _unit };
_destination = selectRandom _destination;

// check for roads
private _roads = _destination nearRoads (_range * 0.5);
if (_roads isNotEqualTo []) then {_destination = POSITIONAGL(selectRandom _roads);};

Check failure on line 63 in addons/main/functions/VehicleAction/fnc_doVehicleJink.sqf

View workflow job for this annotation

GitHub Actions / build

unparseable syntax

unparseable syntax

// make tanks pop smoke when moving
// _vehicle forceweaponfire ["SmokeLauncher", "SmokeLauncher"]; <-- not working! Will revist at a later date - nkenny
private _time = _vehicle getVariable [QGVAR(smokescreenTime), 0];
if (RND(0.4) && {_time < time}) then {
(commander _vehicle) forceWeaponFire ["SmokeLauncher", "SmokeLauncher"];
_vehicle setVariable [QGVAR(smokescreenTime), time + 30 + random 20];
};

// execute
_vehicle doMove _destination;
Expand Down

0 comments on commit f8cf007

Please sign in to comment.