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

Flatten out support responses and block support calls for mine kills #3386

Merged
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
6 changes: 5 additions & 1 deletion A3A/addons/core/functions/AI/fn_callForSupport.sqf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* Simulates the call for support by a group by making the teamleader a bit more dumb for a time

Execution on: HC or Server
Execution on: HC or Server, group-local

Scope: Internal

Expand All @@ -22,6 +22,10 @@ if(_side != Occupants and _side != Invaders) exitWith {
Error_2("Non-enemy group %1 of side %2 managed to call callForSupport", _group, _side);
};

// Don't call support against units unless there's slightly more information than damage dealt
// Should rule out calls for mines/charges but still pick up snipers (maybe only after the second kill)
if (_target isKindOf "CAManBase" and { _group knowsAbout _target <= 1.5 }) exitWith {};

//If groupleader is down, dont call support
if !(_groupLeader call A3A_fnc_canFight) exitWith {};

Expand Down
25 changes: 16 additions & 9 deletions A3A/addons/core/functions/Supports/fn_maxDefenceSpend.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,13 @@ else
_maxSpendLoc = _maxSpendLoc * (_defMul - _defSub);
Debug_3("Max location spend %1 from defmul %2 and defsub %3", _maxSpendLoc, _defMul, _defSub);


// Prevent overreacting to threats: recentDamage + enemyStr - friendlyStr
// Recent damage, generated by AIReactOnKill & AIVehInit stuff?
private _recentDamage = [_side, _callPos, 300] call A3A_fnc_getRecentDamage; // should this be related to marker size? hmm

// Accumulate base strength of nearby enemies
private _enemyStr = 0;
private _nearEnemies = units _targetSide inAreaArray [_callPos, 500, 500];
if (_target isEqualType objNull) then { _nearEnemies pushBackUnique gunner vehicle _target }; // add target, in case it's shooting from long range
if (_target isEqualType objNull and { _target distance2d _callPos > 400 }) then {
// Include enemies near the target
_nearEnemies = _nearEnemies arrayIntersect (units _targetSide inAreaArray [getPosATL _target, 100, 100]);
};
{
if !(_x call A3A_fnc_canFight) then { continue };
if (vehicle _x isKindOf "Air") then { continue };
Expand All @@ -126,6 +124,17 @@ else
};
} forEach _nearEnemies;

// Cap max location spend when enemies are a small proportion of total rebel firepower
if (_targetSide == teamPlayer) then {
private _maxSpendProp = 0.1 + (_enemyStr / (30 * A3A_activePlayerCount)) ^ 0.6;
Debug_1("Max spend by rebel threat proportion: %1", _maxSpendProp);
_maxSpendLoc = _maxSpendLoc min _maxSpendProp;
};

// Prevent overreacting to threats: recentDamage + enemyStr - friendlyStr
// Recent damage, generated by AIReactOnKill & AIVehInit stuff?
private _recentDamage = [_side, _callPos, 300] call A3A_fnc_getRecentDamage; // should this be related to marker size? hmm

// counter with friendly unit strength
private _friendStr = 0;
private _nearFriends = units _side inAreaArray [_callPos, 500, 500];
Expand All @@ -140,11 +149,9 @@ else
//};
} forEach _nearFriends;

_threatBalance = (2*_recentDamage + _enemyStr) / (_friendStr max 1);
_threatBalance = (2.6*_recentDamage + _enemyStr) / (1 + _friendStr + _recentDamage);
_threatBalance = 1 min (_threatBalance - 1);
Debug_4("Threat balance %1 from: Recent damage %2 enemy strength %3 friend strength %4", _threatBalance, _recentDamage, _enemyStr, _friendStr);

// _maxSpend = _maxSpend min 2*(2*_recentDamage + _enemyStr - _friendStr);
};
if (_maxSpendLoc <= 0 or _threatBalance <= 0) exitWith { 0 }; // possible if near enemy markers

Expand Down