-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1294 from CBATeam/switchableAttachments
add CBA_fnc_switchableAttachments
- Loading branch information
Showing
4 changed files
with
62 additions
and
11 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
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)); | ||
}; | ||
}; |
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,7 @@ | ||
class CfgFunctions { | ||
class CBA { | ||
class Inventory { | ||
PATHTO_FNC(switchableAttachments); | ||
}; | ||
}; | ||
}; |
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,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 {}; | ||
|
||
_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 |