From 9641d306e6917d2646f11225f8bba95e93ac1fbe Mon Sep 17 00:00:00 2001 From: ulteq Date: Thu, 10 Nov 2016 16:43:01 +0100 Subject: [PATCH] Reused already calculated initSpeed --- addons/fcs/functions/fnc_calculateSolution.sqf | 3 +++ addons/fcs/functions/fnc_firedEH.sqf | 9 ++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/addons/fcs/functions/fnc_calculateSolution.sqf b/addons/fcs/functions/fnc_calculateSolution.sqf index 61bfbd8c58..41cbfa5069 100644 --- a/addons/fcs/functions/fnc_calculateSolution.sqf +++ b/addons/fcs/functions/fnc_calculateSolution.sqf @@ -17,6 +17,7 @@ params ["_vehicle","_turret","_distance","_angleTarget"]; TRACE_4("params",_vehicle,_turret,_distance,_angleTarget); +private _FCSInitSpeed = []; private _FCSMagazines = []; private _FCSElevation = []; private _turretConfig = [configFile >> "CfgVehicles" >> typeOf _vehicle, _turret] call EFUNC(common,getTurretConfigPath); @@ -64,6 +65,7 @@ private _turretConfig = [configFile >> "CfgVehicles" >> typeOf _vehicle, _turret private _offset = "ace_fcs" callExtension format ["%1,%2,%3,%4", _initSpeed, _airFriction, _angleTarget, _distance]; _offset = parseNumber _offset; + _FCSInitSpeed pushBack _initSpeed; _FCSMagazines pushBack _magazine; _FCSElevation pushBack _offset; }; @@ -71,5 +73,6 @@ private _turretConfig = [configFile >> "CfgVehicles" >> typeOf _vehicle, _turret } count (_vehicle magazinesTurret _turret); [_vehicle, format ["%1_%2", QGVAR(Distance), _turret], _distance] call EFUNC(common,setVariablePublic); +[_vehicle, format ["%1_%2", QGVAR(InitSpeed), _turret], _FCSInitSpeed] call EFUNC(common,setVariablePublic); [_vehicle, format ["%1_%2", QGVAR(Magazines), _turret], _FCSMagazines] call EFUNC(common,setVariablePublic); [_vehicle, format ["%1_%2", QGVAR(Elevation), _turret], _FCSElevation] call EFUNC(common,setVariablePublic); diff --git a/addons/fcs/functions/fnc_firedEH.sqf b/addons/fcs/functions/fnc_firedEH.sqf index bf4c7a9e43..1fbc16116e 100644 --- a/addons/fcs/functions/fnc_firedEH.sqf +++ b/addons/fcs/functions/fnc_firedEH.sqf @@ -19,14 +19,16 @@ private _FCSMagazines = _vehicle getVariable [format ["%1_%2", QGVAR(Magazines), if !(_magazine in _FCSMagazines) exitWith {}; +private _FCSInitSpeed = _vehicle getVariable format ["%1_%2", QGVAR(InitSpeed), _turret]; private _FCSElevation = _vehicle getVariable format ["%1_%2", QGVAR(Elevation), _turret]; -// GET ELEVATION OFFSET OF CURRENT MAGAZINE +// GET ELEVATION OFFSET AND INITSPEED OF CURRENT MAGAZINE private _offset = 0; - +private _initSpeed = 0; { if (_x == _magazine) exitWith { _offset = _FCSElevation select _forEachIndex; + _initSpeed = _FCSInitSpeed select _forEachIndex; }; } forEach _FCSMagazines; @@ -35,9 +37,6 @@ private _zeroDistance = currentZeroing _gunner; if (_zeroDistance > 0) then { private _weaponCombo = [_weapon, _magazine, _ammo, _zeroDistance]; if !(_weaponCombo isEqualTo (_gunner getVariable [QGVAR(lastWeaponCombo), []])) then { - // Hackish way of getting initSpeed. @todo: replace it by correct calculation and caching - private _initSpeed = vectorMagnitude velocity _projectile; - private _airFriction = getNumber (configFile >> "CfgAmmo" >> _ammo >> "airFriction"); private _antiOffset = "ace_fcs" callExtension format ["%1,%2,%3,%4", _initSpeed, _airFriction, 0, _zeroDistance]; _antiOffset = parseNumber _antiOffset;