2015-01-12 09:48:26 +00:00
|
|
|
/*
|
2015-02-02 08:35:17 +00:00
|
|
|
* Author: Garth 'L-H' de Wet
|
|
|
|
* Starts defusing an explosive
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Unit <OBJECT>
|
|
|
|
* 1: Target explosive <OBJECT>
|
|
|
|
*
|
|
|
|
* Return Value:
|
2017-06-08 13:31:51 +00:00
|
|
|
* None
|
2015-02-02 08:35:17 +00:00
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [player, ACE_Interaction_Target] call ACE_Explosives_fnc_StartDefuse;
|
|
|
|
*
|
|
|
|
* Public: Yes
|
|
|
|
*/
|
2015-01-13 21:21:31 +00:00
|
|
|
#include "script_component.hpp"
|
2015-08-15 19:35:33 +00:00
|
|
|
|
|
|
|
params ["_unit", "_target"];
|
|
|
|
TRACE_2("params",_unit,_target);
|
2015-04-29 05:05:02 +00:00
|
|
|
|
2015-04-01 18:43:18 +00:00
|
|
|
_target = attachedTo (_target);
|
2015-01-12 09:48:26 +00:00
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _fnc_DefuseTime = {
|
2015-08-15 19:35:33 +00:00
|
|
|
params ["_specialist", "_target"];
|
|
|
|
TRACE_2("defuseTime",_specialist,_target);
|
2017-10-10 14:39:59 +00:00
|
|
|
private _defuseTime = 5;
|
2016-01-14 22:05:56 +00:00
|
|
|
if (isNumber(ConfigFile >> "CfgAmmo" >> typeOf (_target) >> QGVAR(DefuseTime))) then {
|
|
|
|
_defuseTime = getNumber(ConfigFile >> "CfgAmmo" >> typeOf (_target) >> QGVAR(DefuseTime));
|
2015-04-06 20:20:11 +00:00
|
|
|
};
|
|
|
|
if (!_specialist && {GVAR(PunishNonSpecialists)}) then {
|
|
|
|
_defuseTime = _defuseTime * 1.5;
|
|
|
|
};
|
|
|
|
_defuseTime
|
2015-01-12 09:48:26 +00:00
|
|
|
};
|
2017-10-10 14:39:59 +00:00
|
|
|
private _actionToPlay = "MedicOther";
|
2015-01-12 09:48:26 +00:00
|
|
|
if (STANCE _unit == "Prone") then {
|
2015-04-06 20:20:11 +00:00
|
|
|
_actionToPlay = "PutDown";
|
2015-01-12 09:48:26 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
if (ACE_player != _unit) then {
|
2015-04-06 20:20:11 +00:00
|
|
|
// If the unit is a player, call the function on the player.
|
|
|
|
if (isPlayer _unit) then {
|
2016-06-03 00:59:18 +00:00
|
|
|
[QGVAR(startDefuse), [_unit, _target], _unit] call CBA_fnc_targetEvent;
|
2015-04-06 20:20:11 +00:00
|
|
|
} else {
|
2016-07-12 14:16:01 +00:00
|
|
|
[_unit, _actionToPlay] call EFUNC(common,doGesture);
|
2015-05-01 09:38:09 +00:00
|
|
|
_unit disableAI "MOVE";
|
|
|
|
_unit disableAI "TARGET";
|
2017-10-10 14:39:59 +00:00
|
|
|
private _defuseTime = [[_unit] call EFUNC(Common,isEOD), _target] call _fnc_DefuseTime;
|
2015-05-01 09:38:09 +00:00
|
|
|
[{
|
2015-08-15 19:35:33 +00:00
|
|
|
params ["_unit", "_target"];
|
|
|
|
TRACE_2("defuse finished",_unit,_target);
|
2015-05-01 09:38:09 +00:00
|
|
|
[_unit, _target] call FUNC(defuseExplosive);
|
|
|
|
_unit enableAI "MOVE";
|
|
|
|
_unit enableAI "TARGET";
|
2016-05-22 13:27:24 +00:00
|
|
|
}, [_unit, _target], _defuseTime] call CBA_fnc_waitAndExecute;
|
2015-04-06 20:20:11 +00:00
|
|
|
};
|
2015-01-12 09:48:26 +00:00
|
|
|
} else {
|
2016-07-12 14:16:01 +00:00
|
|
|
[_unit, _actionToPlay] call EFUNC(common,doGesture);
|
2017-10-10 14:39:59 +00:00
|
|
|
private _isEOD = [_unit] call EFUNC(Common,isEOD);
|
|
|
|
private _defuseTime = [_isEOD, _target] call _fnc_DefuseTime;
|
2015-04-06 20:20:11 +00:00
|
|
|
if (_isEOD || {!GVAR(RequireSpecialist)}) then {
|
2016-07-10 18:49:06 +00:00
|
|
|
[_defuseTime, [_unit,_target], {(_this select 0) call FUNC(defuseExplosive)}, {}, (localize LSTRING(DefusingExplosive)), {true}, ["isNotSwimming"]] call EFUNC(common,progressBar);
|
2015-04-06 20:20:11 +00:00
|
|
|
};
|
2015-01-12 09:48:26 +00:00
|
|
|
};
|