From 886ffacb35a2ddbd1638093287e2818e4a199ad9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Badano?= Date: Thu, 15 Jan 2015 23:36:58 -0300 Subject: [PATCH] overheating: replace last spawn by a PFH --- .../overheating/functions/fnc_jamWeapon.sqf | 27 ++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/addons/overheating/functions/fnc_jamWeapon.sqf b/addons/overheating/functions/fnc_jamWeapon.sqf index e84dbb4a53..beb3a1925b 100644 --- a/addons/overheating/functions/fnc_jamWeapon.sqf +++ b/addons/overheating/functions/fnc_jamWeapon.sqf @@ -23,23 +23,26 @@ _jammedWeapons pushBack _weapon; _unit setVariable [QGVAR(jammedWeapons), _jammedWeapons]; + // this is to re-activate the 'DefaultAction', so you can jam a weapon while full auto shooting -[_unit, _weapon] spawn { - _unit = _this select 0; - _weapon = _this select 1; +_fnc_stopCurrentBurst = { + EXPLODE_2_PVT(_this,_params,_pfhId); + EXPLODE_4_PVT(_params,_unit,_weapon,_ammo,_startFrame); - _ammo = _unit ammo _weapon; + // Skip the first execution of the PFH + if (diag_frameno == _startFrame) exitWith {}; - _frame = diag_frameno; + // Remove the PFH on the second execution + [_pfhId] call cba_fnc_removePerFrameHandler; - if (_ammo > 0) then { + _unit setAmmo [_weapon, _ammo]; +}; + +// Stop current burst +_ammo = _unit ammo _weapon; +if (_ammo > 0) then { _unit setAmmo [_weapon, 0]; - - waitUntil {_frame < diag_frameno}; - - _unit setAmmo [_weapon, _ammo]; - //[localize "STR_ACE_Overheating_WeaponJammed"] call EFUNC(common,displayTextStructured); - }; + [_fnc_stopCurrentBurst, 0, [_unit, _weapon, _ammo, diag_frameno]] call cba_fnc_addPerFrameHandler; }; // only display the hint once, after you try to shoot an already jammed weapon