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
};
};
Question
inkko
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:
Link to comment
Share on other sites
6 answers to this question
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now