Skip to content

Commit

Permalink
Propagate TADS direction with a variable (#679)
Browse files Browse the repository at this point in the history
Co-authored-by: Snow(Dryden) <60583203+Ollieollieolllie@users.noreply.github.com>
  • Loading branch information
mattysmith22 and Ollieollieolllie authored Jan 5, 2025
1 parent b550f45 commit 7b4392a
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ if (!(_heli getVariable ["fza_ah64_aircraftInitialised", false]) && local _heli)
_heli setVariable ["fza_ah64_freeCursorEnabled", false];
_heli setVariable ["fza_ah64_freeCursorHpos", 0.5];
_heli setVariable ["fza_ah64_freeCursorVpos", 0.5];

_heli setVariable ["fza_ah64_lastTimePropagated", 0];
_heli setVariable ["fza_ah64_tadsElevation", 0];
_heli setVariable ["fza_ah64_tadsAzimuth", 0];

if (player in _heli && !is3den && {fza_ah64_showPopupv2_2 && !fza_ah64_introShownThisScenario}) then {
_heli spawn {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ params ["_heli", "_acq"];

switch _acq do {
case "TADS" : {
_heli vectorModelToWorldVisual (([1] + ([_heli, [0], true] call CBA_fnc_turretDir)) call CBA_fnc_polar2vect)
private _tadsAzimuth = _heli getVariable "fza_ah64_tadsAzimuth";
private _tadsElevation = _heli getVariable "fza_ah64_tadsElevation";
_heli vectorModelToWorldVisual ([1, _tadsAzimuth, _tadsElevation] call CBA_fnc_polar2vect)
};
case "PHS" : {
if (isNull driver _heli) exitWith {[_heli, "FXD"] call fza_fnc_targetingAcqVec};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,26 @@ params["_heli"];
#define SCALE_KM_METERS 0.001
#define HYDRA_TIME_KM 1.353

private _currentTurret = _heli call fza_fnc_currentTurret;
private _gunnnerUnit = _heli turretUnit [0];

if (_currentTurret isEqualTo [0] || !(isplayer _gunnnerUnit)) then {
private _azimuth = -deg(_heli animationPhase "tads_tur");
private _elevation = deg(_heli animationPhase "tads");
_heli setVariable ["fza_ah64_tadsAzimuth", _azimuth];
_heli setVariable ["fza_ah64_tadsElevation", _elevation];

if (isMultiplayer && (_heli getVariable "fza_ah64_lastTimePropagated") + 0.1 < time) then {
{
_heli setVariable [_x, _heli getVariable _x, true];
} forEach [
"fza_ah64_tadsAzimuth",
"fza_ah64_tadsElevation"
];
_heli setVariable ["fza_ah64_lastTimePropagated", time, true];
};
};

private _was = _heli getVariable "fza_ah64_was";
private _sight = [_heli, "fza_ah64_sight"] call fza_fnc_getSeatVariable;
private _onGnd = [_heli] call fza_sfmplus_fnc_onGround;
Expand Down Expand Up @@ -148,12 +168,12 @@ if (_was == WAS_WEAPON_GUN) then {
if (_gunFailed) exitwith {
_heli selectweapon "fza_cannon_inhibit";
};
private _pan = _heli animationPhase "tads_tur";
private _tilt = _heli animationPhase "tads";
if !(-86 < deg _pan && deg _pan < 86) then {
private _tadsElevation = _heli getVariable "fza_ah64_tadsElevation";
private _tadsAzimuth = _heli getVariable "fza_ah64_tadsAzimuth";
if !(-86 < _tadsAzimuth && _tadsAzimuth < 86) then {
_inhibit = "AZ LIMIT";
};
if !(-60 < deg _tilt && deg _tilt < 11) then {
if !(-60 < _tadsElevation && _tadsElevation < 11) then {
_inhibit = "EL LIMIT";
};
if (_inhibit != "") then {
Expand All @@ -169,8 +189,8 @@ if (_was == WAS_WEAPON_GUN) then {
_maingun = 0;
_inhibit = "GUN FIXED";
};
_mainturret = [_pan, rad -86, rad 86] call BIS_fnc_clamp;
_maingun = [_tilt, rad -60, rad 11] call BIS_fnc_clamp;
_mainturret = -rad ([_tadsAzimuth, -86, 86] call BIS_fnc_clamp);
_maingun = rad ([_tadsElevation, -60, 11] call BIS_fnc_clamp);
};
if (_gunFailed) then {
_mainturret = _heli animationphase "mainTurret";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,9 @@ if (_heli getVariable "fza_ah64_selectedMissile" == "fza_agm114l_wep") then {

private _angleOffAxis = [];
if _constraintBoxUseTads then {
_angleOffAxis = [_heli, [0], true] call CBA_fnc_turretDir;
private _tadsAzimuth = _heli getVariable "fza_ah64_tadsAzimuth";
private _tadsElevation = _heli getVariable "fza_ah64_tadsElevation";
_angleOffAxis = [_tadsAzimuth, _tadsElevation];
_angleOffAxis set [1, -(_angleOffAxis # 1)];
} else {
if (_vector isNotEqualTo []) then {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ if (_acBusOn && _dcBusOn) then {

if (_tadsShouldBeStowed != _heli getVariable "fza_ah64_tadsStow") then {
[_heli, "fza_ah64_tadsStow", _tadsShouldBeStowed] call fza_fnc_animSetValue;
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,10 @@ if !isNil "_dir" then {
_fcrDir = [_fcrhdg - direction _heli] call CBA_fnc_simplifyAngle180;
_fcrantennafor = linearConversion [-120,120,_fcrDir,0.44,0.56,true];
};
_sensorposx = (_heli animationphase "tads_tur") * -0.025;
_sensorposy = (_heli animationphase "tads") * -0.015;
private _tadsElevation = _heli getVariable "fza_ah64_tadsElevation";
private _tadsAzimuth = _heli getVariable "fza_ah64_tadsAzimuth";
_sensorposx = rad(_tadsAzimuth * 0.025);
_sensorposy = rad(_tadsElevation * -0.015);
if (_sensorposy < 0) then {
_sensorposy = (_heli animationphase "tads") * -0.026;
};
Expand Down Expand Up @@ -672,12 +674,11 @@ if ((_heli getVariable "fza_ah64_hmdfsmode" != "trans" && _heli getVariable "fza
};

// CAMERA HEADINGS FOR GUNNER

if (cameraView == "GUNNER" && player == gunner _heli) then {
_tadsdir = (deg(_heli animationphase "tads_tur") * -1);
_tadsdir = _tadsAzimuth;
_curwpdir = _tadsdir;
};
private _alternatesensorpan = (if (player == gunner _heli) then {deg(_heli animationPhase "pnvs")} else {-deg (_heli animationSourcePhase "tads_tur")});
private _alternatesensorpan = (if (player == gunner _heli) then {deg(_heli animationPhase "pnvs")} else {-deg _tadsAzimuth});
private _alternatesensortilt = if (player == gunner _heli) then {linearConversion [-1, 1, (deg(_heli animationPhase "pnvs_vert")), -45, 20]} else {deg (_heli animationSourcePhase "tads")};

private _modelAlternateSensorVect = [sin _alternatesensorpan, cos _alternatesensorpan, sin _alternatesensortilt];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ if (cameraView != "GUNNER") then {_Offset = 0.14;};

private _tex = ["\fza_ah64_us\tex\HDU\ah64_rkt.paa", "\fza_ah64_us\tex\HDU\ah64_rkt_fxd"] select (_sight == 3);
_steeringCursorControl ctrlSetText _tex;
_screenPos = [_Offset + deg (_heli animationPhase "tads_tur")*-4, 9.2 + (_pylonelev/0.64)] call fza_ihadss_fnc_angleToScreen;
private _tadsAzimuth = _heli getVariable "fza_ah64_tadsAzimuth";
_screenPos = [_Offset + _tadsAzimuth*4, 9.2 + (_pylonelev/0.64)] call fza_ihadss_fnc_angleToScreen;

_steeringCursorControl ctrlSetPosition [_screenPos#0 - _conW/2, _screenPos#1 - _conH/2, _conW, _conH];
_steeringCursorControl ctrlCommit 0;
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ if (isNil "_nextPointPos") then {
};

//Alternate Sensor Bearing
private _alternatesensorpan = (if (player == gunner _heli) then {deg(_heli animationPhase "pnvs")} else {-deg (_heli animationSourcePhase "tads_tur")});
private _tadsAzimuth = _heli getVariable "fza_ah64_tadsAzimuth";
private _tadsElevation = _heli getVariable "fza_ah64_tadsElevation";
private _alternatesensorpan = (if (player == gunner _heli) then {deg(_heli animationPhase "pnvs")} else {_tadsAzimuth});
_heli setUserMfdValue [MFD_INDEX_OFFSET(MFD_IND_FCR_ALTERNATE_SENSOR), _alternatesensorpan];

//FCR CenterLine
Expand All @@ -72,10 +74,8 @@ _heli setUserMfdValue [MFD_INDEX_OFFSET(MFD_IND_FCR_CENTERLINE), _fcrHeading];
_heli setUserMfdValue [MFD_INDEX_OFFSET(MFD_IND_FCR_PREV_CENTER), _lastHeading];

//TADS POS
([_heli, [0], true] call CBA_fnc_turretDir) params ["_tadsX", "_tadsY"];
private _tadsX = _tadsX call CBA_fnc_simplifyAngle180;
_heli setUserMfdValue [MFD_INDEX_OFFSET(MFD_IND_FCR_FOV_X), _tadsX];
_heli setUserMfdValue [MFD_INDEX_OFFSET(MFD_IND_FCR_FOV_Y), -_tadsY];
_heli setUserMfdValue [MFD_INDEX_OFFSET(MFD_IND_FCR_FOV_X), _tadsAzimuth];
_heli setUserMfdValue [MFD_INDEX_OFFSET(MFD_IND_FCR_FOV_Y), -_tadsElevation];

//Cued LOS
private _curTurret = [_heli] call fza_fnc_currentTurret;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ if (isNil "_nextPointPos") then {
_heli setUserMfdValue [MFD_INDEX_OFFSET(MFD_IND_FLT_FLY_TO_CUE_Y), _flyToCueY];
};

private _alternatesensorpan = (if (player == gunner _heli) then {deg(_heli animationPhase "pnvs")} else {-deg (_heli animationSourcePhase "tads_tur")});
private _tadsAzimuth = _heli getVariable "fza_ah64_tadsAzimuth";
private _alternatesensorpan = (if (player == gunner _heli) then {deg(_heli animationPhase "pnvs")} else {_tadsAzimuth});
_heli setUserMfdValue [MFD_INDEX_OFFSET(MFD_IND_FLT_ALTERNATE_SENSOR), _alternatesensorpan];

_heli getVariable "fza_ah64_fcrLastScan" params ["_dir"];
Expand Down

0 comments on commit 7b4392a

Please sign in to comment.