2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2015-01-11 16:42:31 +00:00
|
|
|
/*
|
|
|
|
* Author: KoffeinFlummi
|
2016-02-06 20:07:05 +00:00
|
|
|
* Adjusts the direction of a shell. Called from the unified fired EH only if the gunner is a player.
|
2015-01-11 16:42:31 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2016-02-06 19:29:58 +00:00
|
|
|
* None. Parameters inherited from EFUNC(common,firedEH)
|
2015-01-11 16:42:31 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
2015-12-10 15:00:14 +00:00
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
|
|
|
* call ace_fcs_fnc_firedEH
|
|
|
|
*
|
2015-12-10 15:00:14 +00:00
|
|
|
* Public: No
|
2015-01-11 16:42:31 +00:00
|
|
|
*/
|
2015-01-12 10:02:44 +00:00
|
|
|
|
2016-02-06 20:07:05 +00:00
|
|
|
//IGNORE_PRIVATE_WARNING ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle", "_gunner", "_turret"];
|
|
|
|
TRACE_10("firedEH:",_unit, _weapon, _muzzle, _mode, _ammo, _magazine, _projectile, _vehicle, _gunner, _turret);
|
|
|
|
|
2015-12-10 15:00:14 +00:00
|
|
|
private _FCSMagazines = _vehicle getVariable [format ["%1_%2", QGVAR(Magazines), _turret], []];
|
2015-02-04 02:20:55 +00:00
|
|
|
|
|
|
|
if !(_magazine in _FCSMagazines) exitWith {};
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2016-11-10 15:43:01 +00:00
|
|
|
private _FCSInitSpeed = _vehicle getVariable format ["%1_%2", QGVAR(InitSpeed), _turret];
|
2016-04-02 02:51:22 +00:00
|
|
|
private _FCSElevation = _vehicle getVariable format ["%1_%2", QGVAR(Elevation), _turret];
|
|
|
|
|
2016-11-10 15:43:01 +00:00
|
|
|
// GET ELEVATION OFFSET AND INITSPEED OF CURRENT MAGAZINE
|
2015-12-10 15:00:14 +00:00
|
|
|
private _offset = 0;
|
2016-11-10 15:43:01 +00:00
|
|
|
private _initSpeed = 0;
|
2015-01-11 16:42:31 +00:00
|
|
|
{
|
2015-02-04 02:20:55 +00:00
|
|
|
if (_x == _magazine) exitWith {
|
2015-01-14 20:07:41 +00:00
|
|
|
_offset = _FCSElevation select _forEachIndex;
|
2016-11-10 15:43:01 +00:00
|
|
|
_initSpeed = _FCSInitSpeed select _forEachIndex;
|
2015-01-14 20:07:41 +00:00
|
|
|
};
|
2015-01-11 16:42:31 +00:00
|
|
|
} forEach _FCSMagazines;
|
|
|
|
|
2016-03-08 03:17:46 +00:00
|
|
|
// Calculate the correction due to vanilla zeroing
|
|
|
|
private _zeroDistance = currentZeroing _gunner;
|
|
|
|
if (_zeroDistance > 0) then {
|
|
|
|
private _weaponCombo = [_weapon, _magazine, _ammo, _zeroDistance];
|
|
|
|
if !(_weaponCombo isEqualTo (_gunner getVariable [QGVAR(lastWeaponCombo), []])) then {
|
|
|
|
private _airFriction = getNumber (configFile >> "CfgAmmo" >> _ammo >> "airFriction");
|
|
|
|
private _antiOffset = "ace_fcs" callExtension format ["%1,%2,%3,%4", _initSpeed, _airFriction, 0, _zeroDistance];
|
|
|
|
_antiOffset = parseNumber _antiOffset;
|
|
|
|
|
|
|
|
_gunner setVariable [QGVAR(lastWeaponCombo), _weaponCombo];
|
|
|
|
_gunner setVariable [QGVAR(lastAntiOffset), _antiOffset];
|
|
|
|
};
|
|
|
|
private _antiOffset = _gunner getVariable QGVAR(lastAntiOffset);
|
|
|
|
|
|
|
|
_offset = _offset - _antiOffset;
|
|
|
|
TRACE_4("fired",_gunner, currentZeroing _gunner, _antiOffset, _offset);
|
|
|
|
};
|
|
|
|
|
2015-05-01 16:55:44 +00:00
|
|
|
[_projectile, (_vehicle getVariable format ["%1_%2", QGVAR(Azimuth), _turret]), _offset, 0] call EFUNC(common,changeProjectileDirection);
|
2015-04-06 20:37:18 +00:00
|
|
|
|
2016-02-06 19:29:58 +00:00
|
|
|
// Remove the platform velocity
|
2015-12-10 15:00:14 +00:00
|
|
|
if (vectorMagnitude velocity _vehicle > 2) then {
|
|
|
|
private _sumVelocity = (velocity _projectile) vectorDiff (velocity _vehicle);
|
|
|
|
|
2015-04-07 01:36:39 +00:00
|
|
|
_projectile setVelocity _sumVelocity;
|
|
|
|
};
|
|
|
|
|
2015-01-11 16:42:31 +00:00
|
|
|
// Air burst missile
|
2015-02-14 06:51:13 +00:00
|
|
|
// handle locally only
|
|
|
|
if (!local _gunner) exitWith {};
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-02-14 06:51:13 +00:00
|
|
|
if (getNumber (configFile >> "CfgAmmo" >> _ammo >> QGVAR(Airburst)) == 1) then {
|
2016-03-08 03:28:44 +00:00
|
|
|
private _zeroing = _vehicle getVariable [format ["%1_%2", QGVAR(Distance), _turret], currentZeroing _gunner];
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-02-14 06:51:13 +00:00
|
|
|
if (_zeroing < 50) exitWith {};
|
|
|
|
if (_zeroing > 1500) exitWith {};
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-02-14 06:51:13 +00:00
|
|
|
[FUNC(handleAirBurstAmmunitionPFH), 0, [_vehicle, _projectile, _zeroing]] call CBA_fnc_addPerFrameHandler;
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|