ACE3/addons/fcs/functions/fnc_calculateSolution.sqf

76 lines
2.9 KiB
Plaintext
Raw Normal View History

/*
* Author: VKing
* Calculate FCS solution
*
* Arguments:
* 0: Vehicle
* 1: Turret
* 2: Target distance
* 3: Azimuth offset
*
2016-06-18 09:50:41 +00:00
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"
params ["_vehicle","_turret","_distance","_angleTarget"];
2016-05-20 02:39:15 +00:00
TRACE_4("params",_vehicle,_turret,_distance,_angleTarget);
private _FCSMagazines = [];
private _FCSElevation = [];
private _turretConfig = [configFile >> "CfgVehicles" >> typeOf _vehicle, _turret] call EFUNC(common,getTurretConfigPath);
{
private _magazine = _x;
private _ammo = getText (configFile >> "CfgMagazines" >> _magazine >> "ammo");
private _bulletSimulation = getText (configFile >> "CfgAmmo" >> _ammo >> "simulation");
if !(_bulletSimulation == "shotMissile") then {
private _maxElev = getNumber (_turretConfig >> "maxElev");
private _initSpeed = getNumber (configFile >> "CfgMagazines" >> _magazine >> "initSpeed");
private _airFriction = getNumber (configFile >> "CfgAmmo" >> _ammo >> "airFriction");
{
2016-01-21 14:01:41 +00:00
private _weapon = _x;
private _muzzles = getArray (configFile >> "CfgWeapons" >> _weapon >> "muzzles");
private _weaponMagazines = getArray (configFile >> "CfgWeapons" >> _weapon >> "magazines");
{
if (_x != "this") then {
2016-01-21 14:01:41 +00:00
_weaponMagazines append getArray (configFile >> "CfgWeapons" >> _weapon >> _x >> "magazines");
};
false
} count _muzzles;
// Fix the `in` operator being case sensitive and BI fucking up the spelling of their own classnames
2016-02-07 12:08:31 +00:00
private _weaponMagazinesCheck = _weaponMagazines apply {toLower _x};
// Another BIS fix: ShotBullet simulation uses weapon initSpeed, others ignore it
if (toLower _magazine in _weaponMagazinesCheck && {_bulletSimulation == "shotBullet"}) exitWith {
private _initSpeedCoef = getNumber(configFile >> "CfgWeapons" >> _weapon >> "initSpeed");
if (_initSpeedCoef < 0) then {
_initSpeed = _initSpeed * -_initSpeedCoef;
};
if (_initSpeedCoef > 0) then {
_initSpeed = _initSpeedCoef;
};
};
false
} count (_vehicle weaponsTurret _turret);
private _offset = "ace_fcs" callExtension format ["%1,%2,%3,%4", _initSpeed, _airFriction, _angleTarget, _distance];
_offset = parseNumber _offset;
_FCSMagazines pushBack _magazine;
_FCSElevation pushBack _offset;
};
false
} count (_vehicle magazinesTurret _turret);
[_vehicle, format ["%1_%2", QGVAR(Distance), _turret], _distance] 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);