2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2015-01-11 16:42:31 +00:00
|
|
|
/*
|
2015-02-02 08:35:17 +00:00
|
|
|
* Author: Garth 'L-H' de Wet
|
|
|
|
* Adds an explosive as a clacker item to the passed unit if the unit has the required item.
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Unit <OBJECT>
|
|
|
|
* 1: Explosive <OBJECT>
|
|
|
|
* 2: Magazine classname <STRING>
|
|
|
|
* 3: Extra variables <ARRAY>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
2015-04-10 03:56:19 +00:00
|
|
|
* [player, _explosive, "SatchelCharge_Remote_Mag", [ConfigFile >> "ACE_Triggers" >> "Command"]] call ACE_Explosives_fnc_addClacker;
|
2015-02-02 08:35:17 +00:00
|
|
|
*
|
|
|
|
* Public: Yes
|
|
|
|
*/
|
2015-08-15 19:35:33 +00:00
|
|
|
|
|
|
|
params ["_unit", "_explosive", "_magazineClass"];
|
|
|
|
TRACE_3("params",_unit,_explosive,_magazineClass);
|
|
|
|
|
2015-01-11 16:42:31 +00:00
|
|
|
// Config is the last item in the list of passed in items.
|
2017-10-10 14:39:59 +00:00
|
|
|
private _config = (_this select 3) select (count (_this select 3) - 1);
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _requiredItems = getArray(_config >> "requires");
|
|
|
|
private _hasRequired = true;
|
|
|
|
private _detonators = [_unit] call FUNC(getDetonators);
|
2015-01-11 16:42:31 +00:00
|
|
|
{
|
2015-04-06 20:20:11 +00:00
|
|
|
if !(_x in _detonators) exitWith{
|
|
|
|
_hasRequired = false;
|
|
|
|
};
|
2024-06-11 15:34:32 +00:00
|
|
|
} forEach _requiredItems;
|
2015-01-11 16:42:31 +00:00
|
|
|
|
|
|
|
if !(_hasRequired) exitWith {};
|
2017-10-10 14:39:59 +00:00
|
|
|
private _config = ConfigFile >> "CfgMagazines" >> _magazineClass >> "ACE_Triggers" >> configName _config;
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _clacker = _unit getVariable [QGVAR(Clackers), []];
|
2015-01-12 09:48:26 +00:00
|
|
|
GVAR(PlacedCount) = GVAR(PlacedCount) + 1;
|
2015-04-06 20:10:00 +00:00
|
|
|
|
2015-05-28 19:59:04 +00:00
|
|
|
_clacker pushBack [_explosive, getNumber(_config >> "FuseTime"), format [localize LSTRING(DetonateCode),
|
2015-04-06 20:20:11 +00:00
|
|
|
GVAR(PlacedCount)], _magazineClass, configName ((_this select 3) select (count (_this select 3) - 1))];
|
2015-04-06 20:10:00 +00:00
|
|
|
|
2015-01-12 09:48:26 +00:00
|
|
|
_unit setVariable [QGVAR(Clackers), _clacker, true];
|
2015-08-19 22:25:45 +00:00
|
|
|
|
|
|
|
//display clacker code message:
|
|
|
|
[format [localize LSTRING(DetonateCode), GVAR(PlacedCount)]] call EFUNC(common,displayTextStructured);
|
2020-11-08 23:26:02 +00:00
|
|
|
|
|
|
|
[QGVAR(clackerAdded), [_unit, _explosive, GVAR(PlacedCount)]] call CBA_fnc_localEvent;
|