From beaa60e59af8f2fca903c3d4ed08e5857a82a79f Mon Sep 17 00:00:00 2001 From: A Clark Date: Sat, 24 Nov 2012 08:42:41 -0600 Subject: [PATCH] locking vaults --- dayz_code/actions/tent_pack.sqf | 1 + dayz_code/actions/vault_lock.sqf | 4 ++ dayz_code/actions/vault_pack.sqf | 1 + dayz_code/actions/vault_pitch.sqf | 4 +- dayz_code/actions/vault_unlock.sqf | 4 ++ dayz_code/compile/fn_selfActions.sqf | 28 +++++++-- dayz_code/compile/player_lockVault.sqf | 77 ++++++++++++++++++++++++ dayz_code/compile/player_unlockVault.sqf | 77 ++++++++++++++++++++++++ dayz_code/init/compiles.sqf | 2 + dayz_code/init/variables.sqf | 3 + dayz_equip/config.cpp | 14 ++++- 11 files changed, 208 insertions(+), 7 deletions(-) create mode 100644 dayz_code/actions/vault_lock.sqf create mode 100644 dayz_code/actions/vault_unlock.sqf create mode 100644 dayz_code/compile/player_lockVault.sqf create mode 100644 dayz_code/compile/player_unlockVault.sqf diff --git a/dayz_code/actions/tent_pack.sqf b/dayz_code/actions/tent_pack.sqf index cb7ee89ed..365c2dde1 100644 --- a/dayz_code/actions/tent_pack.sqf +++ b/dayz_code/actions/tent_pack.sqf @@ -1,3 +1,4 @@ private["_obj","_bag","_pos"]; +hintSilent format["DEBUG: %1",_this]; _obj = _this select 3; _obj spawn player_packTent; diff --git a/dayz_code/actions/vault_lock.sqf b/dayz_code/actions/vault_lock.sqf new file mode 100644 index 000000000..9348cdd70 --- /dev/null +++ b/dayz_code/actions/vault_lock.sqf @@ -0,0 +1,4 @@ +private["_obj","_bag","_pos"]; +hintSilent format["DEBUG: %1",_this]; +_obj = _this select 3; +_obj spawn player_unlockVault; diff --git a/dayz_code/actions/vault_pack.sqf b/dayz_code/actions/vault_pack.sqf index b350dff28..051440ac9 100644 --- a/dayz_code/actions/vault_pack.sqf +++ b/dayz_code/actions/vault_pack.sqf @@ -1,3 +1,4 @@ private["_obj","_bag","_pos"]; +hintSilent format["DEBUG: %1",_this]; _obj = _this select 3; _obj spawn player_packVault; diff --git a/dayz_code/actions/vault_pitch.sqf b/dayz_code/actions/vault_pitch.sqf index 46dbdd061..a10026092 100644 --- a/dayz_code/actions/vault_pitch.sqf +++ b/dayz_code/actions/vault_pitch.sqf @@ -47,7 +47,7 @@ if (!_isOk) then { sleep 5; //place tent (local) - _tent = createVehicle ["VaultStorage", _location, [], 0, "CAN_COLLIDE"]; + _tent = createVehicle ["VaultStorageLocked", _location, [], 0, "CAN_COLLIDE"]; _tent setdir _dir; _tent setpos _location; player reveal _tent; @@ -57,7 +57,7 @@ if (!_isOk) then { //player setVariable ["tentUpdate",["Land_A_tent",_dir,_location,[dayz_tentWeapons,dayz_tentMagazines,dayz_tentBackpacks]],true]; - dayzPublishObj = [dayz_characterID,_tent,[_dir,_location],"VaultStorage"]; + dayzPublishObj = [dayz_characterID,_tent,[_dir,_location],"VaultStorageLocked"]; publicVariable "dayzPublishObj"; if (isServer) then { dayzPublishObj call server_publishObj; diff --git a/dayz_code/actions/vault_unlock.sqf b/dayz_code/actions/vault_unlock.sqf new file mode 100644 index 000000000..9348cdd70 --- /dev/null +++ b/dayz_code/actions/vault_unlock.sqf @@ -0,0 +1,4 @@ +private["_obj","_bag","_pos"]; +hintSilent format["DEBUG: %1",_this]; +_obj = _this select 3; +_obj spawn player_unlockVault; diff --git a/dayz_code/compile/fn_selfActions.sqf b/dayz_code/compile/fn_selfActions.sqf index fd758c8bc..3792bc322 100644 --- a/dayz_code/compile/fn_selfActions.sqf +++ b/dayz_code/compile/fn_selfActions.sqf @@ -52,7 +52,6 @@ if (!isNull cursorTarget and !_inVehicle and (player distance cursorTarget < 4)) _isZombie = cursorTarget isKindOf "zZombie_base"; _isDestructable = cursorTarget isKindOf "BuiltItems"; _isTent = cursorTarget isKindOf "TentStorage"; - _isVault = cursorTarget isKindOf "VaultStorage"; _isFuel = false; _isAlive = alive cursorTarget; _text = getText (configFile >> "CfgVehicles" >> typeOf cursorTarget >> "displayName"); @@ -163,16 +162,29 @@ if (!isNull cursorTarget and !_inVehicle and (player distance cursorTarget < 4)) s_player_packtent = -1; }; - - //Packing my vault + //Allow owner to unlock vault + if(cursorTarget isKindOf "VaultStorageLocked" and _canDo and _ownerID == dayz_characterID) then { + if ((s_player_unlockvault < 0) and (player distance cursorTarget < 3)) then { + s_player_unlockvault = player addAction ["Unlock Vault", "\z\addons\dayz_code\actions\vault_unlock.sqf",cursorTarget, 0, false, true, "",""]; + }; + } else { + player removeAction s_player_unlockvault; + s_player_unlockvault = -1; + }; + + //Allow owner to pack vault if(cursorTarget isKindOf "VaultStorage" and _canDo and _ownerID == dayz_characterID) then { if ((s_player_packvault < 0) and (player distance cursorTarget < 3)) then { s_player_packvault = player addAction ["Pack Vault", "\z\addons\dayz_code\actions\vault_pack.sqf",cursorTarget, 0, false, true, "",""]; - // s_player_packvault = player addAction ["Lock Vault", "\z\addons\dayz_code\actions\vault_pack.sqf",cursorTarget, 0, false, true, "",""]; + }; + if ((s_player_lockvault < 0) and (player distance cursorTarget < 3)) then { + s_player_lockvault = player addAction ["Lock Vault", "\z\addons\dayz_code\actions\vault_lock.sqf",cursorTarget, 0, false, true, "",""]; }; } else { player removeAction s_player_packvault; s_player_packvault = -1; + player removeAction s_player_lockvault; + s_player_lockvault = -1; }; //Repairing Vehicles @@ -504,4 +516,12 @@ if (!isNull cursorTarget and !_inVehicle and (player distance cursorTarget < 4)) s_player_fillfuel = -1; player removeAction s_player_studybody; s_player_studybody = -1; + + // vault + player removeAction s_player_unlockvault; + s_player_unlockvault = -1; + player removeAction s_player_packvault; + s_player_packvault = -1; + player removeAction s_player_lockvault; + s_player_lockvault = -1; }; \ No newline at end of file diff --git a/dayz_code/compile/player_lockVault.sqf b/dayz_code/compile/player_lockVault.sqf new file mode 100644 index 000000000..2286aee4a --- /dev/null +++ b/dayz_code/compile/player_lockVault.sqf @@ -0,0 +1,77 @@ +/* +[_obj] spawn player_unlockVault; +*/ +private["_objectID","_objectUID","_obj","_ownerID","_dir","_pos","_bag","_holder","_weapons","_magazines","_backpacks","_objWpnTypes","_objWpnQty","_countr"]; +_obj = _this; +_ownerID = _obj getVariable["CharacterID","0"]; +_objectID = _obj getVariable["ObjectID","0"]; +_objectUID = _obj getVariable["ObjectUID","0"]; +player playActionNow "Medic"; + +player removeAction s_player_lockvault; +s_player_lockvault = -1; + +if(_ownerID == dayz_characterID) then { + _alreadyPacking = _obj getVariable["packing",0]; + + if (_alreadyPacking == 1) exitWith {cutText ["That vault is already being unlocked." , "PLAIN DOWN"]}; + + _obj setVariable["packing",1]; + + _dir = direction _obj; + _pos = getposATL _obj; + [player,"tentpack",0,false] call dayz_zombieSpeak; + sleep 3; + + //place tent (local) + _holder = createVehicle ["VaultStorageLocked",_pos,[], 0, "CAN_COLLIDE"]; + _holder setdir _dir; + player reveal _holder; + + _holder setVariable["CharacterID",_ownerID,true]; + _holder setVariable["ObjectID",_objectID,true]; + _holder setVariable["ObjectUID",_objectUID,true]; + + _weapons = getWeaponCargo _obj; + _magazines = getMagazineCargo _obj; + _backpacks = getBackpackCargo _obj; + + // dayzDeleteObj = [_objectID,_objectUID]; + // publicVariableServer "dayzDeleteObj"; + // if (isServer) then { + // dayzDeleteObj call local_deleteObj; + // }; + + deleteVehicle _obj; + + //Add weapons + _objWpnTypes = _weapons select 0; + _objWpnQty = _weapons select 1; + _countr = 0; + { + _holder addweaponcargoGlobal [_x,(_objWpnQty select _countr)]; + _countr = _countr + 1; + } forEach _objWpnTypes; + + //Add Magazines + _objWpnTypes = _magazines select 0; + _objWpnQty = _magazines select 1; + _countr = 0; + { + _holder addmagazinecargoGlobal [_x,(_objWpnQty select _countr)]; + _countr = _countr + 1; + } forEach _objWpnTypes; + + //Add Backpacks + _objWpnTypes = _backpacks select 0; + _objWpnQty = _backpacks select 1; + _countr = 0; + { + _holder addbackpackcargoGlobal [_x,(_objWpnQty select _countr)]; + _countr = _countr + 1; + } forEach _objWpnTypes; + + cutText ["Your vault has been unlocked", "PLAIN DOWN"]; +} else { + cutText ["You cannot unlock this vault, it is not yours", "PLAIN DOWN"]; +}; \ No newline at end of file diff --git a/dayz_code/compile/player_unlockVault.sqf b/dayz_code/compile/player_unlockVault.sqf new file mode 100644 index 000000000..9d8d1a92f --- /dev/null +++ b/dayz_code/compile/player_unlockVault.sqf @@ -0,0 +1,77 @@ +/* +[_obj] spawn player_unlockVault; +*/ +private["_objectID","_objectUID","_obj","_ownerID","_dir","_pos","_bag","_holder","_weapons","_magazines","_backpacks","_objWpnTypes","_objWpnQty","_countr"]; +_obj = _this; +_ownerID = _obj getVariable["CharacterID","0"]; +_objectID = _obj getVariable["ObjectID","0"]; +_objectUID = _obj getVariable["ObjectUID","0"]; +player playActionNow "Medic"; + +player removeAction s_player_unlockvault; +s_player_unlockvault = -1; + +if(_ownerID == dayz_characterID) then { + _alreadyPacking = _obj getVariable["packing",0]; + + if (_alreadyPacking == 1) exitWith {cutText ["That vault is already being unlocked." , "PLAIN DOWN"]}; + + _obj setVariable["packing",1]; + + _dir = direction _obj; + _pos = getposATL _obj; + [player,"tentpack",0,false] call dayz_zombieSpeak; + sleep 3; + + //place tent (local) + _holder = createVehicle ["VaultStorage",_pos,[], 0, "CAN_COLLIDE"]; + _holder setdir _dir; + player reveal _holder; + + _holder setVariable["CharacterID",_ownerID,true]; + _holder setVariable["ObjectID",_objectID,true]; + _holder setVariable["ObjectUID",_objectUID,true]; + + _weapons = getWeaponCargo _obj; + _magazines = getMagazineCargo _obj; + _backpacks = getBackpackCargo _obj; + + // dayzDeleteObj = [_objectID,_objectUID]; + // publicVariableServer "dayzDeleteObj"; + // if (isServer) then { + // dayzDeleteObj call local_deleteObj; + // }; + + deleteVehicle _obj; + + //Add weapons + _objWpnTypes = _weapons select 0; + _objWpnQty = _weapons select 1; + _countr = 0; + { + _holder addweaponcargoGlobal [_x,(_objWpnQty select _countr)]; + _countr = _countr + 1; + } forEach _objWpnTypes; + + //Add Magazines + _objWpnTypes = _magazines select 0; + _objWpnQty = _magazines select 1; + _countr = 0; + { + _holder addmagazinecargoGlobal [_x,(_objWpnQty select _countr)]; + _countr = _countr + 1; + } forEach _objWpnTypes; + + //Add Backpacks + _objWpnTypes = _backpacks select 0; + _objWpnQty = _backpacks select 1; + _countr = 0; + { + _holder addbackpackcargoGlobal [_x,(_objWpnQty select _countr)]; + _countr = _countr + 1; + } forEach _objWpnTypes; + + cutText ["Your vault has been unlocked", "PLAIN DOWN"]; +} else { + cutText ["You cannot unlock this vault, it is not yours", "PLAIN DOWN"]; +}; \ No newline at end of file diff --git a/dayz_code/init/compiles.sqf b/dayz_code/init/compiles.sqf index 74b514887..b5c777fe7 100644 --- a/dayz_code/init/compiles.sqf +++ b/dayz_code/init/compiles.sqf @@ -28,6 +28,8 @@ if (!isDedicated) then { player_fired = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_fired.sqf"; //Runs when player fires. Alerts nearby Zeds depending on calibre and audial rating player_packTent = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_packTent.sqf"; player_packVault = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_packVault.sqf"; + player_unlockVault = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\vault_unlock.sqf"; + player_lockVault = compile preprocessFileLineNumbers "\z\addons\dayz_code\actions\vault_lock.sqf"; control_zombieAgent = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\control_zombieAgent.sqf"; player_updateGui = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_updateGui.sqf"; player_crossbowBolt = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_crossbowBolt.sqf"; diff --git a/dayz_code/init/variables.sqf b/dayz_code/init/variables.sqf index 733bb95ac..1291c21fc 100644 --- a/dayz_code/init/variables.sqf +++ b/dayz_code/init/variables.sqf @@ -55,6 +55,8 @@ dayz_resetSelfActions = { s_player_butcher = -1; s_player_packtent = -1; s_player_packvault = -1; + s_player_lockvault = -1; + s_player_unlockvault = -1; s_player_fillwater = -1; s_player_fillwater2 = -1; s_player_fillfuel = -1; @@ -171,6 +173,7 @@ dayz_zombieTargetList = [ dayzHit = []; dayzPublishObj = []; //used for eventhandler to spawn a mirror of players tent dayzHideBody = objNull; + dayzPublishVeh = []; // for vehicle traders dayzTraderMenu = []; // For all traders diff --git a/dayz_equip/config.cpp b/dayz_equip/config.cpp index ac14c6400..0aacea45b 100644 --- a/dayz_equip/config.cpp +++ b/dayz_equip/config.cpp @@ -1584,6 +1584,7 @@ class CfgVehicles { class NonStrategic; class BuiltItems: NonStrategic{}; + class BuiltItemsVault: NonStrategic{}; class TrapItems: NonStrategic{}; class Wire_cat1: BuiltItems { @@ -1604,6 +1605,17 @@ class CfgVehicles displayName = "Wire (CAT2)"; model = "\dayz_equip\models\wire_cat2.p3d"; }; + class VaultStorageLocked: BuiltItemsVault + { + scope = 2; + destrType = "DestructNo"; + cost = 100; + model = "\dayz_equip\models\safe1.p3d"; + mapSize = 2; + armor = 2000; + displayName = "Locked Vault"; + vehicleClass = "Fortifications"; + }; class Hedgehog_DZ: BuiltItems { scope = 2; @@ -1923,7 +1935,7 @@ class CfgVehicles transportMaxMagazines = 200; transportMaxWeapons = 10; transportMaxBackpacks = 5; - }; + }; class CardboardBox: ReammoBox {