#============================================================================== # ■ XP-RGSS-61-gld クエストシステム【ギルド】 by Claimh #------------------------------------------------------------------------------ #【イベントスクリプト操作】 #◆ギルドの呼び出し # call_guild(ギルドID) もしくは $scene = Scene_Guild.new(ギルドID) # ・普通のギルド # ギルドIDは0にするか、省略してください。 # ・特定ギルドでのみ受け付けるクエストがあるギルド # ギルドIDに適切な値を設定してください。 # 普通のギルド用のクエストに加えて、 # StGuildクラスで特定ギルドに指定されたクエストが受付られます。 #============================================================================== class Scene_Guild #-------------------------------------------------------------------------- # ● オブジェクト初期化 # id : ギルドID #-------------------------------------------------------------------------- def initialize(id=0) @id = id end #-------------------------------------------------------------------------- # ● メイン処理 #-------------------------------------------------------------------------- def main start # 開始処理 Graphics.transition # トランジション実行 loop do Graphics.update # ゲーム画面を更新 Input.update # 入力情報を更新 update # フレーム更新 break if $scene != self # 画面が切り替わったらループを中断 end Graphics.update Graphics.freeze # トランジション準備 terminate # 終了処理 end #-------------------------------------------------------------------------- # ● 開始処理 #-------------------------------------------------------------------------- def start @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 @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) $game_system.se_play($data_system.decision_se) @cation.visible = false elsif Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) @cation.visible = false end elsif @result.visible @result.update if Input.trigger?(Input::C) $game_system.se_play($data_system.decision_se) @result.visible = false @list.data_refresh(Quest::REPORT, true, @list.index) elsif Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) @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) $game_system.se_play($data_system.cancel_se) $scene = Scene_Map.new elsif Input.trigger?(Input::C) $game_system.se_play($data_system.decision_se) 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? $game_system.se_play($data_system.cursor_se) @info.page_up end return elsif Input.repeat?(Input::R) if @info.enable_down? $game_system.se_play($data_system.cursor_se) @info.page_down end return end @list.update if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) 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? $game_system.se_play($data_system.buzzer_se) @cation.set_text(@list.cause) else if Quest::GUILD_LIST[@cmd.index] == Quest::SHOP and $game_system.quest.over_playing? $game_system.se_play($data_system.buzzer_se) @cation.set_text("進行中のクエスト数が\\n制限数を超過しています") return end $game_system.se_play($data_system.decision_se) @select.select_start(Quest::GUILD_LIST[@cmd.index]) end elsif Input.trigger?(Input::LEFT) if @info.enable_left? $game_system.se_play($data_system.cursor_se) @info.page_left end elsif Input.trigger?(Input::RIGHT) if @info.enable_right? $game_system.se_play($data_system.cursor_se) @info.page_right end end end #---------------------------------------------------------------------------- # ● フレーム更新 (選択ウィンドウ) #---------------------------------------------------------------------------- def update_select @select.update if Input.trigger?(Input::B) $game_system.se_play($data_system.cancel_se) @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 $game_system.se_play($data_system.decision_se) end @select.active = false @select.visible = false end end #---------------------------------------------------------------------------- # ● クエストの受付 #---------------------------------------------------------------------------- def quest_start if @list.current_item.commission > 0 # 手数料ある場合はShop-SE $game_system.se_play($data_system.shop_se) else $game_system.se_play($data_system.decision_se) 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 $game_system.se_play($data_system.buzzer_se) @cation.set_text(@list.cause) end end end class Window_GuildCmd < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(0, 0, 640, 64) 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, 32, @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(240, 200, 360, 96) 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, 32, text) end end class Window_GuildSelect < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(240, 200, 360, 96) 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, 32, text) w = self.width / @column_max - 64 x = 1 % @column_max * (w + 32) + 32 self.contents.draw_text(32, 32, w, 32, "はい", 1) self.contents.draw_text(x, 32, w, 32, "いいえ", 1) end #-------------------------------------------------------------------------- # ● カーソルの矩形更新 #-------------------------------------------------------------------------- def update_cursor_rect # カーソル位置が 0 未満の場合 if @index < 0 self.cursor_rect.empty return end # 現在の行を取得 row = @index / @column_max # 現在の行が、表示されている先頭の行より前の場合 if row < self.top_row # 現在の行が先頭になるようにスクロール self.top_row = row end # 現在の行が、表示されている最後尾の行より後ろの場合 if row > self.top_row + (self.page_row_max - 1) # 現在の行が最後尾になるようにスクロール self.top_row = row - (self.page_row_max - 1) end # カーソルの幅を計算 cursor_width = self.width / @column_max - 64 # カーソルの座標を計算 x = @index % @column_max * (cursor_width + 32) + 32 y = @index / @column_max * 32 - self.oy + 32 # カーソルの矩形を更新 self.cursor_rect.set(x, y, cursor_width, 32) end end