O Sistema de Banco Avançado, como o próprio nome diz, permite criar eventos de caráter bancário num game/projeto de RPG Maker XP. Com o script implantado, o herói pode depositar ou retirar, itens e dinheiro.
O Sistema de Banco Avançado, como o próprio nome diz, permite criar eventos de caráter bancário num game/projeto de RPG Maker XP. Com o script implantado, o herói pode depositar ou retirar, itens e dinheiro, em eventos que chamam o script call_depository
(olhe a demo disponível para download).
Na demo não é possível ler os comentários, estão todos com ‘????’. Provavelmente perderam-se caracteres especiais. Mas conseguimos achar o código com os comentários originais (alguns estão em japonês)
Para chamar o script no jogo, crie um novo evento. Clique duas vezes na área em branco para chamar a tela de comandos. Na 3° aba selecione o último comando de nome “Chamar script” ou “Call Script”. Nele cole este código: $scene = Scene_Depository.new
Para que este script funcione corretamente, é necessário ter um outro script base, chamado KGC_Module:
################################################################# #######################KGC_Depository############################ ################################################################# # O script permite adicionar o sistema de deposito ou banco, que #permite que os itens ou dinheiro possam ser guardados para depois #serem resgatados, algo semelhante ao Breath of Fire II ################################################################## module KGC #Nome dos menus de comandos DEPOSITORY_COMMAND = [ "Depositar Dinheiro", "Retirar Dinheiro", "Depositar Item", "Retirar Item" ] #Texto que ira aparecer na janela de Ajuda. DEPOSITORY_HELP = [ "Depositar o dinheiro", "Retirar o dinheiro", "Depositar o Item", "Retirar o Item" ] DEPOSITORY_GOLD_DIGITS = 7 #Quantidade de digitos(Dinheiro) DEPOSIT_GOLD = "Quanto?" WDEPOSIT_GOLD = "Quanto?" DEPOSIT_ITEM = "Quanto?" WDEPOSIT_ITEM = "Quanto?" end $imported["Depository"] = true #-------------------------------------------------------------------------- # ● 預かり所呼び出し #-------------------------------------------------------------------------- def call_depository # プレイヤーの姿勢を矯正 $game_player.straighten # 預かり所画面に切り替え $scene = Scene_Depository.new end #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★ #============================================================================== # ■ Game_Party #============================================================================== class Game_Party #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias initialize_KGC_Depository initialize def initialize # 元の処理を実行 initialize_KGC_Depository @deposit_gold = 0 @deposit_item, @deposit_weapon, @deposit_armor = [], [], [] end #-------------------------------------------------------------------------- # ● 預けた金取得 #-------------------------------------------------------------------------- def deposit_gold @deposit_gold = 0 if @deposit_gold == nil return @deposit_gold end #-------------------------------------------------------------------------- # ● 預けた金増加 # number : 増加量 #-------------------------------------------------------------------------- def gain_deposit_gold(number) @deposit_gold = 0 if @deposit_gold == nil @deposit_gold += number end #-------------------------------------------------------------------------- # ● 預けた金減少 # number : 減少量 #-------------------------------------------------------------------------- def lose_deposit_gold(number) self.gain_deposit_gold(-number) end #-------------------------------------------------------------------------- # ● 預けたアイテム取得 # id : ID #-------------------------------------------------------------------------- def deposit_item_number(id) @deposit_item = [] if @deposit_item == nil return @deposit_item[id] != nil ? @deposit_item[id] : 0 end #-------------------------------------------------------------------------- # ● 預けたアイテム増加 # id : ID # number : 個数 #-------------------------------------------------------------------------- def gain_deposit_item(id, number) @deposit_item = [] if @deposit_item == nil @deposit_item[id] = 0 if @deposit_item[id] == nil @deposit_item[id] += number end #-------------------------------------------------------------------------- # ● 預けたアイテム減少 # id : ID # number : 個数 #-------------------------------------------------------------------------- def lose_deposit_item(id, number) self.gain_deposit_item(id, -number) end #-------------------------------------------------------------------------- # ● 預けた武器取得 # id : ID #-------------------------------------------------------------------------- def deposit_weapon_number(id) @deposit_weapon = [] if @deposit_weapon == nil return @deposit_weapon[id] != nil ? @deposit_weapon[id] : 0 end #-------------------------------------------------------------------------- # ● 預けた武器増加 # id : ID # number : 個数 #-------------------------------------------------------------------------- def gain_deposit_weapon(id, number) @deposit_weapon = [] if @deposit_weapon == nil @deposit_weapon[id] = 0 if @deposit_weapon[id] == nil @deposit_weapon[id] += number end #-------------------------------------------------------------------------- # ● 預けた武器減少 # id : ID # number : 個数 #-------------------------------------------------------------------------- def lose_deposit_weapon(id, number) self.gain_deposit_weapon(id, -number) end #-------------------------------------------------------------------------- # ● 預けた防具取得 # id : ID #-------------------------------------------------------------------------- def deposit_armor_number(id) @deposit_armor = [] if @deposit_armor == nil return @deposit_armor[id] != nil ? @deposit_armor[id] : 0 end #-------------------------------------------------------------------------- # ● 預けた防具増加 # id : ID # number : 個数 #-------------------------------------------------------------------------- def gain_deposit_armor(id, number) @deposit_armor = [] if @deposit_armor == nil @deposit_armor[id] = 0 if @deposit_armor[id] == nil @deposit_armor[id] += number end #-------------------------------------------------------------------------- # ● 預けた防具減少 # id : ID # number : 個数 #-------------------------------------------------------------------------- def lose_deposit_armor(id, number) self.gain_deposit_armor(id, -number) end end #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★ #============================================================================== # ■ Window_DepositoryCommand #------------------------------------------------------------------------------ # 預かり所画面で、操作を選択するウィンドウです。 #============================================================================== class Window_DepositoryCommand < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(0, 64, 640, 64) self.y = 128 if $imported["HelpExtension"] self.contents = Bitmap.new(width - 32, height - 32) # コマンド一覧を作成 @commands = KGC::DEPOSITORY_COMMAND @item_max = @commands.size @column_max = @commands.size @item_width = (width - 32) / @commands.size self.back_opacity = 160 self.index = 0 refresh end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh for i in 0...@commands.size rect = Rect.new(@item_width * i, 0, @item_width, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) self.contents.font.color = system_color self.contents.draw_text(rect, @commands[i], 1) end end #-------------------------------------------------------------------------- # ● カーソルの矩形更新 #-------------------------------------------------------------------------- def update_cursor_rect if index != -1 self.cursor_rect.set(@item_width * index, 0, @item_width, 32) end end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help @help_window.set_text(KGC::DEPOSITORY_HELP[self.index]) end end #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★ #============================================================================== # ■ Window_DepositoryGold #------------------------------------------------------------------------------ # 預かり所画面で、金額を入力するウィンドウです。 #============================================================================== class Window_DepositoryGold <Window_Base>= 2 $game_system.se_play($data_system.cursor_se) @index = (@index + 1) % @digits_max end end # カーソル左 if Input.repeat?(Input::LEFT) if @digits_max >= 2 $game_system.se_play($data_system.cursor_se) @index = (@index + @digits_max - 1) % @digits_max end end update_cursor_rect end end #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★ #============================================================================== # ■ Window_DepositoryItem #------------------------------------------------------------------------------ # 預かり所画面で、預けたアイテムの一覧を表示するウィンドウです。 #============================================================================== class Window_DepositoryItem <Window_Selectable> 0 @data.push($data_items[i]) end end for i in 1...$data_weapons.size if $game_party.weapon_number(i) > 0 @data.push($data_weapons[i]) end end for i in 1...$data_armors.size if $game_party.armor_number(i) > 0 @data.push($data_armors[i]) end end else for i in 1...$data_items.size if $game_party.deposit_item_number(i) > 0 @data.push($data_items[i]) end end for i in 1...$data_weapons.size if $game_party.deposit_weapon_number(i) > 0 @data.push($data_weapons[i]) end end for i in 1...$data_armors.size if $game_party.deposit_armor_number(i) > 0 @data.push($data_armors[i]) end end end # 項目数が 0 でなければビットマップを作成し、全項目を描画 @item_max = @data.size if @item_max > 0 self.contents = Bitmap.new(width - 32, row_max * 32) for i in 0...@item_max draw_item(i, type) end end end #-------------------------------------------------------------------------- # ● 項目の描画 # index : 項目番号 # type : 形式 #-------------------------------------------------------------------------- def draw_item(index, type) item = @data[index] case item when RPG::Item number = type == 0 ? $game_party.item_number(item.id) : $game_party.deposit_item_number(item.id) when RPG::Weapon number = type == 0 ? $game_party.weapon_number(item.id) : $game_party.deposit_weapon_number(item.id) when RPG::Armor number = type == 0 ? $game_party.armor_number(item.id) : $game_party.deposit_armor_number(item.id) end x = 4 + index % 2 * (288 + 32) y = index / 2 * 32 rect = Rect.new(x, y, self.width / @column_max - 32, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) bitmap = RPG::Cache.icon(item.icon_name) self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24)) self.contents.draw_text(x + 28, y, 212, 32, item.name, 0) self.contents.draw_text(x + 240, y, 16, 32, ":", 1) self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2) end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help @help_window.set_text(self.item == nil ? "" : self.item.description) end end #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★ #============================================================================== # ■ Window_DepositoryNumber #------------------------------------------------------------------------------ # 預かり所で使用する、数値入力用のウィンドウです。 #============================================================================== class Window_DepositoryNumber <Window_Base>= 2 $game_system.se_play($data_system.cursor_se) @index = (@index + 1) % @digits_max end end # カーソル左 if Input.repeat?(Input::LEFT) if @digits_max >= 2 $game_system.se_play($data_system.cursor_se) @index = (@index + @digits_max - 1) % @digits_max end end update_cursor_rect end end #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★ #============================================================================== # ■ Scene_Depository #------------------------------------------------------------------------------ # 預かり所画面の処理を行うクラスです。 #============================================================================== class Scene_Depository #-------------------------------------------------------------------------- # ● メイン処理 #-------------------------------------------------------------------------- def main # スプライトセット作成 @spriteset = Spriteset_Map.new # 各種ウィンドウを作成 if $imported["HelpExtension"] @dummy_window = Window_Base.new(0, 192, 640, 288) @help_window = Window_HelpExtension.new else @dummy_window = Window_Base.new(0, 128, 640, 352) @help_window = Window_Help.new end @dummy_window.back_opacity = 160 @help_window.back_opacity = 160 @command_window = Window_DepositoryCommand.new @gold_window = Window_DepositoryGold.new @item_window = Window_DepositoryItem.new @number_window = Window_DepositoryNumber.new # ヘルプウィンドウを関連付け @command_window.help_window = @help_window @item_window.help_window = @help_window # トランジション実行 Graphics.transition # メインループ loop do # ゲーム画面を更新 Graphics.update # 入力情報を更新 Input.update # フレーム更新 update # 画面が切り替わったらループを中断 if $scene != self break end end # トランジション準備 Graphics.freeze # 解放 @spriteset.dispose @dummy_window.dispose @help_window.dispose @command_window.dispose @gold_window.dispose @item_window.dispose @number_window.dispose end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update # ウィンドウを更新 @dummy_window.update @help_window.update @command_window.update @gold_window.update @item_window.update @number_window.update # コマンドウィンドウがアクティブの場合: update_command を呼ぶ if @command_window.active update_command return end # ゴールドウィンドウがアクティブの場合: update_gold を呼ぶ if @gold_window.active update_gold return end # アイテムウィンドウがアクティブの場合: update_item を呼ぶ if @item_window.active update_item return end # 個数ウィンドウがアクティブの場合: update_number を呼ぶ if @number_window.active update_number return end end #-------------------------------------------------------------------------- # ● フレーム更新 (コマンドウィンドウがアクティブの場合) #-------------------------------------------------------------------------- def update_command # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # マップ画面に切り替え $scene = Scene_Map.new return end # C ボタンが押された場合 if Input.trigger?(Input::C) # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # カーソル位置で分岐 case @command_window.index when 0 # ゴールドウィンドウに切り替え @gold_window.active = true @gold_window.visible = true @gold_window.reset(0) @help_window.set_text(KGC::DEPOSIT_GOLD) when 1 # ゴールドウィンドウに切り替え @gold_window.active = true @gold_window.visible = true @gold_window.reset(1) @help_window.set_text(KGC::WDEPOSIT_GOLD) when 2 # アイテムウィンドウに切り替え @item_window.active = true @item_window.visible = true @item_window.refresh(0) when 3 # アイテムウィンドウに切り替え @item_window.active = true @item_window.visible = true @item_window.refresh(1) end @command_window.active = false # ダミーウィンドウ消去 @dummy_window.visible = false return end end #-------------------------------------------------------------------------- # ● フレーム更新 (ゴールドウィンドウがアクティブの場合) #-------------------------------------------------------------------------- def update_gold # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # コマンドウィンドウに切り替え @command_window.active = true @gold_window.active = false @gold_window.visible = false @dummy_window.visible = true return end # C ボタンが押された場合 if Input.trigger?(Input::C) # 入力した金額を取得 price = @gold_window.price # 金額が 0 の場合 if price == 0 # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # コマンドウィンドウに切り替え @command_window.active = true @gold_window.active = false @gold_window.visible = false @dummy_window.visible = true return end # ショップ SE を演奏 $game_system.se_play($data_system.shop_se) # カーソル位置で分岐 case @command_window.index when 0 # 預ける $game_party.lose_gold(price) $game_party.gain_deposit_gold(price) when 1 # 引き出す $game_party.gain_gold(price) $game_party.lose_deposit_gold(price) end # ゴールドウィンドウをリセット @gold_window.reset(@command_window.index) return end end #-------------------------------------------------------------------------- # ● フレーム更新 (アイテムウィンドウがアクティブの場合) #-------------------------------------------------------------------------- def update_item # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # コマンドウィンドウに切り替え @command_window.active = true @item_window.active = false @item_window.visible = false @dummy_window.visible = true return end # C ボタンが押された場合 if Input.trigger?(Input::C) # 選択アイテムを取得 @item = @item_window.item # 空欄の場合 if @item == nil # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return end # 個数ウィンドウのアイテムを設定 @number_window.item = @item # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # カーソル位置で分岐 case @command_window.index when 2 # 預ける @number_window.set_text(KGC::DEPOSIT_ITEM) when 3 # 引き出す @number_window.set_text(KGC::WDEPOSIT_ITEM) end # 個数ウィンドウをリセット @number_window.reset(@command_window.index - 2) # 個数ウィンドウに切り替え @item_window.active = false @number_window.active = true @number_window.visible = true return end end #-------------------------------------------------------------------------- # ● フレーム更新 (個数ウィンドウがアクティブの場合) #-------------------------------------------------------------------------- def update_number # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # アイテムウィンドウに切り替え @item_window.active = true @number_window.active = false @number_window.visible = false return end # C ボタンが押された場合 if Input.trigger?(Input::C) # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) number = @number_window.number # カーソル位置で分岐 case @command_window.index when 2 # 預ける case @item when RPG::Item $game_party.lose_item(@item.id, number) $game_party.gain_deposit_item(@item.id, number) when RPG::Weapon $game_party.lose_weapon(@item.id, number) $game_party.gain_deposit_weapon(@item.id, number) when RPG::Armor $game_party.lose_armor(@item.id, number) $game_party.gain_deposit_armor(@item.id, number) end when 3 # 引き出す case @item when RPG::Item $game_party.gain_item(@item.id, number) $game_party.lose_deposit_item(@item.id, number) when RPG::Weapon $game_party.gain_weapon(@item.id, number) $game_party.lose_deposit_weapon(@item.id, number) when RPG::Armor $game_party.gain_armor(@item.id, number) $game_party.lose_deposit_armor(@item.id, number) end end # アイテムウィンドウをリフレッシュ @item_window.refresh(@command_window.index - 2) # アイテムウィンドウに切り替え @item_window.active = true @number_window.active = false @number_window.visible = false return end end end
Obs.: se tiver o problema de acesso de local de memória inválido, ao rodar a demo, veja este post.
Observação: se você gostou deste post ou ele lhe foi útil de alguma forma, por favor considere apoiar financeiramente a Gaming Room. Fico feliz só de ajudar, mas a contribuição do visitante é muito importante para que este site continua existindo e para que eu possa continuar provendo este tipo de conteúdo e melhorar cada vez mais. Acesse aqui e saiba como. Obrigado!