Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add CBA_fnc_switchableAttachments #1294

Merged
merged 2 commits into from
Mar 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions addons/accessory/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Extended_PreStart_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preStart));
};
};

class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit));
};
};
7 changes: 7 additions & 0 deletions addons/accessory/CfgFunctions.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class CfgFunctions {
class CBA {
class Inventory {
PATHTO_FNC(switchableAttachments);
};
};
};
13 changes: 2 additions & 11 deletions addons/accessory/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,5 @@ class CfgPatches {
};
};

class Extended_PreStart_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preStart));
};
};

class Extended_PreInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_preInit));
};
};
#include "CfgEventHandlers.hpp"
#include "CfgFunctions.hpp"
42 changes: 42 additions & 0 deletions addons/accessory/fnc_switchableAttachments.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#include "script_component.hpp"
/* ----------------------------------------------------------------------------
Function: CBA_fnc_switchableAttachments
Description:
Returns all attachments the item can eventually switch to.
Parameters:
0: _item - Attachment classname <STRING>
Returns:
_items - List of switchable items, contains original item. <ARRAY>
Examples:
(begin example)
"acc_pointer_IR" call CBA_fnc_switchableAttachments
(end)
Author:
commy2
---------------------------------------------------------------------------- */

params ["_item"];

private _cfgWeapons = configfile >> "CfgWeapons";
private _config = _cfgWeapons >> _item;

private _forward = [];
while {
_config = _cfgWeapons >> getText (_config >> "MRT_SwitchItemNextClass");
isClass _config && {_forward pushBackUnique configName _config != -1}
} do {};

commy2 marked this conversation as resolved.
Show resolved Hide resolved
_config = _cfgWeapons >> _item;
private _backward = [];
while {
_config = _cfgWeapons >> getText (_config >> "MRT_SwitchItemPrevClass");
isClass _config && {_backward pushBackUnique configName _config != -1}
} do {};

_forward = _forward + _backward;
_forward arrayIntersect _forward // return