diff --git a/addons/frag/XEH_PREP.hpp b/addons/frag/XEH_PREP.hpp index 16e2a95ef7c..758cbff8956 100644 --- a/addons/frag/XEH_PREP.hpp +++ b/addons/frag/XEH_PREP.hpp @@ -14,5 +14,6 @@ PREP(fired); PREP(frago); PREP(getFragInfo); PREP(getSpallInfo); +PREP(setClassBlacklisted); PREP(shouldFrag); PREP(shouldSpall); diff --git a/addons/frag/functions/fnc_addBlacklist.sqf b/addons/frag/functions/fnc_addBlacklist.sqf index 323a9cf87f0..e1ed5fd2fef 100644 --- a/addons/frag/functions/fnc_addBlacklist.sqf +++ b/addons/frag/functions/fnc_addBlacklist.sqf @@ -1,24 +1,32 @@ #include "..\script_component.hpp" /* - * Author: Jaynus, NouberNou + * Author: Jaynus, NouberNou, Lambda.Tiger * Adds a round to the blacklist (will be ignored) and removes any ace_frag event handlers added to it. + * Once blacklisted a projectile can not be "unblacklisted." * * Arguments: - * 0: Projectile + * 0: Projectile to be blacklisted * * Return Value: - * None + * Was the projectile blacklisted * * Example: * [_projectile] call ace_frag_fnc_addBlackList * - * Public: No + * Public: Yes */ -params ["_projectile"]; +params [["_projectile", objNull, [objNull]]]; TRACE_2("addBlackList",_projectile,typeOf projectile); -_projectile setVariable [QGVAR(blacklisted), true]; -_projectile removeEventHandler ["HitPart", _projectile getVariable [QGVAR(hitPartEventHandler), -1]]; +if (isNull _projectile || {!isClass (configFile >> "CfgAmmo" >> (typeOf _projectile))}) exitWith { + TRACE_1("Invalid projectile",_this); + false; +}; -nil // return +_projectile setVariable [QGVAR(blacklisted), true]; +_projectile removeEventHandler [ + "HitPart", + _projectile getVariable [QGVAR(hitPartEventHandler), -1] +]; +true; diff --git a/addons/frag/functions/fnc_setClassBlacklisted.sqf b/addons/frag/functions/fnc_setClassBlacklisted.sqf new file mode 100644 index 00000000000..03a13500258 --- /dev/null +++ b/addons/frag/functions/fnc_setClassBlacklisted.sqf @@ -0,0 +1,49 @@ +#include "..\script_component.hpp" +/* + * Author: Lambda.Tiger + * Blacklist an ammo class preventing it from producing fragments and/or spall. + * This function will not allow you to force a projectile to produce fragments or spall. + * Once an ammo class has been blacklisted, it can be removed from the blacklist using this function without restarting the mission. + * + * Arguments: + * 0: Class name of the ammo to be blacklisted + * 1: Should a projectile be blacklisted from producing fragments (default: true) + * 2: Should a projectile be blacklisted from producing spall (default: true) + * + * Return Value: + * Were the changes properly applied + * + * Example: + * // Stop "ACE_20mm_HE" from producing spall + * ["ACE_20mm_HE", false, true] call ace_frag_fnc_setClassBlacklisted; + * + * Public: Yes + */ +params [ + ["_ammo", "", [""]], + ["_blacklistFrag", true, [true]], + ["_blacklistSpall", true, [true]] +]; +TRACE_3("addBlackListClass",_ammo,_blacklistFrag,_blacklistSpall); + +if (_ammo isEqualTo "" || {!isClass (configFile >> "CfgAmmo" >> _ammo)}) exitWith { + INFO_1("Invalid ammo class [%1]",_ammo); + false +}; + +if (_blacklistFrag) then { + GVAR(shouldFragCache) set [_ammo, false]; +} else { + GVAR(shouldFragCache) deleteAt _ammo; + _ammo call FUNC(shouldFrag); +}; + + +if (_blacklistSpall) then { + GVAR(shouldSpallCache) set [_ammo, false]; +} else { + GVAR(shouldSpallCache) deleteAt _ammo; + _ammo call FUNC(shouldSpall); +}; + +true