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>
|
|
|
|
* 0: Explosive <OBJECT>
|
|
|
|
* 1: Fuse time <NUMBER>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [player, 100, [Explosive, 1]] call ACE_Explosives_fnc_detonateExplosive; // has to be within range
|
|
|
|
* [player, -1, [Explosive, 1]] call ACE_Explosives_fnc_detonateExplosive; // range ignored.
|
|
|
|
*
|
|
|
|
* Public: Yes
|
|
|
|
*/
|
2015-01-13 21:21:31 +00:00
|
|
|
#include "script_component.hpp"
|
2015-04-01 18:43:18 +00:00
|
|
|
private ["_result", "_ignoreRange", "_helper"];
|
|
|
|
EXPLODE_3_PVT(_this,_unit,_range,_item);
|
2015-01-11 16:42:31 +00:00
|
|
|
_ignoreRange = (_range == -1);
|
|
|
|
_result = true;
|
|
|
|
|
|
|
|
if (!_ignoreRange && {(_unit distance (_item select 0)) > _range}) exitWith {false};
|
|
|
|
|
2015-03-31 21:20:32 +00:00
|
|
|
_helper = (attachedTo (_item select 0));
|
|
|
|
if (!isNull(_helper)) then {
|
|
|
|
detach (_item select 0);
|
|
|
|
deleteVehicle _helper;
|
|
|
|
};
|
|
|
|
|
2015-01-11 16:42:31 +00:00
|
|
|
if (getNumber (ConfigFile >> "CfgAmmo" >> typeof (_item select 0) >> "TriggerWhenDestroyed") == 0) then {
|
|
|
|
private ["_exp", "_previousExp"];
|
|
|
|
_previousExp = _item select 0;
|
2015-01-12 09:48:26 +00:00
|
|
|
_exp = getText (ConfigFile >> "CfgAmmo" >> typeof (_previousExp) >> "ACE_Explosive");
|
2015-01-11 16:42:31 +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-02-01 18:38:15 +00:00
|
|
|
[{
|
|
|
|
_explosive = _this;
|
|
|
|
if (!isNull _explosive) then {
|
2015-03-31 21:20:32 +00:00
|
|
|
_explosive setDamage 1;
|
2015-02-01 18:38:15 +00:00
|
|
|
};
|
|
|
|
}, _item select 0, _item select 1, 0] call EFUNC(common,waitAndExecute);
|
|
|
|
|
2015-01-11 16:42:31 +00:00
|
|
|
_result
|