Skip to content

Commit

Permalink
fix updating flashlight fx after attachment switch (#1154)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
tbeswick96 authored and commy2 committed Jun 7, 2019
1 parent 79773f1 commit 3606d6f
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions addons/accessory/fnc_switchAttachment.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,34 @@ 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");
if !(_switchItemHintText isEqualTo "") then {
hintSilent format ["%1", _switchItemHintText];
};
playSound "click";
["CBA_attachmentSwitched", [_unit, _currItem, _switchItem, _currWeaponType]] call CBA_fnc_localEvent;
} else {
playSound "ClickSoft";
};
Expand Down

0 comments on commit 3606d6f

Please sign in to comment.