From fca6268887f1e9fd9e29671bd9ebf86e8e0ba5b4 Mon Sep 17 00:00:00 2001 From: John Jordan Date: Sun, 11 Aug 2024 01:06:41 +0100 Subject: [PATCH] Make dive bomb runs less accurate against infantry targets --- .../core/functions/Supports/fn_SUP_CASDiveBombRun.sqf | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/A3A/addons/core/functions/Supports/fn_SUP_CASDiveBombRun.sqf b/A3A/addons/core/functions/Supports/fn_SUP_CASDiveBombRun.sqf index 7138212f81..b4812d00c9 100644 --- a/A3A/addons/core/functions/Supports/fn_SUP_CASDiveBombRun.sqf +++ b/A3A/addons/core/functions/Supports/fn_SUP_CASDiveBombRun.sqf @@ -17,6 +17,9 @@ private _group = group driver _plane; (_plane getVariable "diveParams") params ["_startAlt", "_endAlt", "_diveSpeed", "_diveAngle", "_turnRate", "_bombDrag"]; +// Reduce accuracy against foot troops +private _targetOffset = [0,0,0]; +if (_target isKindOf "Man") then { _targetOffset getPos [random 100, random 360]; _targetOffset set [2, 0] }; // Delay on loop until we're in the correct position private _inPosition = false; @@ -28,6 +31,7 @@ while {true} do { // Target lead calc private _timeToTarget = 1.1 * (_plane distance _target) / _diveSpeed; private _targetPos = eyePos _target vectorAdd (velocity _target vectorMultiply _timeToTarget); // posASL + _targetPos = _targetPos vectorAdd _targetOffset; private _targDirFwd = getPosASL _plane vectorFromTo _targetPos; _targDirFwd = vectorNormalized [_targDirFwd#0, _targDirFwd#1, 0]; @@ -65,7 +69,7 @@ _plane setVariable ["A3A_diveLastDir", vectorDir _plane]; _plane setVariable ["A3A_diveLastPos", getPosASL _plane]; private _ehID = addMissionEventHandler ["EachFrame", { - _thisArgs params ["_plane", "_target", "_endAlt", "_diveSpeed", "_turnRate", "_bombDrag"]; + _thisArgs params ["_plane", "_target", "_endAlt", "_diveSpeed", "_turnRate", "_bombDrag", "_targetOffset"]; if (!alive _target or !canMove _plane or isNull driver _plane) exitWith { Debug("EachFrame handler abandoned due to target or plane damage"); @@ -78,6 +82,7 @@ private _ehID = addMissionEventHandler ["EachFrame", { private _bombOffset = _bombOffset vectorAdd (vectorNormalized [_dir#1, -(_dir#0), 0] vectorMultiply (_bombDrag#1)); private _timeToTarget = (_plane distance _target) / _diveSpeed; private _targetPos = getPosASL _target vectorAdd (velocity _target vectorMultiply _timeToTarget) vectorAdd _bombOffset; + _targetPos = _targetPos vectorAdd _targetOffset; private _targetDir = getPosASL _plane vectorFromTo _targetPos; // heading adjustment @@ -103,7 +108,7 @@ private _ehID = addMissionEventHandler ["EachFrame", { _plane setVectorDirAndUp [_dir, _dir vectorCrossProduct [0,0,1] vectorCrossProduct _dir]; _plane setVelocity (_dir vectorMultiply _diveSpeed); - if (getPosATL _plane#2 < _endAlt) exitWith { + if (getPosASL _plane#2 - getPosASL _target#2 < _endAlt) exitWith { removeMissionEventHandler ["EachFrame", _thisEventHandler]; driver _plane enableAI "All"; if (_targetDir vectorDotProduct vectorDir _plane < 0.9) exitWith { @@ -126,7 +131,7 @@ private _ehID = addMissionEventHandler ["EachFrame", { _plane setVariable ["bombsDropped", true]; }; -}, [_plane, _target, _endAlt, _diveSpeed, _turnRate, _bombDrag]]; +}, [_plane, _target, _endAlt, _diveSpeed, _turnRate, _bombDrag, _targetOffset]]; waitUntil { sleep 1; !(getEventHandlerInfo ["EachFrame", _ehID] # 0) };