#============================================================================== # ■ VX-RGSS2-16-gld クエストシステム【ギルド】 by Claimh #------------------------------------------------------------------------------ #【イベントスクリプト操作】 #◆ギルドの呼び出し # call_guild(ギルドID) もしくは $scene = Scene_Guild.new(ギルドID) # ・普通のギルド # ギルドIDは0にするか、省略してください。 # ・特定ギルドでのみ受け付けるクエストがあるギルド # ギルドIDに適切な値を設定してください。 # 普通のギルド用のクエストに加えて、 # StGuildクラスで特定ギルドに指定されたクエストが受付られます。 #============================================================================== class Scene_Guild < Scene_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 # id : ギルドID #-------------------------------------------------------------------------- def initialize(id=0) @id = id end #-------------------------------------------------------------------------- # ● 開始処理 #-------------------------------------------------------------------------- def start create_menu_background @cmd = Window_GuildCmd.new @list = Window_QuestList.new(-1, @id) @info = Window_QuestInfo.new @list.help_window = @info @cmd.help_window = @list @rank = Window_QuestRank.new(true) @cation = Window_GuildCation.new @select = Window_GuildSelect.new @result = Window_QuestResult.new if Quest::GUILD_LIST.size <= 1 @cmd.visible = false @cmd.active = false @list.active = true end end #-------------------------------------------------------------------------- # ● 終了処理 #-------------------------------------------------------------------------- def terminate dispose_menu_background @cmd.dispose @list.dispose @info.dispose @rank.dispose @cation.dispose @select.dispose @result.dispose end #---------------------------------------------------------------------------- # ● フレーム更新 #---------------------------------------------------------------------------- def update if @cation.visible @cation.update if Input.trigger?(Input::C) Sound.play_decision @cation.visible = false elsif Input.trigger?(Input::B) Sound.play_cancel @cation.visible = false end elsif @result.visible @result.update if Input.trigger?(Input::C) Sound.play_decision @result.visible = false @list.data_refresh(Quest::REPORT, true, @list.index) elsif Input.trigger?(Input::B) Sound.play_cancel @result.visible = false @list.data_refresh(Quest::REPORT, true, @list.index) end elsif @select.active update_select elsif @cmd.active update_cmd elsif @list.active update_list end end #---------------------------------------------------------------------------- # ● フレーム更新 (コマンドウィンドウ) #---------------------------------------------------------------------------- def update_cmd @cmd.update if Input.trigger?(Input::B) Sound.play_cancel $scene = Scene_Map.new elsif Input.trigger?(Input::C) Sound.play_decision case Quest::GUILD_LIST[@cmd.index] when Quest::REPORT, Quest::SHOP @cmd.active = false; @list.active = true when Quest::EXIT $scene = Scene_Map.new end return end end #---------------------------------------------------------------------------- # ● フレーム更新 (リストウィンドウ) #---------------------------------------------------------------------------- def update_list if Input.repeat?(Input::L) if @info.enable_up? Sound.play_cursor @info.page_up end return elsif Input.repeat?(Input::R) if @info.enable_down? Sound.play_cursor @info.page_down end return end @list.update if Input.trigger?(Input::B) Sound.play_cancel if Quest::GUILD_LIST.size > 1 @cmd.active = true @list.active = false else $scene = Scene_Map.new end elsif Input.trigger?(Input::C) unless @list.current_index_active? Sound.play_buzzer @cation.set_text(@list.cause) else if Quest::GUILD_LIST[@cmd.index] == Quest::SHOP and $game_system.quest.over_playing? Sound.play_buzzer @cation.set_text("進行中のクエスト数が\\n制限数を超過しています") return end Sound.play_decision @select.select_start(Quest::GUILD_LIST[@cmd.index]) end elsif Input.trigger?(Input::LEFT) if @info.enable_left? Sound.play_cursor @info.page_left end elsif Input.trigger?(Input::RIGHT) if @info.enable_right? Sound.play_cursor @info.page_right end end end #---------------------------------------------------------------------------- # ● フレーム更新 (選択ウィンドウ) #---------------------------------------------------------------------------- def update_select @select.update if Input.trigger?(Input::B) Sound.play_cancel @select.active = false @select.visible = false elsif Input.trigger?(Input::C) if @select.index == 0 case Quest::GUILD_LIST[@cmd.index] when Quest::REPORT; quest_report when Quest::SHOP; quest_start else; p "異常: Scene_Guild.update_select#{Quest::GUILD_LIST[@cmd.index]}" end else Sound.play_decision end @select.active = false @select.visible = false end end #---------------------------------------------------------------------------- # ● クエストの受付 #---------------------------------------------------------------------------- def quest_start if @list.current_item.commission > 0 # 手数料ある場合はShop-SE Sound.play_shop else Sound.play_decision end @list.quest_start @rank.refresh end #---------------------------------------------------------------------------- # ● クエストの報告 #---------------------------------------------------------------------------- def quest_report if @list.quest_clear?(@list.index) @list.quest_clear @result.refresh(@list.current_item) @rank.refresh elsif @list.quest_fail?(@list.index) @list.quest_fail @result.refresh(@list.current_item) @rank.refresh else Sound.play_buzzer @cation.set_text(@list.cause) end end end class Window_GuildCmd < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(0, 0, 544, WLH+32) self.contents = Bitmap.new(width - 32, height - 32) @commands = Quest.guild_name @item_max = @column_max = @commands.size refresh self.index = 0 end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh self.contents.clear for i in 0...@item_max draw_item(i) end end #-------------------------------------------------------------------------- # ● 項目の描画 #-------------------------------------------------------------------------- def draw_item(index) w = self.width / @column_max x = index % @column_max * w self.contents.draw_text(x, 0, w-32, WLH, @commands[index], 1) end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help @help_window.data_refresh(Quest::GUILD_LIST[@index]) @help_window.update_help end end class Window_GuildCation < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(200, 200, 312, WLH*2+32) self.contents = Bitmap.new(width - 32, height - 32) self.z = 500 self.visible = false end #-------------------------------------------------------------------------- # ● テキスト表示 #-------------------------------------------------------------------------- def set_text(text) return if text == "" self.visible = true self.pause = true self.contents.clear Quest.draw_quest_text(self.contents, 0, 0, self.contents.width-32, WLH, text) end end class Window_GuildSelect < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(200, 200, 312, WLH*2+32) self.contents = Bitmap.new(width - 32, height - 32) self.z = 500 @column_max = @item_max = 2 self.active = false self.visible = false end #-------------------------------------------------------------------------- # ● クエストを受ける #-------------------------------------------------------------------------- def select_start(type) case type when Quest::REPORT; text = "このクエストを報告しますか?" when Quest::SHOP; text = "このクエストを受けますか?" else; return end self.active = true self.visible = true self.index = 1 self.contents.clear self.contents.draw_text(0, 0, self.width, WLH, text) w = self.width / @column_max - 64 x = 1 % @column_max * (w + 32) + 32 self.contents.draw_text(item_rect(0), "はい", 1) self.contents.draw_text(item_rect(1), "いいえ", 1) end #-------------------------------------------------------------------------- # ● 項目を描画する矩形の取得 # index : 項目番号 #-------------------------------------------------------------------------- def item_rect(index) rect = Rect.new(0, 0, 0, 0) rect.width = (contents.width + @spacing) / @column_max - @spacing rect.height = WLH rect.x = index % @column_max * (rect.width + @spacing) rect.y = index / @column_max * WLH + WLH return rect end end