-
Notifications
You must be signed in to change notification settings - Fork 739
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Common - Add
ace_common_fnc_switchAttachmentMode
(#10135)
* Common - Add `ace_common_fnc_switchAttachmentMode` * Update addons/common/functions/fnc_switchAttachmentMode.sqf * Update addons/common/functions/fnc_switchAttachmentMode.sqf * playSound only for ACE_player Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> --------- Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
- Loading branch information
1 parent
8eefffe
commit ba22c40
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
#include "..\script_component.hpp" | ||
/* | ||
* Author: PabstMirror | ||
* Switch attachment from one mode to another - based on CBA_accessory_fnc_switchAttachment | ||
* | ||
* Arguments: | ||
* 0: Unit <OBJECT> | ||
* 1: From <STRING> | ||
* 2: To <STRING> | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Example: | ||
* [player, "ACE_DBAL_A3_Green_VP", "ACE_DBAL_A3_Green"] call ace_common_fnc_switchAttachmentMode | ||
* | ||
* Public: No | ||
*/ | ||
|
||
params ["_unit", "_currItem", "_switchItem"]; | ||
TRACE_3("switchAttachmentMode",_unit,_currItem,_switchItem); | ||
|
||
switch (currentWeapon _unit) do { | ||
case (""): {}; | ||
case (primaryWeapon _unit): { | ||
private _currWeaponType = 0; | ||
_unit removePrimaryWeaponItem _currItem; | ||
[{ | ||
params ["_unit", "", "_switchItem"]; | ||
_unit addPrimaryWeaponItem _switchItem; | ||
["CBA_attachmentSwitched", _this] call CBA_fnc_localEvent; | ||
}, [_unit, _currItem, _switchItem, _currWeaponType]] call CBA_fnc_execNextFrame; | ||
}; | ||
case (handgunWeapon _unit): { | ||
private _currWeaponType = 1; | ||
_unit removeHandgunItem _currItem; | ||
[{ | ||
params ["_unit", "", "_switchItem"]; | ||
_unit addHandgunItem _switchItem; | ||
["CBA_attachmentSwitched", _this] call CBA_fnc_localEvent; | ||
}, [_unit, _currItem, _switchItem, _currWeaponType]] call CBA_fnc_execNextFrame; | ||
}; | ||
case (secondaryWeapon _unit): { | ||
private _currWeaponType = 2; | ||
_unit removeSecondaryWeaponItem _currItem; | ||
[{ | ||
params ["_unit", "", "_switchItem"]; | ||
_unit addSecondaryWeaponItem _switchItem; | ||
["CBA_attachmentSwitched", _this] call CBA_fnc_localEvent; | ||
}, [_unit, _currItem, _switchItem, _currWeaponType]] call CBA_fnc_execNextFrame; | ||
}; | ||
}; | ||
private _configSwitchItem = configfile >> "CfgWeapons" >> _switchItem; | ||
private _switchItemHintText = getText (_configSwitchItem >> "MRT_SwitchItemHintText"); | ||
private _switchItemHintImage = getText (_configSwitchItem >> "picture"); | ||
if (_switchItemHintText isNotEqualTo "") then { | ||
[[_switchItemHintImage, 2.0], [_switchItemHintText], true] call CBA_fnc_notify; | ||
}; | ||
if (_unit == ACE_player) then { | ||
playSound "click"; | ||
}; |