2015-01-11 16:42:31 +00:00
|
|
|
/*
|
|
|
|
* Author: KoffeinFlummi
|
|
|
|
*
|
|
|
|
* Adjusts the direction of a shell.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* -> arguments of the FiredBIS EH
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*/
|
|
|
|
|
2015-01-12 10:02:44 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-05-01 16:55:44 +00:00
|
|
|
private ["_vehicle", "_weapon", "_ammo", "_magazine", "_projectile", "_sumVelocity"];
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-02-04 02:20:55 +00:00
|
|
|
_vehicle = _this select 0;
|
|
|
|
_weapon = _this select 1;
|
|
|
|
_ammo = _this select 4;
|
|
|
|
_magazine = _this select 5;
|
|
|
|
_projectile = _this select 6;
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-02-04 02:20:55 +00:00
|
|
|
private ["_gunner", "_turret"];
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2015-02-04 02:20:55 +00:00
|
|
|
_gunner = [_vehicle, _weapon] call EFUNC(common,getGunner);
|
|
|
|
_turret = [_gunner] call EFUNC(common,getTurretIndex);
|
|
|
|
|
2015-02-14 19:20:03 +00:00
|
|
|
// Exit if the unit isn't a player
|
2015-02-14 22:13:43 +00:00
|
|
|
if !([_gunner] call EFUNC(common,isPlayer)) exitWith {};
|
2015-02-04 02:20:55 +00:00
|
|
|
|
|
|
|
private ["_FCSMagazines", "_FCSElevation", "_offset"];
|
|
|
|
|
2015-03-03 21:09:38 +00:00
|
|
|
_FCSMagazines = _vehicle getVariable [(format ["%1_%2", QGVAR(Magazines), _turret]), []];
|
2015-02-04 02:20:55 +00:00
|
|
|
_FCSElevation = _vehicle getVariable format ["%1_%2", QGVAR(Elevation), _turret];
|
|
|
|
|
|
|
|
if !(_magazine in _FCSMagazines) exitWith {};
|
2015-01-11 16:42:31 +00:00
|
|
|
|
|
|
|
// GET ELEVATION OFFSET OF CURRENT MAGAZINE
|
|
|
|
_offset = 0;
|
|
|
|
{
|
2015-02-04 02:20:55 +00:00
|
|
|
if (_x == _magazine) exitWith {
|
2015-01-14 20:07:41 +00:00
|
|
|
_offset = _FCSElevation select _forEachIndex;
|
|
|
|
};
|
2015-01-11 16:42:31 +00:00
|
|
|
} forEach _FCSMagazines;
|
|
|
|
|
|
|
|
|
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
|
|
|
|
2015-04-07 01:36:39 +00:00
|
|
|
// Remove the platform velocity
|
|
|
|
if( (vectorMagnitude velocity _vehicle) > 2) then {
|
|
|
|
_sumVelocity = (velocity _projectile) vectorDiff (velocity _vehicle);
|
|
|
|
_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 {
|
|
|
|
private "_zeroing";
|
|
|
|
_zeroing = _vehicle getVariable [format ["%1_%2", QGVAR(Distance), _turret], currentZeroing _vehicle];
|
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
|
|
|
};
|