~ Lock Pick System(otwieranie skrzyń za pomocą wytrycha) ~
Krótki opis:
chcesz otworzyc skrzynie nie potrzebujesz już klucza wystarczy wytrych
Autor:
Dargor
Kompatybilność:
RPG Maker XP
Skrypt:
Spoiler:
Kod:
#==============================================================================
# ** Lock Pick System
#------------------------------------------------------------------------------
# Author: Dargor
# Requested by: Isopaha
# Version 1.6
# 25/06/2007
#==============================================================================
# * Instructions
#------------------------------------------------------------------------------
# - Setup an event and use the call script command:
# $scene = Scene_LockPick.new(event_id, lock_level, max_try)
# max_try: maximum number of trys before the lock is broken.
# When set to -1, the lock can't be broken
#------------------------------------------------------------------------------
# * Note
#------------------------------------------------------------------------------
# - Thanks to Isopaha for requesting the script! And don't forget to
# give me credits!
#==============================================================================
module Lockpicking
Actors = [1,2]
Classes = [1,2,3]
Use_Actors_Level = [2]
Exp_Curve_File = "Data/Lockpick_Exp_Curve.rxdata"
#--------------------------------------------------------------------------
# * Generate Experience Curve
#--------------------------------------------------------------------------
def self.generate_exp_curve(base_exp = 2)
file = File.new(Exp_Curve_File, "w")
code = IO.readlines(Exp_Curve_File)
for i in 0...100
last_exp = 1 if last_exp.nil?
formula = base_exp + last_exp + rand(3)
exp = [[formula, last_exp+rand(2)].max, 9999].min
code[i] = "Level #{i+1} = #{exp}\n"
last_exp = exp
end
file.write(code)
end
end
#==============================================================================
# ** Game_Temp
#------------------------------------------------------------------------------
# This class handles temporary data that is not included with save data.
# Refer to "$game_temp" for the instance of this class.
#==============================================================================
class Game_Temp
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :lockpick_success
attr_accessor :lockpick_actor
attr_accessor :lockpick_target_level
attr_accessor :lockpick_levelup_flag
attr_accessor :lockpick_use
#--------------------------------------------------------------------------
# * Alias Listing
#--------------------------------------------------------------------------
alias dargor_lock_temp_initialize initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
dargor_lock_temp_initialize
@lockpick_success = false
@lockpick_actor = nil
@lockpick_target_level = 1
@lockpick_levelup_flag = []
@lockpick_use = 20
end
#--------------------------------------------------------------------------
# * Repair Lock Pick (#use)
#--------------------------------------------------------------------------
def repair_lockpick(value=20)
@lockpick_use = value
end
end
#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
# This class handles data surrounding the system. Backround music, etc.
# is managed here as well. Refer to "$game_system" for the instance of
# this class.
#==============================================================================
class Game_System
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :lockpick_id
#--------------------------------------------------------------------------
# * Alias Listing
#--------------------------------------------------------------------------
alias dargor_lock_system_initialize initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
dargor_lock_system_initialize
@lockpick_id = 33
end
end
#==============================================================================
# ** Game_Actor
#------------------------------------------------------------------------------
# This class handles the actor. It's used within the Game_Actors class
# ($game_actors) and refers to the Game_Party class ($game_party).
#==============================================================================
class Game_Actor
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :lockpicking_level
attr_accessor :lockpicking_level_max
attr_accessor :lockpicking_exp
#--------------------------------------------------------------------------
# * Alias Listing
#--------------------------------------------------------------------------
alias dargor_lock_actor_setup setup
#--------------------------------------------------------------------------
# * Setup
# actor_id : actor ID
#--------------------------------------------------------------------------
def setup(actor_id)
dargor_lock_actor_setup(actor_id)
@lockpicking_level = 1
@lockpicking_level_max = 100
@lockpicking_exp = read_exp
end
def can_lockpick?
return (Lockpicking::Actors.include?(id) and
Lockpicking::Classes.include?(@class_id))
end
#--------------------------------------------------------------------------
# * Lock Pick (Lock picking process)
#--------------------------------------------------------------------------
def lockpick
# Store the target lock level into lock_level
lock_level = $game_temp.lockpick_target_level
# Succes rate formula (depends on the lock picking level type)
if Lockpicking::Use_Actors_Level.include?(@id)
success_rate = (@level*100)/lock_level
@lockpicking_level = @level
else
success_rate = (@lockpicking_level*100)/lock_level
end
# If lock pick use is 0, unequip it (Used when lock pick is a RPG::Weapon)
if $game_temp.lockpick_use == 0
#$game_temp.lockpick_actor.equip(0, 0)
#$game_party.lose_weapon($game_system.lockpick_id, 1)
return
else
$game_temp.lockpick_use -= 1
end
# Success Randomization
if rand(100) <= success_rate
# Skip exp/level step if using actor's level instead of
# lock picking level
unless Lockpicking::Use_Actors_Level.include?(@id)
last_level = @lockpicking_level
@lockpicking_exp = 0 if @lockpicking_exp.nil?
@lockpicking_exp += 1
check_lockpicking_level
# Check for lock picking level up
if last_level < @lockpicking_level
$game_temp.lockpick_levelup_flag[@actor_id] = true
else
$game_temp.lockpick_levelup_flag[@actor_id] = false
end
end
# Success
$game_temp.lockpick_success = true
return
else
# Failure
$game_temp.lockpick_success = false
return
end
end
#--------------------------------------------------------------------------
# * Read Current Lock Picking Exp
#--------------------------------------------------------------------------
def read_exp
return 0 if @lockpicking_level == @lockpicking_level_max
Lockpicking.generate_exp_curve unless FileTest.exist?(Lockpicking::Exp_Curve_File)
file = File.open(Lockpicking::Exp_Curve_File)
until file.eof?
data = file.readline
line = data.dup
if data.include?("Level #{@lockpicking_level}")
now_exp = line.split(' = ')
exp = now_exp[1].to_i
return exp
end
end
end
#--------------------------------------------------------------------------
# * Read Lock Picking Exp Needed For Next Level
#--------------------------------------------------------------------------
def exp_needed
return if @lockpicking_level == @lockpicking_level_max
unless FileTest.exist?(Lockpicking::Exp_Curve_File)
Lockpicking.generate_exp_curve
end
next_level = @lockpicking_level+1
file = File.open(Lockpicking::Exp_Curve_File)
until file.eof?
data = file.readline
line = data.dup
if data.include?("Level #{next_level}")
now_exp = line.split(' = ')
exp = now_exp[1].to_i
return exp
end
end
end
#--------------------------------------------------------------------------
# * Check Lockpicking Level
#--------------------------------------------------------------------------
def check_lockpicking_level
if @lockpicking_exp >= exp_needed
@lockpicking_level += 1
end
return @lockpicking_level
end
end
#==============================================================================
# ** Game_Event
#------------------------------------------------------------------------------
# This class deals with events. It handles functions including event page
# switching via condition determinants, and running parallel process events.
# It's used within the Game_Map class.
#==============================================================================
class Game_Event < Game_Character
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :broken # broken
#--------------------------------------------------------------------------
# * Alias Listing
#--------------------------------------------------------------------------
alias lockpick_event_initialize initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(map_id, event)
@broken = false
lockpick_event_initialize(map_id, event)
end
#--------------------------------------------------------------------------
# * Broken?
#--------------------------------------------------------------------------
def broken?
return @broken
end
end
Nie możesz pisać nowych tematów Nie możesz odpowiadać w tematach Nie możesz zmieniać swoich postów Nie możesz usuwać swoich postów Nie możesz głosować w ankietach Nie możesz załączać plików na tym forum Możesz ściągać załączniki na tym forum