Skip to content

Commit 3ecbb67

Browse files
authored
Improve Dodging and reactions (#422)
* Improve Dodging and reactions Take advantage of new getUnitState command Fix some cases of units warping through cover Improve Dodge and Cover conditions. Units are more likely to drop prone and appear suppressed if under heavy fire. * Update fnc_doCover.sqf Removed #define. It didn't improve readability in any way.
1 parent 84f9808 commit 3ecbb67

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

addons/danger/functions/fnc_brainReact.sqf

+3-4
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,10 @@ _unit setVariable ["ace_medical_ai_lastHit", CBA_missionTime];
3535

3636
// cover move when explosion
3737
if (
38-
getSuppression _unit < 0.6
39-
&& {(speed _unit) isEqualTo 0}
40-
&& {_type in [DANGER_EXPLOSION, DANGER_FIRE]}
38+
getSuppression _unit > 0.5
39+
|| {(getUnitState _unit) isEqualTo "REPLAN"}
40+
|| {(currentCommand _unit) isEqualTo "STOP"}
4141
) exitWith {
42-
_unit setUnitPosWeak "DOWN";
4342
[_unit] call EFUNC(main,doCover);
4443
_timeout + 1
4544
};

addons/main/functions/UnitAction/fnc_doCover.sqf

+6-4
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,18 @@
1515
*
1616
* Public: No
1717
*/
18-
#define SEARCH_FOR_HIDE 6
1918

2019
params ["_unit", ["_pos", [], [[]]]];
2120

22-
// check if stopped
23-
if (!(_unit checkAIFeature "PATH")) exitWith {false};
21+
// stance change
22+
_unit setUnitPosWeak "DOWN";
23+
24+
// check if stopped or inside a building
25+
if (!(_unit checkAIFeature "PATH") || {(insideBuilding _unit) isEqualTo 1}) exitWith {false};
2426

2527
// find cover
2628
if (_pos isEqualTo []) then {
27-
_pos = nearestTerrainObjects [_unit, ["BUSH", "TREE", "HIDE"], SEARCH_FOR_HIDE, true, true];
29+
_pos = nearestTerrainObjects [_unit, ["BUSH", "TREE", "HIDE"], 6, true, true];
2830
_pos = if (_pos isEqualTo []) then {
2931
getPosASL _unit
3032
} else {

addons/main/functions/UnitAction/fnc_doDodge.sqf

+2-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ private _anim = call {
5858

5959
// drop down
6060
if !(_nearDistance || {_still}) exitWith {
61-
["Down"]
61+
_unit setUnitPosWeak "DOWN";
62+
"Down"
6263
};
6364

6465
// move back ~ more checks because sometimes we want the AI to move forward in CQB - nkenny

0 commit comments

Comments
 (0)