[Script] [ACE] [Scene/Menu] Perfect Bank

sanggameboysanggameboy Posts: 1,943Registered
[align=center][size=x-large]Perfect Bank[/size][/align]

[chapter]Giới thiệu[/chapter]
Có chức năng như một ngân hàng. Bạn gửi vào, sau đó rút ra :D

[chapter]Hình ảnh[/chapter]
bankss.png

[chapter]Cách sử dụng[/chapter]
Bỏ trên script Main là được

[chapter]Script[/chapter]
=begin =========================================================================
Dekita's                                                                   v1.0
                              ★ Perfect BANK™ ★

================================================================================
 Script Information:
====================
 This script simply creates a "bank" scene, you can deposit / withdraw
 items, weapons, armors and cash.
 You can also set the bank to already have items ect at the start of the game.
 
================================================================================
 ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
================================================================================
 1. You must give credit to "Dekita"
 2. You are NOT allowed to repost this script.(or modified versions)
 3. You are NOT allowed to convert this script.(into other game engines e.g RGSS2)
 4. You are NOT allowed to use this script for Commercial games.
 5. ENJOY!

"FINE PRINT" 
By using this script you hereby agree to the above terms and conditions, 
 if any violation of the above terms occurs "legal action" may be taken.
Not understanding the above terms and conditions does NOT mean that 
 they do not apply to you.
If you wish to discuss the terms and conditions in further detail you can 
contact me at http://dekitarpg.wordpress.com/ or DekitaRPG@gmail.com 

================================================================================
 History:
=========
 D /M /Y
 22/o1/2o13 - Re-wired Player PC (pokemon script), into a full bank,

================================================================================
 Credit and Thanks to :
=======================
 
================================================================================
 Known Bugs:
============
 N/A
 
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 If a new bug is found please contact me at
 http://dekitarpg.wordpress.com/ 
 
================================================================================
 INSTRUCTIONS:
==============
 Place this script UNDER "▼ Materials" and ABOVE "▼ Main" in your script editor.
        
================================================================================
 Script Calls :
==========
 $game_storage.gain_cash(amount)
 $game_storage.add_to_items(id, amount)
 $game_storage.add_to_weapons(id, amount)
 $game_storage.add_to_armors(id, amount)
 
 The above script calls *should* be fairly obvious, replace id with the id of 
 the item (found in the database). replace amount with the amount you want.
 
 SceneManager.call(Scene_BANK)
 This script call , calls the bank scene.
 
=end #=========================================================================#
module Game_Storage
  
  Initial_CASH = 2000
  
   # Format = [ [item id, amount], [item id, amount] ]
  Initial_Items = [ [1, 1], [2, 2], [3, 3], [4, 4], [5, 4], [6, 4] ]

  # Format = Same As Above.
  Initial_Weapons = [ [1, 1], [2, 2], [3, 3], [4, 4], [5, 4], [6, 4] ]

  # Format = Same As Above.
  Initial_Armors = [ [1, 1], [2, 2], [3, 3], [4, 4], [5, 4], [6, 4] ]

end ; module PC_Scene # DO NOT DELETE THIS LINE !!

  Money_Vocab  = "Money"
  Money_Prefix = "£ "
  Money_Icon   = 361
  
  Items_Vocab   = "Items"
  Weapons_Vocab = "Weapons"
  Armors_Vocab  = "Armors"
  
  Current_Money_Vocab = "In Pocket :"
  Banked_Money_Vocab  = "In Bank :"
  
  Deposit_Vocab   = "Deposit"
  Deposit_Info    = "Deposit Money, Items or Equipment into your account."
  Deposit_Cash    = "Deposit Money into your account."
  Deposit_Items   = "Deposit Items into your account."
  Deposit_Weapons = "Deposit Weapons into your account."
  Deposit_Armors  = "Deposit Armors into your account."
  
  Withdraw_Vocab   = "Withdraw"
  Withdraw_Info    = "Withdraw Money, Items or Equipment from your account."
  Withdraw_Cash    = "Withdraw Money from your account."
  Withdraw_Items   = "Withdraw Items from your account."
  Withdraw_Weapons = "Withdraw Weapons into your account."
  Withdraw_Armors  = "Withdraw Armors into your account."

  # If you hold this key, while on the NUMBER screen, it will increase / decrease
  # the selection amount faster. 
  Key = :SHIFT
  
end                       #####################
                          # CUSTOMISATION END #
                          #####################
#===============================================================================#
#☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
#                                                                               #
#                       http://dekitarpg.wordpress.com/                         #
#                                                                               #
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
#===============================================================================#
# ARE YOU MODIFYING BEYOND THIS POINT? \.\.                                     #
# YES?\.\.                                                                      #
# OMG, REALLY? \|                                                               #
# WELL SLAP MY FACE AND CALL ME A DRAGONITE.\..\..                              #
# I REALLY DIDN'T THINK YOU HAD IT IN YOU.\..\..                                #
#################################################################################
# PC Scene Script 1 :~ Player PC Scene  #   http://dekitarpg.wordpress.com/     #
#################################################################################

$imported = {} if $imported.nil?
$imported[:Dekita_BANK] = true

#===============================================================================#
class Window_Player_PC_Number < Window_ShopNumber                               #
#===============================================================================#

  def initialize(x, y)
    super(x, y, window_height)
  end

  def window_width
    return Graphics.width / 2
  end
  
  def window_height
    return line_height + 24
  end
  
  def refresh
    contents.clear
    draw_the_item
    draw_number
  end
  
  def draw_number
    change_color(normal_color)
    draw_text(cursor_x - 28, item_y, 22, line_height, "×")
    draw_text(cursor_x, item_y, cursor_width - 4, line_height, @number, 2)
  end
  
  def draw_the_item
    if @item == $data_items[0]
      draw_icon(PC_Scene::Money_Icon, 0, item_y, true)
      draw_text(25, item_y, window_width, line_height, PC_Scene::Money_Vocab)
    else
      draw_item_name(@item, 0, item_y)
    end
  end
  
  def item_y
    return 0
  end
  
  def figures
    return 4
  end
  
  def update_number
    if Input.press?(PC_Scene::Key)
      change_number(100)  if Input.repeat?(:UP)
      change_number(-100) if Input.repeat?(:DOWN)
      change_number(10)   if Input.repeat?(:RIGHT)
      change_number(-10)  if Input.repeat?(:LEFT)
    else
      super
    end
  end

  def update_cursor
    cursor_rect.set(0, 0, 0, 0)
  end

  def change_number(amount)
    @number = [[@number + amount, @max].min, 0].max
  end

  def set(item, max, price, currency_unit = nil)
    @item = item
    @max = max
    @price = price
    @currency_unit = currency_unit if currency_unit
    @number = @item == $data_items[0] ? 0 : 1
    refresh
  end

end

#==============================================================================
class Window_PC_GOLD < Window_Gold
#==============================================================================

  def window_width
    return ((Graphics.width / 4 * 2))
  end

  def refresh
    contents.clear
    draw_gold
  end
  
  def draw_gold
    x = 0 ; y = 0 
    change_color(normal_color)
    draw_text(x, y, window_width, line_height, PC_Scene::Current_Money_Vocab)
    draw_text(x, y, window_width-24, line_height, unit + value.to_s, 2)
  end
  
  def unit
    PC_Scene::Money_Prefix
  end

end
#==============================================================================
class Window_PC_GOLD_InBank < Window_PC_GOLD
#==============================================================================
  
  def draw_gold
    x = 0 ; y = 0 
    change_color(normal_color)
    draw_text(x, y, window_width, line_height, PC_Scene::Banked_Money_Vocab)
    draw_text(x, y, window_width-24, line_height, unit + value.to_s, 2)
  end
  
  def value
    $game_storage.cash
  end
  
end

#==============================================================================
class Window_Player_PC_Command < Window_Command
#==============================================================================

  def initialize(x, y)
    super(x, y)
    draw_items_info
    type
  end
  
  def change_type(type = :items)
    @type = type
  end
  
  def type
    @type
  end
  
  def window_width
    return Graphics.width - (Graphics.width / 4 * 2)
  end
  
  def window_height
    return Graphics.height - fitting_height(6)
  end
  
  def make_command_list
    case @type
    when :items
    	for item in $game_storage.items
        add_item_command(item)
		  end
    when :weapons
    	for item in $game_storage.weapons
        add_item_command(item)
		  end      
    when :armors
    	for item in $game_storage.armors
        add_item_command(item)
		  end      
    end
	end
  
	def add_item_command(item)
		add_command(""  , :avail_item, true)
	end  
 
  def draw_items_info
    x = 0 ; y = 0
    case @type
    when :items
      for item in $game_storage.items
        y = draw_infoo(x, y, item)
      end
    when :weapons
      for item in $game_storage.weapons
        y = draw_infoo(x, y, item)
      end
    when :armors
      for item in $game_storage.armors
        y = draw_infoo(x, y, item)
      end
    end
  end
  
  def draw_infoo(x, y, item)
    draw_icon(item[0].icon_index, x, y, true)
    draw_text(x+25, y, window_width-50, line_height, item[0].name, 0)
    draw_text(x, y, window_width-25, line_height, "×#{item[1]} ", 2)
    return y + line_height
  end
  
  def refresh
    super
    draw_items_info
  end
  
end

#==============================================================================
class Window_Player_PC_Bag_Command < Window_Player_PC_Command
#==============================================================================
  
  def make_command_list
    case @type
    when :items
    	for item in $game_party.items
        add_item_command(item)
		  end
    when :weapons
    	for item in $game_party.weapons
        add_item_command(item)
		  end      
    when :armors
    	for item in $game_party.armors
        add_item_command(item)
		  end      
    end
	end
  
	def add_item_command(item)
		add_command(""  , :avail_item, true)
	end  
 
  def draw_items_info
    x = 0
    y = 0
    case @type
    when :items
      for item in $game_party.items
        y = draw_infoo(x, y, item)
      end
    when :weapons
      for item in $game_party.weapons
        y = draw_infoo(x, y, item)
      end
    when :armors
      for item in $game_party.armors
        y = draw_infoo(x, y, item)
      end
    end
  end

  def draw_infoo(x, y, item)
    item_count = $game_party.item_number(item)
    draw_icon(item.icon_index, x, y, true)
    draw_text(x+25, y, window_width-50, line_height, item.name, 0)
    draw_text(x, y, window_width-25, line_height, "×#{item_count} ", 2)
    return y + line_height
  end
  
end

#==============================================================================
class Window_Player_PC_Action_Command < Window_HorzCommand
#==============================================================================

  def window_width
    return Graphics.width
  end
  
  def make_command_list
    add_command(PC_Scene::Deposit_Vocab,  :deposit)
    add_command(PC_Scene::Withdraw_Vocab, :withdraw)
	end
  
  def col_max
    return 2
  end
  
end

#==============================================================================
class Window_Player_PC_Action_Command_2 < Window_Player_PC_Action_Command
#==============================================================================

  def make_command_list
    add_command(PC_Scene::Money_Vocab,   :cash)
    add_command(PC_Scene::Items_Vocab,   :items)
    add_command(PC_Scene::Weapons_Vocab, :weapons)
    add_command(PC_Scene::Armors_Vocab,  :armors)
	end
  
  def col_max
    return 4
  end
  
end

#==============================================================================
class Scene_BANK < Scene_Base
#==============================================================================
  
  def start
    super
    create_help_window
    create_action_commands
    create_action_commands_2
    create_main_commands
    create_player_bag_commands
    create_number_window
    create_gold_window
    create_bankgold_window
  end
  
  def create_help_window
    @help_window = Window_Help.new
    @help_window.viewport = @viewport
  end

  def create_gold_window
    @gold_window = Window_PC_GOLD.new
    @gold_window.x = 0
    @gold_window.y = @action_com_wind.y + @action_com_wind.height
  end  

  def create_bankgold_window
    @bankgold_window = Window_PC_GOLD_InBank.new
    @bankgold_window.x = ((Graphics.width / 4 * 2))
    @bankgold_window.y = @action_com_wind.y + @action_com_wind.height
  end  

  def create_action_commands
    wx = 0
    wy = @help_window.height
    @action_com_wind = Window_Player_PC_Action_Command.new(wx, wy)
    @action_com_wind.set_handler(:deposit, method(:command_trigger_nxt_choice))
    @action_com_wind.set_handler(:withdraw, method(:command_trigger_nxt_choice))
    @action_com_wind.set_handler(:cancel,    method(:return_scene))
    @my_current_symbol = :deposit
  end
  
  def create_action_commands_2
    wx = 0
    wy = @help_window.height
    @action_com_wind_2 = Window_Player_PC_Action_Command_2.new(wx, wy)
    @action_com_wind_2.set_handler(:cash,      method(:command_trigger_cash))
    @action_com_wind_2.set_handler(:items,     method(:command_trigger_items))
    @action_com_wind_2.set_handler(:weapons,   method(:command_trigger_weapons))
    @action_com_wind_2.set_handler(:armors,    method(:command_trigger_armors))
    @action_com_wind_2.set_handler(:cancel,    method(:command_back_to_firstchoice))
    @action_com_wind_2.deactivate
    @action_com_wind_2.select(-1)
    @action_com_wind_2.hide
  end
  
  def create_main_commands
    wx = Graphics.width / 2
    wy = @action_com_wind.y + (@action_com_wind.height * 2)
    @main_com_wind = Window_Player_PC_Command.new(wx, wy)
    @main_com_wind.set_handler(:avail_item, method(:command_items))
    @main_com_wind.set_handler(:cancel,     method(:command_back_to_2nd_choice))
    @main_com_wind.deactivate
    @main_com_wind.select(-1)
  end
    
  def create_player_bag_commands
    wx = 0
    wy = @action_com_wind.y + (@action_com_wind.height * 2)
    @bag_com_wind = Window_Player_PC_Bag_Command.new(wx, wy)
    @bag_com_wind.set_handler(:avail_item, method(:command_items))
    @bag_com_wind.set_handler(:cancel,     method(:command_back_to_2nd_choice))
    @bag_com_wind.deactivate
    @bag_com_wind.select(-1)
  end
    
  def create_number_window
    wx = Graphics.width / 4
    wy = @action_com_wind.y + @action_com_wind.height
    @number_window = Window_Player_PC_Number.new(wx, wy)
    @number_window.viewport = @viewport
    @number_window.set_handler(:ok,     method(:confirm_numbers))
    @number_window.set_handler(:cancel, method(:cancel_numbers))
    @number_window.hide
  end

  def command_trigger_nxt_choice
    @action_com_wind.hide
    @action_com_wind_2.show
    @action_com_wind_2.activate
    @action_com_wind_2.select(0)
  end
  
  def command_trigger_cash
    item = $data_items[0]
    case @action_com_wind.current_symbol
    when :deposit  ; max = $game_party.gold
      price = $game_party.gold == 0 ? 0 : 1
    when :withdraw ; max = $game_storage.cash
      price = $game_storage.cash == 0 ? 0 : 1
    end
    @action_com_wind_2.deactivate
    @number_window.set(item, max, price)
    @number_window.open
    @number_window.activate
    @number_window.show
  end
  
  def command_trigger_items
    @action_com_wind_2.deactivate
    case @action_com_wind.current_symbol
    when :deposit
      @bag_com_wind.activate
      @bag_com_wind.select(0)
    when :withdraw
      @main_com_wind.activate
      @main_com_wind.select(0)
    end
  end
  
  def command_trigger_weapons
    @action_com_wind_2.deactivate
    case @action_com_wind.current_symbol
    when :deposit
      @bag_com_wind.activate
      @bag_com_wind.select(0)
    when :withdraw
      @main_com_wind.activate
      @main_com_wind.select(0)
    end
  end
  
  def command_trigger_armors
    @action_com_wind_2.deactivate
    case @action_com_wind.current_symbol
    when :deposit
      @bag_com_wind.activate
      @bag_com_wind.select(0)
    when :withdraw
      @main_com_wind.activate
      @main_com_wind.select(0)
    end
  end
  
  def command_back_to_firstchoice
    @action_com_wind_2.deactivate
    @action_com_wind_2.select(-1)
    @action_com_wind_2.hide
    @action_com_wind.show
    @action_com_wind.activate
  end
  
  def command_back_to_2nd_choice
    @main_com_wind.deactivate
    @main_com_wind.select(-1)
    @bag_com_wind.deactivate
    @bag_com_wind.select(-1)
    @action_com_wind_2.activate
  end

	def command_items
    case @action_com_wind_2.current_symbol
    when:items
      case @action_com_wind.current_symbol
      when :deposit
        item = $data_items[$game_party.items[@bag_com_wind.index].id]
        max = $game_party.item_number(item)
      when :withdraw
        item = $game_storage.items[@main_com_wind.index][0]
        max = $game_storage.items[@main_com_wind.index][1]
      end
    when :weapons
      case @action_com_wind.current_symbol
      when :deposit
        item = $data_weapons[$game_party.weapons[@bag_com_wind.index].id]
        max = $game_party.item_number(item)
      when :withdraw
        item = $game_storage.weapons[@main_com_wind.index][0]
        max = $game_storage.weapons[@main_com_wind.index][1]
      end
    when :armors
      case @action_com_wind.current_symbol
      when :deposit
        item = $data_armors[$game_party.armors[@bag_com_wind.index].id]
        max = $game_party.item_number(item)
      when :withdraw
        item = $game_storage.armors[@main_com_wind.index][0]
        max = $game_storage.armors[@main_com_wind.index][1]
      end
    end
    price = 1
    @number_window.set(item, max, price)
    @number_window.activate
    @number_window.show
	end
	
  def confirm_numbers
    case @action_com_wind.current_symbol
    when :deposit
      case @action_com_wind_2.current_symbol
      when :cash
        deposit_cash(@number_window.number)
        @action_com_wind_2.activate
      when :items
        deposit_items(@number_window.number)
        @bag_com_wind.activate
      when :weapons
        deposit_weapons(@number_window.number)
        @bag_com_wind.activate
      when :armors
        deposit_armors(@number_window.number)
        @bag_com_wind.activate
      end
    when :withdraw
      case @action_com_wind_2.current_symbol
      when :cash
        withdraw_cash(@number_window.number)
        @action_com_wind_2.activate
      when :items
        withdraw_items(@number_window.number)
        @main_com_wind.activate
      when :weapons
        withdraw_weapons(@number_window.number)
        @main_com_wind.activate
      when :armors
        withdraw_armors(@number_window.number)
        @main_com_wind.activate
      end
    end
    @number_window.deactivate
    @number_window.hide
  end
  
  def cancel_numbers
    case @action_com_wind.current_symbol
    when :deposit
      case @action_com_wind_2.current_symbol
      when :cash
        @action_com_wind_2.activate
      when :items, :weapons, :armors
        @bag_com_wind.activate
      end
    when :withdraw
      case @action_com_wind_2.current_symbol
      when :cash
        @action_com_wind_2.activate
      when :items, :weapons, :armors
        @main_com_wind.activate
      end
    end
    @number_window.deactivate
    @number_window.hide
  end

  def deposit_cash(amount)
    $game_party.lose_gold(amount)
    $game_storage.gain_cash(amount)
    @gold_window.refresh
    @bankgold_window.refresh
  end
  
  def withdraw_cash(amount)
    $game_party.gain_gold(amount)
    $game_storage.lose_cash(amount)
    @gold_window.refresh
    @bankgold_window.refresh
  end
  
  def deposit_items(amount)
    inv_item = $game_party.items[@bag_com_wind.index].id
    $game_party.lose_item($data_items[inv_item], amount)
    already_had_item = false
    $game_storage.items.each {|item| 
    item[1] += amount if item[0].id == inv_item
    already_had_item = true if item[0].id == inv_item ; }
    $game_storage.add_to_items(inv_item, amount) if !already_had_item
    @bag_com_wind.refresh
    @main_com_wind.refresh
    @bag_com_wind.activate
  end
  
  def withdraw_items(amount)
    gsi = $game_storage.items[@main_com_wind.index]
    gsi[1] -= amount
    $game_party.gain_item(gsi[0], amount)
    if gsi[1] < 1
      $game_storage.items.delete_at(@main_com_wind.index)
      @main_com_wind.index -= 1
    end
    @main_com_wind.refresh
    @bag_com_wind.refresh
    @main_com_wind.activate
  end

  def deposit_weapons(amount)
    inv_item = $game_party.weapons[@bag_com_wind.index].id
    $game_party.lose_item($data_weapons[inv_item], amount)
    already_had_item = false
    $game_storage.weapons.each {|item| 
    item[1] += amount if item[0].id == inv_item
    already_had_item = true if item[0].id == inv_item ; }
    $game_storage.add_to_weapons(inv_item, amount) if !already_had_item
    @bag_com_wind.refresh
    @main_com_wind.refresh
    @bag_com_wind.activate
  end
  
  def withdraw_weapons(amount)
    gsi = $game_storage.weapons[@main_com_wind.index]
    gsi[1] -= amount
    $game_party.gain_item(gsi[0], amount)
    if gsi[1] < 1
      $game_storage.weapons.delete_at(@main_com_wind.index)
      @main_com_wind.index -= 1
    end
    @main_com_wind.refresh
    @bag_com_wind.refresh
    @main_com_wind.activate
  end

  def deposit_armors(amount)
    inv_item = $game_party.armors[@bag_com_wind.index].id
    $game_party.lose_item($data_armors[inv_item], amount)
    already_had_item = false
    $game_storage.items.each {|item| 
    item[1] += amount if item[0].id == inv_item
    already_had_item = true if item[0].id == inv_item ; }
    $game_storage.add_to_armors(inv_item, amount) if !already_had_item
    @bag_com_wind.refresh
    @main_com_wind.refresh
    @bag_com_wind.activate
  end
  
  def withdraw_armors(amount)
    gsi = $game_storage.armors[@main_com_wind.index]
    gsi[1] -= amount
    $game_party.gain_item(gsi[0], amount)
    if gsi[1] < 1
      $game_storage.armors.delete_at(@main_com_wind.index)
      @main_com_wind.index -= 1
    end
    @main_com_wind.refresh
    @bag_com_wind.refresh
    @main_com_wind.activate
  end

  def update
    super
    update_help_text
    update_wind_type
  end

  def update_help_text
    if @action_com_wind.active
      update_text_one
    elsif @action_com_wind_2.active
      update_text_two
    elsif @main_com_wind.active
      update_text_three
    end
  end
  
  def update_text_one
    text = @action_com_wind.current_symbol == :deposit ? 
    PC_Scene::Deposit_Info : PC_Scene::Withdraw_Info
    @help_window.set_text(text)
  end
  
  def update_text_two
    case @action_com_wind_2.current_symbol
    when :cash  ; 
      text = @action_com_wind.current_symbol == :deposit ? 
      PC_Scene::Deposit_Cash : PC_Scene::Withdraw_Cash
    when :items ; text = PC_Scene::Withdraw_Info
      text = @action_com_wind.current_symbol == :deposit ? 
      PC_Scene::Deposit_Items : PC_Scene::Withdraw_Items
    when :weapons ; text = PC_Scene::Withdraw_Info
      text = @action_com_wind.current_symbol == :deposit ? 
      PC_Scene::Deposit_Weapons : PC_Scene::Withdraw_Weapons
    when :armors ; text = PC_Scene::Withdraw_Info
      text = @action_com_wind.current_symbol == :deposit ? 
      PC_Scene::Deposit_Armors : PC_Scene::Withdraw_Armors
    end
    @help_window.set_text(text)
  end

  def update_text_three
    case @action_com_wind_2.current_symbol
#    when :cash  ; 
    when :items ; text = PC_Scene::Withdraw_Info
      text = $game_storage.items[@main_com_wind.index][0]
    when :weapons ; text = PC_Scene::Withdraw_Info
      text = $game_storage.weapons[@main_com_wind.index][0]
    when :armors ; text = PC_Scene::Withdraw_Info
      text = $game_storage.armors[@main_com_wind.index][0]
    end
    @help_window.set_item(text)
  end
  
  
  def update_wind_type
    if @main_com_wind.type != @action_com_wind_2.current_symbol
      @main_com_wind.change_type(@action_com_wind_2.current_symbol) 
      @main_com_wind.refresh
    end
    if @bag_com_wind.type != @action_com_wind_2.current_symbol
      @bag_com_wind.change_type(@action_com_wind_2.current_symbol) 
      @bag_com_wind.refresh
    end
  end
  
end
#===============================================================================#
#                   PC Scene Script 1(Player PC Scene) END                      #
#===============================================================================#
#                      http://dekitarpg.wordpress.com/                          #
#===============================================================================#
module DataManager
#===============================================================================#
  
  class << self ; 
    alias :cgo_game_storage :create_game_objects
    alias :msc_game_storage :make_save_contents
    alias :esc_game_storage :extract_save_contents
  end
  
  def self.create_game_objects
    cgo_game_storage 
    $game_storage = PC_Storage.new
  end

  def self.make_save_contents
    contents = msc_game_storage 
    contents[:game_storage] = $game_storage
    contents
  end
  
  def self.extract_save_contents(contents)
    esc_game_storage(contents)
    $game_storage = contents[:game_storage]
  end
  
end

#==============================================================================
class PC_Storage
#==============================================================================
  
  attr_reader :cash
  attr_reader :items
  attr_reader :weapons
  attr_reader :armors

  def initialize
    setup
  end

  def setup
    @cash    = get_initial_stored_cash
    @items   = get_initial_stored_items
    @weapons = get_initial_stored_weapons
    @armors  = get_initial_stored_armors
  end

  def get_initial_stored_cash
    Game_Storage::Initial_CASH
  end
  
  def get_initial_stored_items
    items = []
    for item_info in Game_Storage::Initial_Items
      next if item_info[0] == nil || item_info[0] <= 0
      items.push([ $data_items[item_info[0]] , item_info[1] ]) 
    end
    items
  end

  def get_initial_stored_weapons
    items = []
    for item_info in Game_Storage::Initial_Weapons
      next if item_info[0] == nil || item_info[0] <= 0
      items.push([ $data_weapons[item_info[0]] , item_info[1] ]) 
    end
    items
  end

  def get_initial_stored_armors
    items = []
    for item_info in Game_Storage::Initial_Armors
      next if item_info[0] == nil || item_info[0] <= 0
      items.push([ $data_armors[item_info[0]] , item_info[1] ]) 
    end
    items
  end

  def add_to_items(item_id, amount)
    return if item_id == nil || item_id <= 0 || amount == nil || amount <= 0
    @items.push([$data_items[item_id], amount])
  end

  def add_to_weapons(item_id, amount)
    return if item_id == nil || item_id <= 0 || amount == nil || amount <= 0
    @items.push([$data_weapons[item_id], amount])
  end

  def add_to_armors(item_id, amount)
    return if item_id == nil || item_id <= 0 || amount == nil || amount <= 0
    @items.push([$data_armors[item_id], amount])
  end

  def gain_cash(amount)
    @cash += amount
  end

  def lose_cash(amount)
    @cash -= amount
    @cash = 0 if @cash < 0
  end
  
end

#===============================================================================#
#                               - SCRIPT END -                                  #
#===============================================================================#
#                      http://dekitarpg.wordpress.com/                          #
#===============================================================================#

[chapter]Điều khoản sử dụng[/chapter]
Không được phép sử dụng script này trong dự án thương mại.
ONLY FREE

[chapter]Credit[/chapter]
Dekita

Comments

  • leequangsonleequangson Posts: 730Registered
    Mấy cái script này có nhan nhản
    Ủng hộ post +1
  • gaubaccucgaubaccuc Posts: 22Registered
    cho hỏi làm sao để kích hoạt dc nó
  • David ChaseDavid Chase Posts: 1,766Registered
    Cái này thích hợp với city role đấy
    nhưng nó là VX!
    tại sao lại như thế :((
  • sanggameboysanggameboy Posts: 1,943Registered
    gaubaccuc wrote:
    cho hỏi làm sao để kích hoạt dc nó

    Trong bảng Event bạn thêm 1 lệnh GỌI SCRIPT và copy cái này vào:
    SceneManager.call(Scene_BANK)

    Ngoài ra:
    $game_storage.gain_cash(số lượng) (tăng tiền)
    $game_storage.add_to_items(số thứ tự item trong database, số lượng)
    $game_storage.add_to_weapons(số thứ tự vũ khí trong database, số lượng)
    $game_storage.add_to_armors(số thứ tự giáp trong database, số lượng)
  • gaubaccucgaubaccuc Posts: 22Registered
    Trong bảng Event bạn thêm 1 lệnh GỌI SCRIPT và copy cái này vào:
    SceneManager.call(Scene_BANK)

    Ngoài ra:
    $game_storage.gain_cash(số lượng) (tăng tiền)
    $game_storage.add_to_items(số thứ tự item trong database, số lượng)
    $game_storage.add_to_weapons(số thứ tự vũ khí trong database, số lượng)
    $game_storage.add_to_armors(số thứ tự giáp trong database, số lượng)
    [/quote]
    Mấy cái $game mình để trong SCRIPT EDITOR hay chung với cái Event
  • sanggameboysanggameboy Posts: 1,943Registered
    gaubaccuc wrote:
    Trong bảng Event bạn thêm 1 lệnh GỌI SCRIPT và copy cái này vào:
    SceneManager.call(Scene_BANK)

    Ngoài ra:
    $game_storage.gain_cash(số lượng) (tăng tiền)
    $game_storage.add_to_items(số thứ tự item trong database, số lượng)
    $game_storage.add_to_weapons(số thứ tự vũ khí trong database, số lượng)
    $game_storage.add_to_armors(số thứ tự giáp trong database, số lượng)
    Mấy cái $game mình để trong SCRIPT EDITOR hay chung với cái Event
    [/quote]

    Call Script trong bảng Event
  • gaubaccucgaubaccuc Posts: 22Registered
    Bạn có demo không ? Nếu có cho mình dc ko ?
  • sanggameboysanggameboy Posts: 1,943Registered
    gaubaccuc wrote:
    Bạn có demo không ? Nếu có cho mình dc ko ?

    Demo để làm gì?
    Copy Script vào dự án của bạn thì xong ngay mà.
    Mấy cái này mù Script cũng làm được -.-
    Vì đã có sẵn hướng dẫn bằng tiếng Anh trong script. Bạn chỉ cần đọc
    và tự mình nghiên cứu tí là được. ;)
Sign In or Register to comment.