2015-01-11 16:42:31 +00:00
|
|
|
/*
|
2015-02-02 08:35:17 +00:00
|
|
|
* Author: Garth 'L-H' de Wet
|
2015-02-02 09:42:14 +00:00
|
|
|
* Causes the unit to detonate the passed explosive.
|
2015-02-02 08:35:17 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Unit <OBJECT>
|
|
|
|
* 1: Max range (-1 to ignore) <NUMBER>
|
|
|
|
* 2: Explosive <ARRAY>
|
2015-04-06 16:22:43 +00:00
|
|
|
* 0: Explosive <OBJECT>
|
2015-10-21 20:52:21 +00:00
|
|
|
* 1: Fuse time <NUMBER>
|
2017-05-10 16:28:44 +00:00
|
|
|
* 3: Trigger Item Classname <STRING>
|
2015-02-02 08:35:17 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
2017-05-10 16:28:44 +00:00
|
|
|
* [player, 100, [Explosive, 1], "ACE_Clacker"] call ACE_Explosives_fnc_detonateExplosive; // has to be within range
|
|
|
|
* [player, -1, [Explosive, 1], "ACE_Cellphone"] call ACE_Explosives_fnc_detonateExplosive; // range ignored.
|
2015-02-02 08:35:17 +00:00
|
|
|
*
|
|
|
|
* Public: Yes
|
|
|
|
*/
|
2015-01-13 21:21:31 +00:00
|
|
|
#include "script_component.hpp"
|
2015-08-15 19:35:33 +00:00
|
|
|
|
2017-05-10 16:28:44 +00:00
|
|
|
params ["_unit", "_range", "_item", ["_triggerClassname", "#unknown", [""]]];
|
|
|
|
TRACE_4("detonateExplosive",_unit,_range,_item,_triggerClassname);
|
2015-08-15 19:35:33 +00:00
|
|
|
|
|
|
|
private ["_result", "_ignoreRange", "_pos"];
|
|
|
|
|
2015-01-11 16:42:31 +00:00
|
|
|
_ignoreRange = (_range == -1);
|
2015-08-15 19:35:33 +00:00
|
|
|
if (!_ignoreRange && {(_unit distance (_item select 0)) > _range}) exitWith {TRACE_1("out of range",_range); false};
|
2015-01-11 16:42:31 +00:00
|
|
|
|
2017-05-10 16:28:44 +00:00
|
|
|
_result = true;
|
|
|
|
{
|
|
|
|
// Pass [Unit<OBJECT>, MaxRange <NUMBER>, Explosive <OBJECT>, FuzeTime <NUMBER>, TriggerItem <STRING>]
|
|
|
|
private _handlerResult = [_unit, _range, _item select 0, _item select 1, _triggerClassname] call _x;
|
|
|
|
if (_handlerResult isEqualTo false) then {TRACE_1("Handler Failed",_forEachIndex); _result = false};
|
|
|
|
} forEach GVAR(detonationHandlers);
|
|
|
|
if (!_result) exitWith {false};
|
|
|
|
|
2015-11-30 16:19:57 +00:00
|
|
|
if (getNumber (ConfigFile >> "CfgAmmo" >> typeOf (_item select 0) >> "TriggerWhenDestroyed") == 0) then {
|
2015-04-06 16:22:43 +00:00
|
|
|
private ["_exp", "_previousExp"];
|
|
|
|
_previousExp = _item select 0;
|
2016-01-14 22:05:56 +00:00
|
|
|
_exp = getText (ConfigFile >> "CfgAmmo" >> typeOf (_previousExp) >> QGVAR(Explosive));
|
2015-04-06 16:22:43 +00:00
|
|
|
if (_exp != "") then {
|
|
|
|
_exp = createVehicle [_exp, [0,0,15001], [], 0, "NONE"];
|
|
|
|
_exp setDir (getDir _previousExp);
|
|
|
|
_item set [0, _exp];
|
|
|
|
_pos = getPosASL _previousExp;
|
|
|
|
deleteVehicle _previousExp;
|
|
|
|
_exp setPosASL _pos;
|
|
|
|
};
|
2015-01-11 16:42:31 +00:00
|
|
|
};
|
2016-12-14 20:06:32 +00:00
|
|
|
|
2017-09-10 14:44:57 +00:00
|
|
|
if (isNull (_item select 0)) then {
|
|
|
|
WARNING_1("Explosive is null [%1]",_this);
|
|
|
|
};
|
|
|
|
if ((getNumber (configFile >> "CfgAmmo" >> (typeOf (_item select 0)) >> "triggerWhenDestroyed")) != 1) then {
|
|
|
|
WARNING_1("Explosive is not triggerWhenDestroyed [%1]",typeOf (_item select 0));
|
|
|
|
};
|
|
|
|
|
2016-12-14 20:06:32 +00:00
|
|
|
[QGVAR(detonate), [_unit, _item select 0, _item select 1]] call CBA_fnc_serverEvent;
|
2015-02-01 18:38:15 +00:00
|
|
|
|
2015-01-11 16:42:31 +00:00
|
|
|
_result
|