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

Fix ai ammo usage check in do smoke #365

Merged
merged 6 commits into from
Feb 18, 2024
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
1 change: 1 addition & 0 deletions addons/main/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
PREP(addShareInformationHandler);
PREP(checkMagazineAiUsageFlags);
PREP(doAnimation);
PREP(doCallout);
PREP(doGesture);
Expand Down
6 changes: 2 additions & 4 deletions addons/main/functions/UnitAction/fnc_doSmoke.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
params [
["_unit", objNull, [grpNull, objNull, []]],
["_pos", [], [[]]],
["_type", 6, [0]]
["_type", 4, [0]]
];

// single unit
Expand All @@ -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
Expand Down
37 changes: 37 additions & 0 deletions addons/main/functions/fnc_checkMagazineAiUsageFlags.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "script_component.hpp"
/*
* Author: joko // Jonas
* Checks if a given ammo has a aiUsageFlagSet
*
* Arguments:
* 0: Ammo <String>
* 1: Flags <Number>
*
* 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;
Loading