From 4e31a4b57f8352800ce59d3e215e1b228acd96a4 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Fri, 23 Jan 2015 16:40:39 -0600 Subject: [PATCH] First Pass --- addons/vehiclelock/$PBOPREFIX$ | 2 +- addons/vehiclelock/CfgEventHandlers.hpp | 5 + addons/vehiclelock/CfgMagazines.hpp | 9 + addons/vehiclelock/CfgVehicles.hpp | 100 ++++++++ addons/vehiclelock/CfgWeapons.hpp | 41 ++++ addons/vehiclelock/XEH_preInit.sqf | 14 ++ addons/vehiclelock/config.cpp | 217 +----------------- .../functions/fn_addKeyForVehicle.sqf | 48 ---- .../functions/fn_getVehicleSideKey.sqf | 36 --- .../functions/fn_hasKeyForVehicle.sqf | 43 ---- addons/vehiclelock/functions/fn_lockpick.sqf | 71 ------ .../vehiclelock/functions/fn_moduleInit.sqf | 67 ------ .../vehiclelock/functions/fn_moduleSync.sqf | 47 ---- .../functions/fn_serverSetupCustomKey.sqf | 32 --- .../functions/fn_setVehicleLock.sqf | 29 --- .../functions/fnc_addKeyForVehicle.sqf | 45 ++++ .../functions/fnc_getVehicleSideKey.sqf | 38 +++ .../functions/fnc_hasKeyForVehicle.sqf | 45 ++++ addons/vehiclelock/functions/fnc_lockpick.sqf | 74 ++++++ .../vehiclelock/functions/fnc_moduleInit.sqf | 51 ++++ .../vehiclelock/functions/fnc_moduleSync.sqf | 52 +++++ .../functions/fnc_serverSetupCustomKeyEH.sqf | 31 +++ .../functions/fnc_setVehicleLockEH.sqf | 33 +++ .../functions/script_component.hpp | 1 + addons/vehiclelock/readme.md | 37 +++ addons/vehiclelock/readme.txt | 37 --- addons/vehiclelock/script_component.hpp | 15 ++ addons/vehiclelock/stringtable.xml | 24 +- 28 files changed, 616 insertions(+), 628 deletions(-) create mode 100644 addons/vehiclelock/CfgEventHandlers.hpp create mode 100644 addons/vehiclelock/CfgMagazines.hpp create mode 100644 addons/vehiclelock/CfgVehicles.hpp create mode 100644 addons/vehiclelock/CfgWeapons.hpp create mode 100644 addons/vehiclelock/XEH_preInit.sqf delete mode 100644 addons/vehiclelock/functions/fn_addKeyForVehicle.sqf delete mode 100644 addons/vehiclelock/functions/fn_getVehicleSideKey.sqf delete mode 100644 addons/vehiclelock/functions/fn_hasKeyForVehicle.sqf delete mode 100644 addons/vehiclelock/functions/fn_lockpick.sqf delete mode 100644 addons/vehiclelock/functions/fn_moduleInit.sqf delete mode 100644 addons/vehiclelock/functions/fn_moduleSync.sqf delete mode 100644 addons/vehiclelock/functions/fn_serverSetupCustomKey.sqf delete mode 100644 addons/vehiclelock/functions/fn_setVehicleLock.sqf create mode 100644 addons/vehiclelock/functions/fnc_addKeyForVehicle.sqf create mode 100644 addons/vehiclelock/functions/fnc_getVehicleSideKey.sqf create mode 100644 addons/vehiclelock/functions/fnc_hasKeyForVehicle.sqf create mode 100644 addons/vehiclelock/functions/fnc_lockpick.sqf create mode 100644 addons/vehiclelock/functions/fnc_moduleInit.sqf create mode 100644 addons/vehiclelock/functions/fnc_moduleSync.sqf create mode 100644 addons/vehiclelock/functions/fnc_serverSetupCustomKeyEH.sqf create mode 100644 addons/vehiclelock/functions/fnc_setVehicleLockEH.sqf create mode 100644 addons/vehiclelock/functions/script_component.hpp create mode 100644 addons/vehiclelock/readme.md delete mode 100644 addons/vehiclelock/readme.txt create mode 100644 addons/vehiclelock/script_component.hpp diff --git a/addons/vehiclelock/$PBOPREFIX$ b/addons/vehiclelock/$PBOPREFIX$ index c5c7ac3b55..cc7552b3f3 100644 --- a/addons/vehiclelock/$PBOPREFIX$ +++ b/addons/vehiclelock/$PBOPREFIX$ @@ -1 +1 @@ -AGM_VehicleLock \ No newline at end of file +z\ace\addons\vehiclelock \ No newline at end of file diff --git a/addons/vehiclelock/CfgEventHandlers.hpp b/addons/vehiclelock/CfgEventHandlers.hpp new file mode 100644 index 0000000000..b928bc2de6 --- /dev/null +++ b/addons/vehiclelock/CfgEventHandlers.hpp @@ -0,0 +1,5 @@ +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; diff --git a/addons/vehiclelock/CfgMagazines.hpp b/addons/vehiclelock/CfgMagazines.hpp new file mode 100644 index 0000000000..198c617509 --- /dev/null +++ b/addons/vehiclelock/CfgMagazines.hpp @@ -0,0 +1,9 @@ +class CfgMagazines { + class CA_Magazine; + class ACE_key_customKeyMagazine: CA_Magazine { + picture = QUOTE(PATHTOF(ui\keyBlack.paa)); + displayName = "ACE Vehicle Key"; //!!!CANNONT be localized!!!, because it is used as part of the magazineDetail string + descriptionShort = "$STR_ACE_Vehicle_Item_Custom_Description"; + count = 1; + }; +}; diff --git a/addons/vehiclelock/CfgVehicles.hpp b/addons/vehiclelock/CfgVehicles.hpp new file mode 100644 index 0000000000..79591280d8 --- /dev/null +++ b/addons/vehiclelock/CfgVehicles.hpp @@ -0,0 +1,100 @@ +#define MACRO_LOCK_ACTIONS \ + class ACE_unlockVehicle { \ + displayName = "$STR_ACE_Vehicle_Action_UnLock"; \ + distance = 4; \ + condition = QUOTE(([ARR_2(_player, _target)] call FUNC(hasKeyForVehicle)) && {(locked _target) in [ARR_2(2,3)]}); \ + statement = QUOTE([ARR_3('SetVehicleLock', [_target], [ARR_2(_target,false)])] call EFUNC(common,targetEvent)); \ + showDisabled = 0; \ + priority = 0.3; \ + icon = QUOTE(PATHTOF(ui\key_menuIcon_ca.paa)); \ + }; \ + class ACE_lockVehicle { \ + displayName = "$STR_ACE_Vehicle_Action_Lock"; \ + distance = 4; \ + condition = QUOTE(([ARR_2(_player, _target)] call FUNC(hasKeyForVehicle)) && {(locked _target) in [ARR_2(0,1)]}); \ + statement = QUOTE([ARR_3('SetVehicleLock', [_target], [ARR_2(_target,true)])] call EFUNC(common,targetEvent)); \ + showDisabled = 0; \ + priority = 0.2; \ + icon = QUOTE(PATHTOF(ui\key_menuIcon_ca.paa)); \ + }; \ + class ACE_lockpickVehicle { \ + displayName = "$STR_ACE_Vehicle_Action_Lockpick"; \ + distance = 4; \ + condition = QUOTE([ARR_3(_player, _target, 'canLockpick')] call FUNC(lockpick)); \ + statement = QUOTE([ARR_3(_player, _target, 'startLockpick')] call FUNC(lockpick)); \ + showDisabled = 0; \ + priority = 0.1; \ + }; + +class CfgVehicles { + class LandVehicle; + class Car: LandVehicle { + class ACE_Actions { + MACRO_LOCK_ACTIONS + }; + }; + class Tank: LandVehicle { + class ACE_Actions { + MACRO_LOCK_ACTIONS + }; + }; + class Air; + class Helicopter: Air { + class ACE_Actions { + MACRO_LOCK_ACTIONS + }; + }; + + class Logic; + class Module_F: Logic { + class ArgumentsBaseUnits {}; + class ModuleDescription {}; + }; + class ACE_VehicleLock_ModuleSetup: Module_F { + author = "$STR_ACE_Common_ACETeam"; + category = "ACE"; + displayName = "Vehicle Lock Setup"; + function = "ACE_VehicleLock_fnc_moduleInit"; + scope = 2; + isGlobal = 1; + icon = QUOTE(PATHTOF(ui\IconLock_ca.paa)); + functionPriority = 0; + class Arguments { + class SetLockState { + displayName = "Set Lock State"; // Argument label + description = "Set lock state for all vehicles on map at start"; // Tooltip description + typeName = "NUMBER"; // Value type, can be "NUMBER", "STRING" or "BOOL" + class values { + class None {name = "As Is"; value = 0; default = 1;}; + class Side {name = "Locked"; value = 1;}; + class Unique {name = "Unlocked"; value = 2;}; + }; + }; + class LockpickStrength { + displayName = "Global Lockpick Strength"; + description = "Global Time to lockpick (in seconds). Default: 10"; + typeName = "NUMBER"; // Value type, can be "NUMBER", "STRING" or "BOOL" + defaultValue = "10"; // Default text filled in the input box + }; + }; + class ModuleDescription: ModuleDescription { + description = "Settings for lockpick strength and initial vehicle lock state. Removes ambiguous lock states.
Source: vehiclelock.pbo"; + }; + }; + + class ACE_VehicleLock_ModuleSyncedAssign: Module_F { + author = "$STR_ACE_Common_ACETeam"; + category = "ACE"; + displayName = "Vehicle Key Assign"; + function = "ACE_VehicleLock_fnc_moduleSync"; + scope = 2; + isGlobal = 1; + icon = QUOTE(PATHTOF(ui\IconLock_ca.paa)); + functionPriority = 0; + class Arguments {}; + class ModuleDescription: ModuleDescription { + description = "Sync with vehicles and players. Will handout custom keys to players for every synced vehicle. Only valid for objects present at mission start.
Source: vehiclelock.pbo"; + sync[] = {"AnyPlayer", "AnyVehicle"}; + }; + }; +}; diff --git a/addons/vehiclelock/CfgWeapons.hpp b/addons/vehiclelock/CfgWeapons.hpp new file mode 100644 index 0000000000..c7df1116f8 --- /dev/null +++ b/addons/vehiclelock/CfgWeapons.hpp @@ -0,0 +1,41 @@ +class CfgWeapons { + class InventoryItem_Base_F; + class ACE_ItemCore; + + class ACE_key_master: ACE_ItemCore { + author = "$STR_ACE_Core_ACETeam"; + displayName = "Vehicle Key: Master"; + descriptionShort = "$STR_ACE_Vehicle_Item_Master_Description"; + model = "\A3\weapons_F\ammo\mag_univ.p3d"; + picture = QUOTE(PATHTOF(ui\keyBlack.paa)); + scope = 2; + class ItemInfo: InventoryItem_Base_F { + mass = 0.1; + }; + }; + class ACE_key_lockpick: ACE_key_master { + displayName = "Lockpick"; + descriptionShort = "$STR_ACE_Vehicle_Item_Lockpick_Description"; + picture = QUOTE(PATHTOF(ui\lockpick.paa)); + }; + class ACE_key_west: ACE_key_master { + displayName = "Vehicle Key: West"; + descriptionShort = "$STR_ACE_Vehicle_Item_West_Description"; + picture = QUOTE(PATHTOF(ui\keyBlue.paa)); + }; + class ACE_key_east: ACE_key_master { + displayName = "Vehicle Key: East"; + descriptionShort = "$STR_ACE_Vehicle_Item_East_Description"; + picture = QUOTE(PATHTOF(ui\keyRed.paa)); + }; + class ACE_key_indp: ACE_key_master { + displayName = "Vehicle Key: Independent"; + descriptionShort = "$STR_ACE_Vehicle_Item_Indp_Description"; + picture = QUOTE(PATHTOF(ui\keyPurple.paa)); + }; + class ACE_key_civ: ACE_key_master { + displayName = "Vehicle Key: Civilian"; + descriptionShort = "$STR_ACE_Vehicle_Item_Civ_Description"; + picture = QUOTE(PATHTOF(ui\keyGreen.paa)); + }; +}; diff --git a/addons/vehiclelock/XEH_preInit.sqf b/addons/vehiclelock/XEH_preInit.sqf new file mode 100644 index 0000000000..7040450597 --- /dev/null +++ b/addons/vehiclelock/XEH_preInit.sqf @@ -0,0 +1,14 @@ +#include "script_component.hpp" + +PREP(addKeyForVehicle); +PREP(getVehicleSideKey); +PREP(hasKeyForVehicle); +PREP(lockpick); +PREP(moduleInit); +PREP(moduleSync); +PREP(serverSetupCustomKeyEH); +PREP(setVehicleLockEH); + +//Add Event Handlers +["SetupCustomKey", {_this call FUNC(serverSetupCustomKeyEH)}] call EFUNC(common,addEventHandler); +["SetVehicleLock", {_this call FUNC(setVehicleLockEH)}] call EFUNC(common,addEventHandler); diff --git a/addons/vehiclelock/config.cpp b/addons/vehiclelock/config.cpp index 95306a15e1..83850a2bef 100644 --- a/addons/vehiclelock/config.cpp +++ b/addons/vehiclelock/config.cpp @@ -1,215 +1,22 @@ +#include "script_component.hpp" + class CfgPatches { - class AGM_VehicleLock { + class ADDON { units[] = {}; weapons[] = {}; - requiredVersion = 0.6; - requiredAddons[] = {"AGM_Core", "AGM_Interaction"}; - version = "0.95"; - versionStr = "0.95"; - versionAr[] = {0,95,0}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_common", "ace_interaction"}; author[] = {"PabstMirror"}; authorUrl = "https://github.com/PabstMirror/"; + VERSION_CONFIG; }; }; -class AGM_Parameters_Numeric { - AGM_VehicleLock_DefaultLockpickStrength = 10; +class ACE_Parameters_Numeric { + GVAR(DefaultLockpickStrength) = 10; }; -class CfgFunctions { - class AGM_VehicleLock { - class AGM_VehicleLock { - file = "AGM_vehicleLock\functions"; - class addKeyForVehicle; - class getVehicleSideKey; - class hasKeyForVehicle; - class lockpick; - class moduleInit; - class moduleSync; - class serverSetupCustomKey; - class setVehicleLock; - }; - }; -}; - -class CfgMagazines { - class CA_Magazine; - class AGM_magazine_customKey: CA_Magazine { - picture = "\AGM_vehicleLock\ui\keyBlack.paa"; - displayName = "AGM Vehicle Key"; //!!!CANNONT be localized!!!, because it is used as part of the magazineDetail string - descriptionShort = "$STR_AGM_Vehicle_Item_Custom_Description"; - }; -}; - -class CfgWeapons { - class InventoryItem_Base_F; - class AGM_ItemCore; - - class AGM_item_key_master: AGM_ItemCore { - author = "$STR_AGM_Core_AGMTeam"; - displayName = "Vehicle Key: Master"; - descriptionShort = "$STR_AGM_Vehicle_Item_Master_Description"; - model = "\A3\weapons_F\ammo\mag_univ.p3d"; - picture = "\AGM_vehicleLock\ui\keyBlack.paa"; - scope = 2; - class ItemInfo: InventoryItem_Base_F { - mass = 0.1; - }; - }; - class AGM_item_key_lockpick: AGM_item_key_master { - displayName = "Lockpick"; - descriptionShort = "$STR_AGM_Vehicle_Item_Lockpick_Description"; - picture = "\AGM_vehicleLock\ui\lockpick.paa"; - }; - class AGM_item_key_west: AGM_item_key_master { - displayName = "Vehicle Key: West"; - descriptionShort = "$STR_AGM_Vehicle_Item_West_Description"; - picture = "\AGM_vehicleLock\ui\keyBlue.paa"; - }; - class AGM_item_key_east: AGM_item_key_master { - displayName = "Vehicle Key: East"; - descriptionShort = "$STR_AGM_Vehicle_Item_East_Description"; - picture = "\AGM_vehicleLock\ui\keyRed.paa"; - }; - class AGM_item_key_indp: AGM_item_key_master { - displayName = "Vehicle Key: Independent"; - descriptionShort = "$STR_AGM_Vehicle_Item_Indp_Description"; - picture = "\AGM_vehicleLock\ui\keyPurple.paa"; - }; - class AGM_item_key_civ: AGM_item_key_master { - displayName = "Vehicle Key: Civilian"; - descriptionShort = "$STR_AGM_Vehicle_Item_Civ_Description"; - picture = "\AGM_vehicleLock\ui\keyGreen.paa"; - }; -}; - -#define MACRO_LOCK_ACTIONS \ - class AGM_unlockVehicle { \ - displayName = "$STR_AGM_Vehicle_Action_UnLock"; \ - distance = 4; \ - condition = "([_player, AGM_Interaction_Target] call AGM_VehicleLock_fnc_hasKeyForVehicle) && {(locked AGM_Interaction_Target) in [2, 3]}"; \ - statement = "[AGM_Interaction_Target, false] call AGM_VehicleLock_fnc_setVehicleLock"; \ - showDisabled = 1; \ - priority = 0.3; \ - icon = "\AGM_vehicleLock\ui\key_menuIcon_ca.paa"; \ - }; \ - class AGM_lockVehicle { \ - displayName = "$STR_AGM_Vehicle_Action_Lock"; \ - distance = 4; \ - condition = "([_player, AGM_Interaction_Target] call AGM_VehicleLock_fnc_hasKeyForVehicle) && {(locked AGM_Interaction_Target) in [0, 1]}"; \ - statement = "[AGM_Interaction_Target, true] call AGM_VehicleLock_fnc_setVehicleLock"; \ - showDisabled = 1; \ - priority = 0.2; \ - icon = "\AGM_vehicleLock\ui\key_menuIcon_ca.paa"; \ - }; \ - class AGM_lockpickVehicle { \ - displayName = "$STR_AGM_Vehicle_Action_Lockpick"; \ - distance = 4; \ - condition = "[_player, AGM_Interaction_Target, 'canLockpick'] call AGM_VehicleLock_fnc_lockpick"; \ - statement = "[_player, AGM_Interaction_Target, 'startLockpick'] call AGM_VehicleLock_fnc_lockpick"; \ - showDisabled = 0; \ - priority = 0.1; \ - }; - -class CfgVehicles { - class Logic; - class Module_F: Logic { - class ArgumentsBaseUnits {}; - class ModuleDescription {}; - }; - class AGM_VehicleLock_ModuleSetup: Module_F { - author = "$STR_AGM_Core_AGMTeam"; - category = "AGM"; - displayName = "Vehicle Lock Setup"; - function = "AGM_VehicleLock_fnc_moduleInit"; - scope = 2; - isGlobal = 1; - icon = "\AGM_VehicleLock\ui\IconLock_ca.paa"; - functionPriority = 0; - class Arguments { - class SideKeysAssignment { - displayName = "Players Start Side Keys"; // Argument label - description = "Which players start wtih side keys (e.g.: agm_item_key_west)"; // Tooltip description - typeName = "NUMBER"; // Value type, can be "NUMBER", "STRING" or "BOOL" - class values { - class Nobody { - name = "Nobody"; - value = 0; - default = 1; - }; - class GroupLeads { - name = "Group Leads"; - value = 1; - }; - class Everyone { - name = "Everyone"; - value = 2; - }; - }; - }; - class SetLockState { - displayName = "Set Lock State"; // Argument label - description = "Set lock state for all vehicles on map"; // Tooltip description - typeName = "NUMBER"; // Value type, can be "NUMBER", "STRING" or "BOOL" - class values { - class None { - name = "As Is"; - value = 0; - default = 1; - }; - class Side { - name = "Locked"; - value = 1; - }; - class Unique { - name = "Unlocked"; - value = 2; - }; - }; - }; - class LockpickStrength { - displayName = "Global Lockpick Strength"; - description = "Global Time to lockpick (in seconds). Default: 10"; - typeName = "NUMBER"; // Value type, can be "NUMBER", "STRING" or "BOOL" - defaultValue = "10"; // Default text filled in the input box - }; - }; - class ModuleDescription: ModuleDescription { - description = "Settings for lockpick strength, auto assigment of keys at start and initial vehicle lock state."; - }; - }; - - class AGM_VehicleLock_ModuleSyncedAssign: Module_F { - author = "$STR_AGM_Core_AGMTeam"; - category = "AGM"; - displayName = "Vehicle Key Assign"; - function = "AGM_VehicleLock_fnc_moduleSync"; - scope = 2; - isGlobal = 1; - icon = "\AGM_VehicleLock\ui\IconLock_ca.paa"; - functionPriority = 0; - class Arguments {}; - class ModuleDescription: ModuleDescription { - description = "Sync with vehicles and players. Will handout custom keys to players for every synced vehicle. Only valid for objects present at mission start."; - sync[] = {"AnyPlayer", "AnyVehicle"}; - }; - }; - - class LandVehicle; - class Car: LandVehicle { - class AGM_Actions { - MACRO_LOCK_ACTIONS - }; - }; - class Tank: LandVehicle { - class AGM_Actions { - MACRO_LOCK_ACTIONS - }; - }; - class Air; - class Helicopter: Air { - class AGM_Actions { - MACRO_LOCK_ACTIONS - }; - }; -}; +#include "CfgEventHandlers.hpp" +#include "CfgMagazines.hpp" +#include "CfgVehicles.hpp" +#include "CfgWeapons.hpp" diff --git a/addons/vehiclelock/functions/fn_addKeyForVehicle.sqf b/addons/vehiclelock/functions/fn_addKeyForVehicle.sqf deleted file mode 100644 index 9841c9c6c1..0000000000 --- a/addons/vehiclelock/functions/fn_addKeyForVehicle.sqf +++ /dev/null @@ -1,48 +0,0 @@ -/* - Name: AGM_VehicleLock_fnc_addKeyForVehicle - - Author: Pabst Mirror - - Description: - Adds a key to a unit that will open a vehicle - - Parameters: - 0: OBJECT - unit - 1: OBJECT - vehicle - 2: BOOL - custom key (true: custom key - false: side key) - - Returns: - Nothing - - Example: - [bob, car1, true] call AGM_VehicleLock_fnc_addKeyForVehicle; -*/ - -#define CUSTOM_KEY_CLASSNAME "AGM_magazine_customKey" - -private ["_unit","_veh","_useCustom","_previousMags","_newMags","_keyMagazine","_keyName"]; - -_unit = [_this, 0, objNull, [objNull]] call bis_fnc_param; -_veh = [_this, 1, objNull, [objNull]] call bis_fnc_param; -_useCustom = [_this, 2, false, [false]] call bis_fnc_param; - -if (isNull _unit) exitWith { - ["addKeyForVehicleClient: null unit"] call BIS_fnc_error; -}; -if (isNull _veh) exitWith { - ["addKeyForVehicleClient: null vehicle"] call BIS_fnc_error; -}; - -if (_useCustom) then { - _previousMags = magazinesDetail _unit; - _unit addMagazine CUSTOM_KEY_CLASSNAME; - _newMags = (magazinesDetail _unit) - _previousMags; - if ((count _newMags) < 1) exitWith { - ["AGM_VehicleLock_fnc_addKeyForVehicle: failed to add magazine (inventory full?)"] call BIS_fnc_error; - }; - _keyMagazine = _newMags select 0; - [[_veh, _keyMagazine], "AGM_VehicleLock_fnc_serverSetupCustomKey", 1] call AGM_Core_fnc_execRemoteFnc; -} else { - _keyName = [_veh] call AGM_VehicleLock_fnc_getVehicleSideKey; - _unit addItem _keyName; -}; diff --git a/addons/vehiclelock/functions/fn_getVehicleSideKey.sqf b/addons/vehiclelock/functions/fn_getVehicleSideKey.sqf deleted file mode 100644 index 948ff5eb11..0000000000 --- a/addons/vehiclelock/functions/fn_getVehicleSideKey.sqf +++ /dev/null @@ -1,36 +0,0 @@ -/* - Name: AGM_VehicleLock_fnc_getVehicleSideKey - - Author: Pabst Mirror - - Description: - Returns the side specifc key for a vehicle - - Parameters: - 0: OBJECT - vehicle - - Returns: - STRING - Key Classname - - Example: - [tank1] call AGM_VehicleLock_fnc_getVehicleSideKey; -*/ - -private ["_veh","_vehConfigSide","_vehSide","_returnValue"]; - -_veh = [_this, 0, objNull, [objNull]] call bis_fnc_param; -if (isNull _veh) exitWith {["AGM_VehicleLock_fnc_getVehicleSideKey: null vehicle"] call BIS_fnc_error; ""}; - -_vehConfigSide = [_veh, true] call bis_fnc_objectSide; -_vehSide = _veh getVariable ["agm_lock_side", _vehConfigSide]; - -_returnValue = ""; - -switch (_vehSide) do { -case (west): {_returnValue = "AGM_item_key_west"}; -case (east): {_returnValue = "AGM_item_key_east"}; -case (resistance): {_returnValue = "AGM_item_key_indp"}; -case (civilian): {_returnValue = "AGM_item_key_civ"}; -}; - -_returnValue diff --git a/addons/vehiclelock/functions/fn_hasKeyForVehicle.sqf b/addons/vehiclelock/functions/fn_hasKeyForVehicle.sqf deleted file mode 100644 index 894b9fc636..0000000000 --- a/addons/vehiclelock/functions/fn_hasKeyForVehicle.sqf +++ /dev/null @@ -1,43 +0,0 @@ -/* - Name: AGM_VehicleLock_fnc_hasKeyForVehicle - - Author: Pabst Mirror - - Description: - Returns if user has a valid key for the vehicle - - Parameters: - 0: OBJECT - unit - 1: OBJECT - vehicle - - Returns: - BOOL - unit has key for vehicle - - Example: - [bob, car] call AGM_VehicleLock_fnc_hasKeyForVehicle; -*/ - -private ["_unit","_veh","_returnValue","_sideKeyName","_customKeys"]; - -_unit = [_this, 0, objNull, [objNull]] call bis_fnc_param; -_veh = [_this, 1, objNull, [objNull]] call bis_fnc_param; - -if (isNull _unit) exitWith {["AGM_VehicleLock_fnc_hasKeyForVehicle: null unit"] call BIS_fnc_error; false}; -if (isNull _veh) exitWith {["AGM_VehicleLock_fnc_hasKeyForVehicle: null vehicle"] call BIS_fnc_error; false}; - -_returnValue = false; - -//Master can open anything "no matter what" -if ("AGM_item_key_master" in (items _unit)) then {_returnValue = true}; - -//Check side key -_sideKeyName = [_veh] call AGM_VehicleLock_fnc_getVehicleSideKey; -if (_sideKeyName in (items _unit)) then {_returnValue = true}; - -//Check custom keys -_customKeys = _veh getVariable ["agm_lock_customKeys", []]; -{ - if (_x in (magazinesDetail _unit)) then {_returnValue = true;}; -} forEach _customKeys; - -_returnValue diff --git a/addons/vehiclelock/functions/fn_lockpick.sqf b/addons/vehiclelock/functions/fn_lockpick.sqf deleted file mode 100644 index bc3e68d189..0000000000 --- a/addons/vehiclelock/functions/fn_lockpick.sqf +++ /dev/null @@ -1,71 +0,0 @@ -/* - Name: AGM_VehicleLock_fnc_lockpick - - Author: Pabst Mirror - - Description: - Handles lockpick functionality from action menu. - - Parameters: - 0: OBJECT - unit - 1: OBJECT - vehicle - 2: STRING - function type - "canLockpick": returns BOOL if lockpick is possible - "startLockpick": starts the process - "finishLockpick": on completions, opens the lock - - Returns: - BOOL - - Example: - [AGM_player, AGM_Interaction_Target, 'canLockpick'] call AGM_VehicleLock_fnc_lockpick -*/ -private ["_unit","_veh","_funcType","_vehLockpickStrenth","_returnValue"]; - -_unit = [_this, 0, objNull, [objNull]] call bis_fnc_param; -_veh = [_this, 1, objNull, [objNull]] call bis_fnc_param; -_funcType = [_this, 2, "", [""]] call bis_fnc_param; - -if (isNull _unit) exitWith { - ["AGM_VehicleLock_fnc_lockpick: null unit"] call BIS_fnc_error; - false -}; -if (isNull _veh) exitWith { - ["AGM_VehicleLock_fnc_lockpick: null vehicle"] call BIS_fnc_error; - false -}; - -//need lockpick item -if (!("AGM_item_key_lockpick" in (items _unit))) exitWith { - false -}; - -_vehLockpickStrenth = _veh getVariable["agm_vehicleLock_pickStr", AGM_VehicleLock_DefaultLockpickStrength]; -if (typeName _vehLockpickStrenth != "SCALAR") exitWith { - ["AGM_VehicleLock_fnc_lockpick: agm_vehicleLock_pickStr invalid: (%1)", _veh] call BIS_fnc_error; - false -}; - -//-1 indicates unpickable lock -if (_vehLockpickStrenth < 0) exitWith { - false -}; - -_returnValue = false; - -switch (true) do { - case (_funcType == "canLockpick"): { - _returnValue = true; - }; - case (_funcType == "startLockpick"): { - [_vehLockpickStrenth, [_unit, _veh, "finishLockpick"], "AGM_VehicleLock_fnc_lockpick", (localize "STR_AGM_Vehicle_Action_LockpickInUse")] call AGM_Core_fnc_progressBar; - }; - case (_funcType == "finishLockpick"): { - [_veh, false] call AGM_VehicleLock_fnc_setVehicleLock; - }; - default { - ["AGM_VehicleLock_fnc_lockpick: bad function type"] call BIS_fnc_error; - }; -}; - -_returnValue; diff --git a/addons/vehiclelock/functions/fn_moduleInit.sqf b/addons/vehiclelock/functions/fn_moduleInit.sqf deleted file mode 100644 index 2e0d44c9c7..0000000000 --- a/addons/vehiclelock/functions/fn_moduleInit.sqf +++ /dev/null @@ -1,67 +0,0 @@ -/* - Name: AGM_VehicleLock_fnc_moduleInit - - Author: Pabst Mirror - - Description: - Function for setup module. Sets default lockpick strength, auto handout keys, and default lock state. - - Parameters: - 0: OBJECT - logic - - Returns: - Nothing - - Example: - called from module -*/ - -_this spawn { - - private ["_logic", "_sideKeysAssignment", "_setLockState", "_lock", "_giveSideKey", "_keyClassName"]; - _logic = [_this, 0, objNull, [objNull]] call BIS_fnc_param; - - _sideKeysAssignment = _logic getVariable["SideKeysAssignment", 0]; - _setLockState = _logic getVariable["SetLockState", 0]; - - if (isServer) then { - [_logic, "AGM_VehicleLock_DefaultLockpickStrength", "LockpickStrength"] call AGM_Core_fnc_readNumericParameterFromModule; - - { //set lock state - _lock = - switch (_setLockState) do { - case (0): {(locked _x) in [2, 3]}; - case (1):{true}; - case (2):{false}; - }; - [_x, _lock] call AGM_VehicleLock_fnc_setVehicleLock; - } - forEach vehicles; - }; - - if (hasInterface) then { - waitUntil {player == player}; - waitUntil {alive player}; - sleep 5; //need to wait for other gear-assign scripts to finish - - _giveSideKey = - switch (_sideKeysAssignment) do { - case (0): {false}; - case (1): {(leader player) == player}; - case (2): {true}; - }; - - if (_giveSideKey) then { - _keyClassName = switch (playerside) do { - case (west): {"AGM_item_key_west"}; - case (east): {"AGM_item_key_east"}; - case (resistance): {"AGM_item_key_indp"}; - case (civilian): {"AGM_item_key_civ"}; - default {""}; - }; - if (_keyClassName != "") then { - player addItem _keyClassName; - }; - }; - }; -}; diff --git a/addons/vehiclelock/functions/fn_moduleSync.sqf b/addons/vehiclelock/functions/fn_moduleSync.sqf deleted file mode 100644 index 75d74b47ad..0000000000 --- a/addons/vehiclelock/functions/fn_moduleSync.sqf +++ /dev/null @@ -1,47 +0,0 @@ -/* - Name: AGM_VehicleLock_fnc_moduleSync - - Author: Pabst Mirror - - Description: - Function for sync module. Assigns keys for all synced vehicles to any players that are synced. - - Parameters: - 0: OBJECT - logic - 1: ARRAY - synced objects (only objects at mission start, so JIP without AI won't be present) - - Returns: - Nothing - - Example: - called from module -*/ - -_this spawn { - private ["_logic","_syncedObjects","_listOfVehicles"]; - - _logic = [_this, 0, objNull, [objNull]] call BIS_fnc_param; - _syncedObjects = [_this, 1, [], [[]]] call BIS_fnc_param; - - if (hasInterface) then { - waitUntil {player == player}; - waitUntil {alive player}; - sleep 5; //need to wait for other gear-assign scripts to finish - - _listOfVehicles = []; { - if ((_x isKindOf "Car") || (_x isKindOf "Tank") || (_x isKindOf "Helicopter")) then { - _listOfVehicles pushBack _x; - }; - } forEach _syncedObjects; - - if ((count _listOfVehicles) == 0) exitWith { - ["AGM_VehicleLock_fnc_moduleSync: no valid vehicles synced"] call BIS_fnc_error; - }; - - if (player in _syncedObjects) then { - { - [player, _x, true] call AGM_VehicleLock_fnc_addKeyForVehicle; - } forEach _listOfVehicles; - }; - }; -}; diff --git a/addons/vehiclelock/functions/fn_serverSetupCustomKey.sqf b/addons/vehiclelock/functions/fn_serverSetupCustomKey.sqf deleted file mode 100644 index 6b16b5cf19..0000000000 --- a/addons/vehiclelock/functions/fn_serverSetupCustomKey.sqf +++ /dev/null @@ -1,32 +0,0 @@ -/* - Name: AGM_VehicleLock_fnc_serverSetupCustomKey - - Author: Pabst Mirror - - Description: - Adds a key (magazineDetail name) to approved keys for a vehicle - - Parameters: - 0: OBJECT - vehicle - 1: STRING - Magazine Name - - Returns: - Nothing - - Example: - [tank1, "todo"] call AGM_VehicleLock_fnc_serverSetupCustomKey; -*/ - -private ["_veh","_key","_currentKeys"]; - -_veh = [_this, 0, objNull, [objNull]] call bis_fnc_param; -_key = [_this, 1, "", [""]] call bis_fnc_param; - -if (!isServer) exitWith {["AGM_VehicleLock_fnc_serverSetupCustomKey: only run on server"] call BIS_fnc_error;}; -if (_key == "") exitWith {["AGM_VehicleLock_fnc_serverSetupCustomKey: empty key string"] call BIS_fnc_error;}; - -//Want this as atomic as possible - -_currentKeys = _veh getVariable ["agm_lock_customKeys", []]; -_currentKeys pushBack _key; -_veh setVariable ["agm_lock_customKeys", _currentKeys, true]; diff --git a/addons/vehiclelock/functions/fn_setVehicleLock.sqf b/addons/vehiclelock/functions/fn_setVehicleLock.sqf deleted file mode 100644 index 83126578cf..0000000000 --- a/addons/vehiclelock/functions/fn_setVehicleLock.sqf +++ /dev/null @@ -1,29 +0,0 @@ -/* - Name: AGM_VehicleLock_fnc_setVehicleLock - - Author: Pabst Mirror - - Description: - Sets a vehicle lock state (MP safe) - - Parameters: - 0: OBJECT - vehicle - 1: BOOL - new lock state - - Returns: - Nothing - - Example: - [tank1, false] call AGM_VehicleLock_fnc_setVehicleLock; -*/ - -private ["_veh","_isLocked","_lockNumber"]; - -_veh = [_this, 0, objNull, [objNull]] call bis_fnc_param; -_isLocked = [_this, 1, false, [false]] call bis_fnc_param; - -if (isNull _veh) exitWith {["AGM_VehicleLock_fnc_setVehicleLock: null vehicle"] call BIS_fnc_error;}; - -_lockNumber = if (_isLocked) then {2} else {0}; -[[_veh, _lockNumber], "{(_this select 0) lock (_this select 1)}", 2] call AGM_Core_fnc_execRemoteFnc; -_veh setVariable ["AGM_LockedInventory", _isLocked, true]; diff --git a/addons/vehiclelock/functions/fnc_addKeyForVehicle.sqf b/addons/vehiclelock/functions/fnc_addKeyForVehicle.sqf new file mode 100644 index 0000000000..c64a0f890d --- /dev/null +++ b/addons/vehiclelock/functions/fnc_addKeyForVehicle.sqf @@ -0,0 +1,45 @@ +/* + Name: ACE_VehicleLock_fnc_addKeyForVehicle + + Author: Pabst Mirror + + Description: + Adds a key to a unit that will open a vehicle + + Parameters: + 0: OBJECT - unit + 1: OBJECT - vehicle + 2: BOOL - custom key (true: custom key (magazine) - false: side key (item)) + + Returns: + Nothing + + Example: + [bob, car1, true] call ACE_VehicleLock_fnc_addKeyForVehicle; +*/ + +#include "script_component.hpp" + +private ["_unit","_veh","_useCustom","_previousMags","_newMags","_keyMagazine","_keyName"]; + +_unit = [_this, 0, objNull, [objNull]] call bis_fnc_param; +_veh = [_this, 1, objNull, [objNull]] call bis_fnc_param; +_useCustom = [_this, 2, false, [false]] call bis_fnc_param; + +if (isNull _unit) exitWith {["addKeyForVehicleClient: null unit"] call BIS_fnc_error;}; +if (isNull _veh) exitWith {["addKeyForVehicleClient: null vehicle"] call BIS_fnc_error;}; + +if (_useCustom) then { + _previousMags = magazinesDetail _unit; + _unit addMagazine ["ACE_key_customKeyMagazine", 1]; + _newMags = (magazinesDetail _unit) - _previousMags; + if ((count _newMags) == 0) exitWith { + ["ACE_VehicleLock_fnc_addKeyForVehicle: failed to add magazine (inventory full?)"] call BIS_fnc_error; + }; + _keyMagazine = _newMags select 0; + TRACE_2("setting up key on server",_veh,_keyMagazine); + ["SetupCustomKey", [_veh, _keyMagazine]] call EFUNC(common,serverEvent); +} else { + _keyName = [_veh] call FUNC(getVehicleSideKey); + _unit addItem _keyName; +}; diff --git a/addons/vehiclelock/functions/fnc_getVehicleSideKey.sqf b/addons/vehiclelock/functions/fnc_getVehicleSideKey.sqf new file mode 100644 index 0000000000..91ccaf490d --- /dev/null +++ b/addons/vehiclelock/functions/fnc_getVehicleSideKey.sqf @@ -0,0 +1,38 @@ +/* +Name: ACE_VehicleLock_fnc_getVehicleSideKey + +Author: Pabst Mirror + +Description: + Returns the side specifc key for a vehicle + +Parameters: + 0: OBJECT - vehicle + +Returns: + STRING - Key Classname + +Example: + [tank1] call ACE_VehicleLock_fnc_getVehicleSideKey; +*/ + +#include "script_component.hpp" + +private ["_veh","_vehConfigSide","_vehSide","_returnValue"]; + +_veh = [_this, 0, objNull, [objNull]] call bis_fnc_param; +if (isNull _veh) exitWith {["ACE_VehicleLock_fnc_getVehicleSideKey: null vehicle"] call BIS_fnc_error; ""}; + +_vehConfigSide = [_veh, true] call BIS_fnc_objectSide; +_vehSide = _veh getVariable [QGVAR(lock_side), _vehConfigSide]; + +_returnValue = ""; + +switch (_vehSide) do { +case (west): {_returnValue = "ACE_key_west"}; +case (east): {_returnValue = "ACE_key_east"}; +case (resistance): {_returnValue = "ACE_key_indp"}; +case (civilian): {_returnValue = "ACE_key_civ"}; +}; + +_returnValue diff --git a/addons/vehiclelock/functions/fnc_hasKeyForVehicle.sqf b/addons/vehiclelock/functions/fnc_hasKeyForVehicle.sqf new file mode 100644 index 0000000000..a1c899edad --- /dev/null +++ b/addons/vehiclelock/functions/fnc_hasKeyForVehicle.sqf @@ -0,0 +1,45 @@ +/* +Name: ACE_VehicleLock_fnc_hasKeyForVehicle + +Author: Pabst Mirror + +Description: + Returns if user has a valid key for the vehicle + +Parameters: + 0: OBJECT - unit + 1: OBJECT - vehicle + +Returns: + BOOL - unit has key for vehicle + +Example: + [bob, car] call ACE_VehicleLock_fnc_hasKeyForVehicle; +*/ + +#include "script_component.hpp" + +private ["_unit","_veh","_returnValue","_sideKeyName","_customKeys"]; + +_unit = [_this, 0, objNull, [objNull]] call bis_fnc_param; +_veh = [_this, 1, objNull, [objNull]] call bis_fnc_param; + +if (isNull _unit) exitWith {["ACE_VehicleLock_fnc_hasKeyForVehicle: null unit"] call BIS_fnc_error; false}; +if (isNull _veh) exitWith {["ACE_VehicleLock_fnc_hasKeyForVehicle: null vehicle"] call BIS_fnc_error; false}; + +_returnValue = false; + +//Master can open anything "no matter what" +if ("ACE_key_master" in (items _unit)) then {_returnValue = true}; + +//Check side key +_sideKeyName = [_veh] call FUNC(getVehicleSideKey); +if (_sideKeyName in (items _unit)) then {_returnValue = true}; + +//Check custom keys +_customKeys = _veh getVariable [QGVAR(customKeys), []]; +{ + if (_x in (magazinesDetail _unit)) then {_returnValue = true;}; +} forEach _customKeys; + +_returnValue diff --git a/addons/vehiclelock/functions/fnc_lockpick.sqf b/addons/vehiclelock/functions/fnc_lockpick.sqf new file mode 100644 index 0000000000..30abc0e4a3 --- /dev/null +++ b/addons/vehiclelock/functions/fnc_lockpick.sqf @@ -0,0 +1,74 @@ +/* +Name: ACE_VehicleLock_fnc_lockpick + +Author: Pabst Mirror + +Description: + Handles lockpick functionality from action menu. + +Parameters: + 0: OBJECT - unit + 1: OBJECT - vehicle + 2: STRING - function type + "canLockpick": returns BOOL if lockpick is possible + "startLockpick": starts the process + "finishLockpick": on completions, opens the lock + +Returns: + BOOL + +Example: + [ACE_player, ACE_Interaction_Target, 'canLockpick'] call ACE_VehicleLock_fnc_lockpick +*/ + +#include "script_component.hpp" + +private ["_unit","_veh","_funcType","_vehLockpickStrenth","_returnValue"]; + +_unit = [_this, 0, objNull, [objNull]] call bis_fnc_param; +_veh = [_this, 1, objNull, [objNull]] call bis_fnc_param; +_funcType = [_this, 2, "", [""]] call bis_fnc_param; + +if (isNull _unit) exitWith { + ["ACE_VehicleLock_fnc_lockpick: null unit"] call BIS_fnc_error; + false +}; +if (isNull _veh) exitWith { + ["ACE_VehicleLock_fnc_lockpick: null vehicle"] call BIS_fnc_error; + false +}; + +//need lockpick item +if (!("ACE_key_lockpick" in (items _unit))) exitWith { + false +}; + +_vehLockpickStrenth = _veh getVariable[QGVAR(LockpickStrength), GVAR(DefaultLockpickStrength)]; +if (typeName _vehLockpickStrenth != "SCALAR") exitWith { + ["ACE_VehicleLock_fnc_lockpick: 'ACE_vehicleLock_LockpickStrength' invalid: (%1)", _veh] call BIS_fnc_error; + false +}; + +//-1 indicates unpickable lock +if (_vehLockpickStrenth < 0) exitWith { + false +}; + +_returnValue = false; + +switch (true) do { +case (_funcType == "canLockpick"): { + _returnValue = true; + }; +case (_funcType == "startLockpick"): { + [_vehLockpickStrenth, [_unit, _veh, "finishLockpick"], "ACE_VehicleLock_fnc_lockpick", (localize "STR_ACE_Vehicle_Action_LockpickInUse")] call EFUNC(common,progressBar); + }; +case (_funcType == "finishLockpick"): { + ["SetVehicleLock", [_veh], [_veh, false]] call EFUNC(common,targetEvent); + }; + default { + ["ACE_VehicleLock_fnc_lockpick: bad function type"] call BIS_fnc_error; + }; +}; + +_returnValue; diff --git a/addons/vehiclelock/functions/fnc_moduleInit.sqf b/addons/vehiclelock/functions/fnc_moduleInit.sqf new file mode 100644 index 0000000000..b0ae230724 --- /dev/null +++ b/addons/vehiclelock/functions/fnc_moduleInit.sqf @@ -0,0 +1,51 @@ +/* +Name: ACE_VehicleLock_fnc_moduleInit + +Author: Pabst Mirror + +Description: + Function for setup module. Sets default lockpick strength, auto handout keys, and default lock state. + +Parameters: + 0: OBJECT - logic + 1: ignored + 2: BOOL - Module Activated +Returns: + Nothing + +Example: + called from module +*/ + +#include "script_component.hpp" + +private ["_sideKeysAssignment", "_setLockState", "_lock"]; + +PARAMS_3(_logic,_syncedUnits,_activated); + +if (!_activated) exitWith {WARNING("Vehicle Lock Init Module - placed but not active");}; + +_sideKeysAssignment = _logic getVariable["SideKeysAssignment", 0]; +_setLockState = _logic getVariable["SetLockState", 0]; + +if (isServer) then { + [_logic, QGVAR(DefaultLockpickStrength), "LockpickStrength"] call EFUNC(common,readNumericParameterFromModule); +}; + +//Run at mission start (anyone besides JIPs) +if (isServer || {player == player}) then { + { + if ((local _x) && {(_x isKindOf "Car") || (_x isKindOf "Tank") || (_x isKindOf "Helicopter")}) then { + //set lock state (eliminates the ambigious 1-"Default" and 3-"Locked for Player" states) + _lock = switch (_setLockState) do { + case (0): {(locked _x) in [2, 3]}; + case (1):{true}; + case (2):{false}; + }; + if (((_lock) && {(locked _x) != 2}) || {(!_lock) && {(locked _x) != 0}}) then { + TRACE_3("Setting Lock State", _lock, (typeOf _x), _x); + ["SetVehicleLock", [_x, _lock]] call EFUNC(common,localEvent); + }; + }; + } forEach vehicles; +}; diff --git a/addons/vehiclelock/functions/fnc_moduleSync.sqf b/addons/vehiclelock/functions/fnc_moduleSync.sqf new file mode 100644 index 0000000000..60c23c5195 --- /dev/null +++ b/addons/vehiclelock/functions/fnc_moduleSync.sqf @@ -0,0 +1,52 @@ +/* +Name: ACE_VehicleLock_fnc_moduleSync + +Author: Pabst Mirror + +Description: + Function for sync module. Assigns keys for all synced vehicles to any players that are synced. + +Parameters: + 0: OBJECT - logic + 1: ARRAY - synced objects (only objects at mission start, so JIP without AI won't be present) + +Returns: + Nothing + +Example: + called from module +*/ + +#include "script_component.hpp" + +PARAMS_3(_logic,_syncedObjects,_activated); + +if !(_activated) exitWith {WARNING("Vehicle Lock Sync Module - placed but not active");}; +if (!isServer) exitWith {}; + +_addKeyAfterGearAssign = { + private ["_syncedObjects", "_listOfVehicles"]; + _syncedObjects = _this select 0; + _listOfVehicles = []; + { + if ((_x isKindOf "Car") || (_x isKindOf "Tank") || (_x isKindOf "Helicopter")) then { + _listOfVehicles pushBack _x; + }; + } forEach _syncedObjects; + + if ((count _listOfVehicles) == 0) exitWith { //Verbose error for mission makers + ["ACE_VehicleLock_fnc_moduleSync: no vehicles synced"] call BIS_fnc_error; + }; + + { + _unit = _x; + if (_unit isKindOf "CAManBase") then { + { + [_unit, _x, true] call FUNC(addKeyForVehicle); + } forEach _listOfVehicles; + }; + } forEach _syncedObjects; +}; + +//Wait to add keys until various gear assigns have finished (~5 seconds) +[_addKeyAfterGearAssign, [_syncedObjects], 5, 1] call EFUNC(common,waitAndExecute); diff --git a/addons/vehiclelock/functions/fnc_serverSetupCustomKeyEH.sqf b/addons/vehiclelock/functions/fnc_serverSetupCustomKeyEH.sqf new file mode 100644 index 0000000000..f9a420841e --- /dev/null +++ b/addons/vehiclelock/functions/fnc_serverSetupCustomKeyEH.sqf @@ -0,0 +1,31 @@ + /* + Name: ACE_VehicleLock_fnc_serverSetupCustomKeyEH + + Author: Pabst Mirror + + Description: + Adds a key (magazineDetail name) to approved keys for a vehicle + + Parameters: + 0: OBJECT - vehicle + 1: STRING - Magazine Name + + Returns: + Nothing + + Example: + [tank1, "someMagainze [id xx:yy]"] call ACE_VehicleLock_fnc_serverSetupCustomKeyEH; +*/ + +#include "script_component.hpp" + +private ["_currentKeys"]; + +PARAMS_2(_veh,_key); + +if (!isServer) exitWith {ERROR("only run on server");}; +if (_key == "") exitWith {ERROR("empty key string");}; + +_currentKeys = _veh getVariable [QGVAR(customKeys), []]; +_currentKeys pushBack _key; +_veh setVariable [QGVAR(customKeys), _currentKeys, true]; diff --git a/addons/vehiclelock/functions/fnc_setVehicleLockEH.sqf b/addons/vehiclelock/functions/fnc_setVehicleLockEH.sqf new file mode 100644 index 0000000000..7aaa9b154c --- /dev/null +++ b/addons/vehiclelock/functions/fnc_setVehicleLockEH.sqf @@ -0,0 +1,33 @@ +/* + Name: ACE_VehicleLock_fnc_setVehicleLockEH + + Author: Pabst Mirror + + Description: + Sets a vehicle lock state because of a "SetVehicleLock" event + + Parameters: + 0: OBJECT - vehicle + 1: BOOL - new lock state + + Returns: + Nothing + + Example: + [tank1, false] call ACE_VehicleLock_fnc_setVehicleLockEH; +*/ + +#include "script_component.hpp" + +private ["_veh","_isLocked","_lockNumber"]; + +_veh = [_this, 0, objNull, [objNull]] call bis_fnc_param; +_isLocked = [_this, 1, false, [false]] call bis_fnc_param; + +_lockNumber = if (_isLocked) then {2} else {0}; + +TRACE_2("Setting Lock State", _veh, _lockNumber); + +_veh lock _lockNumber; + +// _veh setVariable ["ACE_LockedInventory", _isLocked, true]; //todo inventory lock diff --git a/addons/vehiclelock/functions/script_component.hpp b/addons/vehiclelock/functions/script_component.hpp new file mode 100644 index 0000000000..0e05142c6e --- /dev/null +++ b/addons/vehiclelock/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\ace\addons\vehiclelock\script_component.hpp" \ No newline at end of file diff --git a/addons/vehiclelock/readme.md b/addons/vehiclelock/readme.md new file mode 100644 index 0000000000..d0f2d387e0 --- /dev/null +++ b/addons/vehiclelock/readme.md @@ -0,0 +1,37 @@ +Author: PabstMirror + +Adds keys as an item, to lock and unlock vehicles. +Primary target would be role play or TVT, but has uses in all game types, even co-ops (DAC AI will steal unlocked vehicles) + +Two key modes (can be used together): +Simple Side based keys (e.g. "ACE_key_west" works on any hunter) +Custom keys (one key will only open a specific vehicle and nothing else) + +Items Added: + +`ACE_key_lockpick` +`ACE_key_master` +`ACE_key_west` +`ACE_key_east` +`ACE_key_indp` +`ACE_key_civ` + +Magazine added (should never be manualy added, needs to be 'programed' to work on a vehicle): +`ACE_key_customKeyMagazine` + +For Mission Makers: + +Modules: +Vehicle Lock Setup - Settings for lockpick strength and initial vehicle lock state. +Vehicle Key Assign - Sync with vehicles and players. Will handout custom keys to players for every synced vehicle. + +Global Variable: +`ACE_VehicleLock_DefaultLockpickStrength` - Time in seconds to lock pick globaly, can also set per-vehicle (-1 would disable) + +Vehicle setVariables: +`ACE_lock_side` - SIDE: overrides a vehicle's side, allows indfor to use little-bird's with indp keys +`ACE_vehicleLock_pickStr` - NUMBER: secons, determines how long lockpicking with take, overrides ACE_VehicleLock_DefaultLockpickStrength +`ACE_lock_customKeys` - ARRAY: array of strings of magazinesDetails, use the following function to modify + +`[bob, car1, true] call ACE_VehicleLock_fnc_addKeyForVehicle;` +will add a `ACE_magazine_customKey` to bob and program it to work on car1 diff --git a/addons/vehiclelock/readme.txt b/addons/vehiclelock/readme.txt deleted file mode 100644 index e62d9eb83b..0000000000 --- a/addons/vehiclelock/readme.txt +++ /dev/null @@ -1,37 +0,0 @@ -Adds keys as an item, to lock and unlock vehicles. -Primary target would be role play or TVT, but has uses in all game types, even co-ops (DAC AI will steal unlocked vehicles) - -Modules allow fast setup, or can manualy add items and set variables. - -Two key modes (can be used together): -Simple Side based keys (e.g. "AGM_item_key_west" works on any hunter) -Custom keys (one key will only open a specific vehicle and nothing else) - -Items Added: - -AGM_item_key_lockpick -AGM_item_key_master -AGM_item_key_west -AGM_item_key_east -AGM_item_key_indp -AGM_item_key_civ - -Magazine added (should never be manualy added, needs to be 'programed' to work on a vehicle): -AGM_magazine_customKey - -For Mission Makers: - -Modules: -Vehicle Lock Setup - Settings for lockpick strength, auto assigment of keys at start and initial vehicle lock state. -Vehicle Key Assign - Sync with vehicles and players. Will handout custom keys to players for every synced vehicle. - -Global Variable: -AGM_VehicleLock_DefaultLockpickStrength - Time in seconds to lock pick globaly, can also set per-vehicle (-1 would disable) - -Vehicle setVariables: -agm_lock_side - SIDE: overrides a vehicle's side, allows indfor to use little-bird's with indp keys -agm_vehicleLock_pickStr - NUMBER: secons, determines how long lockpicking with take, overrides AGM_VehicleLock_DefaultLockpickStrength -agm_lock_customKeys - ARRAY: array of strings of magazinesDetails, use the following function to modify - -[bob, car1, true] call AGM_VehicleLock_fnc_addKeyForVehicle; -will add a "AGM_magazine_customKey" to bob and program it to work on car1 \ No newline at end of file diff --git a/addons/vehiclelock/script_component.hpp b/addons/vehiclelock/script_component.hpp new file mode 100644 index 0000000000..1700ce4b79 --- /dev/null +++ b/addons/vehiclelock/script_component.hpp @@ -0,0 +1,15 @@ +#define COMPONENT vehiclelock + +#define DEBUG_MODE_FULL + +#include "\z\ace\addons\main\script_mod.hpp" + +#ifdef DEBUG_ENABLED_VEHICLELOCK + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_VEHICLELOCK + #define DEBUG_SETTINGS DEBUG_SETTINGS_VEHICLELOCK +#endif + +#include "\z\ace\addons\main\script_macros.hpp" diff --git a/addons/vehiclelock/stringtable.xml b/addons/vehiclelock/stringtable.xml index c6e8d51d8b..580283dcab 100644 --- a/addons/vehiclelock/stringtable.xml +++ b/addons/vehiclelock/stringtable.xml @@ -1,8 +1,8 @@  - + - + Unlock Vehicle Fahrzeug aufschließen Vehículo abierto @@ -12,7 +12,7 @@ Jármű nyitása Открыть машину - + Lock Vehicle Fahrzeug abschließen Vehículo cerrado @@ -22,7 +22,7 @@ Jármű zárása Закрыть машину - + Lockpick Vehicle Fahrzeug knacken Forzar vehículo @@ -32,7 +32,7 @@ Jármű feltörése Взломать замок - + Picking Lock.... Schloss knacken... Forzando cierre... @@ -42,7 +42,7 @@ Feltörés... Взламываем замок... - + A custom key that will open a specific vehicle. Ein Schlüssel der ein bestimmtes Fahrzeug aufschließt. Una llave concreta abrirá un vehículo concreto. @@ -52,7 +52,7 @@ Kulcs egy járműhez Ключ от конкретной машины. - + A Master Key will open any lock, no matter what! Ein Generalschlüssel der jedes Schloss öffnet... Una llave maestra abrirá cualquier cierre, no importa cual! @@ -62,7 +62,7 @@ Általános kulcs minden járműhez Универсальный ключ, открывающий любой замок. - + A lockpick set that can pick the locks of most vehicles. Ein Dietrich der die meisten Fahrzeugschlösser knacken kann... Un set de ganzúas puede abrir la mayoría de cerraduras de vehículos. @@ -72,7 +72,7 @@ Álkulcs melyik minden járműt nyitni tud Набор отмычек, которым можно взломать почти любую машину. - + A key that should open most WEST vehicles. Ein Schlüssel der die meisten westlichen Fahrzeuge öffnen sollte... Una llave que puede abrir la mayoría de vehículos occidentales. @@ -82,7 +82,7 @@ Általános kulcs WEST járművekhez Ключ для открытия большинства машин Запада. - + A key that should open most EAST vehicle. Ein Schlüssel der die meisten östlichen Fahrzeuge öffnen sollte... Una llave que puede abrir la mayoría de vehículos orientales. @@ -92,7 +92,7 @@ Klíč který by měl otevřít vetšinu Východních vozidel. Ключ для открытия большинства машин Востока. - + A key that should open most INDEP vehicle. Ein Schlüssel der die meisten Fahrzeuge der Aufständischen öffnen sollte... Una llave que puede abrir la mayoría de vehículos independientes. @@ -102,7 +102,7 @@ Klíč který by měl otevřít většinu Nezávislých vozidel. Ключ для открытия большинства машин Независимых. - + A key that should open most CIV vehicle. Ein Schlüssel der die meisten zivilen Fahrzeuge öffnen sollte... Una llave que puede abrir la mayoría de vehículos civiles.