Skip to content

Commit

Permalink
Tweaks to core tested internally (#359)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
nk3nny authored Feb 18, 2024
1 parent b89a6d3 commit 44b5702
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 22 deletions.
2 changes: 1 addition & 1 deletion addons/danger/functions/fnc_brainVehicle.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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 []}
Expand Down
2 changes: 2 additions & 0 deletions addons/danger/functions/fnc_tacticsAssess.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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)}
Expand All @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion addons/danger/functions/fnc_tacticsFlank.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
7 changes: 7 additions & 0 deletions addons/danger/functions/fnc_tacticsReinforce.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
20 changes: 9 additions & 11 deletions addons/danger/scripts/lambs_dangerCivilian.fsm
Original file line number Diff line number Diff line change
Expand Up @@ -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"};
Expand Down Expand Up @@ -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</HEAD>*/
class FSM
{
Expand Down Expand Up @@ -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</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
Expand All @@ -423,8 +421,8 @@ class FSM
priority = 0.000000;
to="Clean_up";
precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
condition=/*%FSM<CONDITION""">*/"getSuppression _this > 0.99"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
condition=/*%FSM<CONDITION""">*/"time > _timeDodge && getSuppression _this > 0.99"/*%FSM</CONDITION""">*/;
action=/*%FSM<ACTION""">*/"[_this] call lambs_main_fnc_doFleeing;"/*%FSM</ACTION""">*/;
};
/*%FSM</LINK>*/
};
Expand Down
3 changes: 2 additions & 1 deletion addons/main/functions/GroupAction/fnc_doGroupAssault.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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];
};
Expand Down
4 changes: 2 additions & 2 deletions addons/main/functions/GroupAction/fnc_doGroupFlank.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions addons/main/functions/UnitAction/fnc_doAssault.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ private _pos = call {
};

// select target location
_doMove = true;
_getHide
};

Expand Down
2 changes: 1 addition & 1 deletion addons/main/functions/UnitAction/fnc_doAssaultMemory.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions addons/main/functions/UnitAction/fnc_doAssaultSpeed.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 44b5702

Please sign in to comment.