Ogłoszenie 

Uwaga! To forum jest w trybie offline.
Wszelką pomoc uzyskasz pod adresem
forum.ultimateam.pl


Administracja Forum


Poprzedni temat «» Następny temat
otwieranie skrzyn za pomoca wyrtycha
Autor Wiadomość
pool123 




Preferowany:
RPG Maker XP

Dołączył: 30 Lip 2012
Posty: 2
Wysłany: Wto 21 Sie, 2012 10:13
otwieranie skrzyn za pomoca wyrtycha
~ 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

#==============================================================================
# ** Window_LockLevel
#------------------------------------------------------------------------------
#  This window displays lock picking variables (User level, Target level, #use).
#==============================================================================

class Window_LockLevel < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(16,16,240,128)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.back_opacity = 160
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    if $game_temp.lockpick_actor.nil?
      return
    end
    # Draw User Lock Picking Level
    self.contents.font.color = system_color
    self.contents.draw_text(0,0,200,32,'Lock Picking Level:')
    self.contents.font.color = normal_color
    if Lockpicking::Use_Actors_Level.include?($game_temp.lockpick_actor.id)
      lockpicking_level = $game_temp.lockpick_actor.level.to_s
      self.contents.draw_text(0,0,200,32,lockpicking_level,2)
    else
      lockpicking_level = $game_temp.lockpick_actor.lockpicking_level.to_s
      self.contents.draw_text(0,0,200,32,lockpicking_level,2)
    end
    # Draw Target Lock Level
    self.contents.font.color = system_color
    self.contents.draw_text(0,32,160,32,'Target Lock Level:')
    self.contents.font.color = normal_color
    lock_level = $game_temp.lockpick_target_level.to_s
    self.contents.draw_text(0,32,200,32,lock_level,2)
    # Draw Lock Pick #use
    self.contents.font.color = system_color
    self.contents.draw_text(0,64,160,32,'Use:')
    self.contents.font.color = normal_color
    use = $game_temp.lockpick_use.to_s
    self.contents.draw_text(0,64,200,32,use,2)
  end
end

#==============================================================================
# ** Scene_LockPick
#------------------------------------------------------------------------------
#  This class performs lock picking screen processing.
#==============================================================================

class Scene_LockPick
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(event, level, max_try=-1)
    @event = $game_map.events[event]
    $game_temp.lockpick_target_level = level
    @max_try = max_try
  end
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    @step = 0
    @spriteset = Spriteset_Map.new
    @lockpick_level = Window_LockLevel.new
    @lockpick_message = Window_Help.new
    @lockpick_message.visible = false
    @lockpick_message.y = 416
    @lockpick_message.back_opacity = 160
    @lockpick_message.pause = true
    @commands = []
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      @commands << actor.name if actor.can_lockpick?
    end
    @lockpick_commands = Window_Command.new(160,@commands)
    @lockpick_commands.x = 16
    @lockpick_commands.y = @lockpick_level.y + @lockpick_level.height
    @lockpick_commands.back_opacity = 160
    # Execute transition
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Refresh map
    $game_map.refresh
    # Prepare for transition
    Graphics.freeze
    @spriteset.dispose
    # Dispose of windows
    @lockpick_commands.dispose
    @lockpick_level.dispose
    @lockpick_message.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    $game_party.refresh
    @lockpick_commands.update
    @lockpick_message.update
    @lockpick_level.refresh
    $game_temp.lockpick_actor = $game_party.actors[@lockpick_commands.index]
    unless @lockpick_message.visible
      equipped_weapon = $game_temp.lockpick_actor.weapon_id
      if Input.trigger?(Input::C) #and equipped_weapon == $game_system.lockpick_id
        $game_system.se_play($data_system.decision_se)
        $game_temp.lockpick_actor.lockpick
        unless @max_try == -1 and not @event.broken
          @max_try -= 1
          @lockpick_message.visible = true
          if @max_try == 0
            @lockpick_message.set_text('Lock broken.',1)
            @event.broken = true
            @step = 3
            return
          end
        end
        if $game_temp.lockpick_use == 0
          @lockpick_message.set_text('Lock pick used up!',1)
          @step = 3
          return
        end
        if $game_temp.lockpick_success
          @lockpick_message.set_text('Lock pick success!',1)
          key = [$game_map.map_id, @event.id, "A"]
          $game_self_switches[key] = true
          $game_map.need_refresh = true
          if $game_temp.lockpick_levelup_flag[$game_temp.lockpick_actor.id]
            @step = 1
          else
            @step = 2
          end
        else
          @lockpick_message.set_text('Lock pick failed.',1)
          @step = 3
        end
        return
      #elsif Input.trigger?(Input::C) and equipped_weapon != $game_system.lockpick_id
       # name = $game_temp.lockpick_actor.name
       # @lockpick_message.set_text("#{name} doesn't have a lock pick!",1)
       # @step = 3
      elsif Input.trigger?(Input::B)
        $game_temp.lockpick_target_level = nil
        $game_temp.lockpick_actor = nil
        $scene = Scene_Map.new
        return
      end
    else
      actor_id = $game_temp.lockpick_actor.id
      if Input.trigger?(Input::C)
        #$game_system.se_play($data_system.decision_se)
        case @step
        when 1
          name = $game_temp.lockpick_actor.name
          new_level = $game_temp.lockpick_actor.lockpicking_level
          @lockpick_message.set_text("#{name}'s lock picking raised to level #{new_level}!",1)
          $game_temp.lockpick_levelup_flag[actor_id] == false
          @step = 2
        when 2
          $scene = Scene_Map.new
          return
        when 3
          @step = 0
          @lockpick_message.visible = false
        end
      end
    end
  end
end


Screeny:
Spoiler:



Demo:
niepotrzebne
________________________
Gość Od Kozaków gorsi są tchórze
 
 
noorbert 




Preferowany:
RPG Maker XP

Dołączył: 17 Mar 2012
Posty: 71
Wysłany: Wto 21 Sie, 2012 10:54
Takie coś to ja kiedyś zrobiłem na zwykłych zdarzeniach. Tylke nie wyglądało to tak dobrze jak na screenie.
________________________

 
 
Nex 




Preferowany:
RPG Maker XP

Pomógł: 15 razy
Dołączył: 27 Paź 2012
Posty: 145
Wysłany: Czw 22 Lis, 2012 17:38
Coś takiego już widziałem ale to jest chyba lepsze bo ma więcej szczegółów
 
 
Wyświetl posty z ostatnich:   
Odpowiedz do tematu
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
Dodaj temat do Ulubionych
Wersja do druku

Skocz do:  

Powered by phpBB modified by Przemo © 2003 phpBB Group | Template Klam by Ayene