# ▼▲▼ XSE_S1 スキル・セレクト ▼▲▼ # # #============================================================================== # カスタマイズポイント #============================================================================== module XSE # スキル装備可能個数(1〜10) SKILL_MAX = 8 end module XSE BG = "XSE_S1" # 背景画像(windowskinフォルダ) BG_OPACITY = 224 # 背景画像の不透明度(0〜255) OPACITY = 128 # 各ウィンドウの不透過度(0〜255) end #============================================================================== # セレクトスキルの割り込み [上書き] #============================================================================== class Game_Actor < Game_Battler def original_skills @skills end def skills @active_skills = [] if @active_skills == nil return @active_skills.compact end def active_skills=(set) @active_skills = set end def select_skills @active_skills = [] if @active_skills == nil @active_skills end end #============================================================================== # Scene_XSE #============================================================================== class Scene_XSE #-------------------------------------------------------------------------- # オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(actor_index = 0, equip_index = 0) @actor_index = actor_index end #-------------------------------------------------------------------------- # メイン処理 #-------------------------------------------------------------------------- def main # アクターを取得 @actor = $game_party.actors[@actor_index] # 各表示項目の作成 @bg_sprite = Spriteset_Map.new @bg = MenuBG.new @select_window = Window_SkillSelect.new(@actor) @name_plate = NamePlate.new(@actor) @skill_window = Window_OriginalSkill.new(@actor) @help_window = Window_Help2.new @select_window.help_window = @help_window @skill_window.help_window = @help_window # トランジション実行 Graphics.transition # メインループ loop do # ゲーム画面を更新 Graphics.update # 入力情報を更新 Input.update # フレーム更新 update # 画面が切り替わったらループを中断 if $scene != self break end end # トランジション準備 Graphics.freeze # ウィンドウを解放 @help_window.dispose @bg.dispose @skill_window.dispose @select_window.dispose @name_plate.dispose @bg_sprite.dispose end #-------------------------------------------------------------------------- # フレーム更新 #-------------------------------------------------------------------------- def update if @skill_window.active update_skill else update_select end end #-------------------------------------------------------------------------- # フレーム更新 セレクト部分 #-------------------------------------------------------------------------- def update_select # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # メニュー画面に切り替え $scene = Scene_Menu.new(XSE::MENU_INDEX) return end # C ボタンが押された場合 if Input.trigger?(Input::C) # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # スキルウィンドウへ移行 @skill_window.index = 0 @skill_window.active = true @select_window.active = false return end # R ボタンが押された場合 if Input.trigger?(Input::R) # カーソル SE を演奏 $game_system.se_play($data_system.cursor_se) # 次のアクターへ @actor_index += 1 @actor_index %= $game_party.actors.size # 切り替え $scene = Scene_XSE.new(@actor_index) return end # L ボタンが押された場合 if Input.trigger?(Input::L) # カーソル SE を演奏 $game_system.se_play($data_system.cursor_se) # 前のアクターへ @actor_index += $game_party.actors.size - 1 @actor_index %= $game_party.actors.size # 切り替え $scene = Scene_XSE.new(@actor_index) return end @select_window.update end #-------------------------------------------------------------------------- # フレーム更新 スキル選択部分 #-------------------------------------------------------------------------- def update_skill @skill_window.update # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # セレクトウィンドウへ移行 @skill_window.index = -1 @skill_window.active = false @select_window.active = true return end # C ボタンが押された場合 if Input.trigger?(Input::C) # 装備後の総APを予測 skills = @actor.skills.dup for i in 0...skills.size if skills[i] == @skill_window.skill.id skills[i] = nil end end skills[@select_window.index] = @skill_window.skill.id ap = 0 for skill_id in skills skill = $data_skills[skill_id.to_i] ap += skill.ap if skill end # APが高すぎた場合 if ap > @actor.ap # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return end # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # スキル変化予測を実適用 @actor.active_skills = skills @select_window.refresh # セレクトウィンドウへ移行 @skill_window.index = -1 @skill_window.active = false @select_window.active = true return end end end #============================================================================== # Window_SkillSelect #============================================================================== class Window_SkillSelect < Window_Selectable include XRXS_FitWindow #-------------------------------------------------------------------------- # オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(actor) @actor = actor h = XSE::SKILL_MAX * 26 + 32 super(-32, 112, 368, h+32) self.contents = Bitmap.new(width - 32, height - 32) @item_max = XSE::SKILL_MAX self.index = 0 refresh end #-------------------------------------------------------------------------- # リフレッシュ #-------------------------------------------------------------------------- def refresh self.contents.clear use_ap = 0 for skill_id in @actor.skills skill = $data_skills[skill_id] use_ap += skill.ap if skill end now_ap = @actor.ap - use_ap skin = RPG::Cache.windowskin(XSE::NumberL) self.contents.font.color = system_color self.contents.font.size = 16 self.contents.draw_text(192,2,64,24, XSE::AP_S, 2) self.contents.font.size = 20 self.contents.blt_number(316,23, skin, now_ap) skin = RPG::Cache.windowskin(XSE::NumberS) for i in 0...@item_max x = 16 y = 26 * i + 28 # スキル名・APの取得 skill_id = @actor.select_skills[i] skill = $data_skills[skill_id.to_i] if skill icon = RPG::Cache.icon(skill.icon_name) name = skill.name ap = skill.ap self.contents.blt(x+2, y+1, icon, icon.rect) self.contents.font.color = normal_color self.contents.draw_text(x + 28, y+2, 224, 22, name) self.contents.font.size = 18 self.contents.blt_number(x + 300, y+19, skin, ap) else self.contents.font.color = disabled_color self.contents.draw_text(x+28, y+2, 224, 22, "---") end end end #-------------------------------------------------------------------------- # カーソルの矩形更新 #-------------------------------------------------------------------------- def update_cursor_rect case self.index when -1 self.cursor_rect.empty else self.cursor_rect.set(16, self.index * 26 + 28, 312, 26) end end #-------------------------------------------------------------------------- # スキルの取得 #-------------------------------------------------------------------------- def skill return $data_skills[@actor.skills[self.index].to_i] end #-------------------------------------------------------------------------- # ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help @help_window.set_text(self.skill == nil ? "" : self.skill.description) end end #============================================================================== # Window_OriginalSkill #============================================================================== class Window_OriginalSkill < Window_Selectable include XRXS_FitWindow #-------------------------------------------------------------------------- # オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(actor) super(320, 112, 328, 352) @actor = actor refresh self.active = false self.index = -1 end #-------------------------------------------------------------------------- # スキルの取得 #-------------------------------------------------------------------------- def skill return @data[self.index] end #-------------------------------------------------------------------------- # リフレッシュ #-------------------------------------------------------------------------- def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] for i in 0...@actor.original_skills.size skill = $data_skills[@actor.original_skills[i]] if skill != nil @data.push(skill) 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) end end end #-------------------------------------------------------------------------- # 項目の描画 #-------------------------------------------------------------------------- def draw_item(index) skill = @data[index] x = 8 y = index * 32 rect = Rect.new(x, y, self.width - 32, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) bitmap = RPG::Cache.icon(skill.icon_name) opacity = self.contents.font.color == normal_color ? 255 : 128 self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) self.contents.font.size = 20 self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0) skin = RPG::Cache.windowskin(XSE::NumberS) self.contents.font.size = 18 self.contents.blt_number(x + 280, y+23, skin, skill.ap) end #-------------------------------------------------------------------------- # ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help @help_window.set_text(self.skill == nil ? "" : self.skill.description) end end