Skip to content

Commit

Permalink
Improve Climb and Auto Performance (#690)
Browse files Browse the repository at this point in the history
* Improve Climb and Auto Performance

* Update fn_engine.sqf

* Update fn_engine.sqf

* Update fn_engine.sqf
  • Loading branch information
BradMick authored Jan 20, 2025
1 parent d429a6a commit 097d4d0
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ private _engPctTQ = _heli getVariable "fza_sfmplus_engPctTQ" select _e
private _engTGT = _heli getVariable "fza_sfmplus_engTGT" select _engNum;
private _engOilPSI = _heli getVariable "fza_sfmplus_engOilPSI" select _engNum;
private _engFF = _heli getVariable "fza_sfmplus_engFF" select _engNum;
private _collectiveOutput = _heli getVariable "fza_sfmplus_collectiveOutput";
private _engThrottle = 0.0;
private _engSimTime = getNumber (_sfmPlusConfig >> "engSimTime");

Expand Down Expand Up @@ -88,10 +89,11 @@ switch (_engState) do {
//Ng
_engPctNG = [_engPctNG, 0.0, _deltaTime] call BIS_fnc_lerp;
//Np
if (!_isAutorotating) then {
_engPctNP = [_engPctNP, 0.0, _deltaTime] call BIS_fnc_lerp;
if (_isAutorotating) then {
private _autoNp = linearConversion[0.0, 0.5, _collectiveOutput, 1.10, 0.0, true];
_engPctNP = [_engPctNP, _autoNp, _deltaTime] call BIS_fnc_lerp;
} else {
_engPctNP = 1.01;
_engPctNP = [_engPctNP, 0.0, _deltaTime] call BIS_fnc_lerp;
};
//Tq
_engPctTQ = [_engPctTQ, 0.0, _deltaTime] call BIS_fnc_lerp;
Expand Down Expand Up @@ -123,7 +125,7 @@ switch (_engState) do {
[_heli, "fza_sfmplus_engState", _engNum, "ON", true] call fza_fnc_setArrayVariable;
};
//Ng
_engSetNG = _engBaseNG + (_engMaxNG - _engBaseNG) * _engThrottle * (_heli getVariable "fza_sfmplus_collectiveOutput");
_engSetNG = _engBaseNG + (_engMaxNG - _engBaseNG) * _engThrottle * _collectiveOutput;
_engPctNG = [_engPctNG, _engSetNG, _deltaTime] call BIS_fnc_lerp;
//Np
if (_isSingleEng) then {
Expand All @@ -136,10 +138,11 @@ switch (_engState) do {
private _droopFactor = 1 - (_engPctTQ / _engLimitTQ);
_droopFactor = [_droopFactor, -1.0, 0.0] call BIS_fnc_clamp;
//Autorotation handler
if (!_isAutorotating) then {
_engPctNP = [_engPctNP, _engBaseNP + _droopFactor, _deltaTime] call BIS_fnc_lerp;
if (_isAutorotating) then {
private _autoNp = linearConversion[0.0, 0.23, _collectiveOutput, 1.10, 1.01, true];
_engPctNP = [_engPctNP, _autoNp, _deltaTime] call BIS_fnc_lerp;
} else {
_engPctNP = 1.01;
_engPctNP = [_engPctNP, _engBaseNP + _droopFactor, _deltaTime] call BIS_fnc_lerp;
};
} else {
//If the engine is overspeeding, then do over speed things
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ if (_eng1State == "OFF" && _eng2State == "OFF" && !_isAutorotating && local _hel

//Autorotation handler
private _velXY = vectorMagnitude [velocityModelSpace _heli # 0, velocityModelSpace _heli # 1];
if ( ((_eng1State == "OFF" && _eng2State == "OFF") || (_eng1PwrLvrState in ["OFF", "IDLE"] && _eng2PwrLvrState in ["OFF", "IDLE"]))
&& _engPctTQ < 0.10
if ( _engPctTQ < 0.10
&& !_onGnd
&& _rtrRPM > EPSILON) then {
_heli setVariable ["fza_sfmplus_isAutorotating", true];
} else {
_heli setVariable ["fza_sfmplus_isAutorotating", false];
};
//systemChat format ["_isAutorotating = %1", _heli getVariable "fza_sfmplus_isAutorotating"];
//End Autorotation handler
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,50 @@ private _rtrGndEffScalar = [_rtrGndEffTable, getMass _heli] call fza_fnc_linearI
private _gndEffScalar = (1 - (_heightAGL / _rtrDiam)) * _rtrGndEffScalar;
_gndEffScalar = [_gndEffScalar, 0.0, 1.0] call BIS_fnc_clamp;
private _gndEffThrust = _rtrThrust * _gndEffScalar;
//private _totThrust = _heli getVariable "fza_sfmplus_rtrThrust" select 0;
private _totThrust = _rtrThrust + _gndEffThrust;//[_totThrust, _rtrThrust + _gndEffThrust, _deltaTime] call BIS_fnc_lerp;

private _eng1TQ = _heli getVariable "fza_sfmplus_engPctTQ" select 0;
private _eng2TQ = _heli getVariable "fza_sfmplus_engPctTQ" select 1;
private _engPctTQ = _eng1TQ max _eng2TQ;

private _cruiseTqTable =
[
[ 0.00, 0.94]
,[ 5.14, 0.90]
,[10.29, 0.82]
,[20.58, 0.62]
,[27.78, 0.53]
,[36.01, 0.49]
,[38.07, 0.49]
,[46.30, 0.52]
,[51.44, 0.56]
,[56.59, 0.64]
,[61.73, 0.72]
,[66.88, 0.85]
,[69.96, 0.94]
,[72.02, 1.01]
,[77.17, 1.18]
];
private _cruiseTq = [_cruiseTqTable, _velXY] call fza_fnc_linearInterp select 1;
private _tqChange = _engPctTq - _cruiseTq;
_tqChange = [_tqChange, 0.0, 0.8] call BIS_fnc_clamp;
private _tqRoCTable =
[
[0.0, 0.00]
,[0.1, 0.11]
,[0.2, 0.22]
,[0.3, 0.32]
,[0.4, 0.43]
,[0.5, 0.54]
,[0.6, 0.65]
,[0.7, 0.75]
,[0.8, 0.86]
];
private _RoCScalar = [_tqRoCTable, _tqChange] call fza_fnc_linearInterp select 1;
//systemChat format ["_tqChange = %1 -- RoC = %2", _tqChange, (_heli getVariable "fza_sfmplus_velClimb") toFixed 0];
private _climbThrust = _rtrThrust * _RoCScalar;
private _totThrust = _rtrThrust + _gndEffThrust + _climbThrust;
[_heli, "fza_sfmplus_rtrThrust", 0, _totThrust, true] call fza_fnc_setArrayVariable;
private _thrustZ = _axisZ vectorMultiply (_totThrust * _deltaTime);
private _thrustZ = _axisZ vectorMultiply (_totThrust * _deltaTime);

//Pitch torque
private _cyclicFwdAftTrim = 0.0;
Expand Down

0 comments on commit 097d4d0

Please sign in to comment.