From 983b44c02a9add3fdd5e2a3e0888d6ae86a971a7 Mon Sep 17 00:00:00 2001 From: commy2 Date: Sat, 14 Feb 2015 07:51:13 +0100 Subject: [PATCH] air burst ammo PFH --- addons/fcs/XEH_preInit.sqf | 1 + addons/fcs/functions/fnc_firedEH.sqf | 26 ++++++------------- .../fnc_handleAirBurstAmmunitionPFH.sqf | 21 +++++++++++++++ 3 files changed, 30 insertions(+), 18 deletions(-) create mode 100644 addons/fcs/functions/fnc_handleAirBurstAmmunitionPFH.sqf diff --git a/addons/fcs/XEH_preInit.sqf b/addons/fcs/XEH_preInit.sqf index 18729ca54f..78a2fd091c 100644 --- a/addons/fcs/XEH_preInit.sqf +++ b/addons/fcs/XEH_preInit.sqf @@ -9,6 +9,7 @@ PREP(canUseRangefinder); PREP(firedEH); PREP(getAngle); PREP(getRange); +PREP(handleAirBurstAmmunitionPFH); PREP(keyDown); PREP(keyUp); PREP(reset); diff --git a/addons/fcs/functions/fnc_firedEH.sqf b/addons/fcs/functions/fnc_firedEH.sqf index 22371a26f4..38e2c90f3c 100644 --- a/addons/fcs/functions/fnc_firedEH.sqf +++ b/addons/fcs/functions/fnc_firedEH.sqf @@ -45,26 +45,16 @@ _offset = 0; [_projectile, (_vehicle getVariable format ["%1_%2", QGVAR(Azimuth), _turret]), _offset, 0] call EFUNC(common,changeProjectileDirection); // Air burst missile -// may need to get rewritten -if (getNumber (configFile >> "CfgAmmo" >> _ammo >> "ACE_Airburst") == 1) then { - _this spawn { - _vehicle = _this select 0; - _projectile = _this select 6; - _distance = _vehicle getVariable [format ["%1_%2", QGVAR(Distance), _turret], currentZeroing _vehicle]; +// handle locally only +if (!local _gunner) exitWith {}; - if (_distance < 50) exitWith {}; - if (_distance > 1500) exitWith {}; +if (getNumber (configFile >> "CfgAmmo" >> _ammo >> QGVAR(Airburst)) == 1) then { + private "_zeroing"; + _zeroing = _vehicle getVariable [format ["%1_%2", QGVAR(Distance), _turret], currentZeroing _vehicle]; - waitUntil {_projectile distance _vehicle > _distance || {!alive _projectile}}; - if (!alive _projectile) exitWith {}; + if (_zeroing < 50) exitWith {}; + if (_zeroing > 1500) exitWith {}; - _position = getPosATL _projectile; - - _subMunition = createVehicle ["ACE_B_35mm_ABM_Helper", _position, [], 0, "FLY"]; - _subMunition setPosATL _position; - _subMunition setVelocity [0, 0, -10]; - - deleteVehicle _projectile; - }; + [FUNC(handleAirBurstAmmunitionPFH), 0, [_vehicle, _projectile, _zeroing]] call CBA_fnc_addPerFrameHandler; }; diff --git a/addons/fcs/functions/fnc_handleAirBurstAmmunitionPFH.sqf b/addons/fcs/functions/fnc_handleAirBurstAmmunitionPFH.sqf new file mode 100644 index 0000000000..7e8480ce18 --- /dev/null +++ b/addons/fcs/functions/fnc_handleAirBurstAmmunitionPFH.sqf @@ -0,0 +1,21 @@ +// by commy2 + +_vehicle = _this select 0 select 0; +_projectile = _this select 0 select 1; +_zeroing = _this select 0 select 2; + +if (isNull _projectile || {!alive _projectile}) exitWith { + [_this select 1] call CBA_fnc_removePerFrameHandler; +}; + +if (_projectile distance _vehicle < _zeroing) exitWith {}; + +_position = getPosATL _projectile; + +_subMunition = createVehicle ["ACE_B_35mm_ABM_Helper", _position, [], 0, "FLY"]; +_subMunition setPosATL _position; +_subMunition setVelocity [0, 0, -10]; + +deleteVehicle _projectile; + +[_this select 1] call CBA_fnc_removePerFrameHandler;