explosives: fixed timer #26

This commit is contained in:
Nicolás Badano 2015-01-15 17:06:38 -03:00
parent f06da9a8c1
commit a4a4ca39f6

View File

@ -1,27 +1,37 @@
/*
Name: ACE_Explosives_fnc_startTimer
Author(s):
Garth de Wet (LH)
Author(s):
Garth de Wet (LH)
Description:
Starts a timer for an explosive.
Description:
Starts a timer for an explosive.
Parameters:
0: OBJECT - Explosive
1: NUMBER - time till detonation
Parameters:
0: OBJECT - Explosive
1: NUMBER - time till detonation
Returns:
Nothing
Returns:
Nothing
Example:
[_explosive, 10] call ACE_Explosives_fnc_startTimer;
Example:
[_explosive, 10] call ACE_Explosives_fnc_startTimer;
*/
#include "script_component.hpp"
[{
private ["_explosive"];
_explosive = _this select 0;
if (!isNull _explosive) then {
[_explosive, -1, [_explosive, 0], true] call FUNC(detonateExplosive);
};
},_this select 1, _this] call CALLSTACK(CBA_fnc_addPerFrameHandler);
private ["_explosive", "_params", "_pfhId", "_placeTime", "_fuseTime"];
_params = _this select 0;
_pfhId = _this select 1;
_placeTime = _params select 1;
_fuseTime = _params select 0 select 1;
// Skip first execution
if (diag_tickTime < _placeTime + _fuseTime / 2) exitWith {};
_explosive = (_params select 0) select 0;
if (!isNull _explosive) then {
[_explosive, -1, [_explosive, 0], true] call FUNC(detonateExplosive);
};
// Remove the PFH
[_pfhId] call cba_fnc_removePerFrameHandler;
},_this select 1, [_this, diag_tickTime]] call CBA_fnc_addPerFrameHandler;