2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2015-01-11 16:42:31 +00:00
|
|
|
/*
|
2016-11-08 13:47:12 +00:00
|
|
|
* Author: KoffeinFlummi, esteldunedain, Ruthberg
|
2016-02-06 21:24:48 +00:00
|
|
|
* Adjusts the flight path of the bullet according to the zeroing. Called from the unified fired EH only for local and non-local players on foot.
|
2015-01-11 16:42:31 +00:00
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Arguments:
|
2016-02-06 21:24:48 +00:00
|
|
|
* None. Parameters inherited from EFUNC(common,firedEH)
|
2015-01-11 16:42:31 +00:00
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Return Value:
|
2015-01-11 16:42:31 +00:00
|
|
|
* None
|
2015-02-10 04:22:10 +00:00
|
|
|
*
|
2017-06-08 13:31:51 +00:00
|
|
|
* Example:
|
|
|
|
* call ace_scopes_fnc_firedEH
|
|
|
|
*
|
2015-02-10 04:22:10 +00:00
|
|
|
* Public: No
|
2015-01-11 16:42:31 +00:00
|
|
|
*/
|
2015-01-16 12:15:14 +00:00
|
|
|
|
2016-02-06 21:24:48 +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-08-07 14:43:06 +00:00
|
|
|
|
2016-11-12 11:04:19 +00:00
|
|
|
if (!(_ammo isKindOf "BulletBase")) exitWith {};
|
|
|
|
|
2016-07-24 04:08:40 +00:00
|
|
|
private _weaponIndex = [_unit, currentWeapon _unit] call EFUNC(common,getWeaponIndex);
|
2015-02-10 04:22:10 +00:00
|
|
|
if (_weaponIndex < 0) exitWith {};
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2017-11-22 08:59:01 +00:00
|
|
|
private _adjustment = _unit getVariable [QGVAR(Adjustment), [[0, 0, 0], [0, 0, 0], [0, 0, 0]]];
|
2018-02-08 18:01:41 +00:00
|
|
|
private _zeroing = (_adjustment select _weaponIndex) vectorMultiply 0.05729578; // Convert zeroing from mils to degrees (value of MRAD_TO_DEG(1))
|
2016-05-20 02:39:15 +00:00
|
|
|
TRACE_1("Adjusting With",_zeroing);
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2017-11-29 10:38:19 +00:00
|
|
|
if (GVAR(correctZeroing) || GVAR(simplifiedZeroing)) then {
|
2016-11-12 11:06:17 +00:00
|
|
|
private _advancedBallistics = missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false];
|
2017-12-15 16:22:31 +00:00
|
|
|
private _baseAngle = (_unit getVariable [QGVAR(baseAngle), [0,0,0]]) select _weaponIndex;
|
2021-10-30 21:42:03 +00:00
|
|
|
private _boreHeight = (_unit getVariable [QGVAR(boreHeight), [0,0,0]]) select _weaponIndex;
|
2016-11-12 11:06:17 +00:00
|
|
|
private _oldZeroRange = currentZeroing _unit;
|
|
|
|
private _newZeroRange = [_unit] call FUNC(getCurrentZeroRange);
|
|
|
|
private _zeroCorrection = missionNamespace getVariable format[QGVAR(%1_%2_%3_%4_%5_%6_%7), _oldZeroRange, _newZeroRange, _boreHeight, _weapon, _ammo, _magazine, _advancedBallistics];
|
|
|
|
if (isNil "_zeroCorrection") then {
|
|
|
|
_zeroCorrection = [_oldZeroRange, _newZeroRange, _boreHeight, _weapon, _ammo, _magazine, _advancedBallistics] call FUNC(calculateZeroAngleCorrection);
|
2018-02-08 18:01:41 +00:00
|
|
|
TRACE_7("new calc",_oldZeroRange,_newZeroRange,_boreHeight,_weapon,_ammo,_magazine,_advancedBallistics);
|
|
|
|
TRACE_1("",_zeroCorrection);
|
2016-11-12 11:06:17 +00:00
|
|
|
};
|
2017-11-29 10:38:19 +00:00
|
|
|
if (GVAR(simplifiedZeroing)) then {
|
|
|
|
_zeroing = [0, 0, _zeroCorrection - _baseAngle];
|
|
|
|
} else {
|
|
|
|
_zeroing = _zeroing vectorAdd [0, 0, _zeroCorrection - _baseAngle];
|
|
|
|
};
|
2017-11-21 22:56:46 +00:00
|
|
|
#ifdef DISABLE_DISPERSION
|
|
|
|
_projectile setVelocity (_unit weaponDirection currentWeapon _unit) vectorMultiply (vectorMagnitude (velocity _projectile));
|
|
|
|
#endif
|
2016-11-07 11:01:36 +00:00
|
|
|
};
|
|
|
|
|
2018-02-08 18:01:41 +00:00
|
|
|
TRACE_1("",_zeroing);
|
2016-11-07 11:01:36 +00:00
|
|
|
if (_zeroing isEqualTo [0, 0, 0]) exitWith {};
|
|
|
|
|
2015-08-08 19:17:03 +00:00
|
|
|
_zeroing params ["_elevation", "_windage", "_zero"];
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-08-23 16:38:19 +00:00
|
|
|
[_projectile, _windage, _elevation + _zero, 0] call EFUNC(common,changeProjectileDirection);
|