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 Group and Contact Suppression #345

Merged
merged 5 commits into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
32 changes: 27 additions & 5 deletions addons/danger/functions/fnc_tacticsContact.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ _group setVariable [QEGVAR(main,currentTactic), "Contact!", EGVAR(main,debug_fun
] call CBA_fnc_waitAndExecute;

// change formation and attack state
_group enableAttack false;
if (isNull objectParent _unit) then {_group enableAttack false;};
_group setFormation (_group getVariable [QGVAR(dangerFormation), formation _unit]);
_group setFormDir (_unit getDir _enemy);

Expand All @@ -68,7 +68,7 @@ _group setFormDir (_unit getDir _enemy);

// gesture + callouts for larger units
private _stealth = (behaviour _unit) isEqualTo "STEALTH";
private _units = (units _unit) select {(currentCommand _x) in ["", "MOVE"] && {!isPlayer _x}};
private _units = (units _unit) select {(currentCommand _x) in ["", "MOVE"] && {!isPlayer _x} && {isNull objectParent _x} && {_x checkAIFeature "MOVE"} && {_x checkAIFeature "PATH"}};
private _count = count _units;
if (_count > 2) then {
// gesture
Expand Down Expand Up @@ -124,6 +124,17 @@ if (
_x setUnitPosWeak selectRandom ["DOWN", "MIDDLE"];
[_x, _posASL vectorAdd [0, 0, 0.8], true] call EFUNC(main,doSuppress);
_x suppressFor 5;
[
{
params ["_unit", "_posASL"];
if (_unit call EFUNC(main,isAlive)) then {
[_unit, _posASL vectorAdd [2 - random 4, 2 - random 4, 0.8], true] call EFUNC(main,doSuppress);
_unit setVariable [QEGVAR(main,currentTask), "Suppress (contact)", EGVAR(main,debug_functions)];
};
},
[_x, _posASL],
5
] call CBA_fnc_waitAndExecute;
_x setVariable [QEGVAR(main,currentTask), "Suppress (contact)", EGVAR(main,debug_functions)];
} foreach _units;

Expand Down Expand Up @@ -155,13 +166,24 @@ if (
) exitWith {
// execute assault ~ forced
{
[_x, _buildings] call EFUNC(main,doAssaultMemory);
//[_x, _buildings] call EFUNC(main,doAssaultMemory);
_x setUnitPos "MIDDLE";
_x forceSpeed 3;
//_x doMove selectRandom _buildings;
_x setVariable [QEGVAR(main,currentTask), "Assault (contact)", EGVAR(main,debug_functions)];

// forced movement
_x setVariable [QGVAR(forceMove), true];
[{_this setVariable [QGVAR(forceMove), nil]}, _x, 5 + random 4] call CBA_fnc_waitAndExecute;
} foreach _units select {getSuppression _x < 0.5};
[
{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check if unit is dead and restore old unitPos

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. Fixed in latest push.

_this setVariable [QGVAR(forceMove), nil];
_this setUnitPos "AUTO";
},
_x,
5 + random 6
] call CBA_fnc_waitAndExecute;
} foreach _units;
_units doMove (_unit getHideFrom _enemy);

// group variable
_group setVariable [QEGVAR(main,currentTactic), "Contact! (aggressive)", EGVAR(main,debug_functions)];
Expand Down
14 changes: 13 additions & 1 deletion addons/main/functions/GroupAction/fnc_doGroupSuppress.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,21 @@ _vehicles = _vehicles select { canFire _x };
if !(_suppress || {(currentCommand _x isEqualTo "Suppress")}) then {
// move forward
_x forceSpeed 3;
_x doMove (_x getPos [20 + random 10, _x getDir _posAGL]);
_x doMove (_x getPos [20, _x getDir _posAGL]);
_x setVariable [QGVAR(currentTask), "Group Suppress (Move)", GVAR(debug_functions)];
};

// follow-up fire
[
{
params ["_unit", "_posASL"];
if (_unit call FUNC(isAlive) && {!(currentCommand _unit isEqualTo "Suppress")}) then {
[_unit, _posASL vectorAdd [2 - random 4, 2 - random 4, 0.8], true] call EFUNC(main,doSuppress);
};
},
[_x, AGLtoASL _posAGL],
5
] call CBA_fnc_waitAndExecute;
} foreach _units;

// vehicles
Expand Down