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
|
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>
|
2023-08-09 03:51:20 +00:00
|
|
|
* - 0: Explosive <OBJECT>
|
|
|
|
* - 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-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
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _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-10-10 14:39:59 +00:00
|
|
|
private _result = true;
|
2022-09-10 18:02:53 +00:00
|
|
|
|
|
|
|
if !([_unit, _range, _item select 0, _item select 1, _triggerClassname] call FUNC(checkDetonateHandlers)) exitWith {false};
|
2017-05-10 16:28:44 +00:00
|
|
|
|
2017-09-10 14:44:57 +00:00
|
|
|
if (isNull (_item select 0)) then {
|
|
|
|
WARNING_1("Explosive is null [%1]",_this);
|
|
|
|
};
|
|
|
|
|
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
|