2015-01-23 22:40:39 +00:00
|
|
|
/*
|
2015-03-15 16:27:21 +00:00
|
|
|
* Author: PabstMirror
|
|
|
|
* Handles lockpick functionality. Three different functions:
|
|
|
|
* "canLockpick": returns BOOL if lockpick is possible
|
|
|
|
* "startLockpick": starts the process
|
|
|
|
* "finishLockpick": on completions, opens the lock
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* 0: Unit (player) <OBJECT>
|
|
|
|
* 1: Vehicle <OBJECT>
|
|
|
|
* 2: Function Type <OBJECT>
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* "canLockpick" <BOOL>
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [ACE_player, ACE_Interaction_Target, 'canLockpick'] call ACE_VehicleLock_fnc_lockpick
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2015-01-23 22:40:39 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-03-15 16:27:21 +00:00
|
|
|
private ["_vehLockpickStrenth","_condition","_returnValue"];
|
2015-01-23 22:40:39 +00:00
|
|
|
|
2015-03-15 16:27:21 +00:00
|
|
|
PARAMS_3(_unit,_veh,_funcType);
|
2015-01-23 22:40:39 +00:00
|
|
|
|
2015-03-15 16:27:21 +00:00
|
|
|
if (isNull _unit) exitWith {ERROR("null unit"); false};
|
|
|
|
if (isNull _veh) exitWith {ERROR("null vehicle"); false};
|
2015-01-23 22:40:39 +00:00
|
|
|
|
2015-04-10 18:05:34 +00:00
|
|
|
//Exit if vehicle unlocked:
|
|
|
|
if ((locked _veh) == 0) exitWith {false};
|
2015-04-10 18:05:14 +00:00
|
|
|
|
2015-01-23 22:40:39 +00:00
|
|
|
//need lockpick item
|
2015-03-15 16:27:21 +00:00
|
|
|
if (!("ACE_key_lockpick" in (items _unit))) exitWith {false};
|
2015-01-23 22:40:39 +00:00
|
|
|
|
2015-01-24 18:58:01 +00:00
|
|
|
_vehLockpickStrenth = _veh getVariable[QGVAR(lockpickStrength), GVAR(DefaultLockpickStrength)];
|
2015-03-15 16:27:21 +00:00
|
|
|
if (typeName _vehLockpickStrenth != "SCALAR") exitWith {ERROR("ACE_vehicleLock_LockpickStrength invalid"); false};
|
2015-01-23 22:40:39 +00:00
|
|
|
|
|
|
|
//-1 indicates unpickable lock
|
2015-03-15 16:27:21 +00:00
|
|
|
if (_vehLockpickStrenth < 0) exitWith {false};
|
|
|
|
|
|
|
|
//Condition check for progressBar
|
|
|
|
_condition = {
|
|
|
|
PARAMS_1(_args);
|
|
|
|
EXPLODE_2_PVT(_args,_unit,_veh);
|
|
|
|
((_unit distance _veh) < 5) && {(speed _veh) < 0.1}
|
2015-01-23 22:40:39 +00:00
|
|
|
};
|
|
|
|
|
2015-03-15 16:27:21 +00:00
|
|
|
if (!([[_unit, _veh]] call _condition)) exitWith {false};
|
2015-01-23 22:40:39 +00:00
|
|
|
|
2015-03-15 16:27:21 +00:00
|
|
|
_returnValue = false;
|
2015-01-23 22:40:39 +00:00
|
|
|
switch (true) do {
|
|
|
|
case (_funcType == "canLockpick"): {
|
2015-03-15 16:27:21 +00:00
|
|
|
_returnValue = true;
|
|
|
|
};
|
2015-01-23 22:40:39 +00:00
|
|
|
case (_funcType == "startLockpick"): {
|
2015-03-15 16:27:21 +00:00
|
|
|
[_vehLockpickStrenth, [_unit, _veh, "finishLockpick"], {(_this select 0) call FUNC(lockpick)}, {}, (localize "STR_ACE_Vehicle_Action_LockpickInUse"), _condition] call EFUNC(common,progressBar);
|
|
|
|
_returnValue = true;
|
2015-01-28 01:49:21 +00:00
|
|
|
};
|
2015-01-23 22:40:39 +00:00
|
|
|
case (_funcType == "finishLockpick"): {
|
2015-03-15 16:27:21 +00:00
|
|
|
["VehicleLock_SetVehicleLock", [_veh], [_veh, false]] call EFUNC(common,targetEvent);
|
|
|
|
_returnValue = true;
|
|
|
|
};
|
|
|
|
default {
|
|
|
|
ERROR("bad function type");
|
|
|
|
};
|
2015-01-23 22:40:39 +00:00
|
|
|
};
|
|
|
|
|
2015-03-15 16:27:21 +00:00
|
|
|
_returnValue
|