From 44b57021177425d480bf185c508b4f6c093a58ce Mon Sep 17 00:00:00 2001 From: nk3nny Date: Sun, 18 Feb 2024 16:13:41 +0100 Subject: [PATCH] Tweaks to core tested internally (#359) * Improvements to vehicle Brain Improved the way DangerPos is handled in the vehicle brain, stopping even more cases of knowledge the AI shouldn't have-- and fixing an issue where the AI would sometimes suppress the sky! Added troops manning static weapons will now abandon them if they run out of ammo Added - soft-skinned, wheeled vehicles will try to JINK if explosions hit nearby. Improved dismount/rotate logic of IFVs and APCs Improved taskFlank use of vehicles. (on the last cycle, vehicles will move to move position) Improved doFleeing handling of vehicles Improved doVehicleRotate performance in minor ways Fixed issue where AI would have more knowledge than appropriate Fixed rare issue where assessing or flanking units would abandon vehicles Fixed - Groups will now ignore empty static weapons. Fixed Rare issue where doVehicleAssault could target empty spots in the sky Misc. performance improvements. * Improved Engagement Added 'half step' movement to doGroupAssault and doAssaultMemory to force movement Improved tacticsAssault timings, and prevents useless positions to be added Improved tactical assessment when assaulting Improved units about to fire rockets are prevented from dodging Fixed Units set to hold fire, stopped, or ordered to remain stealthy will no longer clear buildings Fixed potential 'shooting into air' occurrences Fixed situations where AI would ignore enemies behind them! Misc performance improvements * Update fnc_doUGL.sqf More flexible sorting of 40mm rounds. Allows for a very common modification that makes smoke grenades less bouncy. (previously LAMBS Danger would not recognize these 40mm as 40mm) * Update fnc_doCheckBody.sqf Improves how the AI will check bodies: Adds the ability for AI to pick up backpacks of friendly units Adds ability for AI to pick up AT/AA weapons from friendly units * Minor Fixes tested internally in LAMBS Fixes units set to reinforce that fail to leave their position (by clearing waypoints) Fixes civilian.fsm which could cause AI to become immobile (running in place) Improves tactics flank timings Improves assault memory pathfinding by reverting to previous system (unit central, not leader) Removes tactics attack pattern for enemies which are near and below-- needs a more intelligent solution * Update fnc_doAssault.sqf Allow more dependable movement outside * Fix wrong units dismounting and use distanceSqr in some assault functions Fix vehicles dismounting wrong seats Use DistanceSqr for a few more assault functions * Update lambs_dangerCivilian.fsm Removed unused if-logic --- addons/danger/functions/fnc_brainVehicle.sqf | 2 +- addons/danger/functions/fnc_tacticsAssess.sqf | 2 ++ addons/danger/functions/fnc_tacticsFlank.sqf | 2 +- .../danger/functions/fnc_tacticsReinforce.sqf | 7 +++++++ .../danger/scripts/lambs_dangerCivilian.fsm | 20 +++++++++---------- .../GroupAction/fnc_doGroupAssault.sqf | 3 ++- .../GroupAction/fnc_doGroupFlank.sqf | 4 ++-- .../functions/UnitAction/fnc_doAssault.sqf | 1 + .../UnitAction/fnc_doAssaultMemory.sqf | 2 +- .../UnitAction/fnc_doAssaultSpeed.sqf | 10 +++++----- 10 files changed, 31 insertions(+), 22 deletions(-) diff --git a/addons/danger/functions/fnc_brainVehicle.sqf b/addons/danger/functions/fnc_brainVehicle.sqf index 991a95d1..d670ad0f 100644 --- a/addons/danger/functions/fnc_brainVehicle.sqf +++ b/addons/danger/functions/fnc_brainVehicle.sqf @@ -144,7 +144,7 @@ if (_armored && {!isNull _dangerCausedBy}) exitWith { // foot infantry support ~ unload private _group = group _vehicle; private _cargo = ((fullCrew [_vehicle, "cargo"]) apply {_x select 0}); - _cargo append ((fullCrew [_vehicle, "turret"]) apply {_x select 0}); + _cargo append ((fullCrew [_vehicle, "turret"] select {_x select 4}) apply {_x select 0}); if ( _validTarget && {_cargo isNotEqualTo []} diff --git a/addons/danger/functions/fnc_tacticsAssess.sqf b/addons/danger/functions/fnc_tacticsAssess.sqf index 319c579a..795a21e9 100644 --- a/addons/danger/functions/fnc_tacticsAssess.sqf +++ b/addons/danger/functions/fnc_tacticsAssess.sqf @@ -159,6 +159,7 @@ if !(_enemies isEqualTo [] || {_unitCount < random 4}) then { }; // enemies near and below + /* private _farNoCoverTarget = _enemies findIf { _unit distance2D _x < RANGE_MID && {((getPosASL _x) select 2) < ((_eyePos select 2) - 15)} @@ -169,6 +170,7 @@ if !(_enemies isEqualTo [] || {_unitCount < random 4}) then { _plan pushBack TACTICS_ATTACK; _pos = _enemies select _farNoCoverTarget; }; + */ // enemy at inside buildings or fortified or far private _fortifiedTarget = _enemies findIf { diff --git a/addons/danger/functions/fnc_tacticsFlank.sqf b/addons/danger/functions/fnc_tacticsFlank.sqf index 4d353571..783e106c 100644 --- a/addons/danger/functions/fnc_tacticsFlank.sqf +++ b/addons/danger/functions/fnc_tacticsFlank.sqf @@ -19,7 +19,7 @@ * * Public: No */ -params ["_group", "_target", ["_units", []], ["_cycle", 4], ["_overwatch", []], ["_delay", 100]]; +params ["_group", "_target", ["_units", []], ["_cycle", 4], ["_overwatch", []], ["_delay", 120]]; // group is missing if (isNull _group) exitWith {false}; diff --git a/addons/danger/functions/fnc_tacticsReinforce.sqf b/addons/danger/functions/fnc_tacticsReinforce.sqf index 76068240..0e3bb2bb 100644 --- a/addons/danger/functions/fnc_tacticsReinforce.sqf +++ b/addons/danger/functions/fnc_tacticsReinforce.sqf @@ -74,6 +74,13 @@ if (_units isEqualTo []) then { // has artillery? ~ if so fire in support? // is aircraft or tank? Different movement waypoint? +// clear HOLD waypointss +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; +}; + // formation changes ~ allowed here as Reinforcing units have full autonomy - nkenny private _distance = _unit distance2D _target; if (_distance > 500) then { diff --git a/addons/danger/scripts/lambs_dangerCivilian.fsm b/addons/danger/scripts/lambs_dangerCivilian.fsm index f25eaa7c..4220543a 100644 --- a/addons/danger/scripts/lambs_dangerCivilian.fsm +++ b/addons/danger/scripts/lambs_dangerCivilian.fsm @@ -15,7 +15,7 @@ item10[] = {"Reset",2,250,-700.000000,1400.000000,-600.000000,1450.000000,0.0000 item11[] = {"Hide_vs__run",2,250,-540.000000,40.000000,-440.000000,100.000000,0.000000,"Hide vs. run"}; item12[] = {"Vehicle",4,218,-920.000000,360.000000,-820.000000,420.000000,1.000000,"Vehicle"}; item13[] = {"Man",8,218,-700.000000,350.000000,-600.000000,400.000000,0.000000,"Man"}; -item14[] = {"Man",2,250,-680.000000,600.000000,-580.000000,660.000000,0.000000,"Man"}; +item14[] = {"Man",2,4346,-680.000000,600.000000,-580.000000,660.000000,0.000000,"Man"}; item15[] = {"Order_out",2,250,-940.000000,600.000000,-840.000000,660.000000,0.000000,"Order out"}; item16[] = {"Always",8,218,-800.000000,600.000000,-700.000000,660.000000,0.000000,"Always"}; item17[] = {"Select_danger",2,250,-820.000000,-160.000000,-720.000000,-100.000000,0.000000,"Select danger"}; @@ -180,8 +180,8 @@ link63[] = {54,2}; link64[] = {55,2}; link65[] = {56,4}; link66[] = {57,58}; -globals[] = {0.000000,0,0,0,0,640,480,1,225,6316128,1,-1872.445801,594.427734,1279.814941,-590.437561,1166,884,1}; -window[] = {2,-1,-1,-1,-1,870,52,673,52,3,1184}; +globals[] = {0.000000,0,0,0,0,640,480,1,225,6316128,1,-1487.644531,43.572693,1070.380371,-90.508331,1166,884,1}; +window[] = {2,-1,-1,-1,-1,1026,208,829,208,3,1184}; *//*%FSM*/ class FSM { @@ -393,13 +393,11 @@ class FSM " _this setUnitPos selectRandom [""DOWN"",""DOWN"",""MIDDLE""];" \n "}; " \n "" \n - "// animation" \n - "if (_this call lambs_danger_fnc_fsmAllowAnimation) then {" \n - " _this playMoveNow selectRandom [""ApanPknlMsprSnonWnonDf"", ""ApanPercMsprSnonWnonDf"", ""ApanPpneMsprSnonWnonDf"", ""ApanPpneMrunSnonWnonDf""];" \n - "}; " \n - "" \n "// execute hide" \n - "[_this, _dangerPos] call lambs_main_fnc_doHide; " \n + "[_this, _dangerPos, 10] call lambs_main_fnc_doHide; " \n + "" \n + "// time dodge" \n + "private _timeDodge = time + 2;" \n "" \n ""/*%FSM*/; precondition = /*%FSM*/""/*%FSM*/; @@ -423,8 +421,8 @@ class FSM priority = 0.000000; to="Clean_up"; precondition = /*%FSM*/""/*%FSM*/; - condition=/*%FSM*/"getSuppression _this > 0.99"/*%FSM*/; - action=/*%FSM*/""/*%FSM*/; + condition=/*%FSM*/"time > _timeDodge && getSuppression _this > 0.99"/*%FSM*/; + action=/*%FSM*/"[_this] call lambs_main_fnc_doFleeing;"/*%FSM*/; }; /*%FSM*/ }; diff --git a/addons/main/functions/GroupAction/fnc_doGroupAssault.sqf b/addons/main/functions/GroupAction/fnc_doGroupAssault.sqf index 36e0e6da..87eed7dc 100644 --- a/addons/main/functions/GroupAction/fnc_doGroupAssault.sqf +++ b/addons/main/functions/GroupAction/fnc_doGroupAssault.sqf @@ -49,7 +49,8 @@ private _targetPos = _pos select 0; _assaultPos = _unit getPos [20, _unit getDir _assaultPos]; }; // set movement - if (((expectedDestination _unit) select 0) distance2D _assaultPos > 1) then { + if (((expectedDestination _unit) select 0) distanceSqr _assaultPos > 1) then { + _unit doMove _assaultPos; _unit setDestination [_assaultPos, "LEADER PLANNED", true]; }; diff --git a/addons/main/functions/GroupAction/fnc_doGroupFlank.sqf b/addons/main/functions/GroupAction/fnc_doGroupFlank.sqf index 53e516f0..c4043912 100644 --- a/addons/main/functions/GroupAction/fnc_doGroupFlank.sqf +++ b/addons/main/functions/GroupAction/fnc_doGroupFlank.sqf @@ -21,7 +21,7 @@ params ["_cycle", "_units", "_vehicles", "_pos", "_overwatch"]; // update -_units = _units select { _x call FUNC(isAlive) && { !isPlayer _x } }; +_units = _units select { _x call FUNC(isAlive) && { !isPlayer _x } && {_x distance2D _overwatch > 5}}; _vehicles = _vehicles select { canFire _x }; private _posASL = AGLtoASL (selectRandom _pos); @@ -37,7 +37,7 @@ private _posASL = AGLtoASL (selectRandom _pos); // suppress if ( - RND(0.7) + RND(0.6) && {(leader _x) isNotEqualTo _x} && {!(terrainIntersectASL [eyePos _x, _posASL vectorAdd [0, 0, 3]])} ) then { diff --git a/addons/main/functions/UnitAction/fnc_doAssault.sqf b/addons/main/functions/UnitAction/fnc_doAssault.sqf index 984ef117..1c474ca3 100644 --- a/addons/main/functions/UnitAction/fnc_doAssault.sqf +++ b/addons/main/functions/UnitAction/fnc_doAssault.sqf @@ -53,6 +53,7 @@ private _pos = call { }; // select target location + _doMove = true; _getHide }; diff --git a/addons/main/functions/UnitAction/fnc_doAssaultMemory.sqf b/addons/main/functions/UnitAction/fnc_doAssaultMemory.sqf index e2f7a13d..cbed40fb 100644 --- a/addons/main/functions/UnitAction/fnc_doAssaultMemory.sqf +++ b/addons/main/functions/UnitAction/fnc_doAssaultMemory.sqf @@ -27,7 +27,7 @@ if (_groupMemory isEqualTo []) then { }; // exit or sort it! -_groupMemory = _groupMemory select {(leader _unit) distanceSqr _x < 20164 && {_unit distanceSqr _x > 2.25}}; +_groupMemory = _groupMemory select {_unit distanceSqr _x < 20164 && {_unit distanceSqr _x > 2.25}}; if (_groupMemory isEqualTo []) exitWith { _group setVariable [QGVAR(groupMemory), [], false]; false diff --git a/addons/main/functions/UnitAction/fnc_doAssaultSpeed.sqf b/addons/main/functions/UnitAction/fnc_doAssaultSpeed.sqf index 815338ac..5347ec27 100644 --- a/addons/main/functions/UnitAction/fnc_doAssaultSpeed.sqf +++ b/addons/main/functions/UnitAction/fnc_doAssaultSpeed.sqf @@ -19,10 +19,10 @@ params ["_unit", ["_target", objNull]]; // speed if ((behaviour _unit) isEqualTo "STEALTH") exitWith {_unit forceSpeed 1; 1}; -private _distance = _unit distance2D _target; -if ((speedMode _unit) isEqualTo "FULL") exitWith {private _speed = [24, 3] select (_distance < 12); _unit forceSpeed _speed; _speed}; -if (_distance > 80) exitWith {_unit forceSpeed -1; -1}; -if (_distance > 6) exitWith {_unit forceSpeed 3; 3}; -if (_distance > 3) exitWith {_unit forceSpeed 2; 2}; +private _distanceSqr = _unit distanceSqr _target; +if ((speedMode _unit) isEqualTo "FULL") exitWith {private _speed = [24, 3] select (_distanceSqr < 144); _unit forceSpeed _speed; _speed}; +if (_distanceSqr > 6400) exitWith {_unit forceSpeed -1; -1}; +if (_distanceSqr > 36) exitWith {_unit forceSpeed 3; 3}; +if (_distanceSqr > 9) exitWith {_unit forceSpeed 2; 2}; _unit forceSpeed 1; 1