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

Add features to fnc_tacticsReinforce.sqf #389

Merged
merged 5 commits into from
May 5, 2024
Merged
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
66 changes: 52 additions & 14 deletions addons/danger/functions/fnc_tacticsReinforce.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if (!(_unit call EFUNC(main,isAlive))) exitWith {false};
// free garrisons
private _group = group _unit;
if (EGVAR(main,Loaded_WP) && {!(_unit checkAIFeature "PATH")}) then {
_group = [_group, true] call EFUNC(wp,taskReset);
_group = [_group, true, true] call EFUNC(wp,taskReset);
};

// set new time
Expand All @@ -42,7 +42,7 @@ _group setVariable [QEGVAR(main,currentTactic), "Reinforcing", EGVAR(main,debug_
_group setVariable [QGVAR(isExecutingTactic), true];
_group setVariable [QGVAR(contact), time + _delay];
_group enableAttack false; // gives better fine control of AI - nkenny
_group setBehaviour "AWARE"; // more tractacle speed
_group setBehaviour "AWARE"; // more tractable speed

// reset
[
Expand All @@ -69,41 +69,79 @@ if (_units isEqualTo []) then {
_units = units _unit;
};

// set waiting time for movement order
private _waitForMove = 5;

// get vehicles
private _assignedVehicles = assignedVehicles _group;

// check waypoints -- if none add new?

// commander vehicles? ~ future versions with setting ~ nkenny
if (_assignedVehicles isEqualTo []) then {
private _vehicles = nearestObjects [_unit, ["Landvehicle"], 75];
private _side = getNumber (configOf _unit >> "side");
_vehicles = _vehicles select {alive _x && canMove _x && simulationEnabled _x && {(crew _x) isEqualTo []} && { !isObjectHidden _x } && { locked _x != 2 } && {(getNumber (configOf _x >> "side")) isEqualTo _side}};
if (_vehicles isNotEqualTo []) then {
{
_group addVehicle _x;
_waitForMove = _waitForMove + 2;
} forEach _vehicles;
};
};


// check for unregistered static weapons
private _guns = _units select {(vehicle _x) isKindOf "StaticWeapon"};
if ((_group getVariable [QEGVAR(main,staticWeaponList), []]) isEqualTo []) then {
_group setVariable [QEGVAR(main,staticWeaponList), _guns, true];
_waitForMove = _waitForMove + 1;
};

// check bodies
private _weaponHolders = allDeadMen findIf { (_x distance2D _unit) < 35 };
if (_weaponHolders isNotEqualTo -1) then {
{
[{_this call EFUNC(main,doCheckBody);}, [_x, _x getPos [20, random 360], 35], random 2] call CBA_fnc_waitAndExecute;
_waitForMove = _waitForMove + 2;
} forEach _units;
};

// has artillery? ~ if so fire in support?
// is aircraft or tank? Different movement waypoint?

// clear HOLD waypointss
// clear HOLD, GUARD and DISMISS waypoints
private _waypoints = waypoints _group;
private _currentWP = _waypoints select ((currentWaypoint _group) min ((count _waypoints) - 1));
if ((waypointType _currentWP) isEqualTo "HOLD") then {
[_group] call CBA_fnc_clearWaypoints;
if (_waypoints isNotEqualTo []) then {
private _currentWP = _waypoints select ((currentWaypoint _group) min ((count _waypoints) - 1));
if ((waypointType _currentWP) in ["HOLD", "GUARD", "DISMISS"]) then {
[_group] call CBA_fnc_clearWaypoints;
};
};

// formation changes ~ allowed here as Reinforcing units have full autonomy - nkenny
private _distance = _unit distance2D _target;
if (_distance > 500) then {
_unit setFormation "COLUMN";
_group setFormation selectRandom ["COLUMN", "STAG COLUMN"];
if !(isNull objectParent _unit) then {(vehicle _unit) setUnloadInCombat [false, false];};
} else {
if (_distance > 200) then {
_unit setFormation selectRandom ["WEDGE", "VEE", "LINE"];
_group setFormation selectRandom ["WEDGE", "VEE", "LINE"];
};
if (_distance < GVAR(cqbRange)) then {
_unit setFormation "FILE";
[_unit, _target] call FUNC(tacticsAssault);
// _group setFormation "FILE"; ~formation is set in tacticsAssault ~KRM
[_group, _target] call FUNC(tacticsAssault);
};
};

// pack & deploy static weapons
if !(GVAR(disableAIDeployStaticWeapons)) then {
private _intersect = terrainIntersectASL [eyePos _unit, AGLtoASL (_target vectorAdd [0, 0, 10])];
if (_distance > 400 || {_intersect}) then {
_units = [_units] call EFUNC(main,doGroupStaticPack);
_units = [leader _group] call EFUNC(main,doGroupStaticPack);
};
if (!_intersect) then {
_units = [_units, _target] call EFUNC(main,doGroupStaticDeploy);
_units = [leader _group, _target] call EFUNC(main,doGroupStaticDeploy);
};
};

Expand All @@ -119,7 +157,7 @@ if (!(GVAR(disableAutonomousFlares)) && {_unit call EFUNC(main,isNight)}) then {
_group move _target;
},
[_group, _target],
5
_waitForMove
] call CBA_fnc_waitAndExecute;

// debug
Expand All @@ -128,7 +166,7 @@ if (EGVAR(main,debug_functions)) then {
"%1 TACTICS REINFORCING (%2 with %3 units @ %4m)",
side _unit,
name _unit,
count _units,
count units _group,
round (_unit distance2D _target)
] call EFUNC(main,debugLog);
private _m = [_unit, format ["Reinforcing @ %1m", round (_unit distance2D _target)], _unit call EFUNC(main,debugMarkerColor), "hd_warning"] call EFUNC(main,dotMarker);
Expand Down
Loading