############################# ここからが設定箇所 ############################# class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # ● 左右非対称判定 #-------------------------------------------------------------------------- def mirror? case @id when 0 return true else return false end end end class Game_Enemy < Game_Battler #-------------------------------------------------------------------------- # ● 左右非対称判定 #-------------------------------------------------------------------------- def mirror? case @id when 0 return true else return false end end #-------------------------------------------------------------------------- # ● バトラー行動制限 #-------------------------------------------------------------------------- def move case @id when 0 return true else return false end end end class Game_Battler #-------------------------------------------------------------------------- # ● バトラー行動番号 #-------------------------------------------------------------------------- def anime_code_set case @current_action.kind when 0 if self.is_a?(Game_Actor) case @weapon_id when 0 anime_code = [] else anime_code = [Numset::MOVING_LINE, Numset::ATTACK_LINE, Numset::MOVING_LINE] end else case @weapon_id when 0 anime_code = [] else anime_code = [Numset::MOVING_LINE, Numset::ATTACK_LINE, Numset::MOVING_LINE] end end when 1 case @current_action.skill_id when 0 anime_code = [] else anime_code = [Numset::MAGIC_LINE] end when 2 case @current_action.item_id when 0 anime_code = [] else anime_code = [Numset::ITEM_LINE] end end # 補充 unless anime_code.include?("anime") anime_code.unshift("anime") end unless anime_code.include?("help") anime_code.unshift("help") end anime_code.unshift(0) return anime_code end #-------------------------------------------------------------------------- # ● バトラー行動時間 #-------------------------------------------------------------------------- def anime_time_set case @current_action.kind when 0 if self.is_a?(Game_Actor) case @weapon_id when 0 anime_time = [-1] else anime_time = [32, "start", 16, 32, -1] end else case @id when 0 anime_time = [-1] else anime_time = [32, "start", 16, 32, -1] end end when 1 case @current_action.skill_id when 0 anime_time = [-1] else anime_time = [-1, -1] end when 2 case @current_action.item_id when 0 anime_time = [-1] else anime_time = [-1, -1] end end unless anime_time.include?("start") end anime_time.unshift(0) return anime_time end #-------------------------------------------------------------------------- # ● バトラー移動地点 #-------------------------------------------------------------------------- def move_code_set battler = @active_battler if $scene.target_battlers.size == 1 target = $scene.target_battlers[0] end case @current_action.kind when 0 if self.is_a?(Game_Actor) case @weapon_id when 0 move_code = [] else move_code = [[target.target_x, target.screen_y], [target.target_x, target.screen_y], [@save_x, @save_y]] end else case @id when 0 move_code = [] else move_code = [[target.target_x, target.screen_y], [target.target_x, target.screen_y], [@save_x, @save_y]] end end when 1 case @current_action.skill_id when 0 move_code = [] else move_code = [] end when 2 case @current_action.item_id when 0 move_code = [] else move_code = [] end end return move_code end #-------------------------------------------------------------------------- # ● バトラー移動時間 #-------------------------------------------------------------------------- def move_time_set case @current_action.kind when 0 if self.is_a?(Game_Actor) case @weapon_id when 0 move_time = [] else move_time = [32, 16, 32] end else case @id when 0 move_time = [] else move_time = [32, 16, 32] end end when 1 case @current_action.skill_id when 0 move_code = [] else move_code = [] end when 2 case @current_action.item_id when 0 move_code = [] else move_code = [] end end return move_time end #-------------------------------------------------------------------------- # ● ターゲット移動地点 #-------------------------------------------------------------------------- def target_move_code_set(target) case @current_action.kind when 0 if self.is_a?(Game_Actor) case @weapon_id when 0 else end else case @id when 0 else end end when 1 case @current_action.skill_id when 0 else end when 2 case @current_action.item_id when 0 else end end return move_code end #-------------------------------------------------------------------------- # ● ターゲット移動距離 #-------------------------------------------------------------------------- def target_move_time_set(target) case @current_action.kind when 0 if self.is_a?(Game_Actor) case @weapon_id when 0 else end else case @id when 0 else end end when 1 case @current_action.skill_id when 0 else end when 2 case @current_action.item_id when 0 else end end return move_code end #-------------------------------------------------------------------------- # ● 逃走アニメセット #-------------------------------------------------------------------------- def escape_set if self.is_a?(Game_Actor) case @id when 0 else @anime_code = [0, 1] @anime_time = [0, -1] @move_code = [[800, @screen_y]] @move_time = [16] end else case @id when 0 else @anime_code = [0, 1] @anime_time = [0, -1] @move_code = [[-160, @screen_y]] @move_time = [16] end end end #-------------------------------------------------------------------------- # ● 勝利アニメセット #-------------------------------------------------------------------------- def win_set case @id when 0 else end end end class Sprite_Battler < RPG::Sprite #-------------------------------------------------------------------------- # ● アニメーション設定 #-------------------------------------------------------------------------- def anime_set(animation) case animation.id when 0 animation(animation, @battler.animation_hit, @battler.animation_critical, false, 0) else if Game_Battler.method_defined?("animation_critical") animation(animation, @battler.animation_hit, @battler.animation_critical) else animation(animation, @battler.animation_hit) end end end end #============================================================================== # ■ Numset #------------------------------------------------------------------------------ #  定数を扱うモジュールです。 #============================================================================== module Numset DOUBLE_SPEED = false # アニメーションの倍速化。より細かな表現が可能に。 PINCH_PARSENT = 12.5 # ピンチ時のアニメーションを表示する最大の% LOOP_FRAME = 4 # ループ時のコマ数 LOOP_TIME = 6 # ループ時に一コマを写すフレーム数 STANDING_LINE = 0 # 待機時にループさせる列 MOVING_LINE = 1 # 移動時にループさせる列 ATTACK_LINE = 2 # 攻撃時にループさせる列 SKILL_LINE = 4 # スキル使用時にループさせる列 ITEM_LINE = 4 # 道具使用時にループさせる列 DAMAGE_LINE = 6 # 被ダメージ時にループさせる列 GUARDING_LINE = 6 # 防御時にループさせる列 PINCH_LINE = 5 # ピンチ時にループさせる列 DEAD_LINE = 7 # 戦闘不能時にループさせる列 DAMAGE_TIME = 16 # 戦闘不能になる前にダメージを受けている時間 ESCAPE_TIME = 40 # 逃走までの時間 POSITION_X = [400, 440, 480, 520] # それぞれのX座標 POSITION_Y = [40, 80, 120, 160] # それぞれのY座標 POSITION_PLUS = 30 # 隊列X座標補正 ############################# ここまでが設定箇所 ############################### #-------------------------------------------------------------------------- # 座標から角度を割り出す #-------------------------------------------------------------------------- def self.line_tan(x1, y1, x2, y2) line = Math.hypot(x1 - x2, y1 - y2) if line != 0 red = Math.cos((x1 - x2) / line) return (red * 180 / Math::PI) else return 0 end end end #============================================================================== # ■ RPG::Sprite #------------------------------------------------------------------------------ #  アニメーションの管理を行うクラスです。 #============================================================================== module RPG class Sprite < ::Sprite @@_animations = [] @@_reference_count = {} def initialize(viewport = nil) super(viewport) @_whiten_duration = 0 @_appear_duration = 0 @_escape_duration = 0 @_collapse_duration = 0 @_damage_duration = 0 @_animation_duration =[] @_blink = false @_animation = [] @_animation_hit = [] @_animation_nomove = [] @_animation_xyan = [] @_animation_sprites = [] if Game_Battler.method_defined?("animation_critical") @_animation_critical = [] end @_loop_animation = [] @_loop_animation_index = [] @_loop_animation_xyan = [] @_loop_animation_sprites = [] end def dispose dispose_damage (0...@_animation.size).each{|a| dispose_animation(a)} (0...@_loop_animation.size).each{|a| dispose_loop_animation(a)} super end if Game_Battler.method_defined?("animation_critical") def animation(animation, hit, critical = false, nomove = false, san = 0, *point) return if animation == nil @_animation.push(animation) @_animation_hit.push(hit) @_animation_nomove.push(nomove) @_animation_critical.push(critical) @_animation_duration.push(animation.frame_max) @_animation_xyan.push([point, san]) animation_name = animation.animation_name animation_hue = animation.animation_hue bitmap = RPG::Cache.animation(animation_name, animation_hue) if @@_reference_count.include?(bitmap) @@_reference_count[bitmap] += 1 else @@_reference_count[bitmap] = 1 end @_animation_sprites.push([]) max = 0 for a in animation.frames max = [max, a.cell_max].max end if animation.position != 3 or not @@_animations.include?(animation) for i in 0..max sprite = ::Sprite.new(self.viewport) sprite.bitmap = bitmap sprite.visible = false @_animation_sprites.last.push(sprite) end unless @@_animations.include?(animation) @@_animations.push(animation) end end update_animation(animation_name) end else def animation(animation, hit, nomove = false, san = 0, *point) return if animation == nil @_animation.push(animation) @_animation_hit.push(hit) @_animation_nomove.push(nomove) @_animation_duration.push(animation.frame_max) @_animation_xyan.push([point, san]) animation_name = animation.animation_name animation_hue = animation.animation_hue bitmap = RPG::Cache.animation(animation_name, animation_hue) if @@_reference_count.include?(bitmap) @@_reference_count[bitmap] += 1 else @@_reference_count[bitmap] = 1 end @_animation_sprites.push([]) max = 0 for a in animation.frames max = [max, a.cell_max].max end if animation.position != 3 or not @@_animations.include?(animation) for i in 0..max sprite = ::Sprite.new(self.viewport) sprite.bitmap = bitmap sprite.visible = false @_animation_sprites.last.push(sprite) end unless @@_animations.include?(animation) @@_animations.push(animation) end end update_animation(@_animation.size - 1) end end def loop_animation(animation, san = 0, *point) return if (@_loop_animation.include?(animation) or animation == nil) @_loop_animation.push(animation) @_loop_animation_index.push(0) @_loop_animation_xyan.push([point, san]) animation_name = animation.animation_name animation_hue = animation.animation_hue bitmap = RPG::Cache.animation(animation_name, animation_hue) if @@_reference_count.include?(bitmap) @@_reference_count[bitmap] += 1 else @@_reference_count[bitmap] = 1 end @_loop_animation_sprites.push([]) max = 0 for a in animation.frames max = [max, a.cell_max].max end for i in 0..max sprite = ::Sprite.new(self.viewport) sprite.bitmap = bitmap sprite.visible = false @_loop_animation_sprites.last.push(sprite) end update_loop_animation(@_loop_animation.size - 1) end def dispose_animation(id) if @_animation_sprites[id] != nil sprite = @_animation_sprites[id][0] if sprite != nil @@_reference_count[sprite.bitmap] -= 1 end for sprite in @_animation_sprites[id] sprite.dispose end @_animation_duration.delete_at(id) @_animation_sprites.delete_at(id) @_animation_xyan.delete_at(id) @_animation_hit.delete_at(id) if Game_Battler.method_defined?("animation_critical") @_animation_critical.delete_at(id) end @_animation.delete_at(id) end end def dispose_loop_animation(id) if @_loop_animation_sprites[id] != nil sprite = @_loop_animation_sprites[id][0] if sprite != nil @@_reference_count[sprite.bitmap] -= 1 end for sprite in @_loop_animation_sprites[id] sprite.dispose end @_loop_animation_sprites.delete_at(id) @_loop_animation_xyan.delete_at(id) @_loop_animation_index.delete_at(id) @_loop_animation.delete_at(id) end end def effect? return true if @_whiten_duration > 0 return true if @_appear_duration > 0 return true if @_escape_duration > 0 return true if @_collapse_duration > 0 return true if @_damage_duration > 0 for i in 0...@_animation_duration.size return true if @_animation_duration[i] > 0 end return false end def update super if @_whiten_duration > 0 @_whiten_duration -= 1 self.color.alpha = 128 - (16 - @_whiten_duration) * 10 end if @_appear_duration > 0 @_appear_duration -= 1 self.opacity = (16 - @_appear_duration) * 16 end if @_escape_duration > 0 @_escape_duration -= 1 self.opacity = 256 - (32 - @_escape_duration) * 10 end if @_collapse_duration > 0 @_collapse_duration -= 1 self.opacity = 256 - (48 - @_collapse_duration) * 6 end if @_damage_duration > 0 @_damage_duration -= 1 case @_damage_duration when 38..39 @_damage_sprite.y -= 4 when 36..37 @_damage_sprite.y -= 2 when 34..35 @_damage_sprite.y += 2 when 28..33 @_damage_sprite.y += 4 end @_damage_sprite.opacity = 256 - (12 - @_damage_duration) * 32 if @_damage_duration == 0 dispose_damage end end if @_animation != [] if Numset::DOUBLE_SPEED or (Graphics.frame_count % 2 == 0) result = true for i in 0...@_animation.size i -= 1 if result == false @_animation_duration[i] -= 1 result = update_animation(i) end end end if @_loop_animation != [] if Numset::DOUBLE_SPEED or (Graphics.frame_count % 2 == 0) for i in 0...@_loop_animation.size update_loop_animation(i) @_loop_animation_index[i] += 1 @_loop_animation_index[i] %= @_loop_animation[i].frame_max end end end if @_blink @_blink_count = (@_blink_count + 1) % 32 if @_blink_count < 16 alpha = (16 - @_blink_count) * 6 else alpha = (@_blink_count - 16) * 6 end self.color.set(255, 255, 255, alpha) end @@_animations.clear end def update_animation(id) result = (@_animation_duration[id] > 0) if result frame_index = @_animation[id].frame_max - @_animation_duration[id] cell_data = @_animation[id].frames[frame_index].cell_data position = @_animation[id].position times = [@_animation[id].frame_max, @_animation_duration[id]] animation_set_sprites(@_animation_sprites[id], cell_data, position, times, @_animation_xyan[id]) for timing in @_animation[id].timings if timing.frame == frame_index if Game_Battler.method_defined?("animation_critical") animation_process_timing(timing, @_animation_hit[id], @_animation_critical[id]) else animation_process_timing(timing, @_animation_hit[id]) end end end else dispose_animation(id) end return result end def update_loop_animation(id) frame_index = @_loop_animation_index[id] cell_data = @_loop_animation[id].frames[frame_index].cell_data position = @_loop_animation[id].position times = [@_loop_animation[id].frame_max, @_loop_animation_index[id]] animation_set_sprites(@_loop_animation_sprites[id], cell_data, position, times, @_loop_animation_xyan[id]) for timing in @_loop_animation[id].timings if timing.frame == frame_index animation_process_timing(timing, true) end end end def animation_set_sprites(sprites, cell_data, position, times, xyan = [[], 0]) for i in 0..sprites.size sprite = sprites[i] pattern = cell_data[i, 0] if sprite == nil or pattern == nil or pattern == -1 sprite.visible = false if sprite != nil next end sprite.visible = true sprite.src_rect.set(pattern % 5 * 192, pattern / 5 * 192, 192, 192) if position == 3 if self.viewport != nil sprite.x = self.viewport.rect.width / 2 sprite.y = self.viewport.rect.height - 320 set = 0 if $game_temp.in_battle and self.battler.is_a?(Game_Enemy) for battler in $game_troop.enemies set += battler.screen_x end sprite.x = (set / $game_troop.enemies.size).to_f else for battler in $game_party.actors set += battler.screen_x end sprite.x = (set / $game_party.actors.size).to_f end else sprite.x = 320 sprite.y = 240 end else sprite.x = self.x + self.viewport.rect.x - self.ox + self.src_rect.width / 2 sprite.y = self.y - self.oy * self.zoom_y / 2 + self.viewport.rect.y if position == 0 sprite.y -= self.src_rect.height * self.zoom_y / 4 elsif position == 2 sprite.y += self.src_rect.height * self.zoom_y / 4 end end sprite.x += cell_data[i, 1] sprite.y += cell_data[i, 2] sprite.angle = cell_data[i, 4] if xyan != [[], 0] t = (times[0] - 1) / (times[1] - 1) _t = 1 - t if xyan[0].size >= 6 a = _t ** 3 b = 3 * (_t ** 2) * t c = 3 * _t * (t ** 2) d = t ** 3 sprite.x = a * xyan[0][4] + b * xyan[0][0] + c * xyan[0][2] + d * sprite.x sprite.y = a * xyan[0][5] + b * xyan[0][1] + c * xyan[0][3] + d * sprite.y elsif xyan[0].size >= 4 a = _t ** 2 b = 2 * (_t * t) c = t ** 2 sprite.x = a * xyan[0][2] + b * xyan[0][0] + c * sprite.x sprite.y = a * xyan[0][3] + b * xyan[0][1] + c * sprite.y elsif xyan[0].size >= 2 a = _t b = t sprite.x = a * xyan[0][0] + b * sprite.x sprite.y = a * xyan[0][1] + b * sprite.y end # 直径を求める line = Math.hypot(cell_data[i, 1], cell_data[i, 2]) # セルの回転後の角度を求める if line != 0 asin = Math.asin((cell_data[i, 2] / line).to_f) sin = Math.sin(asin + xyan[1] / 180.0 * Math::PI) cos = Math.cos(asin + xyan[1] / 180.0 * Math::PI) # 実際の値を求める sprite.x += line * cos sprite.y += line * sin sprite.x -= cell_data[i, 1] sprite.y -= cell_data[i, 2] sprite.angle += xyan[1] end end sprite.z = 2000 sprite.ox = 96 sprite.oy = 96 sprite.zoom_x = cell_data[i, 3] / 100.0 sprite.zoom_y = cell_data[i, 3] / 100.0 sprite.mirror = (cell_data[i, 5] == 1) # スプライトの反転判定 if $game_temp.in_battle sprite.mirror ^= true if self.battler.is_a?(Game_Actor) == $game_temp.back_attack end sprite.opacity = cell_data[i, 6] sprite.blend_type = cell_data[i, 7] end end def x=(x) sx = x - self.x if sx != 0 for a in 0...@_animation.size if @_animation_sprites[a] != nil and not @_animation_nomove[a] for i in 0...@_animation_sprites[a].size @_animation_sprites[a][i].x += sx end end end for a in 0...@_loop_animation.size if @_loop_animation_sprites[a] != nil for i in 0...@_loop_animation_sprites[a].size @_loop_animation_sprites[a][i].x += sx end end end end super end def y=(y) sy = y - self.y if sy != 0 for a in 0...@_animation.size if @_animation_sprites[a] != nil and not @_animation_nomove[a] for i in 0...@_animation_sprites[a].size @_animation_sprites[a][i].y += sy end end end for a in 0...@_loop_animation.size if @_loop_animation_sprites[a] != nil for i in 0...@_loop_animation_sprites[a].size @_loop_animation_sprites[a][i].y += sy end end end end super end end end #============================================================================== # ■ Game_Temp #------------------------------------------------------------------------------ #  セーブデータに含まれない、一時的なデータを扱うクラスです。このクラスのイン # スタンスは $game_temp で参照されます。 #============================================================================== class Game_Temp #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :back_attack # バックアタック判定 alias :base_initialize :initialize def initialize base_initialize @back_attack = false end end #============================================================================== # ■ Game_Battler #------------------------------------------------------------------------------ #  バトラーを扱うクラスです。このクラスは Game_Actor クラスと Game_Enemy クラ # スのスーパークラスとして使用されます。 #============================================================================== class Game_Battler #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :mirror # バトラー鏡面判定 attr_accessor :sprite # バトラースプライト attr_accessor :anime_code # バトラーアニメーションの番号 attr_accessor :anime_mode # バトラーアニメーション attr_accessor :anime_time # バトラーアニメーション時間 attr_accessor :move_code # バトラー移動場所 attr_accessor :move_time # バトラー移動時間 attr_accessor :anime_freeze # バトラーアニメーション保持フラグ attr_accessor :anime_nomove # アニメーション移動禁止フラグ #-------------------------------------------------------------------------- # ● 左右非対称判定 #-------------------------------------------------------------------------- def mirror=(bool) @mirror = bool if self.mirror? if bool self.sprite.bitmap = RPG::Cache.battler("#{@battler_name}@m", @battler_hue) else self.sprite.bitmap = RPG::Cache.battler(@battler_name, @battler_hue) end else self.sprite.mirror = bool end end #-------------------------------------------------------------------------- # ● ステートアニメID集 #-------------------------------------------------------------------------- def state_animation_ids result = [] @states.each{|s| unless result.include?($data_states[s].animation_id) result.push($data_states[s].animation_id) end } return result end #-------------------------------------------------------------------------- # ● バトラーアクションセット #-------------------------------------------------------------------------- def set_action @anime_code = anime_code_set @anime_time = anime_time_set @move_code = move_code_set @move_time = move_time_set for target in $scene.target_battlers target.move_code = target_move_code_set(target) target.move_time = target_move_time_set(target) end if (@hp * 100 / self.maxhp) <= Numset::PINCH_PARSENT @anime_code.push(Numset::PINCH_LINE) else @anime_code.push(Numset::STANDING_LINE) end while @move_code != [] @sprite.move(@move_time.shift, @move_code.shift) end end end #============================================================================== # ■ Game_Actor #------------------------------------------------------------------------------ #  アクターを扱うクラスです。このクラスは Game_Actors クラス ($game_actors) # の内部で使用され、Game_Party クラス ($game_party) からも参照されます。 #============================================================================== class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :width # 画像の幅 attr_accessor :height # 画像の高さ attr_accessor :screen_x # X 座標 attr_accessor :screen_y # Y 座標 attr_reader :save_x # 基準 X 座標 attr_reader :save_y # 基準 Y 座標 #-------------------------------------------------------------------------- # ● バトル画面 Z 座標の取得 #-------------------------------------------------------------------------- def screen_z return screen_y end #-------------------------------------------------------------------------- # ● 攻撃用 X 座標の取得 #-------------------------------------------------------------------------- def target_x if self.mirror return 640 - (self.screen_x + self.sprite.bitmap.width / 2) else return self.screen_x - self.sprite.bitmap.width / 2 end end #-------------------------------------------------------------------------- # ● 座標再設定 #-------------------------------------------------------------------------- def screen_setup @screen_x = Numset::POSITION_X[self.index] if self.class.method_defined?("position") @screen_x += ((self.position - 1) * Numset::POSITION_PLUS) else @screen_x += (($data_classes[self.class_id].position - 1) * Numset::POSITION_PLUS) end @screen_x = 640 - @screen_x if $game_temp.back_attack @save_x = @screen_x @screen_y = Numset::POSITION_Y[self.index] @save_y = @screen_y end end #============================================================================== # ■ Game_Enemy #------------------------------------------------------------------------------ #  エネミーを扱うクラスです。このクラスは Game_Troop クラス ($game_troop) の # 内部で使用されます。 #============================================================================== class Game_Enemy < Game_Battler #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :width # 画像の幅 attr_accessor :height # 画像の高さ attr_writer :screen_x # X 座標 attr_writer :screen_y # Y 座標 attr_reader :save_x # 基準 X 座標 attr_reader :save_y # 基準 Y 座標 #-------------------------------------------------------------------------- # ● バトル画面 X 座標の取得 #-------------------------------------------------------------------------- alias :base_screen_x :screen_x def screen_x if @screen_x == nil @screen_x = base_screen_x @save_x = @screen_x @screen_x = 640 - @screen_x if $game_temp.back_attack end return @screen_x end #-------------------------------------------------------------------------- # ● バトル画面 Y 座標の取得 #-------------------------------------------------------------------------- alias :base_screen_y :screen_y def screen_y if @screen_y == nil @screen_y = base_screen_y @save_y = @screen_y end return @screen_y end #-------------------------------------------------------------------------- # ● 攻撃用 X 座標の取得 #-------------------------------------------------------------------------- def target_x if self.mirror return 640 - (self.screen_x - self.sprite.bitmap.width / 2) else return self.screen_x + self.sprite.bitmap.width / 2 end end #-------------------------------------------------------------------------- # ● 座標再設定 #-------------------------------------------------------------------------- def screen_setup end end #============================================================================== # ■ Sprite_Battler #------------------------------------------------------------------------------ #  バトラー表示用のスプライトです。Game_Battler クラスのインスタンスを監視し、 # スプライトの状態を自動的に変化させます。 #============================================================================== class Sprite_Battler < RPG::Sprite #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :event_sprite #-------------------------------------------------------------------------- # ● オブジェクト初期化 # viewport : ビューポート # battler : バトラー (Game_Battler) #-------------------------------------------------------------------------- alias :base_initialize :initialize def initialize(viewport, battler = nil) base_initialize(viewport, battler) setup end #-------------------------------------------------------------------------- # ● セットアップ #-------------------------------------------------------------------------- def setup @duration = [] @duration_m = [] @target_x = [] @target_y = [] @point_x = [] @point_y = [] @event_mirror = false @opacity_target = 0 @opacity_duration = 0 @angle_target = 0 @angle_duration = 0 if @battler != nil @sx = @battler.screen_x @sy = @battler.screen_y @battler.sprite = self @battler_states = [] @battler.mirror = ($game_temp.back_attack and @battler.is_a?(Game_Enemy)) end end #-------------------------------------------------------------------------- # ● バトラーの移動 # duration : 移動時間 # position : 移動座標(配列) #-------------------------------------------------------------------------- def move(duration, *position) @duration.push(duration.to_f) @duration_m.push(duration.to_f) xy = position.shift if $game_temp.back_attack @target_x.push(640 - xy.shift) @target_y.push(640 - xy.shift) else @target_x.push(xy.shift) @target_y.push(xy.shift) end xx = [] yy = [] while position.size >= 1 xy = position.shift if $game_temp.back_attack xx.push(640 - xy.shift) yy.push(640 - xy.shift) else xx.push(xy.shift) yy.push(xy.shift) end end @point_x.push(xx) @point_y.push(yy) end #-------------------------------------------------------------------------- # ● 表示時間 #-------------------------------------------------------------------------- def time if @battler.name =~ /@t(\d+)/ return $1.to_i else return Numset::LOOP_TIME end end #-------------------------------------------------------------------------- # ● 表示コマ数 #-------------------------------------------------------------------------- def frame if @battler.name =~ /@f(\d+)/ return $1.to_i else return Numset::LOOP_FRAME end end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super # バトラーが nil の場合 if @battler == nil if self.bitmap != nil self.bitmap = nil end else unless @battler.anime_freeze @battler.anime_mode += 1 end if @battler.anime_code[0].is_a?(Numeric) and @battler.anime_mode >= @battler.anime_time[0] and @battler.anime_time[0] >= 0 # 先頭のデータを消去 @battler.anime_code.delete_at(0) @battler.anime_time.delete_at(0) end while @battler.anime_code[0].is_a?(String) # フリーズ命令を入れたらば if @battler.anime_code[0] =~ /^[Ff]reeze$/ @battler.anime_freeze ^= true # 先頭のデータを消去 @battler.anime_code.delete_at(0) # コモン命令を入れたらば elsif @battler.anime_code[0] =~ /^[Cc]ommon\((\d+?)\)$/ $scene.common($1.to_i) # 先頭のデータを消去 @battler.anime_code.delete_at(0) # ミラー命令を入れたらば elsif @battler.anime_code[0] =~ /^[Mm]irror$/ @event_mirror ^= true self.mirror ^= true # 先頭のデータを消去 @battler.anime_code.delete_at(0) # 不透明度命令を入れたらば elsif @battler.anime_code[0] =~ /^[Oo]pacity\((\d+),(\d+)\)$/ if $2 == "0" self.opacity = $1.to_i else @opacity_target = $1.to_i @opacity_duration = $2.to_i end # 先頭のデータを消去 @battler.anime_code.delete_at(0) # 角度命令を入れたらば elsif @battler.anime_code[0] =~ /^[Aa]ngle\((\d+),([1-9]\d*)\)$/ @angle_target = $1.to_i @angle_duration = $2.to_i # 先頭のデータを消去 @battler.anime_code.delete_at(0) # アニメ命令を入れたらば elsif @battler.anime_code[0] =~ /^[Aa]nime\((\d+?)\)(@hit)?(@nomove)?(@critical)?$/ # 行動側アニメーション @battler.animation_id = ($1 == nil ? $scene.animation1_id : $1.to_i) @battler.animation_hit = ($2 != nil) @battler.anime_nomove = ($3 != nil) if Game_Battler.method_defined?("animation_critical") @battler.anime_nomove = ($4 != nil) end # 先頭のデータを消去 @battler.anime_code.delete_at(0) # ヘルプ命令を入れたらば elsif @battler.anime_code[0] =~ /^[Hh]elp$/ $scene.help_window.visible ^= true # 先頭のデータを消去 @battler.anime_code.delete_at(0) else # 先頭のデータを消去 @battler.anime_code.delete_at(0) end end # ファイル名か色相が現在のものと異なる場合 @battler_name = @battler.battler_name if @battler.battler_name != @battler_name @battler_hue = @battler.battler_hue if @battler.battler_hue != @battler_hue if @battler_anime_code != @battler.anime_code[0] or (@battler.anime_mode % self.time) == 0 if @battler_anime_code != @battler.anime_code[0] @battler.anime_mode = 0 end @battler_anime_code = @battler.anime_code[0] @battler_anime_mode = @battler.anime_mode self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue) if @battler.is_a?(Game_Actor) or @battler.move @width = bitmap.width / self.frame @height = bitmap.width / self.frame self.ox = @width / 2 self.oy = @height if @battler.anime_freeze rx = @battler_anime_code % self.frame * @width ry = (@battler_anime_code / self.frame).floor * @height else rx = (@battler_anime_mode / self.time).floor % self.frame * @width ry = @battler_anime_code * @height end self.src_rect.set(rx, ry, @width, @height) else @width = bitmap.width @height = bitmap.height self.ox = @width / 2 self.oy = @height @battler.width = @width @battler.height = @height end if @battler.battler_name != @battler_name or @battler.battler_hue != @battler_hue if @battler.is_a?(Game_Enemy) if @battler.dead? or @battler.hidden self.opacity = 0 end end end end # バトラー移動用の処理 if @duration_m != [] if @duration[0] > 0 e = @duration[0].to_f t = ((e - 1) / (@duration_m[0] - 1)) _t = 1 - t case @point_x[0].size when 0 a = _t b = t @battler.screen_x = a * @target_x[0] + b * @sx @battler.screen_y = a * @target_y[0] + b * @sy when 1 a = _t ** 2 b = 2 * _t * t c = _t ** 2 @battler.screen_x = a * @target_x[0] + b * @point_x[0][0] + c * @sx @battler.screen_y = a * @target_y[0] + b * @point_y[0][0] + c * @sy when 2 a = _t ** 3 b = 3 * (_t ** 2) * t c = 3 * _t * (t ** 2) d = t ** 3 @battler.screen_x = a * @target_x[0] + b * @point_x[0][0] + c * @point_x[0][1] + d * @sx @battler.screen_y = a * @target_y[0] + b * @point_y[0][0] + c * @point_y[0][1] + d * @sy end @duration[0] -= 1 else if @target_x[0] != @sx or @target_x.size == 1 if @battler.is_a?(Game_Actor) @battler.mirror = ($game_temp.back_attack != (@target_x[0] < @sx)) else @battler.mirror = ($game_temp.back_attack != (@target_x[0] > @sx)) end self.mirror ^= @event_mirror end @duration.delete_at(0) @duration_m.delete_at(0) @target_x.delete_at(0) @target_y.delete_at(0) @point_x.delete_at(0) @point_y.delete_at(0) @sx = battler.screen_x @sy = battler.screen_y end end # アニメーション ID が現在のものと異なる場合 if @battler_states != @battler.state_animation_ids @battler_states.each{|s| dispose_loop_animation(@_loop_animation.index($data_animations[s])) if not @battler.state_animation_ids.include?(s) } @battler.state_animation_ids.each{|s| loop_animation($data_animations[s]) if not @battler_states.include?(s) } @battler_states = @battler.state_animation_ids end # 明滅 if @battler.blink blink_on else blink_off end # 透明度変更 if @opacity_duration > 0 d = @opacity_duration self.opacity = (self.opacity * (d - 1) + @opacity_target) / d @opacity_duration -= 1 end # 回転度変更 if @angle_duration > 0 d = @angle_duration self.angle = (self.angle + @angle_target) % 360 @angle_duration -= 1 end # 不可視の場合 unless @battler_visible # 出現 if not @battler.hidden and not @battler.dead? and (@battler.damage == nil or @battler.damage_pop) appear @battler_visible = true end end # 可視の場合 if @battler_visible # 逃走 if @battler.hidden $game_system.se_play($data_system.escape_se) escape @battler_visible = false end # 白フラッシュ if @battler.white_flash whiten @battler.white_flash = false end # アニメーション if @battler.animation_id != 0 animation = $data_animations[@battler.animation_id] anime_set(animation) @battler.animation_id = 0 end # ダメージ if @battler.damage_pop damage(@battler.damage, @battler.critical) @battler.damage = nil @battler.critical = false @battler.damage_pop = false end # コラプス if @battler.damage == nil and @battler.dead? if @battler.is_a?(Game_Enemy) or not @battler.move $game_system.se_play($data_system.enemy_collapse_se) collapse @battler_visible = false end if @battler.anime_time[0] != 0 and @battler.anime_code[0] != Numset::DAMAGE_LINE and @battler.anime_code[0] != Numset::DEAD_LINE @duration.clear @duration_m.clear @target_x.clear @target_y.clear @point_x.clear @point_y.clear @battler.anime_code = [0, Numset::DAMAGE_LINE, Numset::DEAD_LINE] @battler.anime_time = [0, Numset::DAMAGE_TIME, -1] end end end # スプライトの座標を設定 self.x = @battler.screen_x self.y = @battler.screen_y self.z = @battler.screen_z end end end #============================================================================== # ■ Spriteset_Battle #------------------------------------------------------------------------------ #  バトル画面のスプライトをまとめたクラスです。このクラスは Scene_Battle クラ # スの内部で使用されます。 #============================================================================== class Spriteset_Battle #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize # ビューポートを作成 @viewport1 = Viewport.new(0, 0, 640, 320) @viewport2 = Viewport.new(0, 0, 640, 480) @viewport3 = Viewport.new(0, 0, 640, 480) @viewport4 = Viewport.new(0, 0, 640, 480) @viewport2.z = 101 @viewport3.z = 200 @viewport4.z = 5000 # バトルバックスプライトを作成 @battleback_sprite = Sprite.new(@viewport1) # エネミースプライトを作成 @enemy_sprites = [] for enemy in $game_troop.enemies.reverse @enemy_sprites.push(Sprite_Battler.new(@viewport1, enemy)) end # アクタースプライトを作成 @actor_sprites = [] for actor in $game_party.actors @actor_sprites.push(Sprite_Battler.new(@viewport1, actor)) end while @actor_sprites.size < 4 @actor_sprites.push(Sprite_Battler.new(@viewport1)) end # 天候を作成 @weather = RPG::Weather.new(@viewport1) # ピクチャスプライトを作成 @picture_sprites = [] for i in 51..100 @picture_sprites.push(Sprite_Picture.new(@viewport3, $game_screen.pictures[i])) end # タイマースプライトを作成 @timer_sprite = Sprite_Timer.new # フレーム更新 update end end #============================================================================== # ■ Interpreter #------------------------------------------------------------------------------ #  イベントコマンドを実行するインタプリタです。このクラスは Game_System クラ # スや Game_Event クラスの内部で使用されます。 #============================================================================== class Interpreter #-------------------------------------------------------------------------- # ● アクションの強制 #-------------------------------------------------------------------------- def command_339 # 戦闘中でなければ無視 if $game_temp.in_battle unless $scene.child_interpreter.running if $game_temp.turn == 0 return true end # イテレータで処理 (便宜的なもので、複数になることはない) iterate_battler(@parameters[0], @parameters[1]) do |battler| # バトラーが存在する場合 if battler.exist? # アクションを設定 battler.current_action.kind = @parameters[2] if battler.current_action.kind == 0 battler.current_action.basic = @parameters[3] else battler.current_action.skill_id = @parameters[3] end # 行動対象を設定 if @parameters[4] == -2 if battler.is_a?(Game_Enemy) battler.current_action.decide_last_target_for_enemy else battler.current_action.decide_last_target_for_actor end elsif @parameters[4] == -1 if battler.is_a?(Game_Enemy) battler.current_action.decide_random_target_for_enemy else battler.current_action.decide_random_target_for_actor end elsif @parameters[4] >= 0 battler.current_action.target_index = @parameters[4] end # 強制フラグを設定 battler.current_action.forcing = true # アクションが有効かつ [すぐに実行] の場合 if battler.current_action.valid? and @parameters[5] == 1 # 強制対象のバトラーを設定 $game_temp.forcing_battler = battler # インデックスを進める @index += 1 # 終了 return false end end end end end # 継続 return true end end #============================================================================== # ■ Arrow_Base #------------------------------------------------------------------------------ #  バトル画面で使用するアローカーソル表示用のスプライトです。このクラスは # Arrow_Enemy クラスと Arrow_Actor クラスのスーパークラスとして使用されます。 #============================================================================== class Arrow_Base < Sprite #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :index # カーソル位置 attr_reader :help_window # ヘルプウィンドウ attr_reader :mode # サイド #-------------------------------------------------------------------------- # ● オブジェクト初期化 # viewport : ビューポート #-------------------------------------------------------------------------- def initialize(viewport, mode) super(viewport) self.bitmap = RPG::Cache.windowskin($game_system.windowskin_name) self.ox = 16 self.oy = 32 self.z = 2500 @mode = mode @blink_count = 0 @index = 0 @help_window = nil update end end #============================================================================== # ■ Arrow_Single #------------------------------------------------------------------------------ #  単体を選択させるためのアローカーソルです。このクラスは Arrow_Base クラ # スを継承します。 #============================================================================== class Arrow_Single < Arrow_Base #-------------------------------------------------------------------------- # ● カーソルが指しているバトラーの取得 #-------------------------------------------------------------------------- def battler if @mode == "enemy" return $game_troop.enemies[@index] else return $game_party.actors[@index] end end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super if @mode == "enemy" # 存在しないエネミーを指していたら飛ばす $game_troop.enemies.size.times do break if self.battler.exist? @index += 1 @index %= $game_troop.enemies.size end # カーソル上 if Input.repeat?(Input::UP) $game_system.se_play($data_system.cursor_se) $game_troop.enemies.size.times do @index += 1 @index %= $game_troop.enemies.size break if self.battler.exist? end end # カーソル下 if Input.repeat?(Input::DOWN) $game_system.se_play($data_system.cursor_se) $game_troop.enemies.size.times do @index += $game_troop.enemies.size - 1 @index %= $game_troop.enemies.size break if self.battler.exist? end end else # 存在しないエネミーを指していたら飛ばす $game_party.actors.size.times do if self.battler.exist? break else if $scene.active_battler.current_action.kind == 1 and $data_skills[$scene.active_battler.current_action.skill_id].scope == 5 break elsif $scene.active_battler.current_action.kind == 2 and $data_items[$scene.active_battler.current_action.item_id].scope == 5 break else @index += 1 @index %= $game_party.actors.size end end end # カーソル上 if Input.repeat?(Input::UP) $game_system.se_play($data_system.cursor_se) $game_party.actors.size.times do if self.battler.exist? @index += 1 @index %= $game_party.actors.size break else if $scene.active_battler.current_action.kind == 1 and $data_skills[$scene.active_battler.current_action.skill_id].scope == 5 break elsif $scene.active_battler.current_action.kind == 2 and $data_items[$scene.active_battler.current_action.item_id].scope == 5 break else @index += 1 @index %= $game_party.actors.size end end end end # カーソル下 if Input.repeat?(Input::DOWN) $game_system.se_play($data_system.cursor_se) $game_party.actors.size.times do if self.battler.exist? @index += ($game_party.actors.size - 1) @index %= $game_party.actors.size break else if $scene.active_battler.current_action.kind == 1 and $data_skills[$scene.active_battler.current_action.skill_id].scope == 5 break elsif $scene.active_battler.current_action.kind == 2 and $data_items[$scene.active_battler.current_action.item_id].scope == 5 break else @index += ($game_party.actors.size - 1) @index %= $game_party.actors.size end end end end end # カーソル横 if Input.repeat?(Input::LEFT) or Input.repeat?(Input::RIGHT) $game_system.se_play($data_system.cursor_se) if @mode == "enemy" @mode = "actor" if @index >= $game_party.actors.size @index %= $game_party.actors.size unless $scene.active_battler.current_action.kind != 1 and $data_skills[$scene.active_battler.current_action.skill_id].scope != 5 unless $scene.active_battler.current_action.kind != 2 and $data_items[$scene.active_battler.current_action.item_id].scope != 5 $game_party.actors.size.times do @index += $game_party.actors.size - 1 @index %= $game_party.actors.size break if self.battler.exist? end end end end else @mode = "enemy" if @index >= $game_troop.enemies.size @index %= $game_troop.enemies.size unless $scene.active_battler.current_action.kind != 1 and $data_skills[$scene.active_battler.current_action.skill_id].scope != 5 unless $scene.active_battler.current_action.kind != 2 and $data_items[$scene.active_battler.current_action.item_id].scope != 5 $game_party.actors.size.times do @index += $game_party.actors.size - 1 @index %= $game_party.actors.size break if self.battler.exist? end end end end end end # スプライトの座標を設定 if self.battler != nil self.x = self.battler.screen_x self.y = self.battler.screen_y end end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help if @mode == "enemy" # ヘルプウィンドウにエネミーの名前とステートを表示 @help_window.set_enemy(self.battler) else # ヘルプウィンドウにアクターのステータスを表示 @help_window.set_actor(self.battler) end end end #============================================================================== # ■ Arrow_All #------------------------------------------------------------------------------ #  サイドを選択させるためのアローカーソルです。このクラスは Arrow_Base クラ # スを継承します。 #============================================================================== class Arrow_All < Arrow_Base #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super # カーソル if Input.repeat?(Input::RIGHT) or Input.repeat?(Input::LEFT) $game_system.se_play($data_system.cursor_se) case @mode when "enemy" @mode = "actor" when "actor" @mode = "enemy" end end size = 0 arrow_x = 0 case @mode when "enemy" for battler in $game_troop.enemies if battler.exist? arrow_x += battler.screen_x size += 1 end end when "actor" for battler in $game_party.actors arrow_x += battler.screen_x size += 1 end end arrow_x /= size # スプライトの座標を設定 self.x = arrow_x self.y = 300 end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help if @mode == "enemy" @help_window.set_text(Numset::ENEMIES_NAME, 1) else @help_window.set_text(Numset::ACTORS_NAME, 1) end end end #============================================================================== # ■ Arrow_Freeze #------------------------------------------------------------------------------ #  固定されたアローカーソルです。このクラスは Arrow_Base クラ # スを継承します。 #============================================================================== class Arrow_Freeze < Arrow_Base #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super # スプライトの座標を設定 if @mode == "single" self.x = $scene.active_battler.screen_x self.y = $scene.active_battler.screen_y else self.x = arrow_x self.y = 300 end end #-------------------------------------------------------------------------- # ● ヘルプテキスト更新 #-------------------------------------------------------------------------- def update_help case @mode when "single" @help_window.set_text($scene.active_battler.name, 1) when "all" @help_window.set_text(Numset::ALL_NAME, 1) end end end #============================================================================== # ■ Scene_Battle #------------------------------------------------------------------------------ #  バトル画面の処理を行うクラスです。 #============================================================================== class Scene_Battle #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :help_window # ヘルプウィンドウ attr_reader :animation1_id # 行動側アニメーションID attr_reader :active_battler # 現在行動中のバトラー attr_reader :target_battlers # 現在の対象の配列 attr_reader :child_interpreter # バトルで使う子インタプリタ #-------------------------------------------------------------------------- # ● メイン処理 #-------------------------------------------------------------------------- def main # 戦闘用の各種一時データを初期化 $game_temp.in_battle = true $game_temp.battle_turn = 0 $game_temp.battle_event_flags.clear $game_temp.battle_abort = false $game_temp.battle_main_phase = false $game_temp.battleback_name = $game_map.battleback_name $game_temp.forcing_battler = nil # バトルイベント用インタプリタを初期化 $game_system.battle_interpreter.setup(nil, 0) # トループを準備 @troop_id = $game_temp.battle_troop_id $game_troop.setup(@troop_id) # アクターコマンドウィンドウを作成 s1 = $data_system.words.attack s2 = $data_system.words.skill s3 = $data_system.words.guard s4 = $data_system.words.item @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4]) @actor_command_window.y = 160 @actor_command_window.back_opacity = 160 @actor_command_window.active = false @actor_command_window.visible = false # その他のウィンドウを作成 @party_command_window = Window_PartyCommand.new @help_window = Window_Help.new @help_window.back_opacity = 160 @help_window.visible = false @status_window = Window_BattleStatus.new @message_window = Window_Message.new # バトラーモーションセットアップ for battler in $game_party.actors + $game_troop.enemies battler.screen_setup if (battler.hp * 100.0 / battler.maxhp) <= Numset::PINCH_PARSENT battler.anime_code = [Numset::PINCH_LINE] else battler.anime_code = [Numset::STANDING_LINE] end battler.anime_mode = 0 battler.anime_time = [] battler.anime_time = [-1] battler.move_code = [] battler.move_time = [] battler.anime_freeze = false end # スプライトセットを作成 @spriteset = Spriteset_Battle.new # ウェイトカウントを初期化 @wait_count = 0 @escape_wait = Numset::ESCAPE_TIME # トランジション実行 if $data_system.battle_transition == "" Graphics.transition(20) else Graphics.transition(40, "Graphics/Transitions/" + $data_system.battle_transition) end # プレバトルフェーズ開始 start_phase1 # メインループ(よく考えたらこれでも良かった) while $scene == self # ゲーム画面を更新 Graphics.update # 入力情報を更新 Input.update # フレーム更新 update end # マップをリフレッシュ $game_map.refresh # トランジション準備 Graphics.freeze # ウィンドウを解放 @actor_command_window.dispose @party_command_window.dispose @help_window.dispose @status_window.dispose @message_window.dispose @skill_window.dispose if @skill_window != nil @item_window.dispose if @item_window != nil @result_window.dispose if @result_window != nil # スプライトセットを解放 @spriteset.dispose # タイトル画面に切り替え中の場合 if $scene.is_a?(Scene_Title) # 画面をフェードアウト Graphics.transition Graphics.freeze end # 戦闘テストからゲームオーバー画面以外に切り替え中の場合 if $BTEST and not $scene.is_a?(Scene_Gameover) $scene = nil end end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update # バトルイベント実行中の場合 if $game_system.battle_interpreter.running? # インタプリタを更新 $game_system.battle_interpreter.update # アクションを強制されているバトラーが存在しない場合 if $game_temp.forcing_battler == nil # バトルイベントの実行が終わった場合 unless $game_system.battle_interpreter.running? # 戦闘継続の場合、バトルイベントのセットアップを再実行 unless judge setup_battle_event end end # アフターバトルフェーズでなければ if @phase != 5 # ステータスウィンドウをリフレッシュ @status_window.refresh end end end # 子インタプリタが存在する場合 if @child_interpreter != nil # 子インタプリタを更新 @child_interpreter.update # 子インタプリタの実行が終わった場合 unless @child_interpreter.running? # 子インタプリタを消去 @child_interpreter = nil end end # システム (タイマー)、画面を更新 $game_system.update $game_screen.update # タイマーが 0 になった場合 if $game_system.timer_working and $game_system.timer == 0 # バトル中断 $game_temp.battle_abort = true end # ウィンドウを更新 @help_window.update @party_command_window.update @actor_command_window.update @status_window.update @message_window.update # スプライトセットを更新 @spriteset.update # トランジション処理中の場合 if $game_temp.transition_processing # トランジション処理中フラグをクリア $game_temp.transition_processing = false # トランジション実行 if $game_temp.transition_name == "" Graphics.transition(20) else Graphics.transition(40, "Graphics/Transitions/" + $game_temp.transition_name) end end # メッセージウィンドウ表示中の場合 if $game_temp.message_window_showing return end # エフェクト表示中の場合 if @spriteset.effect? return end # ゲームオーバーの場合 if $game_temp.gameover # ゲームオーバー画面に切り替え $scene = Scene_Gameover.new return end # タイトル画面に戻す場合 if $game_temp.to_title # タイトル画面に切り替え $scene = Scene_Title.new return end # バトル中断の場合 if $game_temp.battle_abort # バトル開始前の BGM に戻す $game_system.bgm_play($game_temp.map_bgm) # バトル終了 battle_end(1) return end # 逃走する場合 if @escape_succees if @escape_wait == Numset::ESCAPE_TIME # 逃走 SE を演奏 $game_system.se_play($data_system.escape_se) for actor in $game_party.actors actor.escape_set while actor.move_code != [] actor.sprite.move(actor, actor.move_time.shift, actor.move_code.shift) end end end @escape_wait -= 1 if @escape_wait == 0 # バトル開始前の BGM に戻す $game_system.bgm_play($game_temp.map_bgm) # バトル終了 battle_end(1) end return end # ウェイト中の場合 if @wait_count > 0 # ウェイトカウントを減らす @wait_count -= 1 return end # アクションを強制されているバトラーが存在せず、 # かつバトルイベントが実行中の場合 if $game_temp.forcing_battler == nil and $game_system.battle_interpreter.running? return end # フェーズによって分岐 case @phase when 1 # プレバトルフェーズ update_phase1 when 2 # パーティコマンドフェーズ update_phase2 when 3 # アクターコマンドフェーズ update_phase3 when 4 # メインフェーズ update_phase4 when 5 # アフターバトルフェーズ update_phase5 end end #-------------------------------------------------------------------------- # ● アフターバトルフェーズ開始 #-------------------------------------------------------------------------- alias :base_start_phase5 :start_phase5 def start_phase5 for actor in $game_party.actors actor.win_set while actor.move_code != [] actor.sprite.move(actor.move_time.shift, actor.move_code.shift) end end base_start_phase5 end #-------------------------------------------------------------------------- # ● アクターコマンドフェーズ開始 #-------------------------------------------------------------------------- alias :base_start_phase3 :start_phase3 def start_phase3 for actor in $game_party.actors if actor.guarding? if (battler.hp * 100 / battler.maxhp) <= Numset::PINCH_PARSENT actor.anime_code = [Numset::PINCH_LINE] else actor.anime_code = [Numset::STANDING_LINE] end actor.anime_time = [-1] end end base_start_phase3 end #-------------------------------------------------------------------------- # ● アクターコマンドウィンドウのセットアップ #-------------------------------------------------------------------------- alias :base_phase3_setup_command_window :phase3_setup_command_window def phase3_setup_command_window base_phase3_setup_command_window actor = $game_party.actors[@actor_index] # アクターコマンドウィンドウの位置を設定 @actor_command_window.x = actor.screen_x - (actor.sprite.bitmap.height + @actor_command_window.height) @actor_command_window.y = actor.screen_y + (actor.sprite.bitmap.width - @actor_command_window.width) / 2 end #-------------------------------------------------------------------------- # ● フレーム更新 (アクターコマンドフェーズ) #-------------------------------------------------------------------------- def update_phase3 # シングルアローが有効の場合 if @single_arrow != nil update_phase3_battler_select # オールアローが有効の場合 elsif @all_arrow != nil update_phase3_battler_select # フリーズアローが有効の場合 elsif @freeze_arrow != nil update_phase3_battler_select # スキルウィンドウが有効の場合 elsif @skill_window != nil update_phase3_skill_select # アイテムウィンドウが有効の場合 elsif @item_window != nil update_phase3_item_select # アクターコマンドウィンドウが有効の場合 else update_phase3_basic_command end end #-------------------------------------------------------------------------- # ● フレーム更新 (アクターコマンドフェーズ : 基本コマンド) #-------------------------------------------------------------------------- def update_phase3_basic_command # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # 前のアクターのコマンド入力へ phase3_prior_actor return end # C ボタンが押された場合 if Input.trigger?(Input::C) # アクターコマンドウィンドウのカーソル位置で分岐 case @actor_command_window.index when 0 # 攻撃 # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # アクションを設定 @active_battler.current_action.kind = 0 @active_battler.current_action.basic = 0 # 選択を開始 start_battler_select when 1 # スキル # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # アクションを設定 @active_battler.current_action.kind = 1 # スキルの選択を開始 start_skill_select when 2 # 防御 # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # アクションを設定 @active_battler.current_action.kind = 0 @active_battler.current_action.basic = 1 # 次のアクターのコマンド入力へ phase3_next_actor when 3 # アイテム # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # アクションを設定 @active_battler.current_action.kind = 2 # アイテムの選択を開始 start_item_select end return end end #-------------------------------------------------------------------------- # ● フレーム更新 (アクターコマンドフェーズ : スキル選択) #-------------------------------------------------------------------------- def update_phase3_skill_select # スキルウィンドウを可視状態にする @skill_window.visible = true # スキルウィンドウを更新 @skill_window.update # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # スキルの選択を終了 end_skill_select return end # C ボタンが押された場合 if Input.trigger?(Input::C) # スキルウィンドウで現在選択されているデータを取得 @skill = @skill_window.skill # 使用できない場合 if @skill == nil or not @active_battler.skill_can_use?(@skill.id) # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return end # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # アクションを設定 @active_battler.current_action.skill_id = @skill.id # スキルウィンドウを不可視状態にする @skill_window.visible = false # どちらにしろ選択を開始 start_battler_select return end end #-------------------------------------------------------------------------- # ● フレーム更新 (アクターコマンドフェーズ : アイテム選択) #-------------------------------------------------------------------------- def update_phase3_item_select # アイテムウィンドウを可視状態にする @item_window.visible = true # アイテムウィンドウを更新 @item_window.update # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # アイテムの選択を終了 end_item_select return end # C ボタンが押された場合 if Input.trigger?(Input::C) # アイテムウィンドウで現在選択されているデータを取得 @item = @item_window.item # 使用できない場合 unless $game_party.item_can_use?(@item.id) # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return end # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # アクションを設定 @active_battler.current_action.kind = 2 @active_battler.current_action.item_id = @item.id # アイテムウィンドウを不可視状態にする @item_window.visible = false # どちらにしろ選択を開始 start_battler_select return end end #-------------------------------------------------------------------------- # ● フレーム更新 (アクターコマンドフェーズ : バトラー選択) #-------------------------------------------------------------------------- def update_phase3_battler_select # アローを更新 if @single_arrow != nil @single_arrow.update elsif @all_arrow != nil @all_arrow.update elsif @freeze_arrow != nil @freeze_arrow.update end # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # バトラーの選択を中断 p_end_battler_select return end # C ボタンが押された場合 if Input.trigger?(Input::C) # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # アクションを設定 if @single_arrow != nil @active_battler.current_action.target_index = @single_arrow.index end # バトラーの選択を終了 end_battler_select # スキルウィンドウ表示中の場合 if @skill_window != nil # スキルの選択を終了 end_skill_select end # アイテムウィンドウ表示中の場合 if @item_window != nil # アイテムの選択を終了 end_item_select end # 次のアクターのコマンド入力へ phase3_next_actor end end #-------------------------------------------------------------------------- # ● バトラー選択開始 #-------------------------------------------------------------------------- def start_battler_select # スコープを作成 if Game_BattleAction.method_defined?("scope_force") and @active_battler.current_action.scope_force != 0 scope = @active_battler.current_action.scope_force else case @active_battler.current_action.kind when 0 scope = 1 when 1 scope = @skill.scope when 2 scope = @item.scope end end # アロー号事件 case scope when 1 # 敵単体 @single_arrow = Arrow_Single.new(@spriteset.viewport1, "enemy") when 2 # 敵全体 @all_arrow = Arrow_All.new(@spriteset.viewport1, "enemy") when 3 # 味方単体 @single_arrow = Arrow_Single.new(@spriteset.viewport1, "actor") when 4 # 味方全体 @all_arrow = Arrow_All.new(@spriteset.viewport1, "actor") when 5 # 戦闘不能の味方単体 @single_arrow = Arrow_Single.new(@spriteset.viewport1, "actor") when 6 # 戦闘不能の味方全体 @all_arrow = Arrow_All.new(@spriteset.viewport1, "actor") when 7 # 自分自身 @freeze_arrow = Arrow_Freeze.new(@spriteset.viewport1, "single") when 8 # 敵味方全体 @freeze_arrow = Arrow_Freeze.new(@spriteset.viewport1, "all") when 9 # 敵ランダム @all_arrow = Arrow_All.new(@spriteset.viewport1, "enemy") when 10 # 味方ランダム @all_arrow = Arrow_All.new(@spriteset.viewport1, "actor") when 11 # 敵味方ランダム @freeze_arrow = Arrow_Freeze.new(@spriteset.viewport1, "all") when 12 # 全体化 case @active_battler.current_action.kind when 0 scope = 1 when 1 scope = @skill.scope when 2 scope = @item.scope end case scope when 1, 2 @all_arrow = Arrow_All.new(@spriteset.viewport1, "enemy") when 3, 4 @all_arrow = Arrow_All.new(@spriteset.viewport1, "actor") when 5, 6 @all_arrow = Arrow_All.new(@spriteset.viewport1, "actor") end end # ヘルプウィンドウを関連付け if @single_arrow != nil @single_arrow.help_window = @help_window elsif @all_arrow != nil @all_arrow.help_window = @help_window elsif @freeze_arrow != nil @freeze_arrow.help_window = @help_window end # アクターコマンドウィンドウを無効化 @actor_command_window.active = false @actor_command_window.visible = false end #-------------------------------------------------------------------------- # ● バトラー選択中断 #-------------------------------------------------------------------------- def p_end_battler_select if @single_arrow != nil @single_arrow.dispose @single_arrow = nil elsif @all_arrow != nil @all_arrow.dispose @all_arrow = nil else @freeze_arrow != nil @freeze_arrow.dispose @freeze_arrow = nil end # ヘルプウィンドウを隠す @help_window.visible = false # コマンドが [戦う] の場合 if @actor_command_window.index == 0 # アクターコマンドウィンドウを有効化 @actor_command_window.active = true @actor_command_window.visible = true end end #-------------------------------------------------------------------------- # ● バトラー選択終了 #-------------------------------------------------------------------------- def end_battler_select if @single_arrow != nil @single_arrow.dispose @single_arrow = nil elsif @all_arrow != nil @all_arrow.dispose @all_arrow = nil elsif @freeze_arrow != nil freeze_arrow.dispose @freeze_arrow = nil end # ヘルプウィンドウを隠す @help_window.visible = false # コマンドが [戦う] の場合 if @actor_command_window.index == 0 # アクターコマンドウィンドウを有効化 @actor_command_window.active = true @actor_command_window.visible = true end end #-------------------------------------------------------------------------- # ● スキルまたはアイテムの対象側バトラー設定 # scope : スキルまたはアイテムの効果範囲 #-------------------------------------------------------------------------- def set_target_battlers(scope) if Game_BattleAction.method_defined?("scope_force") and @active_battler.current_action.scope_force != 0 # 強引に切り替え if @active_battler.current_action.scope_force == 12 case scope when 1, 2 scope = 2 when 3, 4 scope = 4 when 5, 6 scope = 6 else scope = @active_battler.current_action.scope_force end end end # 行動側バトラーがエネミーの場合 if @active_battler.is_a?(Game_Enemy) # 効果範囲で分岐 case scope when 1 # 敵単体 index = battler.current_action.target_index @target_battlers.push($game_party.smooth_target_actor(index)) when 2 # 敵全体 for actor in $game_party.actors if actor.exist? @target_battlers.push(actor) end end when 3 # 味方単体 index = battler.current_action.target_index @target_battlers.push($game_troop.smooth_target_enemy(index)) when 4 # 味方全体 for enemy in $game_troop.enemies if enemy.exist? @target_battlers.push(enemy) end end when 5 # 味方単体 (HP 0) index = battler.current_action.target_index @target_battlers.push($game_troop.enemies[index]) when 6 # 味方全体 (HP 0) for enemy in $game_troop.enemies if enemy != nil @target_battlers.push(enemy) end end when 7 # 使用者 @target_battlers.push(battler) when 8, 11 # 敵味方全体、敵味方ランダム @target_battlers = [] for battler in $game_party.actors + $game_troop.enemies @target_battlers.push(battler) if battler.exist? end # 自分以外 if @active_battler.current_action.self_exclusion @target_battlers -= [@active_battler] end # 対象ランダムの場合は一体に絞る if scope == 11 @target_battlers = [@target_battlers[rand(@target_battlers.size)]] end when 9 # 敵ランダム targets = [] for actor in $game_party.actors targets.push(actor) if actor.exist? end @target_battlers = [targets[rand(targets.size)]] when 10 # 味方ランダム targets = [] for enemy in $game_troop.enemies if enemy.exist? unless @active_battler.current_action.self_exclusion and enemy == @active_battler targets.push(enemy) end end end @target_battlers = [targets[rand(targets.size)]] end end # 行動側バトラーがアクターの場合 if @active_battler.is_a?(Game_Actor) # 効果範囲で分岐 case scope when 1, 3, 5 # 単体 index = battler.current_action.target_index if @single_arrow.mode == "enemy" @target_battlers.push($game_troop.smooth_target_enemy(index)) else @target_battlers.push($game_party.smooth_target_actor(index)) end when 2, 4, 6 # 全体 if @all_arrow.mode == "enemy" for target in $game_troop.enemies if target.exist? @target_battlers.push(target) end end else for target in $game_party.actors if target.exist? @target_battlers.push(target) end end end when 7 # 使用者 @target_battlers.push(battler) when 8, 11 # 敵味方全体、敵味方ランダム @target_battlers = [] for battler in $game_party.actors + $game_troop.enemies @target_battlers.push(battler) if battler.exist? end # 自分以外 if @active_battler.current_action.self_exclusion @target_battlers -= [@active_battler] end # 対象ランダムの場合は一体に絞る if scope == 11 @target_battlers = [@target_battlers[rand(@target_battlers.size)]] end when 9, 10 # ランダム if @all_arrow.mode == "enemy" for target in $game_troop.enemies if target.exist? targets.push(target) end end else for target in $game_party.actors if target.exist? targets.push(target) end end end @target_battlers = [targets[rand(targets.size)]] end end end #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 3 : 行動側アニメーション) #-------------------------------------------------------------------------- def update_phase4_step3 @help_window.visible = false # ヘルプウィンドウの更新。アクションの種別で分岐 case @active_battler.current_action.kind when 0 # 基本 case @active_battler.current_action.basic when 0 @wait_count = 0 @active_battler.set_action when 1 @help_window.set_text($data_system.words.guard, 1) @help_wait = @help_time @active_battler.anime_code = [0, Numset::GUARDING_LINE] @active_battler.anime_time = [0, -1, -1] end when 1 # スキル skill = $data_skills[battler.current_action.skill_id] @help_window.set_text(skill.name, 1) @help_wait = @help_time @wait_count = 0 @active_battler.set_action when 2 # アイテム item = $data_items[battler.current_action.item_id] @help_window.set_text(item.name, 1) @help_wait = @help_time @wait_count = 0 @active_battler.set_action end # 攻撃前のウェイトを加算 for time in @active_battler.anime_time if time =~ /^start$/i @active_battler.anime_time.delete_if {|a| a =~ /^start$/i} break else @wait_count += time end end # ステップ 4 に移行 @phase4_step = 4 end #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 4 : 対象側アニメーション) #-------------------------------------------------------------------------- alias :base_update_phase4_step4 :update_phase4_step4 def update_phase4_step4 base_update_phase4_step4 for target in @target_battlers if @active_battler != target if target.damage != "Miss" and not target.guarding? target.anime_code = [0, Numset::DAMAGE_LINE] target.anime_time = [0, -1, -1] if (target.hp * 100 / target.maxhp) <= Numset::PINCH_PARSENT target.anime_code.push(Numset::PINCH_LINE) else target.anime_code.push(Numset::STANDING_LINE) end end end end end #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 5 : ダメージ表示) #-------------------------------------------------------------------------- alias :base_update_phase4_step5 :update_phase4_step5 def update_phase4_step5 base_update_phase4_step5 # 攻撃後のウェイト for time in @active_battler.anime_time @wait_count += time end if @animation2_id != 0 min = 2 * $data_animations[@animation2_id].frame_max - 10 @wait_count = [min, @wait_count].min end end #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 6 : リフレッシュ) #-------------------------------------------------------------------------- alias :base_update_phase4_step6 :update_phase4_step6 def update_phase4_step6 # 永続アクションクリア clear_action(@active_battler) if @active_battler.move_time[0] != nil and @active_battler.move_time[0] != 0 @wait_count += @active_battler.move_time.shift end for target in @target_battlers if target != @active_battler clear_action(target) end end @wait_count = 0 base_update_phase4_step6 end #-------------------------------------------------------------------------- # ● 永続アクションクリア #-------------------------------------------------------------------------- def clear_action(battler) if battler.exist? and battler.anime_code[0] == Numset::DEAD_LINE battler.anime_time = [-1] if battler.screen_x != battler.save_x or battler.screen_y != battler.save_y battler.anime_code.unshift(Numset::MOVEING_LINE) battler.anime_time.unshift(16) battler.move_code = [[battler.save_x, battler.save_y]] battler.move_time = [16] end if (battler.hp * 100 / battler.maxhp) <= Numset::PINCH_PARSENT battler.anime_code.push(Numset::PINCH_LINE) else battler.anime_code.push(Numset::STANDING_LINE) end return end if battler.anime_code[0] != Numset::STANDING_LINE and battler.anime_code[0] != Numset::PINCH_LINE and battler.anime_time[0] == -1 unless battler.guarding? if battler.exist? battler.anime_code.delete_at(0) battler.anime_time.delete_at(0) end end end if battler.guarding? battler.anime_code[0] = Numset::GUARDING_LINE end battler.anime_freeze = false battler.sprite.opacity = 0 if battler.sprite.opacity != 0 battler.sprite.angle = 0 if battler.sprite.angle != 0 end #-------------------------------------------------------------------------- # ● コモンイベント作成 #-------------------------------------------------------------------------- def common(id) # コモンイベントを取得 common_event = $data_common_events[id] # コモンイベントが有効の場合 if common_event != nil # 子インタプリタを作成 @child_interpreter = Interpreter.new @child_interpreter.setup(common_event.list, @event_id) end end end