#============================================================================== # ■ VXAce-RGSS3-40 コマンドスキル [window] by Claimh #============================================================================== #============================================================================== # ■ Window_Base #============================================================================== class Window_Base < Window #-------------------------------------------------------------------------- # ● 攻撃スロット数表示 #-------------------------------------------------------------------------- def draw_actor_cmdslot(actor, x, y) slot = CmdBtl.slot_is_tp ? actor.tp.to_i : actor.cmd_slot draw_text(x, y, 80, line_height, slot) end end #============================================================================== # ■ Window_ActorAtkCommand #============================================================================== class Window_ActorAtkCommand < Window_Base LINE = "cmd_line" # ラインファイル L_ST = 60 # ラインスタート位置 L_CR = Color.new(0,0,0, 128) # ラインカラー L_OP = 160 TIME = 15 # スライドフレーム数 #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :finish #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(actor) @finish = false @cmd = ActorAtkCmd.new(actor.id) @count = CmdBtl::TIME super(Graphics.width, 100, 180, fitting_height(2)+6) self.opacity = 0 self.z = 400 refresh @skill_window = Window_ActorCmdSkill.new(self.x-180, self.y + self.height-line_height, actor) end #-------------------------------------------------------------------------- # ● 解放 #-------------------------------------------------------------------------- def dispose super @skill_window.dispose end #-------------------------------------------------------------------------- # ● スライドIN #-------------------------------------------------------------------------- def slide_in goal = Graphics.width - width self.x -= goal / TIME @skill_window.x = self.x if self.x < goal self.x = goal @skill_window.x = self.x return true end return false end #-------------------------------------------------------------------------- # ● スライドOUT #-------------------------------------------------------------------------- def slide_out goal = Graphics.width self.x += goal / TIME @skill_window.x = self.x return self.x >= goal end #-------------------------------------------------------------------------- # ● アクションデータ #-------------------------------------------------------------------------- def actions @cmd.make_actions end def cmds @cmd.size end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh contents.clear draw_base draw_actor_name(@cmd.actor, 0, 0) draw_cmd draw_actor_slot redraw_counter if CmdBtl::USE_TIME end #-------------------------------------------------------------------------- # ● ベース描画 #-------------------------------------------------------------------------- def draw_base cache = Cache.system(LINE) contents.fill_rect(Rect.new(0,line_height*1+8,L_ST,line_height-8), L_CR) contents.fill_rect(Rect.new(0,line_height*2,width,4), L_CR) end def draw_cmd contents.font.size -= 8 draw_text(4, line_height+6, 80, line_height, "Command") contents.font.size += 8 end #-------------------------------------------------------------------------- # ● 攻撃スロット数描画 #-------------------------------------------------------------------------- def draw_actor_slot contents.font.size -= 8 draw_text(100, 4, 80, line_height, "SLOT") contents.font.size += 8 contents.font.italic = contents.font.bold = true contents.font.size += 2 draw_text(100, 0, contents_width-100, line_height, @cmd.remain, 2) contents.font.italic = contents.font.bold = false contents.font.size -= 2 end def redraw_actor_slot r = Rect.new(100, 0, contents_width-100, line_height) contents.clear_rect(r) draw_actor_slot end #-------------------------------------------------------------------------- # ● コマンド入力 #-------------------------------------------------------------------------- def add_command(c) return if c.nil? return Sound.play_buzzer if !CmdBtl.slot_is_tp && (c == :finish && @cmd.size == 0) return finish_cmd(true) if c == :finish return Sound.play_buzzer unless @cmd.attackable?(c) CmdBtl.play_atk_se(c) draw_icon(CmdBtl.attack(c).icon_index, L_ST + 10 + cmds * 28, line_height) @cmd.push(c) redraw_actor_slot @skill_window.refresh(@cmd.predict_skill) finish_cmd if @cmd.full? end #-------------------------------------------------------------------------- # ● コマンド入力終了 #-------------------------------------------------------------------------- def finish_cmd(cancel=false) Sound.play_cancel if cancel @cmd.finish @finish = true end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update add_command(CmdBtl.trigger_atk_cmd) unless @finish update_time if CmdBtl::USE_TIME and !@finish super end #-------------------------------------------------------------------------- # ● 時間フレーム更新 #-------------------------------------------------------------------------- def update_time @count -= 1 finish_cmd if @count == 0 redraw_counter end #-------------------------------------------------------------------------- # ● カウンター描画 #-------------------------------------------------------------------------- def draw_counter(rect) rate = (@count * 1.0 / CmdBtl::TIME) draw_gauge(rect.x, rect.y, rect.width, rate, text_color(CmdBtl::COLOR[0]), text_color(CmdBtl::COLOR[1])) end def redraw_counter rect = Rect.new(0, line_height * 2+2, contents_width, 6) contents.clear_rect(rect) draw_counter(rect) end #-------------------------------------------------------------------------- # ● ゲージの描画 # rate : 割合(1.0 で満タン) # color1 : グラデーション 左端 # color2 : グラデーション 右端 #-------------------------------------------------------------------------- def draw_gauge(x, y, width, rate, color1, color2) fill_w = (width * rate).to_i contents.fill_rect(x, y, width, 4, gauge_back_color) contents.gradient_fill_rect(x, y, fill_w, 4, color1, color2) end end #============================================================================== # ■ Window_ActorCmdSkill #============================================================================== class Window_ActorCmdSkill < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(x, y, actor) @actor = actor super(x, y, Graphics.width - x, fitting_height(1)) self.opacity = 0 self.z = 400 refresh([]) end #-------------------------------------------------------------------------- # ● 行の高さを取得 #-------------------------------------------------------------------------- def line_height return 20 end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh(skills) if self.height != fitting_height(skills.size+1) self.height = fitting_height(skills.size+1) create_contents else contents.clear end draw_skill_text draw_skills(skills) end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def draw_skill_text contents.font.size -= 8 draw_text(0, 0, 80, line_height, "skill") contents.font.size += 8 end #-------------------------------------------------------------------------- # ● スキル予測表示 #-------------------------------------------------------------------------- def draw_skills(skills) contents.font.size -= 8 y = line_height for i in 0...skills.size y = draw_skill_name(skills[i][0], skills[i][1], 0, y, skills[i][2]) end contents.font.size += 8 end #-------------------------------------------------------------------------- # ● スキル名表示 #-------------------------------------------------------------------------- def draw_skill_name(skill, cmd, x, y, enabled=true) return y unless skill return y if cmd.nil? yy = y - (24 - line_height) / 2 draw_icon(CmdBtl.attack(cmd).icon_index, x, yy, enabled) change_color(normal_color, enabled) draw_text(x + 24, y, width, line_height, skill.name) return y + line_height end end #============================================================================== # ■ Window_SkillList #============================================================================== class Window_SkillList < Window_Selectable #-------------------------------------------------------------------------- # ● 攻撃スキルか? #-------------------------------------------------------------------------- def is_cmdskill?(item) CmdBtl.skill_ids(@actor).include?(item.id) end #-------------------------------------------------------------------------- # ● 攻撃スキルをリストに含めるかどうか #-------------------------------------------------------------------------- def include_cmdskill?(item) return true unless $game_party.in_battle !CmdBtl::UNSHOW_SKILL or !is_cmdskill?(item) end #-------------------------------------------------------------------------- # ● スキルをリストに含めるかどうか #-------------------------------------------------------------------------- alias cmdbtl_include? include? def include?(item) cmdbtl_include?(item) && include_cmdskill?(item) end #-------------------------------------------------------------------------- # ● 攻撃スキルを許可状態で表示するかどうか #-------------------------------------------------------------------------- def enable_cmdskill?(item) !$game_party.in_battle or !is_cmdskill?(item) end #-------------------------------------------------------------------------- # ● スキルを許可状態で表示するかどうか #-------------------------------------------------------------------------- alias cmdbtl_enable? enable? def enable?(item) cmdbtl_enable?(item) && enable_cmdskill?(item) end end