From 3606d6f311ad9c43bdcf982ad9d9599f0f8f80d5 Mon Sep 17 00:00:00 2001 From: Tim Beswick Date: Fri, 7 Jun 2019 19:30:50 +0100 Subject: [PATCH] fix updating flashlight fx after attachment switch (#1154) * Add next attachment in next frame - Moves adding of next attachment to next frame - Allows different flashlight modes to be used and update properly when switching - Currently switching from one flashlight to another in the same frame whilst the flashlight is on causes the light effect not to update to the new flashlight Question: Would the localEvent need to be moved into the next frame as well? * Accessory switch localEvent next frame * Suggestions from commy for readability --- addons/accessory/fnc_switchAttachment.sqf | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/addons/accessory/fnc_switchAttachment.sqf b/addons/accessory/fnc_switchAttachment.sqf index a4e8e11ca..44ed07376 100644 --- a/addons/accessory/fnc_switchAttachment.sqf +++ b/addons/accessory/fnc_switchAttachment.sqf @@ -56,15 +56,27 @@ if (!isNil "_switchItem") then { switch (_currWeaponType) do { case 0: { _unit removePrimaryWeaponItem _currItem; - _unit addPrimaryWeaponItem _switchItem; + [{ + params ["_unit", "", "_switchItem"]; + _unit addPrimaryWeaponItem _switchItem; + ["CBA_attachmentSwitched", _this] call CBA_fnc_localEvent; + }, [_unit, _currItem, _switchItem, _currWeaponType]] call CBA_fnc_execNextFrame; }; case 1: { _unit removeHandgunItem _currItem; - _unit addHandgunItem _switchItem; + [{ + params ["_unit", "", "_switchItem"]; + _unit addHandgunItem _switchItem; + ["CBA_attachmentSwitched", _this] call CBA_fnc_localEvent; + }, [_unit, _currItem, _switchItem, _currWeaponType]] call CBA_fnc_execNextFrame; }; case 2: { _unit removeSecondaryWeaponItem _currItem; - _unit addSecondaryWeaponItem _switchItem; + [{ + params ["_unit", "", "_switchItem"]; + _unit addSecondaryWeaponItem _switchItem; + ["CBA_attachmentSwitched", _this] call CBA_fnc_localEvent; + }, [_unit, _currItem, _switchItem, _currWeaponType]] call CBA_fnc_execNextFrame; }; }; private _switchItemHintText = getText (__cfgWeapons >> _switchItem >> "MRT_SwitchItemHintText"); @@ -72,7 +84,6 @@ if (!isNil "_switchItem") then { hintSilent format ["%1", _switchItemHintText]; }; playSound "click"; - ["CBA_attachmentSwitched", [_unit, _currItem, _switchItem, _currWeaponType]] call CBA_fnc_localEvent; } else { playSound "ClickSoft"; };