iPhone App Directory
RPG Maker VX
 
Gallery Members Search Calendar Help


Welcome Guest ( Log In | Register )

Collapse

>Announcement

The 2nd Quarter Contest has arrived! Go check it out in the Community Announcements now!
2 Pages V   1 2 >  
Closed TopicStart new topic
> Lock Picking Script (+demo), Pick locks like your favorite dragonborn!
Neon Black
post Feb 13 2012, 02:15 PM
Post #1



Group Icon


Type: Designer
Alignment: Chaotic Neutral




Lock Picking Script V1.0
Created by Neon Black


What is it?
This script is a lock pick system that functions similar to the one from Skyrim and Fallout. The script has a few different options by default and allows for several different outcomes. I've been told by my testers that it's easy, almost simple to use. This script does require 3 different graphics to be placed in the "pictures" folder.

How can I use it?
Place this script anywhere in the materials section above main. If you notice incompatibility with another script, place this script above that script. If you still experience incompatibility issues, please post what scripts you are using as well as what kind of error you are getting.

Usage: lockpick(x)
To call this script, simply create an event and in a script call put "lockpick(x)" where "x" is the difficulty in a numeric value. It is recommended to only use values from 2~8 since anything outside that range seems too easy or too hard. The script will place a different number into a variable defined in the config section depending on the outcome of lock picking. You can then place conditional branches just below the script call with different results depending on the outcome. The variable can have one of three different values: 1 - Lock picking successful. 2 - Lock picking cancelled or player has no picks. 3 - Lock picking failed by breaking all picks. For a more detailed explanation of all the options and uses of the script, see the header in the script or check the demo.

What does it look like?
Spoiler:



What does it work with?
As far as I know, it should work with pretty much everything. Unless someone somehow decided to make a class with the same name or someone is using the same method I added to game_interpreter this script should function flawlessly alongside pretty much everything.

How can I get the code?
Version 1.0 (base script, 2.12.2012) is available only by clicking this link here.

I would like to use this code.
You are free to use, modify, copy and distribute this code at your own leisure and you do not need to credit me directly, however if you use this code or modify it in any way, please leave the names in the credits box at the top of the code and do not remove that section.

Author's Disclaimer:
Back from a bit of a hiatus with a brand new script. I had thought I had seen a Skyrim style lock pick script here before but I can't seem to find it. Maybe it was a request for this particular script. Anyway, one of my friends asked me for a lock script or an unlocking script or something... I dunno, something along the lines of a lock you had to open by force. I misunderstood him to mean the lock picking system from Skyrim. No harm done. In my personal opinion, this script works almost exactly like the one from Skyrim minus leveling up and such. I'm going to add a few other dialogue boxes to this to display difficulty and durability as well as a few other features (I need this script to work differently than it currently does) but this script works perfectly as-is (as far as I can tell) and is by no means incomplete. Please enjoy it.

And for those of you who need the default graphics, they're all in the demo or in the spoiler box directly below. Make sure you save them under the names "Lock", "Pick", and "Key" or change the names in the config section of the script. As previously mentioned, they go in the "pictures" folder.

Spoiler:



This post has been edited by Neon Black: Mar 21 2012, 12:36 PM


--------------------
Go to the top of the page
 
+Quote Post
   
Supergodjesus
post Feb 17 2012, 07:26 PM
Post #2



Group Icon


Type: Designer
Alignment: Unaligned




I'm surprised more people haven't checked this out or commented - it seems like a really cool script! I will give it a try later on and see how it goes.


--------------------
Keep up-to-date with the greatest RPGs ever: Pioneer Valley Games

Need inexpensive art resources? Let me know!


Need AMAZING game music? Note by Note Studios
Go to the top of the page
 
+Quote Post
   
Neon Black
post Feb 17 2012, 09:13 PM
Post #3



Group Icon


Type: Designer
Alignment: Chaotic Neutral




Looks like it just got approved today actually. No worries though, I'm never in any rush; I know the staff is busy. Gonna add a few more features after I finish 4 other scripts I have planned out. Anyway, everyone, lemme know if you need anything on this one.


--------------------
Go to the top of the page
 
+Quote Post
   
zitser of darkne...
post Feb 18 2012, 12:26 AM
Post #4


Godlike Overlord of all HUD and Scriptlets of Divine +12
Group Icon


Type: Coder
Alignment: Chaotic Good




amazing script and well thought out... i see some good prospect for VX even more than ace... now question... how do i unlock the lock.... always getting broken picks.... i just press C button and that spinny thingy spins around and nothin


--------------------
Go to the top of the page
 
+Quote Post
   
Neon Black
post Feb 18 2012, 05:59 AM
Post #5



Group Icon


Type: Designer
Alignment: Chaotic Neutral




QUOTE (zitser of darkness @ Feb 17 2012, 07:26 PM) *
amazing script and well thought out... i see some good prospect for VX even more than ace... now question... how do i unlock the lock.... always getting broken picks.... i just press C button and that spinny thingy spins around and nothin

Much like in Skyrim or Fallout, your lockpick must be in a certain position to unlock the door. The script actually allows 5 different positions to work at a time within 10 degrees of each other to make it a little easier to line the pick up. If the pick is not exactly in this "sweet zone" then the "key" will twist around a certain amount depending on how close you are. Once it's gone as far as it can, the pick will start to shake and if you hold it there too long, the pick will break. If you have the pick in the sweet zone, the "key" will turn and unlock the door. If you're consistently breaking your pick without the "key" you probably have the difficulty of the lock set too high. If your pick breaks almost as soon as you fail to properly unlock the door, you probably have the durability in the script config set too low. I dunno if that answers your question at all. If it's not any of that, it could be an incompatibility with another script, but I highly doubt this in general.


--------------------
Go to the top of the page
 
+Quote Post
   
zitser of darkne...
post Feb 19 2012, 06:22 AM
Post #6


Godlike Overlord of all HUD and Scriptlets of Divine +12
Group Icon


Type: Coder
Alignment: Chaotic Good




i see... so thats how it works... now here is catch man... i am making a dungeons and dragons staret kit for all of us... your lockpick scene is quite invaluable for the game... here is how it works... lockpicking difficulty is capped at 25... while your open lock skill is capped at 20... now if you have thief tool, you decrease difficulty further more... when you manage to get a very powerful thief tool and have a max open lock skill difficulty will be dropped to 1... as in super easy...


--------------------
Go to the top of the page
 
+Quote Post
   
jesse120
post Feb 19 2012, 05:12 PM
Post #7


Master Eventer, Novice scripter, pathetic spriter
Group Icon


Type: Designer
Alignment: Chaotic Good




Could you make an Oblivion style lockpick?


--------------------
I might not post anything for a while, but I am still here, watching. You may not see me, but I see you.
Still taking event requests. Still watching topics. I will see comments to my posts and respond.
I will probably not update any of my scripts for a while.

I have not gone!!!

Spoiler:

Master eventer
Need an unusual event call me and i might be able to make it
ex vehicle, pet
search number
I do take event requests
search number 10519195120
Please don't put this number on any of your own posts or topics
note: the search number will be on any post I make to aid in searching by author. If I forget to put it on a topic please notify me.

I will try to check any posts/PMs around 7:30 AM, 3:00 PM, and after 6 PM most days (time in Pacific Time)

The ultimate video game

Legend of, Elder, Fear, of Fabled, Fallout, Call, of Modern, Gears, of Halo, Metal, Ghost, Assassin, Mass, Homicide, Fantasy, 5
That stands for
Legend of Zelda, Elder Scrolls, ?????, Fable, Fallout, Call of Duty, Modern Warfare, Gears of War, Halo, Metal Gears, Ghost Recon, Assassin's Creed, Mass Effect, Auto Homicide, Final Fantasy, 5
Let me know if you want a game added to the list

If you are a believer of Jesus Christ, believe he is the only way to heaven, and are 100% proud of it, put this in your sig.
Go to the top of the page
 
+Quote Post
   
Neon Black
post Feb 20 2012, 05:02 AM
Post #8



Group Icon


Type: Designer
Alignment: Chaotic Neutral




QUOTE (zitser of darkness @ Feb 19 2012, 01:22 AM) *
i see... so thats how it works... now here is catch man... i am making a dungeons and dragons staret kit for all of us... your lockpick scene is quite invaluable for the game... here is how it works... lockpicking difficulty is capped at 25... while your open lock skill is capped at 20... now if you have thief tool, you decrease difficulty further more... when you manage to get a very powerful thief tool and have a max open lock skill difficulty will be dropped to 1... as in super easy...

If you would like to use my script for your starter kit, feel free to modify it and use it or whatnot as long as you credit me. If you would like me to modify it in any way for the starter kit, I'm gonna need a little bit more info. There is an issue with what you described however. Because of how the "area" of the lock is calculated, there would be pretty much no difference between certain difficulties above 9 other than how fast the pick breaks. Now, I could rewrite how it's calculated, but I'd do that as an add-on. If you'd really like me to, I can add a "levels" add-on for this script that would probably do what you described, but it will be a while 'til I get to it.

QUOTE (jesse120 @ Feb 19 2012, 12:12 PM) *
Could you make an Oblivion style lockpick?

I'll add it to my list. I had considered doing one before doing this script, but someone wanted this one. Wanted to see if anyone besides me wanted an Oblivion style lockpick script before I made one.


--------------------
Go to the top of the page
 
+Quote Post
   
zitser of darkne...
post Feb 20 2012, 09:07 AM
Post #9


Godlike Overlord of all HUD and Scriptlets of Divine +12
Group Icon


Type: Coder
Alignment: Chaotic Good




no no its cool... no need to modify... on account i decided to make lockpicks relatively harder to look at so they mush avoid missing and breaking picks... as for the oblivion styled lockpick.. look at RMVX.net they have such script...


--------------------
Go to the top of the page
 
+Quote Post
   
dartdaman
post Feb 24 2012, 04:48 PM
Post #10



Group Icon


Type: Designer
Alignment: Chaotic Good




this lockpicking system is awesome
you should also make this script for vx ace

This post has been edited by dartdaman: Feb 24 2012, 04:49 PM


--------------------
Go to the top of the page
 
+Quote Post
   
Faalhaasje
post Feb 24 2012, 06:43 PM
Post #11


Dutchman
Group Icon


Type: Coder
Alignment: Chaotic Good




@dartdaman this is a rpgmakervx forum,, so that probably belongs at rpgmakervxace.com tongue.gif

@neon-black awesome script you made!

~Faal


--------------------
Y can't we event our own lives ლ(ಠ益ಠლ
Go to the top of the page
 
+Quote Post
   
Neon Black
post Feb 24 2012, 09:10 PM
Post #12



Group Icon


Type: Designer
Alignment: Chaotic Neutral




QUOTE (dartdaman @ Feb 24 2012, 11:48 AM) *
this lockpicking system is awesome
you should also make this script for vx ace

When I get VX Ace, I'm going to convert all my scripts to Ace. There are certain reasons not worth going into that I don't like Ace, though.


--------------------
Go to the top of the page
 
+Quote Post
   
jesse120
post Feb 24 2012, 10:41 PM
Post #13


Master Eventer, Novice scripter, pathetic spriter
Group Icon


Type: Designer
Alignment: Chaotic Good




You should make it so when you try to open a chest and have no lockpicks it automaticly takes you to the ran out of picks option with out even showing you the lock. Also could you make the variable modifed by a variable so I can make a lockpick skill.


--------------------
I might not post anything for a while, but I am still here, watching. You may not see me, but I see you.
Still taking event requests. Still watching topics. I will see comments to my posts and respond.
I will probably not update any of my scripts for a while.

I have not gone!!!

Spoiler:

Master eventer
Need an unusual event call me and i might be able to make it
ex vehicle, pet
search number
I do take event requests
search number 10519195120
Please don't put this number on any of your own posts or topics
note: the search number will be on any post I make to aid in searching by author. If I forget to put it on a topic please notify me.

I will try to check any posts/PMs around 7:30 AM, 3:00 PM, and after 6 PM most days (time in Pacific Time)

The ultimate video game

Legend of, Elder, Fear, of Fabled, Fallout, Call, of Modern, Gears, of Halo, Metal, Ghost, Assassin, Mass, Homicide, Fantasy, 5
That stands for
Legend of Zelda, Elder Scrolls, ?????, Fable, Fallout, Call of Duty, Modern Warfare, Gears of War, Halo, Metal Gears, Ghost Recon, Assassin's Creed, Mass Effect, Auto Homicide, Final Fantasy, 5
Let me know if you want a game added to the list

If you are a believer of Jesus Christ, believe he is the only way to heaven, and are 100% proud of it, put this in your sig.
Go to the top of the page
 
+Quote Post
   
Neon Black
post Feb 25 2012, 12:11 AM
Post #14



Group Icon


Type: Designer
Alignment: Chaotic Neutral




QUOTE (jesse120 @ Feb 24 2012, 05:41 PM) *
You should make it so when you try to open a chest and have no lockpicks it automaticly takes you to the ran out of picks option with out even showing you the lock.

I was planning on making a few changes concerning how it is handled if the player does not have any lock picks. So this will be an option at that time.

QUOTE (jesse120 @ Feb 24 2012, 05:41 PM) *
Also could you make the variable modifed by a variable so I can make a lockpick skill.

Could you explain this a little more? I'm not quite sure I understand what you mean. I do have a few more plans for this script and your idea might fall in those plans, but I need to un-lazy before I can start on those.


--------------------
Go to the top of the page
 
+Quote Post
   
jesse120
post Feb 25 2012, 01:45 AM
Post #15


Master Eventer, Novice scripter, pathetic spriter
Group Icon


Type: Designer
Alignment: Chaotic Good




I am tinking of having a $game_variable that ajusts the dificulty of a lock slightly. The higher the variable the eayser the lock so it is like a lockpick skill. Also you should have the variable so at cirten levels you have pirks like unbrekalepick. You should also have an item that is an unbreakable pick like skeletons key in oblivion so you dont have to have all picks break on not break.


--------------------
I might not post anything for a while, but I am still here, watching. You may not see me, but I see you.
Still taking event requests. Still watching topics. I will see comments to my posts and respond.
I will probably not update any of my scripts for a while.

I have not gone!!!

Spoiler:

Master eventer
Need an unusual event call me and i might be able to make it
ex vehicle, pet
search number
I do take event requests
search number 10519195120
Please don't put this number on any of your own posts or topics
note: the search number will be on any post I make to aid in searching by author. If I forget to put it on a topic please notify me.

I will try to check any posts/PMs around 7:30 AM, 3:00 PM, and after 6 PM most days (time in Pacific Time)

The ultimate video game

Legend of, Elder, Fear, of Fabled, Fallout, Call, of Modern, Gears, of Halo, Metal, Ghost, Assassin, Mass, Homicide, Fantasy, 5
That stands for
Legend of Zelda, Elder Scrolls, ?????, Fable, Fallout, Call of Duty, Modern Warfare, Gears of War, Halo, Metal Gears, Ghost Recon, Assassin's Creed, Mass Effect, Auto Homicide, Final Fantasy, 5
Let me know if you want a game added to the list

If you are a believer of Jesus Christ, believe he is the only way to heaven, and are 100% proud of it, put this in your sig.
Go to the top of the page
 
+Quote Post
   
Neon Black
post Feb 25 2012, 03:14 AM
Post #16



Group Icon


Type: Designer
Alignment: Chaotic Neutral




QUOTE (jesse120 @ Feb 24 2012, 08:45 PM) *
I am tinking of having a $game_variable that ajusts the dificulty of a lock slightly. The higher the variable the eayser the lock so it is like a lockpick skill. Also you should have the variable so at cirten levels you have pirks like unbrekalepick. You should also have an item that is an unbreakable pick like skeletons key in oblivion so you dont have to have all picks break on not break.

I'll add a few of those options to the script later. When I do update this there will be several new options including things I haven't heard mentioned yet. I made this script to be exactly like Skyrim's because I knew people would want it like that, but I personally need it to be much different for what I'm going to use it for. Maybe I should have called this a version less than 1.0 considering the number of things I'm going to add. Or maybe the new one will just be 2.0.


--------------------
Go to the top of the page
 
+Quote Post
   
jet kast
post Apr 1 2012, 06:42 PM
Post #17



Group Icon


Type: Undisclosed




looks nice im gona download it and compare it with the old lockpicing script that i already know about however this one looks much more promising smile.gif
Go to the top of the page
 
+Quote Post
   
jesse120
post Apr 7 2012, 08:26 PM
Post #18


Master Eventer, Novice scripter, pathetic spriter
Group Icon


Type: Designer
Alignment: Chaotic Good




I have modified this script so that you no longer have to decide if you want to have a breakable pick or not because you can change it any time in the game with a switch. The new script is here.

CODE
###--------------------------------------------------------------------------###
# Lockpick script #
# Version 1.1 #
# #
# Credits: #
# Original code by: Neonblack #
# Modified by: Jesse120 #
# #
# This code is free to use, modify, or distribute whithout credit as long as #
# you DO NOT REMOVE anyone's name from the credits above. If you modify the #
# code you may add your name to the "Modified by:" section. #
###--------------------------------------------------------------------------###

###--------------------------------------------------------------------------###
# Revision information: #
# V.Alpha - 2.11.2012 #
# Wrote main script #
# V1.0 - 2.12.2012 #
# Debbugged, polished, and documented script #
# V1.1 - 4.7.20012 #
# Modified so that breaking a pick is dependent on an in-game switch #
###--------------------------------------------------------------------------###

###--------------------------------------------------------------------------###
# Compatibility: #
# New Scene entirely; should run with just about everything. #
###--------------------------------------------------------------------------###

###--------------------------------------------------------------------------###
# Instructions: #
# Place this script in the "Materials" section of the scripts above main. #
# This script is NOT plug and play and requires additional graphics and #
# several setting changes to work properly. Please be sure you have #
# imported the required graphics before continuing. #
# #
# To use, place a script call in an event and use the following script call: #
# lockpick(x) #
# Define "x" as a numeric value that represents the difficulty of the lock #
# where lower numbers are easier to pick. It is recommended to only use #
# values ranging form 2-8 because 1 seems to be too easy and 9 seems to be #
# too hard. #
# #
# When a lock is picked, one of three different numbers will be returned in #
# pre-determined variable. The numbers are as follows. #
# 1 - Returned if the player picks the lock. #
# 2 - Returned if the player cancels lockpicking. #
# 3 - Returned if the player breaks all their picks. #
# #
# The player must have at least one of a pre-determined item in order to #
# pick a lock. The item is determined in the config section. #
###--------------------------------------------------------------------------###

###--------------------------------------------------------------------------###
# Config: #
# These are the default values used by several of the functions in the #
# script. You may change these values as you find your game requires in #
# order to give the player a better playing experience based on your game. #
# #
module CP # Do not edit #
module LOCKPICK # these two lines #
# #
###----- -----###
# The main game settings are below. These include mose of the sound effects #
# and variable settings in the script. #
# #
module SETTINGS # Do not edit this line #
# #
# The ID number of picks in the database. The player must have a least 1 #
# lockpick in their inventory before they can pick locks. #
PICK_ITEM = 22 # Default = 22 #
# #
# The variable that returns the result of lockpicking success. #
VARIABLE = 1 # Default = 1 #
# #
# The sound effect, volume, and pitch played when starting to pick a lock. #
LOCK_SOUND = "Switch2" # Default = "Switch2" #
LOCK_VOLUME = 60 # Default = 60 #
LOCK_PITCH = 110 # Default = 110 #
# #
# The sound effect, volume, and pitch played when unlocking a lock. #
UNLOCK_SOUND = "Key" # Default = "Key" #
UNLOCK_VOLUME = 80 # Default = 80 #
UNLOCK_PITCH = 100 # Default = 100 #
# #
# The sound effect, volume, and pitch played when breaking a pick. #
BREAK_SOUND = "Sword2" # Default = "Sword2" #
BREAK_VOLUME = 60 # Default = 60 #
BREAK_PITCH = 130 # Default = 130 #
# #
# Determines if lockpicks can be broken and the durability lockpicks have. #
# Higher values in durability will take longer to break. #
BREAK_PICK_SWITCH = 1 # Default = 1 if switch true picks break if not they dont #
DURABILITY = 90 # Default = 90 #
# #
# A dialog box can be drawn in the bottom left corner with the remaining #
# picks in your possession. Setting this to false will not show that box. #
# You may also set the text to be shown in the box. #
SHOW_REMAINING = true # Default = true #
ITEM_NAME = "Lockpicks:" # Default = "Lockpicks:" #
# #
end # Don't edit this line either. #
# #
###----- -----###
# The settings for the graphics are below. Use these to specify the graphics #
# used and the X and Y offsets from the middle of the screen. Note that all #
# graphics must exist in the "pictures" folder. #
# #
module LOCK # Don't touch this line #
# #
# Settings for the lock graphic #
X_OFFSET = 0 # Default = 0 #
Y_OFFSET = 0 # Default = 0 #
GRAPHIC = "Lock" # Default = "Lock" #
# #
end # Don't touch #
module PICK # these two lines #
# #
# Settings for the pick graphic. #
X_OFFSET = 0 # Default = 0 #
Y_OFFSET = 30 # Default = 0 #
GRAPHIC = "Pick" # Default = "Pick" #
# #
end # Don't touch #
module KEY # these two lines #
# #
# Settings for the "key" graphic. #
X_OFFSET = 0 # Default = 0 #
Y_OFFSET = -20 # Default = 0 #
GRAPHIC = "Key" # Default = "Key" #
# #
end # Don't touch #
end # these three #
end # lines #
###--------------------------------------------------------------------------###


###--------------------------------------------------------------------------###
# The following lines are the actual core code of the script. While you are #
# certainly invited to look, modifying it may result in undesirable results. #
# Modify at your own risk! #
###--------------------------------------------------------------------------###


##-----
## Allows for ease of access to the script from an event.
##-----
class Game_Interpreter
def lockpick(diffi, picks = 1)
$scene = Scene_Lockpick.new(diffi, picks)
@wait_count = 1
end
end

##-----
## Draws the window for the number of remaining picks.
##-----
class Window_Picks < Window_Base
def initialize
super(0, 360, 160, WLH + 32)
refresh
end

def draw_picks(value, x, y, width)
pick_name = CP::LOCKPICK::SETTINGS::ITEM_NAME
cx = contents.text_size(pick_name).width
self.contents.font.color = normal_color
self.contents.draw_text(x+cx+2, y, width-cx-2, WLH, value)
self.contents.font.color = system_color
self.contents.draw_text(x, y, width, WLH, pick_name)
end

def refresh
self.contents.clear
itemnum = CP::LOCKPICK::SETTINGS::PICK_ITEM
draw_picks($game_party.item_number($data_items[itemnum]), 4, 0, 120)
end
end


##-----
## The bread and butter of the script.
##-----
class Scene_Lockpick < Scene_Base

##-----
## Initialize scene. Sets difficulty and number of picks available.
##-----
def initialize(diffi, picks = 1)
@diffi = diffi
@picks = picks
@key_rotation = 0
@pick_rotation = 90
@zone = rand(90) * 2
@wobble = 0
@durability = CP::LOCKPICK::SETTINGS::DURABILITY

picksnum = CP::LOCKPICK::SETTINGS::PICK_ITEM
@haspicks = true if $game_party.has_item?($data_items[picksnum])
end

##-----
## Start scene. Draws items on screen.
##-----
def start
super
create_menu_background
@picks_window = Window_Picks.new if CP::LOCKPICK::SETTINGS::SHOW_REMAINING
@picks_window.z = 4 if CP::LOCKPICK::SETTINGS::SHOW_REMAINING
create_lock
create_key
create_pick if @haspicks
key_math
end

##-----
## Terminate scene. Removes drawn items.
##-----
def terminate
super
dispose_menu_background
@picks_window.dispose if CP::LOCKPICK::SETTINGS::SHOW_REMAINING
@lock_sprite.dispose
@key_sprite.dispose
@pick_sprite.dispose if @haspicks
end

##-----
## Update scene. Calls the scene's flesh and blood.
##-----
def update
super
update_pick_command
update_key_position
update_pick_position if @haspicks
end

##-----
## Draws the lock at the start of the scene.
##-----
def create_lock
@lock_sprite = Sprite.new(@viewport1)
@lock_sprite.bitmap = Cache.picture(CP::LOCKPICK::LOCK::GRAPHIC)
@lock_sprite.ox = @lock_sprite.width/2
@lock_sprite.oy = @lock_sprite.height/2
@lock_sprite.x = Graphics.width/2 + CP::LOCKPICK::LOCK::X_OFFSET
@lock_sprite.y = Graphics.height/2 + CP::LOCKPICK::LOCK::Y_OFFSET
@lock_sprite.z = 1
end

##-----
## Draws the key at the start of the scene.
##-----
def create_key
@key_sprite = Sprite.new(@viewport1)
@key_sprite.bitmap = Cache.picture(CP::LOCKPICK::KEY::GRAPHIC)
@key_sprite.ox = @key_sprite.width/2
@key_sprite.oy = @key_sprite.height/2
@key_sprite.x = Graphics.width/2 + CP::LOCKPICK::KEY::X_OFFSET
@key_sprite.y = Graphics.height/2 + CP::LOCKPICK::KEY::Y_OFFSET
@key_sprite.z = 3
@k_rotate = @key_rotation
@key_sprite.angle = @k_rotate * -1
end

##-----
## Updates the rotation of the key each frame.
##-----
def update_key_position
return if @key_rotation == @k_rotate
@k_rotate = @key_rotation
@key_sprite.angle = @k_rotate * -1
end

##-----
## Draws the pick at the start of the scene.
##-----
def create_pick
@pick_sprite = Sprite.new(@viewport1)
@pick_sprite.bitmap = Cache.picture(CP::LOCKPICK::PICK::GRAPHIC)
@pick_sprite.ox = @pick_sprite.width/2
@pick_sprite.oy = @pick_sprite.width/2
@pick_sprite.x = Graphics.width/2 + CP::LOCKPICK::PICK::X_OFFSET
@pick_sprite.y = Graphics.height/2 + CP::LOCKPICK::PICK::Y_OFFSET
@pick_sprite.z = 2
@p_rotate = @pick_rotation
@pick_sprite.angle = @p_rotate - 90
end

##-----
## Updates the rotation of the pick each frame.
##-----
def update_pick_position
return if @pick_rotation == @p_rotate and @wobble == @shake
@p_rotate = @pick_rotation
@shake = @wobble
@pick_sprite.angle = @p_rotate - 90 + @shake
end

##-----
## Quick thing to make the wait method work I guess.
##-----
def update_basic
Graphics.update
Input.update
end

##-----
## Aforementioned wait method.
##-----
def wait(dur)
for i in 0...dur
update_basic
end
end

##-----
## Method called when lock is picked successfully.
##-----
def lock_picked
variable = CP::LOCKPICK::SETTINGS::VARIABLE
$game_variables[variable] = 1
update_key_position
wait(20)
picking_end
end

##-----
## Method called when lockpicking is cancelled.
##-----
def lock_stopped
Sound.play_cancel
variable = CP::LOCKPICK::SETTINGS::VARIABLE
$game_variables[variable] = 2
picking_end
end

##-----
## Method called when lockpicking is failed.
##-----
def no_picks
variable = CP::LOCKPICK::SETTINGS::VARIABLE
$game_variables[variable] = 3
picking_end
end

##-----
## End method that returns to the map.
##-----
def picking_end
$scene = Scene_Map.new
end

##-----
## Method containing all the key commands and input.
##-----
def update_pick_command
if Input.trigger?(Input::cool.gif ##----- Cancel
lock_stopped
elsif Input.trigger?(Input::C) ##----- Key turning input
if @haspicks
lsnd = CP::LOCKPICK::SETTINGS::LOCK_SOUND
lvol = CP::LOCKPICK::SETTINGS::LOCK_VOLUME
lpit = CP::LOCKPICK::SETTINGS::LOCK_PITCH
Audio.se_play("Audio/SE/" + lsnd, lvol, lpit)
else
lock_stopped
end
elsif Input.press?(Input::C)
unless @key_rotation > @max_turn - 2
@key_rotation += 2
else
pick_dura
end
if @key_rotation == 90
lsnd = CP::LOCKPICK::SETTINGS::UNLOCK_SOUND
lvol = CP::LOCKPICK::SETTINGS::UNLOCK_VOLUME
lpit = CP::LOCKPICK::SETTINGS::UNLOCK_PITCH
Audio.se_play("Audio/SE/" + lsnd, lvol, lpit)
lock_picked
end
else ##----- Lockpick movement below
@wobble = 0 unless @wobble == 0
@key_rotation -= 2 unless @key_rotation == 0
@key_rotation = 0 if @key_rotation < 0
if Input.press?(Input::RIGHT)
@pick_rotation += 2 unless @pick_rotation == 180
key_math
elsif Input.press?(Input::LEFT)
@pick_rotation -= 2 unless @pick_rotation == 0
key_math
end
end
end

##-----
## Calculates the math allowing the key to turn.
##-----
def key_math
if ((@zone-4)..(@zone+4)) === @pick_rotation
@max_turn = 90
else
check_spot = @pick_rotation - @zone
check_spot *= -1 if check_spot < 0
check_spot -= 4
check_spot *= @diffi
@max_turn = 90 - check_spot
@max_turn = 0 if @max_turn < 0
end
end

##-----
## Checks the pick's durability with each step.
##-----
def pick_dura
@wobble = rand(5) - 2
if $game_switches[CP::LOCKPICK::SETTINGS::BREAK_PICK_SWITCH] == true
@durability -= @diffi
snap_pick if @durability < 1
end
end

##-----
## Snaps the pick if durability is 0 or lower.
##-----
def snap_pick
lsnd = CP::LOCKPICK::SETTINGS::BREAK_SOUND
lvol = CP::LOCKPICK::SETTINGS::BREAK_VOLUME
lpit = CP::LOCKPICK::SETTINGS::BREAK_PITCH
Audio.se_play("Audio/SE/" + lsnd, lvol, lpit)
for i in 0...5
@pick_sprite.y += 3
update_basic
end
wait(10)
change_pick
end

##-----
## Removes a pick and prepares to change it.
##-----
def change_pick
itemnum = CP::LOCKPICK::SETTINGS::PICK_ITEM
$game_party.lose_item($data_items[itemnum], 1)
@picks_window.refresh if CP::LOCKPICK::SETTINGS::SHOW_REMAINING
unless $game_party.has_item?($data_items[itemnum])
no_picks
else
new_pick
end
end

##-----
## Places a new pick if one is present.
##-----
def new_pick
@key_rotation = 0
@pick_rotation = 90
@wobble = 0
@durability = CP::LOCKPICK::SETTINGS::DURABILITY
@pick_sprite.dispose
create_pick
update_key_position
wait(10)
end

end
##----------------------------------------------------------------------------##
## END OF SCRIPT ##
##----------------------------------------------------------------------------##


Sorry about using a scrolling codebox instead of just code tags but the spoiler tags were acting up.


--------------------
I might not post anything for a while, but I am still here, watching. You may not see me, but I see you.
Still taking event requests. Still watching topics. I will see comments to my posts and respond.
I will probably not update any of my scripts for a while.

I have not gone!!!

Spoiler:

Master eventer
Need an unusual event call me and i might be able to make it
ex vehicle, pet
search number
I do take event requests
search number 10519195120
Please don't put this number on any of your own posts or topics
note: the search number will be on any post I make to aid in searching by author. If I forget to put it on a topic please notify me.

I will try to check any posts/PMs around 7:30 AM, 3:00 PM, and after 6 PM most days (time in Pacific Time)

The ultimate video game

Legend of, Elder, Fear, of Fabled, Fallout, Call, of Modern, Gears, of Halo, Metal, Ghost, Assassin, Mass, Homicide, Fantasy, 5
That stands for
Legend of Zelda, Elder Scrolls, ?????, Fable, Fallout, Call of Duty, Modern Warfare, Gears of War, Halo, Metal Gears, Ghost Recon, Assassin's Creed, Mass Effect, Auto Homicide, Final Fantasy, 5
Let me know if you want a game added to the list

If you are a believer of Jesus Christ, believe he is the only way to heaven, and are 100% proud of it, put this in your sig.
Go to the top of the page
 
+Quote Post
   
Edgewing
post Apr 7 2012, 10:24 PM
Post #19



Group Icon


Type: Artist
Alignment: Unaligned




Great script, 100% will use this, But when i get around to it

Thanks for making this great script

Keep up the great work!

- Edge
Go to the top of the page
 
+Quote Post
   
lynx666
post Jan 2 2014, 07:39 PM
Post #20



Group Icon


Type: Musician




Hi! Im trying to use this script in Rpg maker Vx Ace but I got this message... :

Script 'lockpick' line 522: NameError occurred.
undefined method 'create_game_objects' for class 'Scene_Title'

is there a way to repair it ?
Go to the top of the page
 
+Quote Post
   

2 Pages V   1 2 >
Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 24th April 2014 - 09:55 PM

RPGMakerVX.net is an Privacy Policy, Legal.