From 4e6b5308ccaf160b307c6c4a61f067952936f81b Mon Sep 17 00:00:00 2001 From: nk3nny Date: Sun, 18 Feb 2024 13:40:50 +0100 Subject: [PATCH] Improve Group and Contact Suppression (#345) * 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 --- .../danger/functions/fnc_tacticsContact.sqf | 41 +++++++++++++++---- .../GroupAction/fnc_doGroupSuppress.sqf | 14 ++++++- addons/main/functions/fnc_isIndoor.sqf | 2 +- tools/sqf_linter_LogChecker.py | 2 +- 4 files changed, 47 insertions(+), 12 deletions(-) diff --git a/addons/danger/functions/fnc_tacticsContact.sqf b/addons/danger/functions/fnc_tacticsContact.sqf index ae41279c..e780dfa3 100644 --- a/addons/danger/functions/fnc_tacticsContact.sqf +++ b/addons/danger/functions/fnc_tacticsContact.sqf @@ -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); @@ -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 @@ -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 @@ -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)]; diff --git a/addons/main/functions/GroupAction/fnc_doGroupSuppress.sqf b/addons/main/functions/GroupAction/fnc_doGroupSuppress.sqf index e2916784..edac4c6b 100644 --- a/addons/main/functions/GroupAction/fnc_doGroupSuppress.sqf +++ b/addons/main/functions/GroupAction/fnc_doGroupSuppress.sqf @@ -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 diff --git a/addons/main/functions/fnc_isIndoor.sqf b/addons/main/functions/fnc_isIndoor.sqf index 776a26a9..104e5410 100644 --- a/addons/main/functions/fnc_isIndoor.sqf +++ b/addons/main/functions/fnc_isIndoor.sqf @@ -10,7 +10,7 @@ * unit indoor or not * * Example: - * [bob] call lambs_main_fnc_inside; + * [bob] call lambs_main_fnc_isIndoor; * * Public: No */ diff --git a/tools/sqf_linter_LogChecker.py b/tools/sqf_linter_LogChecker.py index a4fa9957..4300e35e 100644 --- a/tools/sqf_linter_LogChecker.py +++ b/tools/sqf_linter_LogChecker.py @@ -1,7 +1,7 @@ import sys import os -defaultFalsePositives = 18 +defaultFalsePositives = 20 def main(): f = open("sqf.log", "r") log = f.readlines()