Jump to content
  • 0

lock picking doors?


inkko

Question

I thought up an idea where if players had a certain item they would have an option to "lock pick" a door in an attempt to enter someones base. I have the entire script done in the manner that I want, I am just having an issue with the self actions part.

 

The way my script works is as so, and is based of krixes self BB:

 

Player has item in inventory and upon using the action they cannot repeat it for X ammount of seconds. There is the universal medic animation throughout the process and it is interruptable. There is a combat check as well. The actual door opening portion is based completely on luck. A random number between 0 and 1000 is chosen and if it is smaller then 25 you succeed in opening the door, otherwise you fail and have to try again. In addition a number between 0 and 100 is chosen and if the number is below 20 you break your item required to lock pick. Kind of confusing explaining it, but all I need to complete it is the self actions part where I just can't seem to find a way to get it working.

 

Here is the code I have for it so far:

//code by Krixes, re-purposed to other use variables re-named 
if (isnil "lastLockpick") then {
lastLockpick = nil;
};
_ctarget = _this select 3; // getting target passed from self actions
_lockpickUseTime = 10; // Amount of time it takes in second for the player to lockpick
_lockpickLastUsedTime = 30; // Amount of time in seconds before player can use lockpick again after a succesful use
 
 
_lockpickTime = time - lastLockpick; // Variable used for easy reference in determining the self bloodbag cooldown
_lockpickUsageTime = time;
_timeout = player getVariable["combattimeout", 0];
_inCombat = if (_timeout >= diag_tickTime) then { true } else { false };
 
if(_lockpickTime < _lockpickLastUsedTime) exitWith { // If cooldown is not done then exit script
cutText [format["You may not pick a lock so soon please wait %1 more seconds!",round((_lockpickTime - _lockpickLastUsedTime)*-1)], "PLAIN DOWN"]; //display text at bottom center of screen when players cooldown is not done
};
 
if (_inCombat) then { // Check if in combat
    cutText [format["You are in Combat and cannot continue your action"], "PLAIN DOWN"]; //display text at bottom center of screen when in combat
} else {
 
player removeAction s_player_selfLockpick; //remove the action from users scroll menu
 
player playActionNow "Medic"; //play animation
 
////////////////////////////////////////////////
// Fancy cancel if interrupted addition start //
////////////////////////////////////////////////
r_interrupt = false; 
_animState = animationState player; 
r_doLoop = true; 
_started = false; 
_finished = false;
while {r_doLoop} do {
_animState = animationState player;
_isMedic = ["medic",_animState] call fnc_inString;
if (_isMedic) then {
_started = true;
};
if(!_isMedic && !r_interrupt && (time - _lockpickUsageTime) < _lockpickUseTime) then {
player playActionNow "Medic";
_isMedic = true;
};
if (_started && !_isMedic && (time - _lockpickUsageTime) > _lockpickUseTime) then {
r_doLoop = false;
_finished = true;
lastBloodbag = time;
};
if (r_interrupt) then {
r_doLoop = false;
};
sleep 0.1;
};
r_doLoop = false;
///////////////////////////////////////////////
// Fancy cancel if interrupted addition end //
//////////////////////////////////////////////
 
if (_finished) then {
_numbergenerator = round (random 1000);
if (_numbergenerator <= 25) then {
cutText [format["You have successfully lockpicked the door."], "PLAIN DOWN"];
// animate open taken from infistar, maybe a better way to do it [_ctarget ] call player_unlockDoor;?
{_ctarget animate [_x,1];} forEach ["Open_hinge","Open_latch","Lights_1","Lights_2","Open_door","DoorR","LeftShutter","RightShutter"];
} else { 
cutText [format["You have failed lockpicking."], "PLAIN DOWN"];
};
sleep 3;
_numbergenerator2 = round (random 100);
if (_numbergenerator2 < 20) then {
cutText [format["You have broken your lockpicking tool."], "PLAIN DOWN"];
player removeMagazine "ItemHotwireKit";
};
lastLockpick = time;
} else {
// this is for handling if interrupted
r_interrupt = false;
player switchMove "";
player playActionNow "stop";
cutText [format["You have interrupted picking a lock!"], "PLAIN DOWN"]; //display text at bottom center of screen on interrupt
};
};
Link to comment
Share on other sites

6 answers to this question

Recommended Posts

  • 0

 

I thought up an idea where if players had a certain item they would have an option to "lock pick" a door in an attempt to enter someones base. I have the entire script done in the manner that I want, I am just having an issue with the self actions part.

 

The way my script works is as so, and is based of krixes self BB:

 

Player has item in inventory and upon using the action they cannot repeat it for X ammount of seconds. There is the universal medic animation throughout the process and it is interruptable. There is a combat check as well. The actual door opening portion is based completely on luck. A random number between 0 and 1000 is chosen and if it is smaller then 25 you succeed in opening the door, otherwise you fail and have to try again. In addition a number between 0 and 100 is chosen and if the number is below 20 you break your item required to lock pick. Kind of confusing explaining it, but all I need to complete it is the self actions part where I just can't seem to find a way to get it working.

 

Here is the code I have for it so far:

I like the idea. I have not tested this yet (I will try harder in the morning but for now maybe try...

 

maybe place the pickable_door aray in init.sqf above     if (isServer) then {

 

 

place at bottom of  fn_Selfactions

pickable_door = ["Uroven1DrevenaBudka", "Uroven2KladaDomek", "Uroven3DrevenyDomek", "Uroven1VelkaBudka", "Uroven2MalyDomek", "Uroven3VelkyDomek"];
if(_typeOfCursorTarget in pickable_door && _hasHotwireKit && (player distance _cursorTarget < 5)) then {
    if (s_player_selfLockpick < 0) then {
        s_player_selfLockpick = player addAction ["lockpick attempt","custom\lockpick.sqf",cursorTarget, 0, false, true, "",""];
    };
} else {
        player removeAction s_player_selfLockpick;
        s_player_selfLockpick = -1;
};

the pickable_doors I added are actually origins house names.

for non origins replace with the names of the doors you want to be able to pick...

or maybe something like this. 

I dont have time to try to find door names....

 

if(_typeOfCursorTarget in _isModularDoor && _hasHotwireKit && (player distance _cursorTarget < 5)) then {
    if (s_player_selfLockpick < 0) then {
        s_player_selfLockpick = player addAction ["lockpick attempt","custom\lockpick.sqf",cursorTarget, 0, false, true, "",""];
    };
} else {
        player removeAction s_player_selfLockpick;
        s_player_selfLockpick = -1;
};

just threw this together so it most likely will not work but its a start...

 

hope it kinda helps

 

 

Link to comment
Share on other sites

  • 0

this works.....

 

pickable_door = ["Land_DZE_LargeWoodDoorLocked", "Land_DZE_WoodDoorLocked", "Land_DZE_GarageWoodDoorLocked", "CinderWallDoorSmallLocked_DZ"];
if(_typeOfCursorTarget in pickable_door && _hasHotwireKit && (player distance _cursorTarget < 5)) then {
    if (s_player_selfLockpick < 0) then {
        s_player_selfLockpick = player addAction ["lockpick attempt","custom\lockpick.sqf",cursorTarget, 0, false, true, "",""];
    };
} else {
        player removeAction s_player_selfLockpick;
        s_player_selfLockpick = -1;
};
Link to comment
Share on other sites

  • 0

now testing  to get as right click option from lockpick

 

my thoughts are...

 

change the pickable_door to global _pickable_door

_pickable_door = ["Land_DZE_LargeWoodDoorLocked", "Land_DZE_WoodDoorLocked", "Land_DZE_GarageWoodDoorLocked", "CinderWallDoorSmallLocked_DZ"];
if(_typeOfCursorTarget in _pickable_door && _hasHotwireKit && (player distance _cursorTarget < 5)) then {
if (s_player_selfLockpick < 0) then {
        s_player_selfLockpick = player addAction ["lockpick attempt","custom\lockpick.sqf",cursorTarget, 0, false, true, "",""];
    };
} else {
        player removeAction s_player_selfLockpick;
        s_player_selfLockpick = -1;
};

then in lockpick.sqf change

_ctarget = nearestObject [player, "pickable_door"]; // getting target passed from self actions

cant test my server is down atm ;(

 

but add it to your custom right click

maccas extraRc or 

deploy anything overwrites\config

 

first way works this is only [wip] for right click option......

Link to comment
Share on other sites

  • 0

I haven't tested anything new in fn_selfactions, but I know the code works fine. I might make it configurable at the top to change percentages tho instead of scrolling through to find it. Obviously I tested it with the percentage more in my favor tho since I wasn't gonna stand around forever xD I tested it with infistars admin tools on a players door. After succeeding the door still says locked but you are able to open and close the door freely. The reason I want to use the _ctarget the way I had it in my draft was so that the target of what you were looking for was passed through to the script since you should only be able to look at doors.

Link to comment
Share on other sites

  • 0

 

this works.....

 

pickable_door = ["Land_DZE_LargeWoodDoorLocked", "Land_DZE_WoodDoorLocked", "Land_DZE_GarageWoodDoorLocked", "CinderWallDoorSmallLocked_DZ"];
if(_typeOfCursorTarget in pickable_door && _hasHotwireKit && (player distance _cursorTarget < 5)) then {
    if (s_player_selfLockpick < 0) then {
        s_player_selfLockpick = player addAction ["lockpick attempt","custom\lockpick.sqf",cursorTarget, 0, false, true, "",""];
    };
} else {
        player removeAction s_player_selfLockpick;
        s_player_selfLockpick = -1;
};

 

This worked for me but it had one issue. The scroll menu would flicker from certain distances. Also I think I need to change my code to not remove the scroll option since after using it you have to back away from the door and approach it again.

Link to comment
Share on other sites

  • 0

Heres an updated version of what I am using, I added some additional things in the config portion for percentages.

 

// new variable to track used time on script. set to nil initially as time is set to it on use.
// 
if (isnil "lastLockpick") then {
lastLockpick = nil;
};
 
_ctarget = _this select 3;
 
// ----------------------- config -----------------------
_lockpickUseTime = 10; // Amount of time it takes in second for the player to lockpick
_lockpickLastUsedTime = 30; // Amount of time in seconds before player can use lockpick again after a succesful use
// _percentfailrange/_percentfail %chance
_percentfailrange = 1000; // random number between 0 and 1000
_percentfail = 10; // greater number will result in higher chance of sucess
//percentbreakrange/_percentbreak %chance 
_percentbreakrange = 100; // random number between 0 and 100
_percentbreak = 20; // lower number will result in a lower chance of breaking your tool.
// ---------------------- config end ---------------------
 
 
_lockpickTime = time - lastLockpick; // Variable used for easy reference in determining the self bloodbag cooldown
_lockpickUsageTime = time;
_timeout = player getVariable["combattimeout", 0];
_inCombat = if (_timeout >= diag_tickTime) then { true } else { false };
 
if(_lockpickTime < _lockpickLastUsedTime) exitWith { // If cooldown is not done then exit script
cutText [format["You may not pick a lock so soon please wait %1 more seconds!",round((_lockpickTime - _lockpickLastUsedTime)*-1)], "PLAIN DOWN"]; //display text at bottom center of screen when players cooldown is not done
};
 
if (_inCombat) then { // Check if in combat
    cutText [format["You are in Combat and cannot continue your action!"], "PLAIN DOWN"]; //display text at bottom center of screen when in combat
} else {
 
player removeAction s_player_selfLockpick; //remove the action from users scroll menu <- necessary?
 
player playActionNow "Medic"; //play animation
 
////////////////////////////////////////////////
// Fancy cancel if interrupted addition start //
////////////////////////////////////////////////
r_interrupt = false; 
_animState = animationState player; 
r_doLoop = true; 
_started = false; 
_finished = false;
while {r_doLoop} do {
_animState = animationState player;
_isMedic = ["medic",_animState] call fnc_inString;
if (_isMedic) then {
_started = true;
};
if(!_isMedic && !r_interrupt && (time - _lockpickUsageTime) < _lockpickUseTime) then {
player playActionNow "Medic";
_isMedic = true;
};
if (_started && !_isMedic && (time - _lockpickUsageTime) > _lockpickUseTime) then {
r_doLoop = false;
_finished = true;
lastBloodbag = time;
};
if (r_interrupt) then {
r_doLoop = false;
};
sleep 0.1;
};
r_doLoop = false;
///////////////////////////////////////////////
// Fancy cancel if interrupted addition end //
//////////////////////////////////////////////
 
if (_finished) then {
_numbergenerator = round (random _percentfailrange);
if (_numbergenerator <= _percentfail) then {
cutText [format["You have successfully lockpicked the door."], "PLAIN DOWN"];
{_ctarget animate [_x,1];} forEach ["Open_hinge","Open_latch","Lights_1","Lights_2","Open_door","DoorR","LeftShutter","RightShutter"];
} else { 
cutText [format["You have failed lockpicking."], "PLAIN DOWN"];
};
sleep 3;
_numbergenerator2 = round (random _percentbreakrange);
if (_numbergenerator2 < _percentbreak) then {
cutText [format["You have broken your lockpicking tool."], "PLAIN DOWN"];
player removeMagazine "ItemHotwireKit";
};
lastLockpick = time;
} else {
// this is for handling if interrupted
r_interrupt = false;
player switchMove "";
player playActionNow "stop";
cutText [format["You have interrupted picking a lock!"], "PLAIN DOWN"]; //display text at bottom center of screen on interrupt
};
};

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...