Headers, Formating, Fixes, Lock Inventory Option

This commit is contained in:
PabstMirror 2015-03-15 11:27:21 -05:00
parent 85f2f5a467
commit 726bf8d407
16 changed files with 433 additions and 408 deletions

View File

@ -3,3 +3,15 @@ class Extended_PreInit_EventHandlers {
init = QUOTE(call COMPILE_FILE(XEH_preInit)); init = QUOTE(call COMPILE_FILE(XEH_preInit));
}; };
}; };
class Extended_PostInit_EventHandlers {
class ADDON {
init = QUOTE(call COMPILE_FILE(XEH_postInit));
};
};
class Extended_InventoryOpened_EventHandlers {
class CAManBase {
class ADDON {
clientInventoryOpened = QUOTE(_this call FUNC(onOpenInventory););
};
};
};

View File

@ -1,9 +1,10 @@
class CfgMagazines { class CfgMagazines {
class CA_Magazine; class CA_Magazine;
class ACE_key_customKeyMagazine: CA_Magazine { class ACE_key_customKeyMagazine: CA_Magazine {
picture = QUOTE(PATHTOF(ui\keyBlack.paa)); picture = QUOTE(PATHTOF(ui\keyBlack.paa));
displayName = "ACE Vehicle Key"; //!!!CANNONT be localized!!!, because it is used as part of the magazineDetail string displayName = "ACE Vehicle Key"; //!!!CANNOT be localized!!!: because it is used as part of the magazineDetail string
descriptionShort = "$STR_ACE_Vehicle_Item_Custom_Description"; descriptionShort = "$STR_ACE_Vehicle_Item_Custom_Description";
count = 1; count = 1;
}; mass = 0;
};
}; };

View File

@ -1,102 +1,107 @@
#define MACRO_LOCK_ACTIONS \ #define MACRO_LOCK_ACTIONS \
class ACE_MainActions { \ class ACE_MainActions { \
class ACE_unlockVehicle { \ class ACE_unlockVehicle { \
displayName = "$STR_ACE_Vehicle_Action_UnLock"; \ displayName = "$STR_ACE_Vehicle_Action_UnLock"; \
distance = 4; \ distance = 4; \
condition = QUOTE(([ARR_2(_player, _target)] call FUNC(hasKeyForVehicle)) && {(locked _target) in [ARR_2(2,3)]}); \ 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)); \ statement = QUOTE([ARR_3('VehicleLock_SetVehicleLock', [_target], [ARR_2(_target,false)])] call EFUNC(common,targetEvent)); \
showDisabled = 0; \ showDisabled = 0; \
priority = 0.3; \ priority = 0.3; \
icon = QUOTE(PATHTOF(ui\key_menuIcon_ca.paa)); \ icon = QUOTE(PATHTOF(ui\key_menuIcon_ca.paa)); \
}; \ }; \
class ACE_lockVehicle { \ class ACE_lockVehicle { \
displayName = "$STR_ACE_Vehicle_Action_Lock"; \ displayName = "$STR_ACE_Vehicle_Action_Lock"; \
distance = 4; \ distance = 4; \
condition = QUOTE(([ARR_2(_player, _target)] call FUNC(hasKeyForVehicle)) && {(locked _target) in [ARR_2(0,1)]}); \ 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)); \ statement = QUOTE([ARR_3('VehicleLock_SetVehicleLock', [_target], [ARR_2(_target,true)])] call EFUNC(common,targetEvent)); \
showDisabled = 0; \ showDisabled = 0; \
priority = 0.2; \ priority = 0.2; \
icon = QUOTE(PATHTOF(ui\key_menuIcon_ca.paa)); \ icon = QUOTE(PATHTOF(ui\key_menuIcon_ca.paa)); \
}; \ }; \
class ACE_lockpickVehicle { \ class ACE_lockpickVehicle { \
displayName = "$STR_ACE_Vehicle_Action_Lockpick"; \ displayName = "$STR_ACE_Vehicle_Action_Lockpick"; \
distance = 4; \ distance = 4; \
condition = QUOTE([ARR_3(_player, _target, 'canLockpick')] call FUNC(lockpick)); \ condition = QUOTE([ARR_3(_player, _target, 'canLockpick')] call FUNC(lockpick)); \
statement = QUOTE([ARR_3(_player, _target, 'startLockpick')] call FUNC(lockpick)); \ statement = QUOTE([ARR_3(_player, _target, 'startLockpick')] call FUNC(lockpick)); \
showDisabled = 0; \ showDisabled = 0; \
priority = 0.1; \ priority = 0.1; \
}; \ }; \
}; };
class CfgVehicles { class CfgVehicles {
class LandVehicle; class LandVehicle;
class Car: LandVehicle { class Car: LandVehicle {
class ACE_Actions { class ACE_Actions {
MACRO_LOCK_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 { class Tank: LandVehicle {
description = "Settings for lockpick strength and initial vehicle lock state. Removes ambiguous lock states.<br/>Source: vehiclelock.pbo"; class ACE_Actions {
MACRO_LOCK_ACTIONS
};
};
class Air;
class Helicopter: Air {
class ACE_Actions {
MACRO_LOCK_ACTIONS
};
}; };
};
class ACE_VehicleLock_ModuleSyncedAssign: Module_F { class Logic;
author = "$STR_ACE_Common_ACETeam"; class Module_F: Logic {
category = "ACE"; class ModuleDescription {};
displayName = "Vehicle Key Assign"; };
function = "ACE_VehicleLock_fnc_moduleSync"; class ACE_VehicleLock_ModuleSetup: Module_F {
scope = 2; author = "$STR_ACE_Common_ACETeam";
isGlobal = 1; category = "ACE";
icon = QUOTE(PATHTOF(ui\IconLock_ca.paa)); displayName = "Vehicle Lock Setup";
functionPriority = 0; function = QUOTE(DFUNC(moduleInit));
class Arguments {}; scope = 2;
class ModuleDescription: ModuleDescription { isGlobal = 0;
description = "Sync with vehicles and players. Will handout custom keys to players for every synced vehicle. Only valid for objects present at mission start.<br/>Source: vehiclelock.pbo"; icon = QUOTE(PATHTOF(ui\IconLock_ca.paa));
sync[] = {"AnyPlayer", "AnyVehicle"}; functionPriority = 0;
class Arguments {
class LockVehicleInventory {
displayName = "Lock Vehicle Inventory";
description = "Locks the inventory of locked vehicles";
typeName = "BOOL";
defaultValue = 0;
};
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 DefaultLockpickStrength {
displayName = "Default Lockpick Strength";
description = "Default 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.<br/>Source: vehiclelock.pbo";
};
};
class ACE_VehicleLock_ModuleSyncedAssign: Module_F {
author = "$STR_ACE_Common_ACETeam";
category = "ACE";
displayName = "Vehicle Key Assign";
function = QUOTE(DFUNC(moduleSync));
scope = 2;
isGlobal = 0;
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.<br/>Source: vehiclelock.pbo";
sync[] = {"AnyPlayer", "AnyVehicle"};
};
}; };
};
}; };

View File

@ -1,41 +1,41 @@
class CfgWeapons { class CfgWeapons {
class InventoryItem_Base_F; class InventoryItem_Base_F;
class ACE_ItemCore; class ACE_ItemCore;
class ACE_key_master: ACE_ItemCore { class ACE_key_master: ACE_ItemCore {
author = "$STR_ACE_Common_ACETeam"; author = "$STR_ACE_Common_ACETeam";
displayName = "Vehicle Key: Master"; displayName = "Vehicle Key: Master";
descriptionShort = "$STR_ACE_Vehicle_Item_Master_Description"; descriptionShort = "$STR_ACE_Vehicle_Item_Master_Description";
model = "\A3\weapons_F\ammo\mag_univ.p3d"; model = "\A3\weapons_F\ammo\mag_univ.p3d";
picture = QUOTE(PATHTOF(ui\keyBlack.paa)); picture = QUOTE(PATHTOF(ui\keyBlack.paa));
scope = 2; scope = 2;
class ItemInfo: InventoryItem_Base_F { class ItemInfo: InventoryItem_Base_F {
mass = 0.1; mass = 0;
}; };
}; };
class ACE_key_lockpick: ACE_key_master { class ACE_key_lockpick: ACE_key_master {
displayName = "Lockpick"; displayName = "Lockpick";
descriptionShort = "$STR_ACE_Vehicle_Item_Lockpick_Description"; descriptionShort = "$STR_ACE_Vehicle_Item_Lockpick_Description";
picture = QUOTE(PATHTOF(ui\lockpick.paa)); picture = QUOTE(PATHTOF(ui\lockpick.paa));
}; };
class ACE_key_west: ACE_key_master { class ACE_key_west: ACE_key_master {
displayName = "Vehicle Key: West"; displayName = "Vehicle Key: West";
descriptionShort = "$STR_ACE_Vehicle_Item_West_Description"; descriptionShort = "$STR_ACE_Vehicle_Item_West_Description";
picture = QUOTE(PATHTOF(ui\keyBlue.paa)); picture = QUOTE(PATHTOF(ui\keyBlue.paa));
}; };
class ACE_key_east: ACE_key_master { class ACE_key_east: ACE_key_master {
displayName = "Vehicle Key: East"; displayName = "Vehicle Key: East";
descriptionShort = "$STR_ACE_Vehicle_Item_East_Description"; descriptionShort = "$STR_ACE_Vehicle_Item_East_Description";
picture = QUOTE(PATHTOF(ui\keyRed.paa)); picture = QUOTE(PATHTOF(ui\keyRed.paa));
}; };
class ACE_key_indp: ACE_key_master { class ACE_key_indp: ACE_key_master {
displayName = "Vehicle Key: Independent"; displayName = "Vehicle Key: Independent";
descriptionShort = "$STR_ACE_Vehicle_Item_Indp_Description"; descriptionShort = "$STR_ACE_Vehicle_Item_Indp_Description";
picture = QUOTE(PATHTOF(ui\keyPurple.paa)); picture = QUOTE(PATHTOF(ui\keyPurple.paa));
}; };
class ACE_key_civ: ACE_key_master { class ACE_key_civ: ACE_key_master {
displayName = "Vehicle Key: Civilian"; displayName = "Vehicle Key: Civilian";
descriptionShort = "$STR_ACE_Vehicle_Item_Civ_Description"; descriptionShort = "$STR_ACE_Vehicle_Item_Civ_Description";
picture = QUOTE(PATHTOF(ui\keyGreen.paa)); picture = QUOTE(PATHTOF(ui\keyGreen.paa));
}; };
}; };

View File

@ -0,0 +1,5 @@
#include "script_component.hpp"
//Add Event Handlers
["VehicleLock_SetupCustomKey", {_this call FUNC(serverSetupCustomKeyEH)}] call EFUNC(common,addEventHandler);
["VehicleLock_SetVehicleLock", {_this call FUNC(setVehicleLockEH)}] call EFUNC(common,addEventHandler);

View File

@ -8,11 +8,8 @@ PREP(hasKeyForVehicle);
PREP(lockpick); PREP(lockpick);
PREP(moduleInit); PREP(moduleInit);
PREP(moduleSync); PREP(moduleSync);
PREP(onOpenInventory);
PREP(serverSetupCustomKeyEH); PREP(serverSetupCustomKeyEH);
PREP(setVehicleLockEH); PREP(setVehicleLockEH);
//Add Event Handlers
["SetupCustomKey", {_this call FUNC(serverSetupCustomKeyEH)}] call EFUNC(common,addEventHandler);
["SetVehicleLock", {_this call FUNC(setVehicleLockEH)}] call EFUNC(common,addEventHandler);
ADDON = true; ADDON = true;

View File

@ -17,6 +17,10 @@ class ACE_Settings {
value = 10; value = 10;
typeName = "SCALAR"; typeName = "SCALAR";
}; };
class GVAR(LockVehicleInventory) {
value = 0;
typeName = "BOOL";
};
}; };
#include "CfgEventHandlers.hpp" #include "CfgEventHandlers.hpp"

View File

@ -1,45 +1,40 @@
/* /*
Name: ACE_VehicleLock_fnc_addKeyForVehicle * Author: PabstMirror
* Adds a key to a unit that will open a vehicle
Author: Pabst Mirror * Note: has global effects for Unit (will add items to remote unit)
*
Description: * Arguments:
Adds a key to a unit that will open a vehicle * 0: Unit <OBJECT>
* 1: Vehicle <OBJECT>
Parameters: * 2: custom key (true: custom key (magazine) - false: side key (item)) <BOOL>
0: OBJECT - unit *
1: OBJECT - vehicle * Return Value:
2: BOOL - custom key (true: custom key (magazine) - false: side key (item)) * None
*
Returns: * Example:
Nothing * [ACE_player, car, true] call ACE_VehicleLock_fnc_addKeyForVehicle
*
Example: * Public: Yes
[bob, car1, true] call ACE_VehicleLock_fnc_addKeyForVehicle; */
*/
#include "script_component.hpp" #include "script_component.hpp"
private ["_unit","_veh","_useCustom","_previousMags","_newMags","_keyMagazine","_keyName"]; private ["_previousMags","_newMags","_keyMagazine","_keyName"];
_unit = [_this, 0, objNull, [objNull]] call bis_fnc_param; PARAMS_3(_unit,_veh,_useCustom);
_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 _unit) exitWith {ERROR("null unit");};
if (isNull _veh) exitWith {["addKeyForVehicleClient: null vehicle"] call BIS_fnc_error;}; if (isNull _veh) exitWith {ERROR("null vehicle");};
if (_useCustom) then { if (_useCustom) then {
_previousMags = magazinesDetail _unit; _previousMags = magazinesDetail _unit;
_unit addMagazine ["ACE_key_customKeyMagazine", 1]; _unit addMagazine ["ACE_key_customKeyMagazine", 1]; //addMagazine array has global effects
_newMags = (magazinesDetail _unit) - _previousMags; _newMags = (magazinesDetail _unit) - _previousMags;
if ((count _newMags) == 0) exitWith { if ((count _newMags) == 0) exitWith {ERROR("failed to add magazine (inventory full?)");};
["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);
_keyMagazine = _newMags select 0; //Have the server run add the key to the vehicle's key array:
TRACE_2("setting up key on server",_veh,_keyMagazine); ["VehicleLock_SetupCustomKey", [_veh, _keyMagazine]] call EFUNC(common,serverEvent);
["SetupCustomKey", [_veh, _keyMagazine]] call EFUNC(common,serverEvent);
} else { } else {
_keyName = [_veh] call FUNC(getVehicleSideKey); _keyName = [_veh] call FUNC(getVehicleSideKey);
_unit addItem _keyName; _unit addItem _keyName; //addItem has global effects
}; };

View File

@ -1,27 +1,25 @@
/* /*
Name: ACE_VehicleLock_fnc_getVehicleSideKey * Author: PabstMirror
* Returns the side specifc key for a vehicle
Author: Pabst Mirror *
* Arguments:
Description: * 0: Vehicle <OBJECT>
Returns the side specifc key for a vehicle *
* Return Value:
Parameters: * The vehicle's side key classname <STRING>
0: OBJECT - vehicle *
* Example:
Returns: * [tank1] call ACE_VehicleLock_fnc_getVehicleSideKey;
STRING - Key Classname *
* Public: No
Example: */
[tank1] call ACE_VehicleLock_fnc_getVehicleSideKey;
*/
#include "script_component.hpp" #include "script_component.hpp"
private ["_veh","_vehConfigSide","_vehSide","_returnValue"]; private ["_vehConfigSide","_vehSide","_returnValue"];
_veh = [_this, 0, objNull, [objNull]] call bis_fnc_param; PARAMS_1(_veh);
if (isNull _veh) exitWith {["ACE_VehicleLock_fnc_getVehicleSideKey: null vehicle"] call BIS_fnc_error; ""};
if (isNull _veh) exitWith {ERROR("null vehicle"); "error"};
_vehConfigSide = [_veh, true] call BIS_fnc_objectSide; _vehConfigSide = [_veh, true] call BIS_fnc_objectSide;
_vehSide = _veh getVariable [QGVAR(lockSide), _vehConfigSide]; _vehSide = _veh getVariable [QGVAR(lockSide), _vehConfigSide];
@ -32,7 +30,7 @@ switch (_vehSide) do {
case (west): {_returnValue = "ACE_key_west"}; case (west): {_returnValue = "ACE_key_west"};
case (east): {_returnValue = "ACE_key_east"}; case (east): {_returnValue = "ACE_key_east"};
case (resistance): {_returnValue = "ACE_key_indp"}; case (resistance): {_returnValue = "ACE_key_indp"};
case (civilian): {_returnValue = "ACE_key_civ"}; default {_returnValue = "ACE_key_civ"};
}; };
_returnValue _returnValue

View File

@ -1,31 +1,27 @@
/* /*
Name: ACE_VehicleLock_fnc_hasKeyForVehicle * Author: PabstMirror
* Returns if user has a valid key for the vehicle
Author: Pabst Mirror *
* Arguments:
Description: * 0: Unit <OBJECT>
Returns if user has a valid key for the vehicle * 1: Vehicle <OBJECT>
*
Parameters: * Return Value:
0: OBJECT - unit * unit has key for vehicle <BOOL>
1: OBJECT - vehicle *
* Example:
Returns: * [bob, car] call ACE_VehicleLock_fnc_hasKeyForVehicle;
BOOL - unit has key for vehicle *
* Public: No
Example: */
[bob, car] call ACE_VehicleLock_fnc_hasKeyForVehicle;
*/
#include "script_component.hpp" #include "script_component.hpp"
private ["_unit","_veh","_returnValue","_sideKeyName","_customKeys"]; private ["_returnValue","_sideKeyName","_customKeys"];
_unit = [_this, 0, objNull, [objNull]] call bis_fnc_param; PARAMS_2(_unit,_veh);
_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 _unit) exitWith {ERROR("null unit"); false};
if (isNull _veh) exitWith {["ACE_VehicleLock_fnc_hasKeyForVehicle: null vehicle"] call BIS_fnc_error; false}; if (isNull _veh) exitWith {ERROR("null vehicle"); false};
_returnValue = false; _returnValue = false;
@ -39,7 +35,7 @@ if (_sideKeyName in (items _unit)) then {_returnValue = true};
//Check custom keys //Check custom keys
_customKeys = _veh getVariable [QGVAR(customKeys), []]; _customKeys = _veh getVariable [QGVAR(customKeys), []];
{ {
if (_x in (magazinesDetail _unit)) then {_returnValue = true;}; if (_x in (magazinesDetail _unit)) then {_returnValue = true;};
} forEach _customKeys; } forEach _customKeys;
_returnValue _returnValue

View File

@ -1,79 +1,66 @@
/* /*
Name: ACE_VehicleLock_fnc_lockpick * Author: PabstMirror
* Handles lockpick functionality. Three different functions:
Author: Pabst Mirror * "canLockpick": returns BOOL if lockpick is possible
* "startLockpick": starts the process
Description: * "finishLockpick": on completions, opens the lock
Handles lockpick functionality from action menu. *
* Arguments:
Parameters: * 0: Unit (player) <OBJECT>
0: OBJECT - unit * 1: Vehicle <OBJECT>
1: OBJECT - vehicle * 2: Function Type <OBJECT>
2: STRING - function type *
"canLockpick": returns BOOL if lockpick is possible * Return Value:
"startLockpick": starts the process * "canLockpick" <BOOL>
"finishLockpick": on completions, opens the lock *
* Example:
Returns: * [ACE_player, ACE_Interaction_Target, 'canLockpick'] call ACE_VehicleLock_fnc_lockpick
BOOL *
* Public: No
Example: */
[ACE_player, ACE_Interaction_Target, 'canLockpick'] call ACE_VehicleLock_fnc_lockpick
*/
#include "script_component.hpp" #include "script_component.hpp"
private ["_unit","_veh","_funcType","_vehLockpickStrenth","_returnValue", "_condition"]; private ["_vehLockpickStrenth","_condition","_returnValue"];
_unit = [_this, 0, objNull, [objNull]] call bis_fnc_param; PARAMS_3(_unit,_veh,_funcType);
_veh = [_this, 1, objNull, [objNull]] call bis_fnc_param;
_funcType = [_this, 2, "", [""]] call bis_fnc_param;
if (isNull _unit) exitWith { if (isNull _unit) exitWith {ERROR("null unit"); false};
["ACE_VehicleLock_fnc_lockpick: null unit"] call BIS_fnc_error; if (isNull _veh) exitWith {ERROR("null vehicle"); false};
false
};
if (isNull _veh) exitWith {
["ACE_VehicleLock_fnc_lockpick: null vehicle"] call BIS_fnc_error;
false
};
//need lockpick item //need lockpick item
if (!("ACE_key_lockpick" in (items _unit))) exitWith { if (!("ACE_key_lockpick" in (items _unit))) exitWith {false};
false
};
_vehLockpickStrenth = _veh getVariable[QGVAR(lockpickStrength), GVAR(DefaultLockpickStrength)]; _vehLockpickStrenth = _veh getVariable[QGVAR(lockpickStrength), GVAR(DefaultLockpickStrength)];
if (typeName _vehLockpickStrenth != "SCALAR") exitWith { if (typeName _vehLockpickStrenth != "SCALAR") exitWith {ERROR("ACE_vehicleLock_LockpickStrength invalid"); false};
["ACE_VehicleLock_fnc_lockpick: 'ACE_vehicleLock_LockpickStrength' invalid: (%1)", _veh] call BIS_fnc_error;
false
};
//-1 indicates unpickable lock //-1 indicates unpickable lock
if (_vehLockpickStrenth < 0) exitWith { if (_vehLockpickStrenth < 0) exitWith {false};
false
//Condition check for progressBar
_condition = {
PARAMS_1(_args);
EXPLODE_2_PVT(_args,_unit,_veh);
((_unit distance _veh) < 5) && {(speed _veh) < 0.1}
}; };
if (!([[_unit, _veh]] call _condition)) exitWith {false};
_returnValue = false; _returnValue = false;
switch (true) do { switch (true) do {
case (_funcType == "canLockpick"): { case (_funcType == "canLockpick"): {
_returnValue = true; _returnValue = true;
}; };
case (_funcType == "startLockpick"): { case (_funcType == "startLockpick"): {
_condition = { [_vehLockpickStrenth, [_unit, _veh, "finishLockpick"], {(_this select 0) call FUNC(lockpick)}, {}, (localize "STR_ACE_Vehicle_Action_LockpickInUse"), _condition] call EFUNC(common,progressBar);
PARAMS_1(_args); _returnValue = true;
EXPLODE_2_PVT(_args,_unit,_veh);
([_unit, objNull, []] call EFUNC(common,canInteractWith)) && ((_unit distance _veh) < 5) && ((speed _veh) < 1)
}; };
[_vehLockpickStrenth, [_unit, _veh, "finishLockpick"], {(_this select 0) call FUNC(lockpick)}, {}, (localize "STR_ACE_Vehicle_Action_LockpickInUse"), _condition] call EFUNC(common,progressBar);
};
case (_funcType == "finishLockpick"): { case (_funcType == "finishLockpick"): {
["SetVehicleLock", [_veh], [_veh, false]] call EFUNC(common,targetEvent); ["VehicleLock_SetVehicleLock", [_veh], [_veh, false]] call EFUNC(common,targetEvent);
}; _returnValue = true;
default { };
["ACE_VehicleLock_fnc_lockpick: bad function type"] call BIS_fnc_error; default {
}; ERROR("bad function type");
};
}; };
_returnValue; _returnValue

View File

@ -1,22 +1,20 @@
/* /*
Name: ACE_VehicleLock_fnc_moduleInit * Author: PabstMirror
* Function for setup module. Sets default lockpick strength and default lock state.
Author: Pabst Mirror *
* Arguments:
Description: * 0: The Module Logic Object <OBJECT>
Function for setup module. Sets default lockpick strength, auto handout keys, and default lock state. * 1: synced objects <ARRAY>
* 2: Activated <BOOL>
Parameters: *
0: OBJECT - logic * Return Value:
1: ignored * None
2: BOOL - Module Activated *
Returns: * Example:
Nothing * [fromModule] call ACE_VehicleLock_fnc_hasKeyForVehicle;
*
Example: * Public: No
called from module */
*/
#include "script_component.hpp" #include "script_component.hpp"
private ["_sideKeysAssignment", "_setLockState", "_lock"]; private ["_sideKeysAssignment", "_setLockState", "_lock"];
@ -24,28 +22,28 @@ private ["_sideKeysAssignment", "_setLockState", "_lock"];
PARAMS_3(_logic,_syncedUnits,_activated); PARAMS_3(_logic,_syncedUnits,_activated);
if (!_activated) exitWith {WARNING("Vehicle Lock Init Module - placed but not active");}; if (!_activated) exitWith {WARNING("Vehicle Lock Init Module - placed but not active");};
if (!isServer) exitWith {};
//Set the GVAR for default lockpick strength
[_logic, QGVAR(DefaultLockpickStrength), "DefaultLockpickStrength"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(LockVehicleInventory), "LockVehicleInventory"] call EFUNC(common,readSettingFromModule);
_sideKeysAssignment = _logic getVariable["SideKeysAssignment", 0];
_setLockState = _logic getVariable["SetLockState", 0]; _setLockState = _logic getVariable["SetLockState", 0];
[{
if (isServer) then { PARAMS_1(_setLockState);
[_logic, QGVAR(DefaultLockpickStrength), "LockpickStrength"] call EFUNC(common,readSettingFromModule); {
}; if ((_x isKindOf "Car") || {_x isKindOf "Tank"} || {_x isKindOf "Helicopter"}) then {
//set lock state (eliminates the ambigious 1-"Default" and 3-"Locked for Player" states)
//Run at mission start (anyone besides JIPs) _lock = switch (_setLockState) do {
if (isServer || {player == player}) then { case (0): {(locked _x) in [2, 3]};
{ case (1):{true};
if ((local _x) && {(_x isKindOf "Car") || (_x isKindOf "Tank") || (_x isKindOf "Helicopter")}) then { case (2):{false};
//set lock state (eliminates the ambigious 1-"Default" and 3-"Locked for Player" states) };
_lock = switch (_setLockState) do { if (((_lock) && {(locked _x) != 2}) || {(!_lock) && {(locked _x) != 0}}) then {
case (0): {(locked _x) in [2, 3]}; TRACE_3("Setting Lock State", _lock, (typeOf _x), _x);
case (1):{true}; ["VehicleLock_SetVehicleLock", [_x], [_x, _lock]] call EFUNC(common,targetEvent);
case (2):{false}; };
}; };
if (((_lock) && {(locked _x) != 2}) || {(!_lock) && {(locked _x) != 0}}) then { } forEach vehicles;
TRACE_3("Setting Lock State", _lock, (typeOf _x), _x); //Delay call until mission start (so everyone has the eventHandler's installed)
["SetVehicleLock", [_x, _lock]] call EFUNC(common,localEvent); }, [_setLockState], 0.25, 0.25] call EFUNC(common,waitAndExecute);
};
};
} forEach vehicles;
};

View File

@ -1,22 +1,20 @@
/* /*
Name: ACE_VehicleLock_fnc_moduleSync * Author: PabstMirror
* Function for sync module. Assigns keys for all synced vehicles to any players that are synced.
Author: Pabst Mirror *
* Arguments:
Description: * 0: The Module Logic Object <OBJECT>
Function for sync module. Assigns keys for all synced vehicles to any players that are synced. * 1: synced objects <ARRAY>
* 2: Activated <BOOL>
Parameters: *
0: OBJECT - logic * Return Value:
1: ARRAY - synced objects (only objects at mission start, so JIP without AI won't be present) * None
*
Returns: * Example:
Nothing * [fromModule] call ACE_VehicleLock_fnc_moduleSync;
*
Example: * Public: No
called from module */
*/
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_3(_logic,_syncedObjects,_activated); PARAMS_3(_logic,_syncedObjects,_activated);
@ -24,29 +22,28 @@ PARAMS_3(_logic,_syncedObjects,_activated);
if !(_activated) exitWith {WARNING("Vehicle Lock Sync Module - placed but not active");}; if !(_activated) exitWith {WARNING("Vehicle Lock Sync Module - placed but not active");};
if (!isServer) exitWith {}; if (!isServer) exitWith {};
_addKeyAfterGearAssign = { [{
private ["_syncedObjects", "_listOfVehicles"]; private ["_listOfVehicles"];
_syncedObjects = _this select 0; PARAMS_1(_syncedObjects);
_listOfVehicles = []; _listOfVehicles = [];
{ {
if ((_x isKindOf "Car") || (_x isKindOf "Tank") || (_x isKindOf "Helicopter")) then { if ((_x isKindOf "Car") || (_x isKindOf "Tank") || (_x isKindOf "Helicopter")) then {
_listOfVehicles pushBack _x; _listOfVehicles pushBack _x;
};
} forEach _syncedObjects;
if ((count _listOfVehicles) == 0) exitWith { //Verbose error for mission makers (only shows on server)
["ACE_VehicleLock_fnc_moduleSync: no vehicles synced"] call BIS_fnc_error;
}; };
} 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)
_unit = _x; }, [_syncedObjects], 5, 1] call EFUNC(common,waitAndExecute);
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);

View File

@ -0,0 +1,40 @@
/*
* Author: PabstMirror
* Handles the inventory opening.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Container <OBJECT>
*
* Return Value:
* Handeled <BOOL>
*
* Example:
* [player, car] call ACE_VehicleLock_fnc_onOpenInventory;
*
* Public: No
*/
#include "script_component.hpp"
PARAMS_2(_unit,_container);
//Only check for player:
if (_unit != ace_player) exitWith {false};
_handeled = false;
if (GVAR(LockVehicleInventory) && //if setting not enabled
{(vehicle ace_player) == ace_player} && //Player dismounted
{(_container isKindOf "Car") || (_container isKindOf "Tank") || (_container isKindOf "Helicopter")} && //container is a lockable veh
{(locked _container) in [2,3]} && //Vehicle is locked
{!([ace_player, _container] call FUNC(hasKeyForVehicle))} //player doesn't have key
) then {
//Give feedback that vehicle is locked
playSound "ACE_Sound_Click";
//don't open the vehicles inventory
_handeled = true;
//Just opens a dummy groundContainer
ACE_player action ["Gear", objNull];
};
_handeled

View File

@ -1,22 +1,19 @@
/* /*
Name: ACE_VehicleLock_fnc_serverSetupCustomKeyEH * Author: PabstMirror
* On the server: Adds a key (magazineDetail name) to approved keys for a vehicle.
Author: Pabst Mirror *
* Arguments:
Description: * 0: Vehicle <OBJECT>
Adds a key (magazineDetail name) to approved keys for a vehicle * 1: Magazine Name <STRING>
*
Parameters: * Return Value:
0: OBJECT - vehicle * None
1: STRING - Magazine Name *
* Example:
Returns: * [tank1, "someMagainze [id xx:yy]"] call ACE_VehicleLock_fnc_serverSetupCustomKeyEH
Nothing *
* Public: Yes
Example: */
[tank1, "someMagainze [id xx:yy]"] call ACE_VehicleLock_fnc_serverSetupCustomKeyEH;
*/
#include "script_component.hpp" #include "script_component.hpp"
private ["_currentKeys"]; private ["_currentKeys"];
@ -24,6 +21,7 @@ private ["_currentKeys"];
PARAMS_2(_veh,_key); PARAMS_2(_veh,_key);
if (!isServer) exitWith {ERROR("only run on server");}; if (!isServer) exitWith {ERROR("only run on server");};
if (isNull _veh) exitWith {ERROR("null vehicle");};
if (_key == "") exitWith {ERROR("empty key string");}; if (_key == "") exitWith {ERROR("empty key string");};
_currentKeys = _veh getVariable [QGVAR(customKeys), []]; _currentKeys = _veh getVariable [QGVAR(customKeys), []];

View File

@ -1,33 +1,25 @@
/* /*
Name: ACE_VehicleLock_fnc_setVehicleLockEH * Author: PabstMirror
* Sets a vehicle lock state because of a "VehicleLock_SetVehicleLock" event
Author: Pabst Mirror *
* Arguments:
Description: * 0: Vehicle <OBJECT>
Sets a vehicle lock state because of a "SetVehicleLock" event * 1: New lock state <BOOL>
*
Parameters: * Return Value:
0: OBJECT - vehicle * None
1: BOOL - new lock state *
* Example:
Returns: * [tank1, false] call ACE_VehicleLock_fnc_setVehicleLockEH;
Nothing *
* Public: Yes
Example: */
[tank1, false] call ACE_VehicleLock_fnc_setVehicleLockEH;
*/
#include "script_component.hpp" #include "script_component.hpp"
private ["_veh","_isLocked","_lockNumber"]; private ["_lockNumber"];
_veh = [_this, 0, objNull, [objNull]] call bis_fnc_param; PARAMS_2(_veh,_isLocked);
_isLocked = [_this, 1, false, [false]] call bis_fnc_param;
_lockNumber = if (_isLocked) then {2} else {0}; _lockNumber = if (_isLocked) then {2} else {0};
TRACE_2("Setting Lock State", _veh, _lockNumber); TRACE_2("Setting Lock State", _veh, _lockNumber);
_veh lock _lockNumber; _veh lock _lockNumber;
// _veh setVariable ["ACE_LockedInventory", _isLocked, true]; //todo inventory lock