diff --git a/addons/main/XEH_PREP.hpp b/addons/main/XEH_PREP.hpp index 51b69a2c..fcbe64f7 100644 --- a/addons/main/XEH_PREP.hpp +++ b/addons/main/XEH_PREP.hpp @@ -1,4 +1,5 @@ PREP(addShareInformationHandler); +PREP(checkMagazineAiUsageFlags); PREP(doAnimation); PREP(doCallout); PREP(doGesture); diff --git a/addons/main/functions/UnitAction/fnc_doSmoke.sqf b/addons/main/functions/UnitAction/fnc_doSmoke.sqf index 095de899..28193c9a 100644 --- a/addons/main/functions/UnitAction/fnc_doSmoke.sqf +++ b/addons/main/functions/UnitAction/fnc_doSmoke.sqf @@ -20,7 +20,7 @@ params [ ["_unit", objNull, [grpNull, objNull, []]], ["_pos", [], [[]]], - ["_type", 6, [0]] + ["_type", 4, [0]] ]; // single unit @@ -38,9 +38,7 @@ if (_magazines isEqualTo []) exitWith {false}; // find smoke shell private _smokeshell = _magazines findIf { - private _ammo = getText (configfile >> "CfgMagazines" >> _x >> "Ammo"); - private _aiAmmoUsage = getNumber (configfile >> "CfgAmmo" >> _ammo >> "aiAmmoUsageFlags"); - _aiAmmoUsage isEqualTo _type + [_x, _type] call FUNC(checkMagazineAiUsageFlags); }; // select smoke diff --git a/addons/main/functions/fnc_checkMagazineAiUsageFlags.sqf b/addons/main/functions/fnc_checkMagazineAiUsageFlags.sqf new file mode 100644 index 00000000..12ce0869 --- /dev/null +++ b/addons/main/functions/fnc_checkMagazineAiUsageFlags.sqf @@ -0,0 +1,37 @@ +#include "script_component.hpp" +/* + * Author: joko // Jonas + * Checks if a given ammo has a aiUsageFlagSet + * + * Arguments: + * 0: Ammo + * 1: Flags + * + * Return Value: + * boolean + * + * Example: + * "SmokeShell" call lambs_main_fnc_checkMagazineAiUsageFlags; + * + * Public: Yes +*/ + +if (isNil QGVAR(aiUsageFlagCache)) then { + GVAR(aiUsageFlagCache) = createHashMap; +}; + +params [["_magazine", ""], ["_flags", 0]]; + +private _hasFlags = GVAR(aiUsageFlagCache) get _magazine; +if (!isNil "_hasFlags") exitWith { + _hasFlags +}; + +// find smoke shell +private _ammo = getText (configfile >> "CfgMagazines" >> _magazine >> "Ammo"); +private _aiAmmoUsage = getNumber (configfile >> "CfgAmmo" >> _ammo >> "aiAmmoUsageFlags"); +_hasFlags = [_aiAmmoUsage, _flags] call BIS_fnc_bitflagsCheck; + +GVAR(aiUsageFlagCache) set [_magazine, _hasFlags]; + +_hasFlags; \ No newline at end of file