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

Improve vehicle maneuverability and defenses #388

Merged
merged 4 commits into from
May 5, 2024
Merged
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
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 = [ASLtoAGL (getPosASL _unit), EGVAR(main,minSuppressionRange) * 2, EGVAR(main,minSuppressionRange), 4, _target] call EFUNC(main,findOverwatch);
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);
} 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 % 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 = parseNumber (_teamAlpha isEqualTo 0);

// vehicles
if (_cycle isEqualTo 1) then {
if ((_cycle % 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 (ASLtoAGL (getPosASL (selectRandom _roads)));};
_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 = ASLtoAGL (getPosASL (selectRandom _roads));};

// 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
2 changes: 1 addition & 1 deletion tools/sqf_linter_LogChecker.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import sys
import os

defaultFalsePositives = 20
defaultFalsePositives = 22
def main():
f = open("sqf.log", "r")
log = f.readlines()
Expand Down
Loading