2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
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
|
|
|
|
2015-08-04 03:11:45 +00:00
|
|
|
params ["_unit", "_veh", "_funcType"];
|
2015-08-07 18:24:47 +00:00
|
|
|
TRACE_3("params",_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
|
2018-09-17 19:03:28 +00:00
|
|
|
if !("ACE_key_lockpick" in (_unit call EFUNC(common,uniqueItems))) exitWith {false};
|
2015-01-23 22:40:39 +00:00
|
|
|
|
2018-10-10 01:21:46 +00:00
|
|
|
private _vehLockpickStrength = _veh getVariable[QGVAR(lockpickStrength), GVAR(DefaultLockpickStrength)];
|
2024-06-18 14:08:03 +00:00
|
|
|
if !(_vehLockpickStrength isEqualType 0) exitWith {
|
|
|
|
ERROR("ACE_vehicleLock_LockpickStrength invalid");
|
|
|
|
false
|
|
|
|
};
|
2015-01-23 22:40:39 +00:00
|
|
|
|
|
|
|
//-1 indicates unpickable lock
|
2018-10-10 01:21:46 +00:00
|
|
|
if (_vehLockpickStrength < 0) exitWith {false};
|
2015-03-15 16:27:21 +00:00
|
|
|
|
|
|
|
//Condition check for progressBar
|
2017-10-10 14:39:59 +00:00
|
|
|
private _condition = {
|
2015-08-04 03:11:45 +00:00
|
|
|
params ["_args"];
|
2015-09-18 02:12:18 +00:00
|
|
|
_args params ["_unit", "_veh"];
|
2015-03-15 16:27:21 +00:00
|
|
|
((_unit distance _veh) < 5) && {(speed _veh) < 0.1}
|
2015-01-23 22:40:39 +00:00
|
|
|
};
|
|
|
|
|
2024-06-18 14:08:03 +00:00
|
|
|
if !([[_unit, _veh]] call _condition) exitWith {false};
|
2015-01-23 22:40:39 +00:00
|
|
|
|
2017-10-10 14:39:59 +00:00
|
|
|
private _returnValue = _funcType in ["canLockpick", "startLockpick", "finishLockpick"];
|
2015-08-04 03:11:45 +00:00
|
|
|
switch (_funcType) do {
|
2017-03-12 04:49:54 +00:00
|
|
|
case "canLockpick": {
|
|
|
|
_returnValue = !([_unit, _veh] call FUNC(hasKeyForVehicle)) && {(locked _veh) in [2, 3]};
|
|
|
|
};
|
2015-08-04 03:11:45 +00:00
|
|
|
case "startLockpick": {
|
2020-10-21 15:38:07 +00:00
|
|
|
[QGVAR(startedLockpick), [_veh]] call CBA_fnc_localEvent;
|
2018-10-10 01:21:46 +00:00
|
|
|
[_vehLockpickStrength, [_unit, _veh, "finishLockpick"], {(_this select 0) call FUNC(lockpick)}, {}, (localize LSTRING(Action_LockpickInUse)), _condition, ["isNotInside", "isNotSwimming"]] call EFUNC(common,progressBar);
|
2015-01-28 01:49:21 +00:00
|
|
|
};
|
2015-08-04 03:11:45 +00:00
|
|
|
case "finishLockpick": {
|
2016-05-25 00:37:24 +00:00
|
|
|
[QGVAR(setVehicleLock), [_veh, false], [_veh]] call CBA_fnc_targetEvent;
|
2020-10-21 15:38:07 +00:00
|
|
|
[QGVAR(finishedLockpick), [_veh]] call CBA_fnc_localEvent;
|
2015-03-15 16:27:21 +00:00
|
|
|
};
|
|
|
|
default {
|
|
|
|
ERROR("bad function type");
|
|
|
|
};
|
2015-01-23 22:40:39 +00:00
|
|
|
};
|
|
|
|
|
2015-03-15 16:27:21 +00:00
|
|
|
_returnValue
|