Skip to content

Commit

Permalink
Improve Group and Contact Suppression (#345)
Browse files Browse the repository at this point in the history
* Improve Group and Contact Suppression

Adds a followup firestate to suppression states
Improves interaction with doAssaultMemory (more predictable)
Fixes vehicles being part of Contact state

* Update fnc_tacticsContact.sqf

Added alive check and reset stance on Contact (Assault)
Fixed edge case scenario which could lead to infantry assaulting to [0,0,0]
Improved timing of Contract (Suppress) and removed some of the debug variables which were being overwritten by 'suppress' regardless.

* Update fnc_tacticsContact.sqf

Removed debug message

* Update fnc_isIndoor.sqf

Tiny change to rerun linter

* Update sqf_linter_LogChecker.py

False positives increased
  • Loading branch information
nk3nny committed Feb 18, 2024
1 parent afdf9bb commit 4e6b530
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 12 deletions.
41 changes: 32 additions & 9 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 @@ -123,8 +123,17 @@ if (
{
_x setUnitPosWeak selectRandom ["DOWN", "MIDDLE"];
[_x, _posASL vectorAdd [0, 0, 0.8], true] call EFUNC(main,doSuppress);
_x suppressFor 5;
_x setVariable [QEGVAR(main,currentTask), "Suppress (contact)", EGVAR(main,debug_functions)];
_x suppressFor 7;
[
{
params ["_unit", "_posASL"];
if (_unit call EFUNC(main,isAlive) && {!(currentCommand _unit isEqualTo "Suppress")}) then {
[_unit, _posASL vectorAdd [2 - random 4, 2 - random 4, 0.8], true] call EFUNC(main,doSuppress);
};
},
[_x, _posASL],
8
] call CBA_fnc_waitAndExecute;
} foreach _units;

// group variable
Expand Down Expand Up @@ -155,13 +164,27 @@ if (
) exitWith {
// execute assault ~ forced
{
[_x, _buildings] call EFUNC(main,doAssaultMemory);
_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};
[
{
params ["_unit", "_unitPos"];
if (_unit call EFUNC(main,isAlive)) then {
_unit setVariable [QGVAR(forceMove), nil];
_unit setUnitPos _unitPos;
};
},
[_x, unitPos _x],
5 + random 6
] call CBA_fnc_waitAndExecute;

// movement and stance
_x setUnitPos "MIDDLE";
_x forceSpeed 3;
_x setVariable [QEGVAR(main,currentTask), "Assault (contact)", EGVAR(main,debug_functions)];

} foreach _units;
_units doMove (selectRandom _buildings);

// 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
2 changes: 1 addition & 1 deletion addons/main/functions/fnc_isIndoor.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* unit indoor or not
*
* Example:
* [bob] call lambs_main_fnc_inside;
* [bob] call lambs_main_fnc_isIndoor;
*
* Public: No
*/
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 = 18
defaultFalsePositives = 20
def main():
f = open("sqf.log", "r")
log = f.readlines()
Expand Down

0 comments on commit 4e6b530

Please sign in to comment.