2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2016-01-21 01:02:50 +00:00
|
|
|
/*
|
|
|
|
* Author: VKing
|
|
|
|
* Calculate FCS solution
|
|
|
|
*
|
|
|
|
* Arguments:
|
2017-06-08 13:31:51 +00:00
|
|
|
* 0: Vehicle <OBJECT>
|
|
|
|
* 1: Turret <ARRAY>
|
|
|
|
* 2: Target distance <NUMBER>
|
|
|
|
* 3: Azimuth offset <UNKNOWN>
|
2016-01-21 01:02:50 +00:00
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Return Value:
|
2016-01-21 01:02:50 +00:00
|
|
|
* None
|
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
|
|
|
* [car, [turret], 5, ?] call ace_fcs_fnc_calculateSolution
|
|
|
|
*
|
2016-01-21 01:02:50 +00:00
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
params ["_vehicle","_turret","_distance","_angleTarget"];
|
2016-05-20 02:39:15 +00:00
|
|
|
TRACE_4("params",_vehicle,_turret,_distance,_angleTarget);
|
2016-01-21 01:02:50 +00:00
|
|
|
|
2016-11-10 15:43:01 +00:00
|
|
|
private _FCSInitSpeed = [];
|
2016-01-21 01:02:50 +00:00
|
|
|
private _FCSMagazines = [];
|
|
|
|
private _FCSElevation = [];
|
2021-02-18 18:58:08 +00:00
|
|
|
private _turretConfig = [configOf _vehicle, _turret] call EFUNC(common,getTurretConfigPath);
|
2016-01-21 01:02:50 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
private _magazine = _x;
|
|
|
|
private _ammo = getText (configFile >> "CfgMagazines" >> _magazine >> "ammo");
|
|
|
|
|
2016-01-21 14:56:53 +00:00
|
|
|
private _bulletSimulation = getText (configFile >> "CfgAmmo" >> _ammo >> "simulation");
|
|
|
|
if !(_bulletSimulation == "shotMissile") then {
|
2016-01-21 01:02:50 +00:00
|
|
|
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");
|
2016-01-21 01:02:50 +00:00
|
|
|
|
|
|
|
{
|
|
|
|
if (_x != "this") then {
|
2016-01-21 14:01:41 +00:00
|
|
|
_weaponMagazines append getArray (configFile >> "CfgWeapons" >> _weapon >> _x >> "magazines");
|
2016-01-21 01:02:50 +00:00
|
|
|
};
|
2024-04-04 11:15:26 +00:00
|
|
|
} forEach _muzzles;
|
2016-01-21 01:02:50 +00:00
|
|
|
|
2016-01-21 01:14:51 +00:00
|
|
|
// Fix the `in` operator being case sensitive and BI fucking up the spelling of their own classnames
|
2024-03-07 21:08:13 +00:00
|
|
|
private _weaponMagazinesCheck = _weaponMagazines apply {toLowerANSI _x};
|
2016-01-21 01:14:51 +00:00
|
|
|
|
|
|
|
// Another BIS fix: ShotBullet simulation uses weapon initSpeed, others ignore it
|
2024-03-07 21:08:13 +00:00
|
|
|
if (toLowerANSI _magazine in _weaponMagazinesCheck && {_bulletSimulation == "shotBullet"}) exitWith {
|
2016-01-21 01:02:50 +00:00
|
|
|
private _initSpeedCoef = getNumber(configFile >> "CfgWeapons" >> _weapon >> "initSpeed");
|
|
|
|
|
|
|
|
if (_initSpeedCoef < 0) then {
|
|
|
|
_initSpeed = _initSpeed * -_initSpeedCoef;
|
|
|
|
};
|
|
|
|
|
|
|
|
if (_initSpeedCoef > 0) then {
|
|
|
|
_initSpeed = _initSpeedCoef;
|
|
|
|
};
|
|
|
|
};
|
2024-04-04 11:15:26 +00:00
|
|
|
} forEach (_vehicle weaponsTurret _turret);
|
2016-01-21 01:02:50 +00:00
|
|
|
|
2024-08-17 15:50:38 +00:00
|
|
|
private _offset = ("ace" callExtension ["fcs", [_initSpeed, _airFriction, _angleTarget, _distance]]) # 0;
|
2016-01-21 01:02:50 +00:00
|
|
|
_offset = parseNumber _offset;
|
|
|
|
|
2016-11-10 15:43:01 +00:00
|
|
|
_FCSInitSpeed pushBack _initSpeed;
|
2016-01-21 01:02:50 +00:00
|
|
|
_FCSMagazines pushBack _magazine;
|
|
|
|
_FCSElevation pushBack _offset;
|
|
|
|
};
|
2024-04-04 11:15:26 +00:00
|
|
|
} forEach (_vehicle magazinesTurret _turret);
|
2016-01-21 01:02:50 +00:00
|
|
|
|
|
|
|
[_vehicle, format ["%1_%2", QGVAR(Distance), _turret], _distance] call EFUNC(common,setVariablePublic);
|
2016-11-10 15:43:01 +00:00
|
|
|
[_vehicle, format ["%1_%2", QGVAR(InitSpeed), _turret], _FCSInitSpeed] call EFUNC(common,setVariablePublic);
|
2016-01-21 01:02:50 +00:00
|
|
|
[_vehicle, format ["%1_%2", QGVAR(Magazines), _turret], _FCSMagazines] call EFUNC(common,setVariablePublic);
|
|
|
|
[_vehicle, format ["%1_%2", QGVAR(Elevation), _turret], _FCSElevation] call EFUNC(common,setVariablePublic);
|