Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues relating to constant dismounts #374

Merged
merged 2 commits into from
Feb 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions addons/danger/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,24 @@ if (isNil QGVAR(dangerUntil)) then {
// EH handling reinforcement and combat mode
[QEGVAR(main,OnInformationShared), {
params [["_unit", objNull], "", ["_target", objNull], ["_groups", []]];

{
private _leader = leader _x;
if (local _leader) then {
// reinforce
if (!isNull _target && { _x getVariable [QGVAR(enableGroupReinforce), false] } && { (_x getVariable [QGVAR(enableGroupReinforceTime), -1]) < time }) then {
if (
!isNull _target
&& {_x getVariable [QGVAR(enableGroupReinforce), false]}
&& {(_x getVariable [QGVAR(enableGroupReinforceTime), -1]) < time }
) then {
[_leader, [getPosASL _unit, (_leader targetKnowledge _target) select 6] select (_leader knowsAbout _target > 1.5)] call FUNC(tacticsReinforce);
};

// set combatMode
if (_leader distance2D _unit < (EGVAR(main,combatShareRange)) && {!(_leader getVariable [QGVAR(disableAI), false])} && {(behaviour _leader) isNotEqualTo "COMBAT"}) then {
[units _x, _target, [_leader, 40, true, true] call EFUNC(main,findBuildings), "information"] call EFUNC(main,doGroupHide);
// reorientate group
if (
!(_leader getVariable [QGVAR(disableAI), false])
&& {(behaviour _leader) isNotEqualTo "COMBAT"}
) then {
//[units _x, _target, [_leader, 40, true, true] call EFUNC(main,findBuildings), "information"] call EFUNC(main,doGroupHide);
_x setFormDir (_leader getDir _unit);
};
};
Expand Down
10 changes: 6 additions & 4 deletions addons/main/functions/UnitAction/fnc_doFleeing.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*
* Public: No
*/
#define SEARCH_FOR_HIDE 4
#define SEARCH_FOR_HIDE 6
#define SEARCH_FOR_BUILDING 8

params ["_unit"];
Expand Down Expand Up @@ -43,6 +43,7 @@ private _vehicle = vehicle _unit;
if (
RND(0.5)
&& {!_onFoot}
&& {morale _unit < 0}
&& {canUnloadInCombat _vehicle || {_vehicle isKindOf "StaticWeapon"}}
&& {(speed _vehicle) < 3}
&& {isTouchingGround _vehicle}
Expand Down Expand Up @@ -81,7 +82,7 @@ if (_onFootAndSeen) then {
};

// calm and inside or under cover!
if ((_suppression < 0.2) && {lineIntersects [_eyePos, _eyePos vectorAdd [0, 0, 10], _unit] || {_distance2D < random 5}}) exitWith {
if ((_suppression < 0.2) && {lineIntersects [_eyePos, _eyePos vectorAdd [0, 0, 10], _unit] || {_distance2D < 15}}) exitWith {
_unit setUnitPos "DOWN";// ~ this forces unit stance which may override mission maker. The effect is good however - nkenny
doStop _unit;
};
Expand All @@ -95,12 +96,13 @@ if (_onFootAndSeen) then {

// find buildings to hide
private _buildings = [_unit, SEARCH_FOR_BUILDING, true, true] call FUNC(findBuildings);
if ((_buildings isNotEqualTo []) && {_distance2D > random 5}) then {
_buildings append (_cover apply {getPos _x});
nk3nny marked this conversation as resolved.
Show resolved Hide resolved
if ((_buildings isNotEqualTo []) && {_distance2D > 5}) then {
_unit doMove selectRandom _buildings;
};

} else {
// follow self! ~ bugfix which prevents untis from getting stuck in fleeing loop inside fsm. - nkenny
// follow self! ~ bugfix which prevents units from getting stuck in fleeing loop inside fsm. - nkenny
_unit doFollow (leader _unit);

// reset
Expand Down
5 changes: 3 additions & 2 deletions addons/main/functions/UnitAction/fnc_doHide.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,20 @@ if (RND(0.1) && { _buildings isNotEqualTo [] }) exitWith {
_unit setUnitPosWeak "DOWN";

// check for rear-cover
private _cover = nearestTerrainObjects [ _unit getPos [1, getDir _unit], ["BUSH", "TREE", "SMALL TREE", "HIDE", "ROCK", "WALL", "FENCE"], 9, true, true ];
private _cover = nearestTerrainObjects [ _unit getPos [1, getDir _unit], ["BUSH", "TREE", "SMALL TREE", "HIDE", "ROCK", "WALL", "FENCE"], 15, true, true ];

// targetPos
private _targetPos = if (_cover isEqualTo []) then {
_unit getPos [10 + random _range, (_pos getDir _unit) + 45 - random 90]
} else {
(_cover select 0) getPos [-1.2, _unit getDir (_cover select 0)]
(_cover select 0) getPos [-0.6, _unit getDir (_cover select 0)]
};

// water means hold
if (surfaceIsWater _targetPos) then {_targetPos = getPosATL _unit;};

// cover move
doStop _unit;
_unit doMove _targetPos;

// debug
Expand Down
11 changes: 7 additions & 4 deletions addons/main/functions/fnc_doShareInformation.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ if !(isNull _target) then {
private _knowsAbout = (_unit knowsAbout _target) min GVAR(maxRevealValue);
{
[_x, [_target, _knowsAbout]] remoteExec ["reveal", leader _x];
} forEach _groups;
} forEach (_groups select {_unit distance2D (leader _x) < GVAR(combatShareRange)});
};

[QGVAR(OnInformationShared), [_unit, group _unit, _target, _groups]] call FUNC(eventCallback);
Expand All @@ -81,17 +81,20 @@ if (
// debug
if (EGVAR(main,debug_functions)) then {
// debug message
["%1 share information (%2 knows %3 to %4 groups @ %5m range)", side _unit, name _unit, (_unit knowsAbout _target) min 1, count _groups, round _range] call FUNC(debugLog);
["%1 share information (%2 knows %3 to %4 groups @ %5m range)", side _unit, name _unit, (_unit knowsAbout _target) min GVAR(maxRevealValue), count _groups, round _range] call FUNC(debugLog);

// debug marker
private _zm = [_unit, [_range,_range], _unit call FUNC(debugMarkerColor), "Border"] call FUNC(zoneMarker);
private _markers = [_zm];
private _zm = [_unit, [_range, _range], _unit call FUNC(debugMarkerColor), "Border"] call FUNC(zoneMarker);
private _zmm = [_unit, [_range min GVAR(combatShareRange), _range min GVAR(combatShareRange)], _unit call FUNC(debugMarkerColor), "SolidBorder"] call FUNC(zoneMarker);
_zmm setMarkerAlphaLocal 0.3;
private _markers = [_zm, _zmm];

// enemy units
{
private _m = [_unit getHideFrom _x, "", _x call FUNC(debugMarkerColor), "mil_triangle"] call FUNC(dotMarker);
_m setMarkerSizeLocal [0.5, 0.5];
_m setMarkerDirLocal (getDir _x);
_m setMarkerTextLocal str (_unit knowsAbout _x);
_markers pushBack _m;
} foreach ((units _target) select {_unit knowsAbout _x > 0});

Expand Down
8 changes: 4 additions & 4 deletions addons/main/functions/fnc_getShareInformationParams.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ private _units = units _unit select {
&& {_x call FUNC(isAlive)}
};
private _index = _units findIf {
_x getVariable [QEGVAR(danger,dangerRadio), false]
|| {(!isNull objectParent _x && {_x distance2D _unit < 70})}
|| {"b_radiobag_01_" in (toLower backpack _x)}
|| {(getNumber (configFile >> "CfgVehicles" >> (backpack _x) >> "tf_hasLRradio")) isEqualTo 1}
_x getVariable [QEGVAR(danger,dangerRadio), false]
//|| {(!isNull objectParent _x && {_x distance2D _unit < 70})}
|| {"b_radiobag_01_" in (toLower backpack _x)}
|| {(getNumber (configFile >> "CfgVehicles" >> (backpack _x) >> "tf_hasLRradio")) isEqualTo 1}
};
_radio = _index isNotEqualTo -1;
if (_radio) then {
Expand Down
Loading