#============================================================================== # ○RGSS2 掘り出し物ショップ #作成者:riru/ガラス細工の夢幻 #http://garasuzaikunomugen.web.fc2.com/index.html #通常のショップとは別に、一つずつだけ販売できるショップの項目を増やせます。 #要するに黄金の太陽のアレです #(再定義がそこそこ多いです。なるべく素材の上部に入れてください #<使い方> #まず、このスクリプトの仕様上1つのイベントに複数のショップの処理があった場合でも掘り出し物の売り切れ情報は共通になってしまいます。 #(例:1つのイベントでショップの処理を2回し、1回目で掘り出し物Aを買うと2回目のリストにある掘り出し物Aはすでに売り切れ状態になっている #ご了承ください。 # #掘り出し物にしたいアイテムや武器、防具のメモ欄に #<ほりだしもの> #と記入します。あとは通常ショップのリストに一緒に入れれば勝手に掘り出し物のリストのほうに入ってくれます。 #ですので、一つのアイテムが通常ショップと掘り出し物ショップの2つに出ることはありません。 #同じアイテムを掘り出し物で出したいという場合は別枠で新たに作って出品してください # #*更新履歴* #2018/1/31 公開 #============================================================================== #============================================================================ # ■ カスタマイズ項目 #============================================================================ RIRU_FIND_VOCAB = "掘り出し物"#売る、買うのところに出る文字です #============================================================================== # ■ Scene_Shop #------------------------------------------------------------------------------ #  ショップ画面の処理を行うクラスです。 #============================================================================== class Scene_Shop < Scene_Base #-------------------------------------------------------------------------- # ● 開始処理 #-------------------------------------------------------------------------- alias riru_horidasi_start start def start riru_horidasi_start @find_window = Window_ShopFind.new(0, 112) @find_window.active = false @find_window.visible = false @find_window.help_window = @help_window end #-------------------------------------------------------------------------- # ● 終了処理 #-------------------------------------------------------------------------- alias riru_horidasi_terminate terminate def terminate riru_horidasi_terminate @find_window.dispose end #-------------------------------------------------------------------------- # ● フレーム更新(再定義 #-------------------------------------------------------------------------- def update super update_menu_background @help_window.update @command_window.update @gold_window.update @dummy_window.update @buy_window.update @sell_window.update @number_window.update @status_window.update @find_window.update#riru追加 if @command_window.active update_command_selection elsif @buy_window.active update_buy_selection elsif @find_window.active#riru追加 update_find_selection elsif @sell_window.active update_sell_selection elsif @number_window.active update_number_input end end #-------------------------------------------------------------------------- # ● コマンドウィンドウの作成(再定義 #-------------------------------------------------------------------------- def create_command_window s1 = Vocab::ShopBuy s2 = RIRU_FIND_VOCAB s3 = Vocab::ShopSell s4 = Vocab::ShopCancel @command_window = Window_Command.new(384, [s1, s2, s3, s4], 4) @command_window.y = 56 if $game_temp.shop_purchase_only @command_window.draw_item(1, false) end end #-------------------------------------------------------------------------- # ● コマンド選択の更新(再定義 #-------------------------------------------------------------------------- def update_command_selection if Input.trigger?(Input::B) Sound.play_cancel $scene = Scene_Map.new elsif Input.trigger?(Input::C) case @command_window.index when 0 # 購入する Sound.play_decision @command_window.active = false @dummy_window.visible = false @buy_window.active = true @buy_window.visible = true @buy_window.refresh @status_window.visible = true when 1 # 掘り出し物 Sound.play_decision @command_window.active = false @dummy_window.visible = false @find_window.active = true @find_window.visible = true @find_window.refresh @status_window.visible = true when 2 # 売却する if $game_temp.shop_purchase_only Sound.play_buzzer else Sound.play_decision @command_window.active = false @dummy_window.visible = false @sell_window.active = true @sell_window.visible = true @sell_window.refresh end when 3 # やめる Sound.play_decision $scene = Scene_Map.new end end end #-------------------------------------------------------------------------- # ● 掘り出し物アイテム選択の更新 #-------------------------------------------------------------------------- def update_find_selection @status_window.item = @buy_window.item if Input.trigger?(Input::B) Sound.play_cancel @command_window.active = true @dummy_window.visible = true @find_window.active = false @find_window.visible = false @status_window.visible = false @status_window.item = nil @help_window.set_text("") return end if Input.trigger?(Input::C) @item = @find_window.item number = $game_party.item_number(@item) if @item.is_a?(RPG::Weapon) i_cat = 0 elsif @item.is_a?(RPG::Armor) i_cat = 1 elsif @item.is_a?(RPG::Item) i_cat = 2 end if @item == nil or @item.price > $game_party.gold or number == 99||$game_system.find_soldout_info[$game_map.map_id][$riru_horidasi_v].include?([i_cat,@item.id]) Sound.play_buzzer else Sound.play_decision max = 1 @find_window.active = false @find_window.visible = false @number_window.set(@item, max, @item.price) @number_window.active = true @number_window.visible = true end end end #-------------------------------------------------------------------------- # ● 個数入力の更新 #-------------------------------------------------------------------------- def update_number_input if Input.trigger?(Input::B) cancel_number_input elsif Input.trigger?(Input::C) decide_number_input end end #-------------------------------------------------------------------------- # ● 個数入力のキャンセル(再定義 #-------------------------------------------------------------------------- def cancel_number_input Sound.play_cancel @number_window.active = false @number_window.visible = false case @command_window.index when 0 # 購入する @buy_window.active = true @buy_window.visible = true when 1 # 掘り出し物 @find_window.active = true @find_window.visible = true when 2 # 売却する @sell_window.active = true @sell_window.visible = true @status_window.visible = false end end #-------------------------------------------------------------------------- # ● 個数入力の決定(再定義 #-------------------------------------------------------------------------- def decide_number_input Sound.play_shop @number_window.active = false @number_window.visible = false case @command_window.index when 0 # 購入する $game_party.lose_gold(@number_window.number * @item.price) $game_party.gain_item(@item, @number_window.number) @gold_window.refresh @buy_window.refresh @status_window.refresh @buy_window.active = true @buy_window.visible = true when 1 # ほりだし $game_party.lose_gold(@number_window.number * @item.price) $game_party.gain_item(@item, @number_window.number) if @item.is_a?(RPG::Weapon) i_cat = 0 elsif @item.is_a?(RPG::Armor) i_cat = 1 elsif @item.is_a?(RPG::Item) i_cat = 2 end $game_system.find_soldout_info[$game_map.map_id][$riru_horidasi_v].push([i_cat,@item.id]) @gold_window.refresh @find_window.refresh @status_window.refresh @find_window.active = true @find_window.visible = true when 2 # 売却する $game_party.gain_gold(@number_window.number * (@item.price / 2)) $game_party.lose_item(@item, @number_window.number) @gold_window.refresh @sell_window.refresh @status_window.refresh @sell_window.active = true @sell_window.visible = true @status_window.visible = false end end end #============================================================================== # ■ Window_ShopBuy #------------------------------------------------------------------------------ #  ショップ画面で、購入できる商品の一覧を表示するウィンドウです。 #============================================================================== class Window_ShopBuy < Window_Selectable #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- alias riru_findbuy_refresh refresh def refresh @data2 = [] for goods_item2 in @shop_goods case goods_item2[0] when 0 item = $data_items[goods_item2[1]] when 1 item = $data_weapons[goods_item2[1]] when 2 item = $data_armors[goods_item2[1]] end hantei = /<ほりだしもの>/ =~ item.note if item != nil&& hantei == nil @data2.push(goods_item2) end end @shop_goods = @data2 riru_findbuy_refresh end end #============================================================================== # ■ Window_ShopFind #------------------------------------------------------------------------------ #  ショップ画面で、掘り出し物の一覧を表示するウィンドウです。 #============================================================================== class Window_ShopFind < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 # x : ウィンドウの X 座標 # y : ウィンドウの Y 座標 #-------------------------------------------------------------------------- def initialize(x, y) super(x, y, 304, 304) @shop_goods = $game_temp.shop_goods refresh self.index = 0 end #-------------------------------------------------------------------------- # ● アイテムの取得 #-------------------------------------------------------------------------- def item return @data[self.index] end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh @data2 = [] for goods_item2 in @shop_goods case goods_item2[0] when 0 item = $data_items[goods_item2[1]] when 1 item = $data_weapons[goods_item2[1]] when 2 item = $data_armors[goods_item2[1]] end hantei = /<ほりだしもの>/ =~ item.note if item != nil&& hantei != nil @data2.push(goods_item2) end end @shop_goods = @data2 @data = [] for goods_item in @shop_goods case goods_item[0] when 0 item = $data_items[goods_item[1]] when 1 item = $data_weapons[goods_item[1]] when 2 item = $data_armors[goods_item[1]] end if item != nil @data.push(item) end end @item_max = @data.size create_contents for i in 0...@item_max draw_item(i) end end #-------------------------------------------------------------------------- # ● 項目の描画 # index : 項目番号 #-------------------------------------------------------------------------- def draw_item(index) item = @data[index] number = $game_party.item_number(item) $game_system.find_soldout_info[$game_map.map_id] = [] if $game_system.find_soldout_info[$game_map.map_id]==nil $game_system.find_soldout_info[$game_map.map_id][$riru_horidasi_v] = [] if $game_system.find_soldout_info[$game_map.map_id][$riru_horidasi_v]==nil if item.is_a?(RPG::Weapon) i_cat = 0 elsif @item.is_a?(RPG::Armor) i_cat = 1 elsif @item.is_a?(RPG::Item) i_cat = 2 end enabled = (item.price <= $game_party.gold and number < 99 && !$game_system.find_soldout_info[$game_map.map_id][$riru_horidasi_v].include?([i_cat,item.id])) rect = item_rect(index) self.contents.clear_rect(rect) draw_item_name(item, rect.x, rect.y, enabled) rect.width -= 4 self.contents.draw_text(rect, item.price, 2) end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help @help_window.set_text(item == nil ? "" : item.description) end end #============================================================================== # ■ Game_System #============================================================================== class Game_System attr_accessor :find_soldout_info #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias riru_soldout_initialize initialize def initialize riru_soldout_initialize @find_soldout_info = [] if @find_soldout_info==nil @find_soldout_info[0] = [] if @find_soldout_info[0]==nil end end #============================================================================== # ■ Game_Interpreter #------------------------------------------------------------------------------ #  イベントコマンドを実行するインタプリタです。このクラスは Game_Map クラス、 # Game_Troop クラス、Game_Event クラスの内部で使用されます。 #============================================================================== class Game_Interpreter #-------------------------------------------------------------------------- # ● ショップの処理 #-------------------------------------------------------------------------- alias riru_horidasi_command_302 command_302 def command_302 $riru_horidasi_v = @event_id riru_horidasi_command_302 end end