mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Tagging - Cache required items check and use uniqueItems (#6582)
* Cache required items check and use uniqueItems * Use config-case for required items
This commit is contained in:
parent
afbf2049ea
commit
61000df120
@ -48,7 +48,6 @@ if (_textures isEqualTo []) exitWith {
|
|||||||
};
|
};
|
||||||
|
|
||||||
_identifier = [_identifier] call CBA_fnc_removeWhitespace;
|
_identifier = [_identifier] call CBA_fnc_removeWhitespace;
|
||||||
_requiredItem = toLower _requiredItem;
|
|
||||||
|
|
||||||
// Add
|
// Add
|
||||||
[QGVAR(applyCustomTag), [_identifier, _displayName, _requiredItem, _textures, _icon]] call CBA_fnc_globalEventJIP;
|
[QGVAR(applyCustomTag), [_identifier, _displayName, _requiredItem, _textures, _icon]] call CBA_fnc_globalEventJIP;
|
||||||
|
@ -33,7 +33,7 @@ private _actions = [];
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
(_this select 2) params ["_unit", "", "", "_requiredItem"];
|
(_this select 2) params ["_unit", "", "", "_requiredItem"];
|
||||||
_requiredItem in ((items _unit) apply {toLower _x})
|
_requiredItem in (_unit call EFUNC(common,uniqueItems))
|
||||||
},
|
},
|
||||||
{},
|
{},
|
||||||
[_unit, _class, _textures, _requiredItem]
|
[_unit, _class, _textures, _requiredItem]
|
||||||
|
@ -25,6 +25,8 @@ params ["_identifier", "_displayName", "_requiredItem"];
|
|||||||
if !(GVAR(cachedTags) select {_x select 0 == _identifier} isEqualTo []) exitWith {
|
if !(GVAR(cachedTags) select {_x select 0 == _identifier} isEqualTo []) exitWith {
|
||||||
INFO_2("Tag with selected identifier already exists: %1 (%2)",_identifier,_displayName)
|
INFO_2("Tag with selected identifier already exists: %1 (%2)",_identifier,_displayName)
|
||||||
};
|
};
|
||||||
|
_requiredItem = configName (configFile >> "CfgWeapons" >> _requiredItem); // Convert To config case
|
||||||
|
_this set [2, _requiredItem];
|
||||||
|
|
||||||
GVAR(cachedTags) pushBack _this;
|
GVAR(cachedTags) pushBack _this;
|
||||||
GVAR(cachedRequiredItems) pushBackUnique _requiredItem;
|
GVAR(cachedRequiredItems) pushBackUnique _requiredItem;
|
||||||
|
@ -19,7 +19,9 @@
|
|||||||
params ["_unit"];
|
params ["_unit"];
|
||||||
|
|
||||||
// Exit if no required item in inventory
|
// Exit if no required item in inventory
|
||||||
if ((GVAR(cachedRequiredItems) arrayIntersect ((items _unit) apply {toLower _x})) isEqualTo []) exitWith {false};
|
if ([_unit, {
|
||||||
|
GVAR(cachedRequiredItems) arrayIntersect (_unit call EFUNC(common,uniqueItems)) isEqualTo []
|
||||||
|
}, _unit, QGVAR(checkRequiredItemsCache), 9999, "cba_events_loadoutEvent"] call EFUNC(common,cachedCall)) exitWith {false};
|
||||||
|
|
||||||
private _startPosASL = eyePos _unit;
|
private _startPosASL = eyePos _unit;
|
||||||
private _cameraPosASL = AGLToASL positionCameraToWorld [0, 0, 0];
|
private _cameraPosASL = AGLToASL positionCameraToWorld [0, 0, 0];
|
||||||
@ -36,7 +38,6 @@
|
|||||||
// Exit if trying to tag a non static object
|
// Exit if trying to tag a non static object
|
||||||
TRACE_1("Obj:",_intersections);
|
TRACE_1("Obj:",_intersections);
|
||||||
|
|
||||||
// Exit if trying to tag a non static object
|
|
||||||
if ((!isNull _object) && {
|
if ((!isNull _object) && {
|
||||||
// If the class is alright, do not exit
|
// If the class is alright, do not exit
|
||||||
if (_object isKindOf "Static") exitWith {false};
|
if (_object isKindOf "Static") exitWith {false};
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
_failure = true;
|
_failure = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
private _requiredItem = toLower (getText (_x >> "requiredItem"));
|
private _requiredItem = getText (_x >> "requiredItem");
|
||||||
if (_requiredItem == "") then {
|
if (_requiredItem == "") then {
|
||||||
ERROR_1("Failed compiling ACE_Tags for tag: %1 - missing requiredItem",_class);
|
ERROR_1("Failed compiling ACE_Tags for tag: %1 - missing requiredItem",_class);
|
||||||
_failure = true;
|
_failure = true;
|
||||||
@ -33,6 +33,8 @@
|
|||||||
if (!isClass (configFile >> "CfgWeapons" >> _requiredItem)) then {
|
if (!isClass (configFile >> "CfgWeapons" >> _requiredItem)) then {
|
||||||
ERROR_2("Failed compiling ACE_Tags for tag: %1 - requiredItem %2 does not exist",_class,_requiredItem);
|
ERROR_2("Failed compiling ACE_Tags for tag: %1 - requiredItem %2 does not exist",_class,_requiredItem);
|
||||||
_failure = true;
|
_failure = true;
|
||||||
|
} else {
|
||||||
|
_requiredItem = configName (configFile >> "CfgWeapons" >> _requiredItem); // convert to config case
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -48,6 +48,6 @@ if (GVAR(quickTag) == 3) then {
|
|||||||
|
|
||||||
// Tag
|
// Tag
|
||||||
if !(_possibleTags isEqualTo []) then {
|
if !(_possibleTags isEqualTo []) then {
|
||||||
private _availableTags = _possibleTags select {(_x select 2) in ((items _unit) apply {toLower _x})};
|
private _availableTags = _possibleTags select {(_x select 2) in (_unit call EFUNC(common,uniqueItems))};
|
||||||
[_unit, selectRandom ((selectRandom _availableTags) select 3)] call FUNC(tag);
|
[_unit, selectRandom ((selectRandom _availableTags) select 3)] call FUNC(tag);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user