#============================================================================== # ■ VX-RGSS2-30 フロントビュー改 [Ver.1.0.0] by Claimh #------------------------------------------------------------------------------ # 戦闘画面を改変します。 #------------------------------------------------------------------------------ #【変更点】 # ・顔グラフィック表示 # ・ダメージポップアップ追加 # ・戦闘メッセージの表示形式変更(1行メッセージ) # ・エネミーの通常攻撃でのアニメーション追加 # メモ欄にて @anime[アニメーションID] で設定 #------------------------------------------------------------------------------ #【VXバグ修正】 # ・復活用のスキル・アイテム使用時にアニメーションが表示されない #------------------------------------------------------------------------------ #【注意点】 # ・文字列キャッシュが必須です。 # ・Scene_Battle等を色々再定義しています。 # 他スクリプトと競合する可能性が大いにあります。 #============================================================================== module FrontViewEx # エネミー、バトルフロントのY座標調整 Y = 20 # ステータスウィンドウの不透明度 ST_WIN_OPC = 255 # コマンドアイコンIndex ICON = [] # ICON[アクターID] = [たたかう, スキル, 防御, アイテム] ICON[0] = [0, 131, 52, 144] # ID=0 : 共通 end module RPG class Enemy #-------------------------------------------------------------------------- # ● 通常攻撃 アニメーション ID の取得 # メモ欄から @anime[アニメーションID] を取得 #-------------------------------------------------------------------------- def atk_animation_id result = @note.scan(/@anime\[(\d+)\]/)[0] return (result.nil? ? 1 : result[0].to_i) end end end #============================================================================== # ■ Game_Battler #============================================================================== class Game_Battler #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :loop_flash # 白フラッシュ(ループ)フラグ attr_accessor :stop_loop # 白フラッシュ(ループ停止)フラグ attr_accessor :pop_hp_damage # ダメージポップ(HP) attr_accessor :pop_mp_damage # ダメージポップ(MP) #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias initialize_fvEx initialize def initialize initialize_fvEx @loop_flash = false @stop_loop = false @pop_hp_damage = false @pop_mp_damage = false end end #============================================================================== # ■ Game_Actor #============================================================================== class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # ● スプライトを使うか? [再定義] #-------------------------------------------------------------------------- def use_sprite? return true end #-------------------------------------------------------------------------- # ● 自動回復の実行 (ターン終了時に呼び出し) [再定義] #-------------------------------------------------------------------------- def do_auto_recovery if auto_hp_recover and not dead? @hp_damage = -1 * (maxhp / 20) self.hp -= @hp_damage end end #-------------------------------------------------------------------------- # ● バトル画面 X 座標の取得 #-------------------------------------------------------------------------- def screen_x column_max = $game_party.members.size w = (544-32) / column_max sx = self.index % column_max * w sx += (96 / column_max) - 16 return sx + 16 + 96/2 end #-------------------------------------------------------------------------- # ● バトル画面 Y 座標の取得 #-------------------------------------------------------------------------- def screen_y return 300+96 end #-------------------------------------------------------------------------- # ● バトル画面 Z 座標の取得 #-------------------------------------------------------------------------- def screen_z return 100 end end #============================================================================== # ■ Game_Enemy #============================================================================== class Game_Enemy < Game_Battler #-------------------------------------------------------------------------- # ● 通常攻撃 アニメーション ID の取得 #-------------------------------------------------------------------------- def atk_animation_id return enemy.atk_animation_id end #-------------------------------------------------------------------------- # ● 通常攻撃 アニメーション ID の取得 (二刀流:武器2) #-------------------------------------------------------------------------- def atk_animation_id2 return 0 end #-------------------------------------------------------------------------- # ● バトル画面 Y 座標の取得 #-------------------------------------------------------------------------- alias screen_y_fvEx screen_y def screen_y return screen_y_fvEx - FrontViewEx::Y end end #============================================================================== # ■ Sprite_Base #------------------------------------------------------------------------------ #  アニメーションの表示処理を追加したスプライトのクラスです。 #============================================================================== class Sprite_Base < Sprite #-------------------------------------------------------------------------- # ● アニメーションスプライトの設定 # frame : フレームデータ (RPG::Animation::Frame) #-------------------------------------------------------------------------- def animation_set_sprites(frame) cell_data = frame.cell_data for i in 0..15 sprite = @animation_sprites[i] next if sprite == nil pattern = cell_data[i, 0] if pattern == nil or pattern == -1 sprite.visible = false next end if pattern < 100 sprite.bitmap = @animation_bitmap1 else sprite.bitmap = @animation_bitmap2 end sprite.visible = true sprite.src_rect.set(pattern % 5 * 192, pattern % 100 / 5 * 192, 192, 192) if @animation_mirror sprite.x = @animation_ox - cell_data[i, 1] sprite.y = @animation_oy - cell_data[i, 2] sprite.angle = (360 - cell_data[i, 4]) sprite.mirror = (cell_data[i, 5] == 0) else sprite.x = @animation_ox + cell_data[i, 1] sprite.y = @animation_oy + cell_data[i, 2] sprite.angle = cell_data[i, 4] sprite.mirror = (cell_data[i, 5] == 1) end sprite.z = self.z + 300 sprite.ox = 96 sprite.oy = 96 sprite.zoom_x = cell_data[i, 3] / 100.0 sprite.zoom_y = cell_data[i, 3] / 100.0 # [VXバグ] 非表示のSpriteに対してアニメーションが表示されない sprite.opacity = cell_data[i, 6] #* self.opacity / 255.0 sprite.blend_type = cell_data[i, 7] end end end #============================================================================== # ■ Sprite_Damage #============================================================================== class Sprite_Damage < Sprite WLH = 24 N = [4,5,6,7,8,9] DIR = [1,-1] T = 100 #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(viewport) super(viewport) self.bitmap = Bitmap.new(120, WLH) self.visible = false @add_x = @base_x = @base_y = 0 @count = T end #-------------------------------------------------------------------------- # ● ビットマップ生成 #-------------------------------------------------------------------------- def create_bitmap(w=120) self.bitmap.dispose self.bitmap = Bitmap.new(w, WLH) end #-------------------------------------------------------------------------- # ● 文字色取得 # n : 文字色番号 (0〜31) #-------------------------------------------------------------------------- def text_color(n) x = 64 + (n % 8) * 8 y = 96 + (n / 8) * 8 return Cache.system("Window").get_pixel(x, y) end #-------------------------------------------------------------------------- # ● 通常文字色の取得 #-------------------------------------------------------------------------- def normal_color return text_color(0) end #-------------------------------------------------------------------------- # ● 装備画面のパワーアップ色の取得 #-------------------------------------------------------------------------- def power_up_color return text_color(24) end #-------------------------------------------------------------------------- # ● ダメージ描画 #-------------------------------------------------------------------------- def damage(x, y, z, ox, oy, w, h, damage) create_bitmap(w) self.x = @base_x = x self.y = @base_y = y-h self.z = z + 10000 self.ox = ox self.oy = oy @base_h = h @add_x = N[rand(N.size)] @dir = DIR[rand(DIR.size)] self.bitmap.font.color = damage < 0 ? power_up_color : normal_color self.bitmap.font.bold = true self.bitmap.draw_text(0, 0, w, WLH, damage.abs, 1) @count = -1 self.visible = true update end def clac_pos_y(t) return 0.2*(t-@add_x)*(t-@add_x)+@base_h end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update return if exit? @count += 1 return if (@count % 2) == 1 t = @count / 2 self.x = @base_x + t * @dir yy = clac_pos_y(t) self.y = @base_y + yy if (yy+WLH) > (@base_h*2) @count = T end self.visible = !exit? end #-------------------------------------------------------------------------- # ● 終了? #-------------------------------------------------------------------------- def exit? return (@count == T) end end #============================================================================== # ■ Sprite_Battler #============================================================================== class Sprite_Battler < Sprite_Base LOOP_F1 = 500 LOOP_F2 = 501 #-------------------------------------------------------------------------- # ● オブジェクト初期化 # viewport : ビューポート # battler : バトラー (Game_Battler) #-------------------------------------------------------------------------- alias initialize_fvEx initialize def initialize(viewport, battler = nil) initialize_fvEx(viewport, battler) create_damage end #-------------------------------------------------------------------------- # ● 解放 #-------------------------------------------------------------------------- alias dispose_fvEx dispose def dispose dispose_fvEx dispose_damage end #-------------------------------------------------------------------------- # ● ダメージスプライト配列初期化 #-------------------------------------------------------------------------- def create_damage @damage_sprite = [] end #-------------------------------------------------------------------------- # ● ダメージスプライト追加 #-------------------------------------------------------------------------- def add_damage_sprite(damage) sprite = Sprite_Damage.new(self.viewport) sprite.damage(self.x,self.y,self.z,self.ox,self.oy,@width,@height, damage) @damage_sprite.push(sprite) end #-------------------------------------------------------------------------- # ● ダメージスプライト開放 #-------------------------------------------------------------------------- def dispose_damage for sprite in @damage_sprite sprite.dispose end end #-------------------------------------------------------------------------- # ● ダメージスプライト更新 #-------------------------------------------------------------------------- def update_damage size = @damage_sprite.size return if size == 0 for i in 0...size sprite = @damage_sprite[i] if sprite.exit? @damage_sprite[i].dispose @damage_sprite[i] = nil else sprite.update end end @damage_sprite.compact! end #-------------------------------------------------------------------------- # ● 新しいエフェクトの設定 #-------------------------------------------------------------------------- alias setup_new_effect_fvEx setup_new_effect def setup_new_effect setup_new_effect_fvEx if @battler.loop_flash if @battler_visible @effect_type = LOOP_F1 @effect_duration = 16 end @battler.loop_flash = false end if @battler.stop_loop if @effect_type == LOOP_F1 or @effect_type == LOOP_F2 @effect_type = 0 @effect_duration = 0 self.color.alpha = 0 end @battler.stop_loop = false end if @battler.pop_hp_damage add_damage_sprite(@battler.hp_damage) @battler.pop_hp_damage = false end if @battler.pop_mp_damage add_damage_sprite(@battler.mp_damage) @battler.pop_mp_damage = false end end #-------------------------------------------------------------------------- # ● エフェクトの更新 #-------------------------------------------------------------------------- alias update_effect_fvEx update_effect def update_effect case @effect_type when LOOP_F1 @effect_duration -= 1 update_whiten @effect_type = LOOP_F2 if @effect_duration == 0 return when LOOP_F2 @effect_duration += 1 update_whiten @effect_type = LOOP_F1 if @effect_duration == 16 return end update_effect_fvEx update_damage end #-------------------------------------------------------------------------- # ● 転送元ビットマップの更新 #-------------------------------------------------------------------------- def update_battler_bitmap case @battler when Game_Actor if @battler.face_name != @battler_name or @battler.face_index != @battler_hue @battler_name = @battler.face_name @battler_hue = @battler.face_index draw_face if (@battler.dead? or @battler.hidden) self.opacity = 0 end end when Game_Enemy if @battler.battler_name != @battler_name or @battler.battler_hue != @battler_hue @battler_name = @battler.battler_name @battler_hue = @battler.battler_hue draw_battler if (@battler.dead? or @battler.hidden) self.opacity = 0 end end end end #-------------------------------------------------------------------------- # ● バトラー描画 #-------------------------------------------------------------------------- def draw_battler self.bitmap.dispose unless self.bitmap.nil? self.bitmap = Cache.battler(@battler.battler_name, @battler.battler_hue) @width = bitmap.width @height = bitmap.height self.ox = @width / 2 self.oy = @height end #-------------------------------------------------------------------------- # ● 顔グラフィック描画 #-------------------------------------------------------------------------- def draw_face self.bitmap.dispose unless self.bitmap.nil? b = Cache.face(@battler.face_name) @width = 96 @height = 96 rect = Rect.new(0, 0, @width, @height) rect.x = @battler.face_index % 4 * 96 rect.y = @battler.face_index / 4 * 96 self.bitmap = Bitmap.new(96, 96) self.bitmap.blt(0, 0, b, rect) b.dispose self.ox = @width / 2 self.oy = @height end end #============================================================================== # ■ Spriteset_Battle #============================================================================== class Spriteset_Battle #-------------------------------------------------------------------------- # ● ビューポートの作成 #-------------------------------------------------------------------------- alias create_viewports_fvEx create_viewports def create_viewports create_viewports_fvEx @viewport4 = Viewport.new(0, 0, 544, 416) @viewport4.z = 10 end #-------------------------------------------------------------------------- # ● バトルフロアスプライトの作成 #-------------------------------------------------------------------------- alias create_battlefloor_fvEx create_battlefloor def create_battlefloor create_battlefloor_fvEx @battlefloor_sprite.y -= FrontViewEx::Y end #-------------------------------------------------------------------------- # ● アクタースプライトの作成 #-------------------------------------------------------------------------- def create_actors @actor_sprites = [] for i in 0...$game_party.members.size @actor_sprites.push(Sprite_Battler.new(@viewport4)) end end #-------------------------------------------------------------------------- # ● ビューポートの解放 #-------------------------------------------------------------------------- alias dispose_viewports_fvEx dispose_viewports def dispose_viewports dispose_viewports_fvEx @viewport4.dispose end #-------------------------------------------------------------------------- # ● アクタースプライトの更新 #-------------------------------------------------------------------------- def update_actors # メンバー変わったときに作り直し if @actor_sprites.size != $game_party.members.size dispose_actors create_actors end for i in 0...$game_party.members.size @actor_sprites[i].battler = $game_party.members[i] @actor_sprites[i].update end end #-------------------------------------------------------------------------- # ● ビューポートの更新 #-------------------------------------------------------------------------- alias update_viewports_fvEx update_viewports def update_viewports update_viewports_fvEx @viewport4.update end end #============================================================================== # ■ Window_BattleMessage #============================================================================== class Window_BattleMessage < Window_Message #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias initialize_fvEx initialize def initialize initialize_fvEx set_window end #-------------------------------------------------------------------------- # ● メッセージの終了 #-------------------------------------------------------------------------- def terminate_message super set_window end #-------------------------------------------------------------------------- # ● ウィンドウの背景と位置の設定 #-------------------------------------------------------------------------- def set_window(pos=0) $game_message.position = pos reset_window end #-------------------------------------------------------------------------- # ● ウィンドウの背景と位置の設定 #-------------------------------------------------------------------------- def reset_window super end end #============================================================================== # ■ Window_BattleMessageText #============================================================================== class Window_BattleMessageText < Window_BattleMessage #-------------------------------------------------------------------------- # ● 定数 #-------------------------------------------------------------------------- MAX_LINE = 1 # 最大行数 #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super self.width = 544+32 self.height = WLH*MAX_LINE+32 self.x = -16 self.y = 416-128-self.height+16 self.z = 0 create_contents self.opacity = 0 self.openness = 255 @lines = [] refresh end #-------------------------------------------------------------------------- # ● ウィンドウの背景と位置の設定 #-------------------------------------------------------------------------- def reset_window end #-------------------------------------------------------------------------- # ● 改行処理 #-------------------------------------------------------------------------- def new_line super @contents_y = 0 @line_count = 0 end #-------------------------------------------------------------------------- # ● メッセージの更新 #-------------------------------------------------------------------------- def update_message if @contents_x == 0 and @text != "" self.contents.fill_rect(Rect.new(0, 0, contents.width, WLH), Color.new(0,0,0,128)) end super end #-------------------------------------------------------------------------- # ● 文章の追加 # text : 追加する文章 #-------------------------------------------------------------------------- def add_instant_text(text) if @lines.size == MAX_LINE replace_instant_text(text) else super(text) end end #-------------------------------------------------------------------------- # ● 行の描画 # index : 行番号 #-------------------------------------------------------------------------- def draw_line(index) rect = Rect.new(0, 0, 0, 0) rect.y += index * WLH rect.width = contents.width rect.height = WLH self.contents.clear_rect(rect) self.contents.fill_rect(rect, Color.new(0,0,0,128)) self.contents.font.color = normal_color rect.x += 4 rect.width -= 8 self.contents.draw_text(rect, @lines[index]) end end #============================================================================== # ■ Window_PartyCommand #============================================================================== class Window_PartyCommand < Window_Command #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize cmd = [Vocab::fight, Vocab::escape] super(128, cmd, 1, cmd.size) draw_item(0, true) draw_item(1, $game_troop.can_escape) self.active = false end #-------------------------------------------------------------------------- # ● 項目の描画 # index : 項目番号 # enabled : 有効フラグ。false のとき半透明で描画 #-------------------------------------------------------------------------- def draw_item(index, enabled = true) rect = item_rect(index) rect.x += 4 rect.width -= 8 self.contents.clear_rect(rect) self.contents.font.color = normal_color self.contents.font.color.alpha = enabled ? 255 : 128 self.contents.draw_text(rect, @commands[index]) end end #============================================================================== # ■ Window_ActorCommand #============================================================================== class Window_ActorCommand < Window_Command ACT_I = 0 # たたかうIndex # ICON = FrontViewEx::ICON #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(138, [], 1, 4) self.active = false self.z += 10 end #-------------------------------------------------------------------------- # ● セットアップ # actor : アクター #-------------------------------------------------------------------------- alias setup_fvEx setup def setup(actor) @actor = actor setup_fvEx(actor) end #-------------------------------------------------------------------------- # ● 項目の描画 #-------------------------------------------------------------------------- def icon_index(index) return ICON[0][index] if @actor.nil? return @actor.weapons[0].icon_index if index == ACT_I and @actor.weapon_id != 0 id = ICON[@actor.id].nil? ? 0 : @actor.id return ICON[id][index] end #-------------------------------------------------------------------------- # ● 項目の描画 # index : 項目番号 # enabled : 有効フラグ。false のとき半透明で描画 #-------------------------------------------------------------------------- def draw_item(index, enabled = true) rect = item_rect(index) rect.x += 4 rect.width -= 8 self.contents.clear_rect(rect) draw_icon(icon_index(index), rect.x, rect.y) rect.x += 24 self.contents.font.color = normal_color self.contents.font.color.alpha = enabled ? 255 : 128 self.contents.draw_text(rect, @commands[index]) end end ##### HP/MP管理用のClass class FveiwObjHpMp TIME = 16 STEP = 1 attr_reader :current #------------------------------------------------------------------------ # ● オブジェクト初期化 #------------------------------------------------------------------------ def initialize(limit=TIME) @current = 0 @target = 0 @step = 0 @limit = limit end #------------------------------------------------------------------------ # ● リセット #------------------------------------------------------------------------ def reset(t) @current = @target = t @step = 0 end #------------------------------------------------------------------------ # ● ターゲット設定 #------------------------------------------------------------------------ def target(t, step=0) @target = t @step = step==0 ? calc_step(@current, @target) : step end #------------------------------------------------------------------------ # ● ステップ計算 #------------------------------------------------------------------------ def calc_step(a, b) return 0 if b == a diff = b - a p diff if diff.abs > 100 pm = diff / diff.abs t = [(diff.abs / STEP).round, @limit].min t = diff.abs if t == 0 step = [1, (diff.abs / t).truncate].max return step * pm end #------------------------------------------------------------------------ # ● カウントUP #------------------------------------------------------------------------ def count if (@target - @current).abs < @step.abs @current = @target else @current += @step end end #------------------------------------------------------------------------ # ● 終了判定 #------------------------------------------------------------------------ def exit? return @current == @target end end #============================================================================== # ■ Sprite_FveiwHPMP #============================================================================== class Sprite_FveiwHPMP < Sprite WLH = 24 #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(viewport, rect, mode=0) super(viewport) self.x = rect.x self.y = rect.y self.bitmap = Bitmap.new(rect.width, rect.height) @obj = FveiwObjHpMp.new @mode = mode end #-------------------------------------------------------------------------- # ● ターゲット改定 #-------------------------------------------------------------------------- def set(actor) @actor = actor target = @mode == 0 ? (actor.hp * 100.0 / [actor.maxhp, 1].max) : (actor.mp * 100.0 / [actor.maxmp, 1].max) @obj.target(target) end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh self.bitmap.clear case @mode when 0 draw_actor_hp_gauge(@obj.current/100.0, 0, 0, 100) draw_actor_hp(@actor, 0, 0, 100) when 1 draw_actor_mp_gauge(@obj.current/100.0, 0, 0, 100) draw_actor_mp(@actor, 0, 0, 100) end end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update return if @obj.exit? @obj.count refresh end #-------------------------------------------------------------------------- # ● 文字色取得 # n : 文字色番号 (0〜31) #-------------------------------------------------------------------------- def text_color(n) x = 64 + (n % 8) * 8 y = 96 + (n / 8) * 8 return Cache.system("Window").get_pixel(x, y) end #-------------------------------------------------------------------------- # ● ゲージ背景色の取得 #-------------------------------------------------------------------------- def gauge_back_color return text_color(19) end #-------------------------------------------------------------------------- # ● HP ゲージの色 1 の取得 #-------------------------------------------------------------------------- def hp_gauge_color1 return text_color(20) end #-------------------------------------------------------------------------- # ● HP ゲージの色 2 の取得 #-------------------------------------------------------------------------- def hp_gauge_color2 return text_color(21) end #-------------------------------------------------------------------------- # ● MP ゲージの色 1 の取得 #-------------------------------------------------------------------------- def mp_gauge_color1 return text_color(22) end #-------------------------------------------------------------------------- # ● MP ゲージの色 2 の取得 #-------------------------------------------------------------------------- def mp_gauge_color2 return text_color(23) end #-------------------------------------------------------------------------- # ● 通常文字色の取得 #-------------------------------------------------------------------------- def normal_color return text_color(0) end #-------------------------------------------------------------------------- # ● システム文字色の取得 #-------------------------------------------------------------------------- def system_color return text_color(16) end #-------------------------------------------------------------------------- # ● ピンチ文字色の取得 #-------------------------------------------------------------------------- def crisis_color return text_color(17) end #-------------------------------------------------------------------------- # ● 戦闘不能文字色の取得 #-------------------------------------------------------------------------- def knockout_color return text_color(18) end #-------------------------------------------------------------------------- # ● HP の文字色を取得 # actor : アクター #-------------------------------------------------------------------------- def hp_color(actor) return knockout_color if actor.hp == 0 return crisis_color if actor.hp < actor.maxhp / 4 return normal_color end #-------------------------------------------------------------------------- # ● MP の文字色を取得 # actor : アクター #-------------------------------------------------------------------------- def mp_color(actor) return crisis_color if actor.mp < actor.maxmp / 4 return normal_color end #-------------------------------------------------------------------------- # ● HP の描画 # actor : アクター # x : 描画先 X 座標 # y : 描画先 Y 座標 # width : 幅 #-------------------------------------------------------------------------- def draw_actor_hp(actor, x, y, width = 120) # draw_actor_hp_gauge(actor, x, y, width) self.bitmap.font.color = system_color self.bitmap.draw_cache_text(x, y, 30, WLH, Vocab::hp_a) self.bitmap.font.color = hp_color(actor) xr = x + width hp = @obj.exit? ? actor.hp : (actor.maxhp * @obj.current/100.0).truncate if width < 120 self.bitmap.draw_cache_num(xr - 40, y, 40, WLH, hp, 2) else self.bitmap.draw_cache_num(xr - 90, y, 40, WLH, hp.truncate, 2) self.bitmap.font.color = normal_color self.bitmap.draw_cache_text(xr - 50, y, 10, WLH, "/", 2) self.bitmap.draw_cache_num(xr - 40, y, 40, WLH, actor.maxhp, 2) end end #-------------------------------------------------------------------------- # ● MP の描画 # actor : アクター # x : 描画先 X 座標 # y : 描画先 Y 座標 # width : 幅 #-------------------------------------------------------------------------- def draw_actor_mp(actor, x, y, width = 120) # draw_actor_mp_gauge(actor, x, y, width) self.bitmap.font.color = system_color self.bitmap.draw_cache_text(x, y, 30, WLH, Vocab::mp_a) self.bitmap.font.color = mp_color(actor) xr = x + width mp = @obj.exit? ? actor.mp : (actor.maxmp * @obj.current/100.0).truncate if width < 120 self.bitmap.draw_cache_num(xr - 40, y, 40, WLH, mp.truncate, 2) else self.bitmap.draw_cache_num(xr - 90, y, 40, WLH, mp, 2) self.bitmap.font.color = normal_color self.bitmap.draw_cache_text(xr - 50, y, 10, WLH, "/", 2) self.bitmap.draw_cache_num(xr - 40, y, 40, WLH, actor.maxmp, 2) end end #-------------------------------------------------------------------------- # ● HP ゲージの描画 # per : パーセント # x : 描画先 X 座標 # y : 描画先 Y 座標 # width : 幅 #-------------------------------------------------------------------------- def draw_actor_hp_gauge(per, x, y, width = 120) gw = width * per #actor.hp / actor.maxhp gc1 = hp_gauge_color1 gc2 = hp_gauge_color2 self.bitmap.fill_rect(x, y + WLH - 8, width, 6, gauge_back_color) self.bitmap.gradient_fill_rect(x, y + WLH - 8, gw, 6, gc1, gc2) end #-------------------------------------------------------------------------- # ● MP ゲージの描画 # per : パーセント # x : 描画先 X 座標 # y : 描画先 Y 座標 # width : 幅 #-------------------------------------------------------------------------- def draw_actor_mp_gauge(per, x, y, width = 120) gw = width * per #actor.mp / [actor.maxmp, 1].max gc1 = mp_gauge_color1 gc2 = mp_gauge_color2 self.bitmap.fill_rect(x, y + WLH - 8, width, 6, gauge_back_color) self.bitmap.gradient_fill_rect(x, y + WLH - 8, gw, 6, gc1, gc2) end end #============================================================================== # ■ Sprite_BtActStatus #============================================================================== class Sprite_BtActStatus < Sprite WLH = 24 #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(actor, r, z=0) r.height += 6 @viewport = Viewport.new(r) super(@viewport) self.bitmap = Bitmap.new(r.width, r.height) self.viewport.z = z + 100 @hp = Sprite_FveiwHPMP.new(@viewport, Rect.new(0, 6+WLH*2, r.width, WLH), 0) @mp = Sprite_FveiwHPMP.new(@viewport, Rect.new(0, 6+WLH*3, r.width, WLH), 1) @hp.z = @mp.z = self.z + 10 refresh(actor) @hp.refresh @mp.refresh end #-------------------------------------------------------------------------- # ● オブジェクト開放 #-------------------------------------------------------------------------- def dispose super @hp.dispose @mp.dispose @viewport.dispose end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh(actor) self.bitmap.clear # self.bitmap.draw_text(0, 4, 120, WLH, actor.name) draw_actor_state(actor, 0, 0, 100) # draw_actor_hp(actor, 0, 6+WLH*2, 100) @hp.set(actor) # draw_actor_mp(actor, 0, 6+WLH*3, 100) @mp.set(actor) end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super @hp.update @mp.update end #-------------------------------------------------------------------------- # ● アイコンの描画 # icon_index : アイコン番号 # x : 描画先 X 座標 # y : 描画先 Y 座標 # enabled : 有効フラグ。false のとき半透明で描画 #-------------------------------------------------------------------------- def draw_icon(icon_index, x, y, enabled = true) b = Cache.system("Iconset") rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24) self.bitmap.blt(x, y, b, rect, enabled ? 255 : 128) end #-------------------------------------------------------------------------- # ● ステートの描画 # actor : アクター # x : 描画先 X 座標 # y : 描画先 Y 座標 # width : 描画先の幅 #-------------------------------------------------------------------------- def draw_actor_state(actor, x, y, width = 96) count = 0 for state in actor.states draw_icon(state.icon_index, x + 24 * count, y) count += 1 break if (24 * count > width - 24) end end end #============================================================================== # ■ Window_BattleStatus #============================================================================== class Window_BattleStatus < Window_Selectable #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize super(0, 416-128, 544, 128, 0) self.z = 1 @actors = [] @column_max = $game_party.members.size create_actors refresh self.active = false self.opacity = FrontViewEx::ST_WIN_OPC end #-------------------------------------------------------------------------- # ● オブジェクト開放 #-------------------------------------------------------------------------- def dispose super dispose_actors end #-------------------------------------------------------------------------- # ● アクター別ウィンドウ作成 #-------------------------------------------------------------------------- def create_actors for i in 0...$game_party.members.size rect = item_rect(i) rect.x += self.x+16 rect.y += self.y+16 rect.height = self.contents.height @actors.push(Sprite_BtActStatus.new($game_party.members[i], rect, self.z)) end end #-------------------------------------------------------------------------- # ● アクター別ウィンドウ開放 #-------------------------------------------------------------------------- def dispose_actors for win in @actors win.dispose end 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.x += (96 / @column_max) - 16 rect.y = index / @column_max * WLH return rect end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- alias refresh_fvEx refresh def refresh if @column_max != $game_party.members.size @column_max = $game_party.members.size dispose_actors create_actors end refresh_fvEx end #-------------------------------------------------------------------------- # ● 項目の描画 # index : 項目番号 #-------------------------------------------------------------------------- def draw_item(index) @actors[index].refresh($game_party.members[index]) end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super for sprite in @actors sprite.update end end end #============================================================================== # ■ Window_Arrow #============================================================================== class Window_Arrow < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(viewport) super(0,0,544,WLH+32) self.viewport = viewport self.visible = false @target = nil end #-------------------------------------------------------------------------- # ● ターゲット設定 #-------------------------------------------------------------------------- def set_target(target) return if @target == target self.visible = true self.width = [120, self.contents.text_size(target.name).width + 40].max create_contents draw_actor_hp_gauge(target, 0, 0, self.contents.width) unless target.actor? draw_actor_name(target, 0, 0) @target = target end #-------------------------------------------------------------------------- # ● 名前の描画 # actor : アクター # x : 描画先 X 座標 # y : 描画先 Y 座標 #-------------------------------------------------------------------------- def draw_actor_name(actor, x, y) self.contents.font.color = hp_color(actor) self.contents.draw_text(x, y, self.contents.width-x, WLH, actor.name) end end #============================================================================== # ■ Arrow_FviewTarget #============================================================================== class Arrow_FviewTarget < Sprite #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :index # カーソル位置 attr_reader :help_window # ヘルプウィンドウ #-------------------------------------------------------------------------- # ● オブジェクト初期化 # viewport : ビューポート # is_actor : アクター or エネミー #-------------------------------------------------------------------------- def initialize(viewport, is_actor=true) super(viewport) self.bitmap = Cache.system("Window") self.ox = 8 self.oy = 8 self.z = 2500 @help_window = Window_Arrow.new(viewport) @blink_count = 0 @is_actor = is_actor self.index = 0 target.stop_loop = false target.loop_flash = true self.src_rect.set(96, 64, 16, 16) update_pos end #-------------------------------------------------------------------------- # ● オブジェクト破棄 #-------------------------------------------------------------------------- def dispose target.loop_flash = false target.stop_loop = true super @help_window.dispose unless @help_window.nil? end #-------------------------------------------------------------------------- # ● 高さ調整 #-------------------------------------------------------------------------- def add_heigth if @is_actor return 96 else return Cache.battler(target.battler_name, target.battler_hue).height end end #-------------------------------------------------------------------------- # ● ターゲット群 #-------------------------------------------------------------------------- def members return $game_party.members if @is_actor return $game_troop.members end #-------------------------------------------------------------------------- # ● カーソルが指しているターゲットの取得 #-------------------------------------------------------------------------- def target return members[@index] end def actor; return target; end def enemy; return target; end #-------------------------------------------------------------------------- # ● カーソル位置の設定 # index : 新しいカーソル位置 #-------------------------------------------------------------------------- def index=(index) @index = index size = members.size for i in 0...size break if !@is_actor and target.exist? @index = (@index + 1) % size end update_help update_pos end #-------------------------------------------------------------------------- # ● カーソル変更(右) #-------------------------------------------------------------------------- def cursor_right target.loop_flash = false target.stop_loop = true self.index = (@index + 1) % members.size target.stop_loop = false target.loop_flash = true end #-------------------------------------------------------------------------- # ● カーソル変更(左) #-------------------------------------------------------------------------- def cursor_left target.loop_flash = false target.stop_loop = true self.index = (@index + members.size - 1) % members.size target.stop_loop = false target.loop_flash = true end #-------------------------------------------------------------------------- # ● ヘルプウィンドウの設定 # help_window : 新しいヘルプウィンドウ #-------------------------------------------------------------------------- def help_window=(help_window) @help_window = help_window update_help if @help_window != nil end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update update_count update_cursor end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update_count @blink_count = (@blink_count + 1) % 32 if (@blink_count % 8) == 0 case (@blink_count / 8) # 転送元の矩形を設定 when 0,1; self.src_rect.set(96, 64, 16, 16) when 2,3; self.src_rect.set(96+16, 64, 16, 16) when 4,5; self.src_rect.set(96+16, 64+16, 16, 16) when 6,7; self.src_rect.set(96, 64+16, 16, 16) end end end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update_help return if @help_window.nil? @help_window.set_target(target) end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update_cursor old_index = @index if Input.trigger?(Input::RIGHT) cursor_right elsif Input.trigger?(Input::LEFT) cursor_left end Sound.play_cursor if old_index != @index end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update_pos self.x = target.screen_x self.y = target.screen_y - add_heigth unless @help_window.nil? @help_window.x = self.x - @help_window.width/2 yy = self.y - self.src_rect.height/2 - @help_window.height @help_window.y = [yy, 0].max self.y += @help_window.y - yy end end end #============================================================================== # ■ Scene_Battle #============================================================================== class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # ● 開始処理 #-------------------------------------------------------------------------- def start super $game_temp.in_battle = true @spriteset = Spriteset_Battle.new @message_window = Window_BattleMessageText.new @action_battlers = [] create_info_viewport end #-------------------------------------------------------------------------- # ● 基本更新処理 # main : メインの update メソッドからの呼び出し #-------------------------------------------------------------------------- alias update_basic_fvEx update_basic def update_basic(main = false) update_basic_fvEx(main) @status_window.update end #-------------------------------------------------------------------------- # ● バトルイベントの処理 #-------------------------------------------------------------------------- def process_battle_event loop do return if judge_win_loss return if $game_temp.next_scene != nil $game_troop.interpreter.update $game_troop.setup_battle_event @message_window.dispose @message_window = Window_BattleMessage.new wait_for_message @message_window.dispose @message_window = Window_BattleMessageText.new process_action if $game_troop.forcing_battler != nil return unless $game_troop.interpreter.running? update_basic end end #-------------------------------------------------------------------------- # ● 勝利の処理 #-------------------------------------------------------------------------- alias process_victory_fvEx process_victory def process_victory @message_window.dispose @message_window = Window_BattleMessage.new process_victory_fvEx end #-------------------------------------------------------------------------- # ● 情報表示ビューポートの作成 #-------------------------------------------------------------------------- def create_info_viewport @status_window = Window_BattleStatus.new @info_viewport = Viewport.new(0, 0, 544, 128) # @party_viewport = Viewport.new(0, 0, 128, 24*2+32) @party_viewport.z = 1000 @party_command_window = Window_PartyCommand.new @party_command_window.viewport = @party_viewport # @actor_viewport = Viewport.new(0, 416-138-128, 138, 24*4+32) @actor_viewport.z = 100 @actor_command_window = Window_ActorCommand.new @actor_command_window.viewport = @actor_viewport # @party_viewport.visible = false @actor_viewport.visible = false @party_viewport.ox = 128 end #-------------------------------------------------------------------------- # ● 情報表示ビューポートの解放 #-------------------------------------------------------------------------- alias dispose_info_viewport_fvEx dispose_info_viewport def dispose_info_viewport dispose_info_viewport_fvEx @party_viewport.dispose @actor_viewport.dispose end #-------------------------------------------------------------------------- # ● 情報表示ビューポートの更新 #-------------------------------------------------------------------------- def update_info_viewport @party_command_window.update @actor_command_window.update # @status_window.update # if @party_command_window.active and @info_viewport.ox > 0 # @info_viewport.ox -= 16 # elsif @actor_command_window.active and @info_viewport.ox < 128 # @info_viewport.ox += 16 # end if @party_command_window.active and @party_viewport.ox > 0 @party_viewport.ox -= 16 elsif @actor_command_window.active and @party_viewport.ox < 128 @party_viewport.ox += 16 end if @actor_command_window.active and @actor_viewport.oy < 0 @actor_viewport.oy += 16 elsif @party_command_window.active and @actor_viewport.oy > 0 @actor_viewport.oy -= 16 end end #-------------------------------------------------------------------------- # ● パーティコマンド選択の開始 #-------------------------------------------------------------------------- def start_party_command_selection if $game_temp.in_battle @status_window.refresh @status_window.index = @actor_index = -1 @active_battler = nil @party_viewport.visible = true @message_window.visible = false @party_command_window.active = true @party_command_window.index = 0 @actor_command_window.active = false @actor_viewport.visible = false $game_party.clear_actions if $game_troop.surprise or not $game_party.inputable? start_main end end end #-------------------------------------------------------------------------- # ● アクターコマンド選択の開始 #-------------------------------------------------------------------------- alias start_actor_command_selection_fvEx start_actor_command_selection def start_actor_command_selection start_actor_command_selection_fvEx @party_viewport.visible = false @actor_viewport.visible = true @actor_viewport.rect.x = @active_battler.screen_x - (96/2) - 21 @actor_viewport.rect.y = 416-128-128 @actor_viewport.oy = -@actor_viewport.rect.height end #-------------------------------------------------------------------------- # ● 次のアクターのコマンド入力へ #-------------------------------------------------------------------------- def next_actor loop do if @actor_index == $game_party.members.size-1 start_main return end @actor_index += 1 @active_battler = $game_party.members[@actor_index] if @active_battler.auto_battle @active_battler.make_action next end break if @active_battler.inputable? end start_actor_command_selection end #-------------------------------------------------------------------------- # ● 前のアクターのコマンド入力へ #-------------------------------------------------------------------------- def prior_actor loop do if @actor_index == 0 start_party_command_selection return end @actor_index -= 1 @active_battler = $game_party.members[@actor_index] next if @active_battler.auto_battle break if @active_battler.inputable? end start_actor_command_selection end #-------------------------------------------------------------------------- # ● 対象敵キャラ選択の開始 #-------------------------------------------------------------------------- def start_target_enemy_selection @target_enemy_window = Arrow_FviewTarget.new(nil, false) @actor_viewport.visible = false if @skill_window != nil @skill_window.visible = false @help_window.visible = false elsif @item_window != nil @item_window.visible = false @help_window.visible = false end end #-------------------------------------------------------------------------- # ● 対象敵キャラ選択の終了 #-------------------------------------------------------------------------- def end_target_enemy_selection @target_enemy_window.dispose @target_enemy_window = nil case @actor_command_window.index when 0 unless @actor_command_window.nil? @actor_command_window.active = true @actor_viewport.visible = true end when 1 unless @skill_window.nil? @skill_window.visible = true @skill_window.active = true @help_window.visible = true end when 3 unless @item_window.nil? @item_window.visible = true @item_window.active = true @help_window.visible = true end end end #-------------------------------------------------------------------------- # ● 対象アクター対象選択の開始 #-------------------------------------------------------------------------- def start_target_actor_selection @target_actor_window = Arrow_FviewTarget.new(nil, true) @actor_command_window.active = false if @skill_window != nil @skill_window.visible = false @help_window.visible = false elsif @item_window != nil @item_window.visible = false @help_window.visible = false end end #-------------------------------------------------------------------------- # ● 対象アクター選択の終了 #-------------------------------------------------------------------------- def end_target_actor_selection @target_actor_window.dispose @target_actor_window = nil case @actor_command_window.index when 0 @actor_command_window.active = true @actor_viewport.visible = true when 1 @skill_window.visible = true @skill_window.active = true @help_window.visible = true when 3 @item_window.visible = true @item_window.active = true @help_window.visible = true end end #-------------------------------------------------------------------------- # ● スキル選択の開始 #-------------------------------------------------------------------------- alias start_skill_selection_fvEx start_skill_selection def start_skill_selection start_skill_selection_fvEx @actor_viewport.visible = false end #-------------------------------------------------------------------------- # ● スキル選択の終了 #-------------------------------------------------------------------------- alias end_skill_selection_fvEx end_skill_selection def end_skill_selection end_skill_selection_fvEx @actor_viewport.visible = true end #-------------------------------------------------------------------------- # ● アイテム選択の開始 #-------------------------------------------------------------------------- alias start_item_selection_fvEx start_item_selection def start_item_selection start_item_selection_fvEx @actor_viewport.visible = false end #-------------------------------------------------------------------------- # ● アイテム選択の終了 #-------------------------------------------------------------------------- alias end_item_selection_fvEx end_item_selection def end_item_selection end_item_selection_fvEx @actor_viewport.visible = true end #-------------------------------------------------------------------------- # ● 戦闘開始の処理 #-------------------------------------------------------------------------- def process_battle_start @message_window.clear wait(10) name = "" names = $game_troop.enemy_names for i in 0...names.size name += "、" if i > 0 name += names[i] end text = sprintf(Vocab::Emerge, name) $game_message.texts.push(text) wait_for_message text = "" if $game_troop.preemptive text = sprintf(Vocab::Preemptive, $game_party.name) $game_message.texts.push(text) elsif $game_troop.surprise text = sprintf(Vocab::Surprise, $game_party.name) $game_message.texts.push(text) end wait_for_message if text != "" @message_window.clear make_escape_ratio process_battle_event start_party_command_selection end #-------------------------------------------------------------------------- # ● 戦闘処理の実行開始 #-------------------------------------------------------------------------- def start_main $game_troop.increase_turn @party_viewport.visible = false @actor_viewport.visible = false @message_window.visible = true @party_command_window.active = false @actor_command_window.active = false @status_window.index = @actor_index = -1 @active_battler = nil @message_window.clear $game_troop.make_actions make_action_orders wait(20) end #-------------------------------------------------------------------------- # ● ターン終了 #-------------------------------------------------------------------------- def turn_end $game_troop.turn_ending = true #$game_party.slip_damage_effect #$game_troop.slip_damage_effect for battler in $game_party.members + $game_troop.members if battler.slip_damage? and battler.hp > 0 battler.slip_damage_effect display_hp_damage(battler) end end #$game_party.do_auto_recovery for battler in $game_party.members if battler.auto_hp_recover and not battler.dead? battler.do_auto_recovery display_hp_damage(battler) end end $game_troop.preemptive = false $game_troop.surprise = false process_battle_event $game_troop.turn_ending = false start_party_command_selection end #-------------------------------------------------------------------------- # ● 戦闘行動の実行 : スキル #-------------------------------------------------------------------------- def execute_action_skill skill = @active_battler.action.skill text = @active_battler.name + skill.message1 @message_window.add_instant_text(text) unless skill.message2.empty? wait(10) @message_window.add_instant_text(skill.message2) end @active_battler.mp -= @active_battler.calc_mp_cost(skill) refresh_status(@active_battler) targets = @active_battler.action.make_targets display_animation(targets, skill.animation_id) $game_temp.common_event_id = skill.common_event_id for target in targets target.skill_effect(@active_battler, skill) display_action_effects(target, skill) end end #-------------------------------------------------------------------------- # ● 攻撃アニメーションの表示 # targets : 対象者の配列 # 敵キャラの場合は [敵の通常攻撃] 効果音を演奏して一瞬待つ。 # アクターの場合は二刀流を考慮 (左手武器は反転して表示) 。 #-------------------------------------------------------------------------- def display_attack_animation(targets) if @active_battler.is_a?(Game_Enemy) and @active_battler.atk_animation_id == 0 Sound.play_enemy_attack wait(15, true) else aid1 = @active_battler.atk_animation_id aid2 = @active_battler.atk_animation_id2 display_normal_animation(targets, aid1, false) display_normal_animation(targets, aid2, true) end wait_for_animation end #-------------------------------------------------------------------------- # ● HP ダメージ表示 # target : 対象者 # obj : スキルまたはアイテム #-------------------------------------------------------------------------- alias display_hp_damage_fvEx display_hp_damage def display_hp_damage(target, obj = nil) refresh_status(target) if target.hp_damage != 0 target.pop_hp_damage = true if target.hp_damage != 0 display_hp_damage_fvEx(target, obj) end #-------------------------------------------------------------------------- # ● MP ダメージ表示 # target : 対象者 # obj : スキルまたはアイテム #-------------------------------------------------------------------------- alias display_mp_damage_fvEx display_mp_damage def display_mp_damage(target, obj = nil) refresh_status(target) if target.mp_damage != 0 target.pop_mp_damage = true if target.mp_damage != 0 display_mp_damage_fvEx(target, obj) end #-------------------------------------------------------------------------- # ● ステート変化の表示 # target : 対象者 # obj : スキルまたはアイテム #-------------------------------------------------------------------------- alias display_state_changes_fvEx display_state_changes def display_state_changes(target, obj = nil) refresh_status(target) if !target.missed and !target.evaded and target.states_active? display_state_changes_fvEx(target, obj) end #-------------------------------------------------------------------------- # ● 行動結果の表示 # target : 対象者 # obj : スキルまたはアイテム #-------------------------------------------------------------------------- def display_action_effects(target, obj = nil) unless target.skipped line_number = @message_window.line_number wait(5) display_critical(target, obj) display_damage(target, obj) display_state_changes(target, obj) # if line_number == @message_window.line_number # display_failure(target, obj) unless target.states_active? # end if line_number != @message_window.line_number wait(30) end @message_window.back_to(line_number) end end #-------------------------------------------------------------------------- # ● ステータスの更新 #-------------------------------------------------------------------------- def refresh_status(battler) return unless battler.actor? @status_window.draw_item(battler.index) end end