# ▽△▽ XRXSv19. MeLT_Skill. スキルベース&パーティスキル ▽△▽ # # publish 2010/ 3/16 # update - /27 # #============================================================================== # カスタマイズポイント #============================================================================== class Window_PartySkill < Window_Selectable Skin = "Window" end module XRXSV19 Commands = ["個人", "パーティ"] end #============================================================================== # 追加対応/その他 #============================================================================== module XRXSV19_UpdateExtra def update_extra return false end def update_extra_command_decide(work_id) end end #============================================================================== # 拡張ヘルプ #============================================================================== class Window_HelpEX < Window_Help def set(item) self.set_text(item == nil ? "" : item.description) end end #============================================================================== # スキルコマンド #============================================================================== class Window_SlideCommand < Window_Command end class Window_SkillCommand < Window_SlideCommand def initialize(actor = nil) @clear_style = ((XRXSV10::BG_NAME rescue "").size >= 1) super(160, XRXSV19::Commands) self.x = -12 self.y = (@clear_style ? 72 : 56) end end #============================================================================== # 背景ウィンドウ #============================================================================== class Window_SkillBack < Window_Selectable def initialize super(0, 56, 544, 304) self.z = 0 end end #============================================================================== # スキル画面 #============================================================================== class Scene_Skill < Scene_Base include XRXSV19_UpdateExtra #-------------------------------------------------------------------------- # ● トランジション実行 #-------------------------------------------------------------------------- def perform_transition Graphics.transition(0) end #-------------------------------------------------------------------------- # 戻り位置 #-------------------------------------------------------------------------- def return_scene_index index = XRXSV10::MENU_SCENES.index(Scene_Skill) rescue 1 return index end #-------------------------------------------------------------------------- # ● 元の画面へ戻る #-------------------------------------------------------------------------- def return_scene $scene = Scene_Menu.new(self.return_scene_index) end #-------------------------------------------------------------------------- # ● 次のアクターの画面に切り替え #-------------------------------------------------------------------------- def next_actor @command_window.slideout! rescue nil @actor_index += 1 @actor_index %= $game_party.members.size @next_scene = Scene_Skill.new(@actor_index) @next_scene_duration = 4 end #-------------------------------------------------------------------------- # ● 前のアクターの画面に切り替え #-------------------------------------------------------------------------- def prev_actor @command_window.slideout! rescue nil @actor_index += $game_party.members.size - 1 @actor_index %= $game_party.members.size @next_scene = Scene_Skill.new(@actor_index) @next_scene_duration = 4 end #-------------------------------------------------------------------------- # ● 開始処理 #-------------------------------------------------------------------------- def start super create_menu_background @clear_style = ((XRXSV10::BG_NAME rescue "").size >= 1) unless @clear_style @back_window = Window_SkillBack.new end @actor = $game_party.members[@actor_index] @viewport = Viewport.new(0, 0, Graphics.width, Graphics.height) @help_window = Window_HelpEX.new @help_window.y = Graphics.height - @help_window.height @status_window = Window_SkillStatus.new(0, 0, @actor) @skill_window = Window_PartySkill.new(@actor) @skill_window.help_window = @help_window @target_window = Window_MenuStatus.new(0, 0) @target_window.z += 3 @command_window = Window_SkillCommand.new(@actor) hide_target_window @help_window.visible = !@clear_style @command_window.slidein! rescue nil @skill_window.active = false @skill_window.visible = false @skill_window.index = -1 @show_actor = @actor @next_scene = nil @next_scene_duration = 0 end #-------------------------------------------------------------------------- # ● 終了処理 #-------------------------------------------------------------------------- def terminate super dispose_menu_background @back_window.dispose if @back_window != nil @help_window.dispose @status_window.dispose @skill_window.dispose @target_window.dispose @command_window.dispose end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super update_menu_background @command_window.update @help_window.update @status_window.update @skill_window.update @target_window.update if @next_scene != nil @next_scene_duration -= 1 if @next_scene_duration < 0 $scene = @next_scene end return end return if update_extra if @command_window.active update_command elsif @skill_window.active update_skill_selection elsif @target_window.active update_target_selection end end #-------------------------------------------------------------------------- # フレーム更新 - コマンド #-------------------------------------------------------------------------- def update_command if Input.trigger?(Input::B) Sound.play_cancel return_scene elsif Input.trigger?(Input::R) Sound.play_cursor next_actor elsif Input.trigger?(Input::L) Sound.play_cursor prev_actor elsif Input.trigger?(Input::C) Sound.play_decision @command_window.decide! rescue nil @command_window.active = false @skill_window.active = true @skill_window.index = 0 @help_window.visible = true work_id = @command_window.index case work_id when 0 @skill_window.set_actor @skill_window.visible = true when 1 @skill_window.set_usable_skills @skill_window.visible = true else @actor = $game_party.members[@actor_index] update_extra_command_decide(work_id) end end end #-------------------------------------------------------------------------- # ● スキル選択の更新 #-------------------------------------------------------------------------- def update_skill_selection if Input.trigger?(Input::B) Sound.play_cancel @skill_window.active = false @skill_window.visible = false @skill_window.index = -1 @command_window.cancel! rescue nil @command_window.active = true @help_window.set_text("") @help_window.visible = !@clear_style elsif Input.trigger?(Input::R) and @command_window.index == 0 Sound.play_cursor next_actor elsif Input.trigger?(Input::L) and @command_window.index == 0 Sound.play_cursor prev_actor elsif Input.trigger?(Input::C) @skill = @skill_window.skill @actor = @skill_window.actor if @skill != nil @actor.last_skill_id = @skill.id end if @actor.skill_can_use?(@skill) Sound.play_decision last_index = @actor_index @actor_index = $game_party.members.index(@actor) determine_skill @actor_index = last_index else Sound.play_buzzer end end end #-------------------------------------------------------------------------- # ● ターゲットウィンドウの表示 #-------------------------------------------------------------------------- alias xrxsv19_show_target_window show_target_window def show_target_window(right) @skill_window.contents_opacity = 80 @skill_window.cursor2_copy! rescue nil xrxsv19_show_target_window(true) @target_window.x += 16 @target_window.slidein! rescue nil @help_window.visible = !@clear_style end #-------------------------------------------------------------------------- # ● ターゲットウィンドウの非表示 #-------------------------------------------------------------------------- def hide_target_window @skill_window.cursor2_dispose! rescue nil @skill_window.contents_opacity = 255 @skill_window.active = true @target_window.visible = false @target_window.active = false @help_window.visible = true @viewport.rect.set(0, 0, Graphics.width, Graphics.height) @viewport.ox = 0 end end #============================================================================== # --- ターゲットウィンドウ用メニューステータスへの対応 --- #============================================================================== module XRXSV19SkillTargetSlidable def slidable_scenes return super + [Scene_Skill] end end class Window_MenuStatus < Window_Selectable include XRXSV19SkillTargetSlidable end #============================================================================== # --- カーソルコピー機能 (Window_Selectableの下位クラス用) --- #============================================================================== class Window_PartySkill < Window_Selectable include XRXSV_CursorCopy rescue nil end #============================================================================== # パーティスキル #============================================================================== class Window_PartySkill < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(actor) @clear_style = ((XRXSV10::BG_NAME rescue "").size >= 1) @data = [] @actors = [] @bitmap_cache = [] @data_cache = [] @actor = actor super(144, 68, 288, 272) @column_max = 1 @mode = 0 self.index = 0 self.opacity = 0 end def dispose dispose_cache super end def dispose_cache for cache in @bitmap_cache if cache != nil cache.dispose end end @bitmap_cache.clear self.contents = Bitmap.new(16,16) end #-------------------------------------------------------------------------- # ● スキルの取得 #-------------------------------------------------------------------------- def skill return @data[self.index] end #-------------------------------------------------------------------------- # アクターの取得 #-------------------------------------------------------------------------- def actor actor2 = @actors[self.index] return (actor2 != nil ? actor2 : @actor) end #-------------------------------------------------------------------------- # セット - 全使用可能パーティスキル #-------------------------------------------------------------------------- def set_usable_skills @data = [] @actors = [] for actor in $game_party.members for skill in actor.skills if actor.skill_can_use?(skill) @data.push(skill) @actors.push(actor) end end end @mode = 1 refresh end #-------------------------------------------------------------------------- # セット - そのアクターの全スキル #-------------------------------------------------------------------------- def set_actor @data = [] @actors = [] for skill in @actor.skills @data.push(skill) if skill.id == @actor.last_skill_id self.index = @data.size - 1 end end @mode = 0 refresh end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh cache = @bitmap_cache[@mode] if cache != nil self.contents = cache @data = @data_cache[@mode] @item_max = @data.size else @item_max = @data.size self.contents = Bitmap.new(16,16) create_contents for i in 0...@item_max draw_item(i) end @bitmap_cache[@mode] = self.contents @data_cache[@mode] = @data end end #-------------------------------------------------------------------------- # ● 項目の描画 #-------------------------------------------------------------------------- def draw_item(index) rect = item_rect(index) self.contents.clear_rect(rect) skill = @data[index] actor = @actors[index] actor = @actor if actor == nil if @clear_style skin = Cache.system(Skin) skin_rect = Rect.new(0,16,64,32) self.contents.stretch_blt(rect, skin, skin_rect, 96) skin_rect = Rect.new(0,80,64,32) self.contents.stretch_blt(rect, skin, skin_rect, 192) end if skill != nil rect.x += 52 rect.width -= 56 enabled = actor.skill_can_use?(skill) draw_item_name(skill, rect.x, rect.y, enabled) cost = actor.calc_mp_cost(skill) if cost >= 1 self.contents.draw_text(rect, cost, 2) end rect.x -= 52 end if actor != nil face_rect = Rect.new(1,1,46,22) self.contents.blt(rect.x + 1, rect.y + 1, actor.miniface, face_rect) end end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help @help_window.set(skill) end end #============================================================================== # 顔グラフィックビットマップの取得 #============================================================================== class Game_Actor < Game_Battler def face bitmap = Bitmap.new(96, 96) face = Cache.face(self.face_name) rect = Rect.new(0, 0, 96, 96) rect.x = self.face_index % 4 * 96 rect.y = self.face_index / 4 * 96 bitmap.blt(0, 0, face, rect) face.dispose return bitmap end end #============================================================================== # 指定領域内での アクターの顔グラフィックの取得 #============================================================================== class Window_Base < Window def get_actor_face(actor, drawable_width = 96, drawable_height = 96) drawable_width = [drawable_width, 96].min drawable_height = [drawable_height, 96].min face = Cache.face(actor.face_name) x = (actor.face_index % 4 * 96) + (96 - drawable_width ) / 2 y = (actor.face_index / 4 * 96) + (96 - drawable_height) / 4 face_rect = Rect.new(x, y, drawable_width, drawable_height) bitmap = Bitmap.new(drawable_width, drawable_height) bitmap.blt(0, 0, face, face_rect) face.dispose return bitmap end end #============================================================================== # ミニフェイスの取得 #============================================================================== class Game_Actor < Game_Battler def miniface return $game_temp.miniface(self) end end class Game_Temp def miniface(actor) @miniface_cache = {} if @miniface_cache == nil key = actor.face_name + "-" + (actor.face_index + 1).to_s cache = @miniface_cache[key] if cache == nil cache = Bitmap.new(48,24) face = Cache.face(actor.face_name) x = (actor.face_index % 4 * 96) y = (actor.face_index / 4 * 96) + 14 #* face_rect = Rect.new(x, y, 96, 48) cache.stretch_blt(cache.rect, face, face_rect) face.dispose @miniface_cache[key] = cache end return cache end def miniface_cache_clear @miniface_cache = {} if @miniface_cache == nil @miniface_cache.values.each{|cache| cache.dispose } @miniface_cache.clear end end