ACE3/addons/explosives/functions/fnc_startDefuse.sqf
Glowbal b489750d5b Minor optimizations using private, params, and isEqualType (#4323)
* Optimizations with private, params, and isEqualType

* Fixed tab being used instead of space

* Fixed tabs inserted by notepad++

* More usage of new private syntax and params

- changed a few checks for an array being empty to `_arr isEqualTo []`
rather than `count _arr == 0`
- added more uses of `private` on the same line as the variable is
declared
- added more uses of params to assign variables passed as parameters
- removed unnecessary parentheses
- removed several unnecessary variable declarations with private array
syntax

* clean up and formatting
2016-09-04 16:44:22 +02:00

69 lines
2.2 KiB
Plaintext

/*
* Author: Garth 'L-H' de Wet
* Starts defusing an explosive
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Target explosive <OBJECT>
*
* Return Value:
* Nothing
*
* Example:
* [player, ACE_Interaction_Target] call ACE_Explosives_fnc_StartDefuse;
*
* Public: Yes
*/
#include "script_component.hpp"
params ["_unit", "_target"];
TRACE_2("params",_unit,_target);
private ["_actionToPlay", "_defuseTime", "_isEOD"];
_target = attachedTo (_target);
_fnc_DefuseTime = {
params ["_specialist", "_target"];
TRACE_2("defuseTime",_specialist,_target);
private ["_defuseTime"];
_defuseTime = 5;
if (isNumber(ConfigFile >> "CfgAmmo" >> typeOf (_target) >> QGVAR(DefuseTime))) then {
_defuseTime = getNumber(ConfigFile >> "CfgAmmo" >> typeOf (_target) >> QGVAR(DefuseTime));
};
if (!_specialist && {GVAR(PunishNonSpecialists)}) then {
_defuseTime = _defuseTime * 1.5;
};
_defuseTime
};
_actionToPlay = "MedicOther";
if (STANCE _unit == "Prone") then {
_actionToPlay = "PutDown";
};
if (ACE_player != _unit) then {
// If the unit is a player, call the function on the player.
if (isPlayer _unit) then {
[QGVAR(startDefuse), [_unit, _target], _unit] call CBA_fnc_targetEvent;
} else {
[_unit, _actionToPlay] call EFUNC(common,doGesture);
_unit disableAI "MOVE";
_unit disableAI "TARGET";
_defuseTime = [[_unit] call EFUNC(Common,isEOD), _target] call _fnc_DefuseTime;
[{
params ["_unit", "_target"];
TRACE_2("defuse finished",_unit,_target);
[_unit, _target] call FUNC(defuseExplosive);
_unit enableAI "MOVE";
_unit enableAI "TARGET";
}, [_unit, _target], _defuseTime] call CBA_fnc_waitAndExecute;
};
} else {
[_unit, _actionToPlay] call EFUNC(common,doGesture);
_isEOD = [_unit] call EFUNC(Common,isEOD);
_defuseTime = [_isEOD, _target] call _fnc_DefuseTime;
if (_isEOD || {!GVAR(RequireSpecialist)}) then {
[_defuseTime, [_unit,_target], {(_this select 0) call FUNC(defuseExplosive)}, {}, (localize LSTRING(DefusingExplosive)), {true}, ["isNotSwimming"]] call EFUNC(common,progressBar);
};
};