#============================================================================== #RTAB观光游第六站,连击效果+连击数显示 (显示部分) #============================================================================== # ▼▲▼ XRXS_BP19. コンボ表示+ヒットボーナス ver.3β ▼▲▼ built 201409 # by 桜雅 在土 #============================================================================== # □ カスタマイズポイント #============================================================================== class XRXS_BP19 # # コンボ持続時間[単位:F](40F が 一秒) # COMBOHIT_DURATION = 90 # # スキン ファイル名 # SKIN_NUMBER = "SixRice_Number.png" SKIN_HIT = "SixRice_HITS.png" end class Game_Battler # # コンボヒットによるダメージ補正力/ヒット数[単位:%] # DAMAGE_INCREASE_PER_HIT = 1 end #============================================================================== # --- XRXS.ナンバースプライト スキン対応! --- #============================================================================== class NumberSprite #-------------------------------------------------------------------------- # ○ オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(skin) [url=home.php?mod=space&uid=81523]@skin[/url] = skin @sprites = [] @width = skin.width/10 [url=home.php?mod=space&uid=291977]@height[/url] = skin.height set_digit(4) # 基本設定値 set(0) end #-------------------------------------------------------------------------- # ○ 桁の設定 #-------------------------------------------------------------------------- def set_digit(digit) @sprites.each{|sprite| sprite.dispose} @sprites.clear digit.times do sprite = Sprite.new sprite.bitmap = @skin sprite.z = 999 sprite.src_rect.set(0, 0, @width, @height) @sprites.push(sprite) end end #-------------------------------------------------------------------------- # ○ 値の設定 #-------------------------------------------------------------------------- def set(number) # 例外補正 0.17b更新 digit = (number ==0) ? 0 : Math.log10(number) if digit > @sprites.size set_digit(digit) end # 各桁の適用 for sprite in @sprites sprite.src_rect.x = number%10 * @width number /= 10 end # ゼロ表示 上から判定し、一度でも 0 でなければそこから表示 zero_display = false for sprite in @sprites.reverse zero_display |= (sprite.src_rect.x != 0) sprite.visible = zero_display end end #-------------------------------------------------------------------------- # ○ 座標などの設定の経由 #-------------------------------------------------------------------------- def x=(n) @sprites.each{|sprite| sprite.x = n n -= @width } end def y=(n) @sprites.each{|sprite| sprite.y = n } end def opacity=(n) @sprites.each{|sprite| sprite.opacity = n } end def dispose @sprites.each{|sprite| sprite.dispose } end end #============================================================================== # □ Window_ComboHit #------------------------------------------------------------------------------ # 戦闘中にコンボ数を表示する透明なウィンドウです。 #============================================================================== class Window_ComboHit < Window_Base #-------------------------------------------------------------------------- # ○ オブジェクト初期化 #-------------------------------------------------------------------------- def initialize @number = NumberSprite.new(RPG::Cache.windowskin(XRXS_BP19::SKIN_NUMBER)) super(200, 80, 200, 80) self.opacity = 0 self.z = 999 self.visible = false self.contents = RPG::Cache.windowskin(XRXS_BP19::SKIN_HIT).dup @active = false @show_duration = 0 @sliding_duration = 0 end #-------------------------------------------------------------------------- # ○ クリア ほか #-------------------------------------------------------------------------- def clear self.visible = false end def x=(n) super @number.x = n if @number != nil end def y=(n) super @number.y = n if @number != nil end def contents_opacity=(n) super @number.opacity = n if @number != nil end def dispose @number.dispose super end #-------------------------------------------------------------------------- # ○ リフレッシュ #-------------------------------------------------------------------------- def refresh(hit_combo, duration) # 可視化 self.contents_opacity = 255 self.visible = true # 設定 @show_duration = duration @sliding_duration = 0 # 描写 @number.set(hit_combo) end #-------------------------------------------------------------------------- # ○ フレーム更新 #-------------------------------------------------------------------------- def update if @sliding_duration > 0 @sliding_duration -= 1 self.contents_opacity -= 32 self.x += 1 if @sliding_duration == 0 self.visible = false end elsif @show_duration > 0 @show_duration -= 1 if @show_duration == 0 @sliding_duration = 8 end end end end
#============================================================================== #RTAB观光游第六站,连击效果+连击数显示 (计算部分) #============================================================================== # 連撃 Ver 1.03 # 配布元・サポートURL # [url]http://members.jcom.home.ne.jp/cogwheel/[/url] #============================================================================== # ■ Scene_Battle (分割定義 4) #------------------------------------------------------------------------------ # バトル画面の処理を行うクラスです。 #============================================================================== # アニメに強さ0のフラッシュが存在した場合、 # 赤:倍率 緑:+スキル・アイテムID でダメージ計算を行う。 # # 连击数,每次伤害比率如何设置,参考动画“千裂斩” class Scene_Battle attr_reader :skill#到此一游 #-------------------------------------------------------------------------- # ● ATB基礎セットアップ #-------------------------------------------------------------------------- alias :atb_setup_straight :atb_setup def atb_setup atb_setup_straight for battler in $game_party.actors + $game_troop.enemies battler.total_damage = {} end end #-------------------------------------------------------------------------- # ● アクション更新 (メインフェーズ) #-------------------------------------------------------------------------- def action_phase(battler) while true # action が 1 の場合、バトラーが行動中かどうか確認 if @action == 1 and battler.phase < 3 for target in battler.target speller = synthe?(target) if speller == nil # ターゲットが通常行動中の場合 if @action_battlers.include?(target) if target.phase > 2 return end end else # ターゲットが連携スキル発動中の場合 for spell in speller if @action_battlers.include?(spell) if spell.phase > 2 return end end end end end end case battler.phase when 1 update_phase4_step1(battler) when 2 update_phase4_step2(battler) when 3 update_phase4_step3(battler) when 4 update_phase4_step4(battler) when 5 update_phase4_step5(battler) when 6 update_phase4_step6(battler) end # ウェイトが入った場合 if battler.wait > 0 # ウェイトカウントを減らして終了 battler.wait -= 1 break end # 行動終了した場合ループを抜ける unless @action_battlers.include?(battler) break end end end #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 1 : アクション準備) #-------------------------------------------------------------------------- def update_phase4_step1(battler) # すでに戦闘から外されている場合 if battler.index == nil @action_battlers.delete(battler) anime_wait_return battler.wait = 1 return end speller = synthe?(battler) if speller == nil # ダメージ食らい中の場合 unless battler.damage.empty? or @action > 2 battler.wait = 1 return end # 行動可能かどうか判定 unless battler.movable? battler.phase = 6 return end else # ダメージ食らい中の場合 for spell in speller unless spell.damage.empty? or @action > 2 battler.wait = 1 return end # 行動可能かどうか判定 unless spell.movable? battler.phase = 6 return end end end # スキル使用時、詠唱時間設定 # 強制アクションかつ [url=home.php?mod=space&uid=316545]@force[/url] が 2 の時はスキルを即時発動 if battler.current_action.kind == 1 and (not battler.current_action.forcing or @force != 2) if battler.rtp == 0 # スキル詠唱中ならば、解除 skill_reset(battler) # スキル詠唱時間設定 recite_time(battler) # 連携技設定 synthe_spell(battler) # スキルを詠唱する場合 if battler.rtp > 0 # 強制アクションかつ @force が 1 の時は連携スキルのみ即時発動 speller = synthe?(battler) if battler.current_action.forcing and @force > 0 and speller != nil for spell in speller spell.rt = spell.rtp end else battler.blink = true if battler.current_action.forcing $game_temp.forcing_battler = nil battler.current_action.forcing = false end @action_battlers.delete(battler) return end end end end # アクターの明滅エフェクト OFF if battler != nil battler.blink = false end speller = synthe?(battler) if speller == nil @spell_p.delete(battler) @spell_e.delete(battler) else for spell in speller spell.blink = false @spell_p.delete(spell) @spell_e.delete(spell) end end # ステップ 2 に移行 battler.phase = 2 end #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 2 : アクション開始) #-------------------------------------------------------------------------- def update_phase4_step2(battler) # 強制アクションでなければ unless battler.current_action.forcing # 制約が [敵を通常攻撃する] か [味方を通常攻撃する] の場合 if battler.restriction == 2 or battler.restriction == 3 # アクションに攻撃を設定 battler.current_action.kind = 0 battler.current_action.basic = 0 end end # アクションの種別より攻撃アニメーションを取得する case battler.current_action.kind when 0 # 基本 if battler.is_a?(Game_Actor) base_id = battler.weapon_id end anime_id = battler.animation2_id # 防御など特殊行動の場合は次のステップへ unless make_basic_action_preparation(battler) return end # 戦闘が終了した場合は行動をキャンセル if fin? battler.phase = 6 return end when 1 # スキル base_id = battler.current_action.skill_id anime_id = $data_skills[battler.current_action.skill_id].animation2_id # スキルが使用できない場合は行動をキャンセル unless make_skill_action_preparation(battler) return end # 戦闘が終了した場合は行動をキャンセル if fin? and $data_skills[anime_id].scope == 1..2 battler.phase = 6 return end when 2 # アイテム base_id = battler.current_action.item_id anime_id = $data_items[battler.current_action.item_id].animation2_id # アイテムが使用できない場合は行動をキャンセル unless make_item_action_preparation(battler) return end # 戦闘が終了した場合は行動をキャンセル if fin? and $data_items[anime_id].scope == 1..2 battler.phase = 6 return end end # アニメーションを検索し、連撃性を変数serialに代入する serial = [] frame = 0 if $data_animations[anime_id] != nil for animation in $data_animations[anime_id].timings color = animation.flash_color # アニメーション・フラッシュの強さが0の場合 if color.alpha == 0 serial.push([color.red.to_i, color.green, animation.frame - frame]) frame = animation.frame end end # 連撃性がない場合単発攻撃 if serial.empty? serial = [[20, 100, $data_animations[anime_id].frame_max - 5]] end else # アニメーションが存在しない場合 serial = [[20, 100, 0]] end # ハッシュ total_damage の作成 total_damage = {} for target in battler.target total_damage[target] = [] end # 連撃回数分ダメージ計算を行う for attack in serial # アクションの種別で分岐 case battler.current_action.kind when 0 # 基本 if battler.is_a?(Game_Actor) # バトラーがアクターの場合、攻撃時に武器を変更する battler.change_weapon(base_id + attack[1] - 100) end make_basic_action_result(battler) when 1 # スキル # 連携スキルのことを考え、スキルIDの変更は内部処理で行う make_skill_action_result(battler, attack[1] - 100) when 2 # アイテム # アイテムIDを設定分変化させる battler.current_action.item_id = base_id + attack[1] - 100 make_item_action_result(battler) end # total_damage へダメージを代入 for target in battler.target # ダメージがある場合、ダメージをX/20倍する。 if target.damage[battler].is_a?(Numeric) damage = target.damage[battler] * attack[0] / 20 else damage = target.damage[battler] end # 回復HP量がある場合、回復HP量をX/20倍する。 if target.recover_hp[battler].is_a?(Numeric) recover_hp = target.recover_hp[battler] * attack[0] / 20 end # 回復SP量がある場合、回復SP量をX/20倍する。 if target.recover_sp[battler].is_a?(Numeric) recover_sp = target.recover_sp[battler] * attack[0] / 20 end critical = target.critical[battler] # total_damage = [ダメージ, クリティカルフラグ, 回復HP量, 回復SP量, # ステート変化, ステート回復, 待ちフレーム時間] total_damage[target].push([damage, critical, recover_hp, recover_sp, target.state_p[battler], target.state_m[battler], attack[2]]) end end # トータルダメージを、バトラーのインスタンスに代入 for target in battler.target target.total_damage[battler] = total_damage[target] end # 武器・スキル・アイテムIDを通常に戻す case battler.current_action.kind when 0 # 基本 if battler.is_a?(Game_Actor) battler.change_weapon(base_id) end when 1 # スキル battler.current_action.skill_id = base_id when 2 # アイテム battler.current_action.item_id = base_id end if battler.phase == 2 # ステップ 3 に移行 battler.phase = 3 end end #-------------------------------------------------------------------------- # ● 基本アクション 準備 #-------------------------------------------------------------------------- def make_basic_action_preparation(battler) # 攻撃の場合 if battler.current_action.basic == 0 # アニメーション ID を設定 battler.anime1 = battler.animation1_id battler.anime2 = battler.animation2_id # 行動側バトラーがエネミーの場合 if battler.is_a?(Game_Enemy) if battler.restriction == 3 target = $game_troop.random_target_enemy elsif battler.restriction == 2 target = $game_party.random_target_actor else index = battler.current_action.target_index target = $game_party.smooth_target_actor(index) end end # 行動側バトラーがアクターの場合 if battler.is_a?(Game_Actor) if battler.restriction == 3 target = $game_party.random_target_actor elsif battler.restriction == 2 target = $game_troop.random_target_enemy else index = battler.current_action.target_index target = $game_troop.smooth_target_enemy(index) end end # 対象側バトラーの配列を設定 battler.target = [target] return true end # 防御の場合 if battler.current_action.basic == 1 # ステップ 3 に移行 battler.phase = 3 return false end #===============0.15b(RTAB官方更新)=========================================== # 逃げるの場合 if battler.is_a?(Game_Enemy) and battler.current_action.basic == 2 # ステップ 3 に移行 battler.phase = 3 return false end #============================================================================= # 何もしないの場合 if battler.current_action.basic == 3 # ステップ 6 に移行 battler.phase = 6 return false end end #-------------------------------------------------------------------------- # ● スキルアクション 準備 #-------------------------------------------------------------------------- def make_skill_action_preparation(battler) # スキルを取得 [url=home.php?mod=space&uid=260100]@skill[/url] = $data_skills[battler.current_action.skill_id] # 連携スキルであるかどうか確認 speller = synthe?(battler) # 強制アクションでなければ unless battler.current_action.forcing # SP 切れなどで使用できなくなった場合 if speller == nil unless battler.skill_can_use?(@skill.id) # ステップ 6 に移行 battler.phase = 6 return false end end end # SP 消費 temp = false if speller != nil for spell in speller if spell.current_action.spell_id == 0 spell.sp -= @skill.sp_cost else spell.sp -= $data_skills[spell.current_action.spell_id].sp_cost end # ステータスウィンドウをリフレッシュ status_refresh(spell) end else battler.sp -= @skill.sp_cost # ステータスウィンドウをリフレッシュ status_refresh(battler) end # アニメーション ID を設定 battler.anime1 = @skill.animation1_id battler.anime2 = @skill.animation2_id # コモンイベント ID を設定 battler.event = @skill.common_event_id # 対象側バトラーを設定 set_target_battlers(@skill.scope, battler) return true end #-------------------------------------------------------------------------- # ● アイテムアクション 準備 #-------------------------------------------------------------------------- def make_item_action_preparation(battler) # アイテムを取得 @item = $data_items[battler.current_action.item_id] # アイテム切れなどで使用できなくなった場合 unless $game_party.item_can_use?(@item.id) # ステップ 6 に移行 battler.phase = 6 return false end # 消耗品の場合 if @item.consumable # 使用したアイテムを 1 減らす $game_party.lose_item(@item.id, 1) end # アニメーション ID を設定 battler.anime1 = @item.animation1_id battler.anime2 = @item.animation2_id # コモンイベント ID を設定 battler.event = @item.common_event_id # 対象を決定 index = battler.current_action.target_index target = $game_party.smooth_target_actor(index) # 対象側バトラーを設定 set_target_battlers(@item.scope, battler) return true end #-------------------------------------------------------------------------- # ● 基本アクション 結果作成 #-------------------------------------------------------------------------- def make_basic_action_result(battler) # 通常攻撃の効果を適用 for target in battler.target target.attack_effect(battler) end end #-------------------------------------------------------------------------- # ● スキルアクション 結果作成 #-------------------------------------------------------------------------- def make_skill_action_result(battler, plus_id) # スキルを取得 @skill = $data_skills[battler.current_action.skill_id + plus_id] # 連携スキルであるかどうか確認 speller = synthe?(battler) # スキルの効果を適用 for target in battler.target if speller != nil damage = 0 effective = false state_p = [] state_m = [] d_result = false for spell in speller if spell.current_action.spell_id != 0 @skill = $data_skills[spell.current_action.spell_id + plus_id] end effective |= target.skill_effect(spell, @skill) if target.damage[spell].class != String d_result = true damage += target.damage[spell] elsif effective effect = target.damage[spell] end state_p += target.state_p[spell] state_m += target.state_m[spell] target.damage.delete(spell) target.state_p.delete(spell) target.state_m.delete(spell) end if d_result target.damage[battler] = damage elsif effective target.damage[battler] = effect end target.state_p[battler] = state_p target.state_m[battler] = state_m else target.skill_effect(battler, @skill) end end end #-------------------------------------------------------------------------- # ● アイテムアクション 結果作成 #-------------------------------------------------------------------------- def make_item_action_result(battler) # アイテムを取得 @item = $data_items[battler.current_action.item_id] # アイテムの効果を適用 for target in battler.target target.item_effect(@item, battler) end end #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 4 : 対象側アニメーション) #-------------------------------------------------------------------------- def update_phase4_step4(battler) # カメラ設定 if battler.target[0].is_a?(Game_Enemy) and battler.anime1 != 0 camera_set(battler) end # 対象側アニメーション for target in battler.target target.animation.push([battler.anime2, (target.damage[battler] != "Miss")]) unless battler.anime2 == 0 battler.wait = 2 * target.total_damage[battler][0][6] - 1 + Graphics.frame_count % 2 end end # ステップ 5 に移行 battler.phase = 5 end #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 5 : ダメージ表示) #-------------------------------------------------------------------------- def update_phase4_step5(battler) next_step = true # ダメージ表示 for target in battler.target # total_damage より全ダメージを算出 total_damage = target.total_damage[battler].shift target.damage[battler] = total_damage[0] target.critical[battler] = total_damage[1] target.recover_hp[battler] = total_damage[2] target.recover_sp[battler] = total_damage[3] target.state_p[battler] = total_damage[4] target.state_m[battler] = total_damage[5] # ダメージ表示フラグをON target.damage_pop[battler] = true # 恭喜你发现了连击计算的关键一行! target.combohit_count if target.damage[battler].to_i > 0 and target.damage[battler] != "Miss" # 実際にダメージを与える # target.damage_effect(battler, battler.current_action.kind) target.damage_effect(battler, battler.current_action.kind,skill)#到此一游 # 余計なハッシュを削除 target.recover_hp.delete(battler) target.recover_sp.delete(battler) target.state_p.delete(battler) target.state_m.delete(battler) # ダメージを全て与えきった場合 if target.total_damage[battler].empty? # ターゲットへの全ダメージを削除 target.total_damage.delete(battler) # 指定時間ウェイトする battler.wait = @damage_wait else # 指定時間ウェイトする next_step = false battler.wait = 2 * target.total_damage[battler][0][6] end # ステータスウィンドウをリフレッシュ status_refresh(target) end if next_step # ステップ 6 に移行 battler.phase = 6 end end #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 6 : リフレッシュ) #-------------------------------------------------------------------------- def update_phase4_step6(battler) # カメラを戻す if battler.target[0].is_a?(Game_Enemy) and @camera == battler @spriteset.screen_target(0, 0, 1) end # スキルラーニング if battler.target[0].is_a?(Game_Actor) and battler.current_action.kind == 1 for target in battler.target if target.is_a?(Game_Actor)#(0.16) skill_learning(target, target.class_id, battler.current_action.skill_id) end #(0.16) end end # アクション強制対象のバトラーをクリア if battler.current_action.forcing == true and battler.current_action.force_kind == 0 and battler.current_action.force_basic == 0 and battler.current_action.force_skill_id == 0 $game_temp.forcing_battler = nil battler.current_action.forcing = false end refresh_phase(battler) speller = synthe?(battler) if speller != nil for spell in speller if spell != battler refresh_phase(spell) end end synthe_delete(speller) end # コモンイベント ID が有効の場合 if battler.event > 0 # イベントをセットアップ common_event = $data_common_events[battler.event] $game_system.battle_interpreter.setup(common_event.list, 0) end act = 0 for actor in $game_party.actors + $game_troop.enemies if actor.movable? act += 1 end end if @turn_cnt >= act and act > 0 @turn_cnt %= act $game_temp.battle_turn += 1 # バトルイベントの全ページを検索 for index in 0...$data_troops[@troop_id].pages.size # イベントページを取得 page = $data_troops[@troop_id].pages[index] # このページのスパンが [ターン] の場合 if page.span == 1 # 実行済みフラグをクリア $game_temp.battle_event_flags[index] = false end end end battler.phase = 1 @action_battlers.delete(battler) end #////////////////////////////////////////////////////////////////////////////// #连击数计算的基础部分Part1 by 桜雅 在土 #------------------------------------------------------------------------------ # ● メイン処理 #------------------------------------------------------------------------------ alias xrxs_bp19_main main def main # コンボヒットウィンドウを作成 @combohit_window = Window_ComboHit.new # 呼び戻す xrxs_bp19_main # ウィンドウを解放 @combohit_window.dispose # コンボクリア $game_party.actors.each {|actor| actor.combohit_clear} end #------------------------------------------------------------------------------ # ● フレーム更新 #------------------------------------------------------------------------------ alias xrxs_bp19_update update def update # フレーム更新 @combohit_window.update $game_party.actors.each {|actor| actor.combohit_update} $game_troop.enemies.each{|enemy| enemy.combohit_update} # 呼び戻す xrxs_bp19_update end #------------------------------------------------------------------------------ # ● フレーム更新 (メインフェーズ ステップ 5 : ダメージ表示) #------------------------------------------------------------------------------ alias xrxs_bp19_update_phase4_step5 update_phase4_step5 def update_phase4_step5(battler) # 呼び戻す xrxs_bp19_update_phase4_step5(battler) # コンボ数の最も高いターゲットを探す max = 0 hit_target = nil for target in battler.target if target.combohit > max max = target.combohit hit_target = target end end if max >= 2 and !hit_target.nil? @combohit_window.x = hit_target.is_a?(Game_Enemy) ? 512 : 512 @combohit_window.refresh(max, hit_target.combohit_duration) end end end #////////////////////////////////////////////////////////////////////////////// #============================================================================== # ■ Game_Battler (分割定義 1) #------------------------------------------------------------------------------ # バトラーを扱うクラスです。このクラスは Game_Actor クラスと Game_Enemy クラ # スのスーパークラスとして使用されます。 #============================================================================== class Game_Battler #-------------------------------------------------------------------------- # ● 公開インスタンス変数追加 #-------------------------------------------------------------------------- attr_accessor :total_damage # 総ダメージ #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias :initialize_straight :initialize def initialize initialize_straight @total_damage = {} end #-------------------------------------------------------------------------- # ● 存在判定 #-------------------------------------------------------------------------- def exist? return (not [url=home.php?mod=space&uid=292300]@Hidden[/url] and (@hp > 0 or @immortal or not @total_damage.empty?)) end #-------------------------------------------------------------------------- # ● 残HP予測 #-------------------------------------------------------------------------- def rest_hp # rest_hp に現HPを代入 rest_hp = @hp # バトラーが受ける全ダメージをrest_hpに反映させる for total in @total_damage for pre_damage in total[1] if pre_damage[0].is_a?(Numeric) rest_hp -= pre_damage[0] end if pre_damage[2].is_a?(Numeric) rest_hp += pre_damage[2] end end end return rest_hp end end #////////////////////////////////////////////////////////////////////////////// #连击数计算的基础部分Part2 by 桜雅 在土 #------------------------------------------------------------------------------ # ● 公開インスタンス変数 #------------------------------------------------------------------------------ def combohit @combohit = 0 if @combohit.nil? return @combohit end def combohit_duration @combohit_duration = 0 if @combohit_duration.nil? return @combohit_duration end #------------------------------------------------------------------------------ # ○ コンボヒットを更新 #------------------------------------------------------------------------------ def combohit_update # 例外補正 @combohit_duration = 0 if @combohit_duration.nil? # カウント if @combohit_duration > 0 @combohit_duration -= 1 # のけぞり時間終了時、コンボ数をリセット @combohit = 0 if @combohit_duration == 0 end end #------------------------------------------------------------------------------ # ○ コンボヒットをカウント #------------------------------------------------------------------------------ def combohit_count # 例外補正 @combohit = 0 if @combohit.nil? # カウント @combohit += 1 @combohit_duration = XRXS_BP19::COMBOHIT_DURATION end #------------------------------------------------------------------------------ # ○ コンボヒットをクリア #------------------------------------------------------------------------------ def combohit_clear @combohit = nil @combohit_duration = nil end #////////////////////////////////////////////////////////////////////////////// #============================================================================== # ■ Game_Actor #------------------------------------------------------------------------------ # アクターを扱うクラスです。このクラスは Game_Actors クラス ($game_actors) # の内部で使用され、Game_Party クラス ($game_party) からも参照されます。 #============================================================================== class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- def change_weapon(id) @weapon_id = id end end #============================================================================== # ■ Sprite_Battler #------------------------------------------------------------------------------ # バトラー表示用のスプライトです。Game_Battler クラスのインスタンスを監視し、 # スプライトの状態を自動的に変化させます。 #============================================================================== class Sprite_Battler < RPG::Sprite #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super # バトラーが nil の場合 if [url=home.php?mod=space&uid=133701]@battler[/url] == nil self.bitmap = nil loop_animation(nil) return end # ファイル名か色相が現在のものと異なる場合 if @battler.battler_name != @battler_name or @battler.battler_hue != @battler_hue # ビットマップを取得、設定 @battler_name = @battler.battler_name @battler_hue = @battler.battler_hue self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue) @width = bitmap.width @height = bitmap.height self.ox = @width / 2 self.oy = @height if @battler.is_a?(Game_Enemy) @battler.height = @height end # 戦闘不能または隠れ状態なら不透明度を 0 にする if @battler.dead? or @battler.hidden self.opacity = 0 end end # アニメーション ID が現在のものと異なる場合 if @battler.state_animation_id != @state_animation_id @state_animation_id = @battler.state_animation_id loop_animation($data_animations[@state_animation_id]) end # 表示されるべきアクターの場合 if @battler.is_a?(Game_Actor) and @battler_visible # メインフェーズでないときは不透明度をやや下げる if $game_temp.battle_main_phase self.opacity += 3 if self.opacity < 255 else self.opacity -= 3 if self.opacity > 207 end end # 明滅 if @battler.blink blink_on else blink_off end # 不可視の場合 unless @battler_visible # 出現 if not @battler.hidden and not @battler.dead? and (@battler.damage.size < 2 or @battler.damage_pop.size < 2) appear @battler_visible = true end end # ダメージ for battler in @battler.damage_pop if battler[0].class == Array if battler[0][1] >= 0 $scene.skill_se else $scene.levelup_se end damage(@battler.damage[battler[0]], false, 2) else damage(@battler.damage[battler[0]], @battler.critical[battler[0]]) end if @battler.damage_sp.include?(battler[0]) damage(@battler.damage_sp[battler[0]], @battler.critical[battler[0]], 1) @battler.damage_sp.delete(battler[0]) end @battler.damage_pop.delete(battler[0]) @battler.damage.delete(battler[0]) @battler.critical.delete(battler[0]) 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 # アニメーション unless @battler.animation.empty? for animation in @battler.animation.reverse animation($data_animations[animation[0]], animation[1]) @battler.animation.delete(animation) end end # コラプス if @battler.total_damage.empty? and @battler.dead? if $scene.dead_ok?(@battler) if @battler.is_a?(Game_Enemy) $game_system.se_play($data_system.enemy_collapse_se) else $game_system.se_play($data_system.actor_collapse_se) end collapse @battler_visible = false end end end # スプライトの座標を設定 self.x = @battler.screen_x self.y = @battler.screen_y self.z = @battler.screen_z if @battler.is_a?(Game_Enemy) self.zoom_x = @battler.real_zoom * @battler.zoom self.zoom_y = @battler.real_zoom * @battler.zoom end end end
# ▽△▽ XRXS.付加属性名称判定 ▽△▽ built 091221 # by 桜雅 在土 #============================================================================== # --- XRXS. 付加属性名称判定モジュール --- #============================================================================== module XRXS #-------------------------------------------------------------------------- # ○ 配列が指定名の属性を持つか判定 #-------------------------------------------------------------------------- def XRXS.element_check(set, element_name) returnar = [false, 0, 0, []] # 存在したか?, 固定値の合計、%値の合計 return returnar if !set.is_a?(Array) or set.size == 0 or element_name == "" for i in set if $data_system.elements[i] =~ /^#{element_name}([+-]?[0-9]+)?(%)?/ returnar[0] = true if $2 == nil returnar[1] += $1.to_i returnar[3].push($1.to_i) else returnar[2] += $1.to_i end end end return returnar end def XRXS.element_include?(set, element_name) return element_check(set, element_name)[0] end def XRXS.element_amount(set, element_name) return element_check(set, element_name)[1] end def XRXS.element_percent(set, element_name) return element_check(set, element_name)[2] end def XRXS.element_numbers(set, element_name) return element_check(set, element_name)[3] end end
# ▽△▽ XRXS. 装備属性取得機構 ▽△▽ built 221114 # by 桜雅 在土 #============================================================================== # --- XRXS. 装備属性取得機構 --- #============================================================================== class Game_Battler #-------------------------------------------------------------------------- # ○ スキルの属性取得 #-------------------------------------------------------------------------- def skill_element_set(skill) return skill.nil? ? [] : skill.element_set end #-------------------------------------------------------------------------- # ○ 全装備の属性取得 #-------------------------------------------------------------------------- def equip_element_set return self.element_set + self.guard_element_set end #-------------------------------------------------------------------------- # ○ 全防具の属性取得 #-------------------------------------------------------------------------- def guard_element_set return [] end end class Game_Actor < Game_Battler def guard_element_set set = [] for id in self.armor_ids next if id.nil? armor = $data_armors[id] set += (armor != nil ? armor.guard_element_set : []) end return set end #-------------------------------------------------------------------------- # ○ 武器 ID配列 #-------------------------------------------------------------------------- def weapon_ids @weapon_ids = [] if @weapon_ids == nil @weapon_ids[0] = @weapon_id return @weapon_ids end #-------------------------------------------------------------------------- # ○ 防具 ID配列 #-------------------------------------------------------------------------- def armor_ids @armor_ids = [] if @armor_ids == nil @armor_ids[0] = @armor1_id @armor_ids[1] = @armor2_id @armor_ids[2] = @armor3_id @armor_ids[3] = @armor4_id return @armor_ids end #-------------------------------------------------------------------------- # ○ 装備配列の取得 #-------------------------------------------------------------------------- def equipments equipments = [] self.weapon_ids.each {|id| equipments.push($data_weapons[id])} self.armor_ids.each {|id| equipments.push($data_armors[id])} return equipments end #-------------------------------------------------------------------------- # ○ 装備中? #-------------------------------------------------------------------------- def equiping?(item) case item when RPG::Weapon return self.weapon_ids.include?(item.id) when RPG::Armor return self.armor_ids.include?(item.id) else return false end end end
# ▼▲▼ XRXS38. 属性修正计算数限制 ▼▲▼ built 081012 # by 桜雅 在土 (原作) # Tetra-Z (強化) #============================================================================== # 简介:此脚本会将“系统默认的属性修正”和“战斗特殊效果属性”分开计算; # 插入此脚本后,“战斗特殊效果属性”将“不计算属性有效度”。 #============================================================================== # □ カスタマイズポイント #============================================================================== module XRXS38 # 属性的限制数量 ELEMENTS_NUMBER_LIMIT = 16 # 属性修正的计算方法 # 0 : 最大(默认的计算方法) # 1 : 乘法 # 2 : 平均 # 3 : 最小 ELEMENT_CORRECT_METHOD = 1 end #============================================================================== # ■ Game_Battler #============================================================================== class Game_Battler #-------------------------------------------------------------------------- # ● 属性修正的计算 + 倍率计算公式 #-------------------------------------------------------------------------- alias xrxs38_elements_correct elements_correct def elements_correct(element_set) elements = element_set.dup # 属性数量的限制 for element_id in element_set if element_id >XRXS38:: ELEMENTS_NUMBER_LIMIT elements.delete(element_id) end end #无属性的场合返回100 return 100 if elements.size == 0 # case XRXS38::ELEMENT_CORRECT_METHOD when 0 # 最大 return xrxs38_elements_correct(elements) when 1 # 乘法 result = 100.0 minus_enable = false for i in elements n = self.element_rate(i) minus_enable |= (n < 0) result *= n / 100.0 end result = -1 * result.abs if minus_enable return result.to_i when 2 # 平均 rates = [] result = 0 for i in elements rates.push(self.element_rate(i)) end for rate in rates result += rate end return result / rates.size when 3 # 最小 for i in elements n = self.element_rate(i) result = n if result.nil? or result > n end return result end end end
#============================================================================== # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息 #============================================================================== # 基础脚本▼▲▼ XRXS19. 特殊効果詰め合わせ DamageEX ver.2 ▼▲▼ built 220920 # by 桜雅 在土 (基本) Tetra-Z (修正) [url]http://scriptself.jpn.org/x/XRXS19.htm[/url] #============================================================================== # ▼▲▼ 战斗特殊效果属性 DamageEX - Plus × RTAB ▼▲▼ # # 适用环境:RTAB Ver 1.16 # # by SixRice (Plus × RTAB改造) Ver.1.03 2006/8/18 # 从1.03版开始记录每次更新。 #============================================================================== # 伤害计算流程: # 1 基础伤害计算 (Game Battler) # 2 忽视躲闪判定 (IGNORE_EVADE) # 3 修正基础伤害 (HP_RATE,SP_RATE,CRITICAL_HIT,ADD_VARIANCE) # 4 固定伤害(取消基础) (FIXDAMAGE) # 5 追加伤害计算 (追加伤害效果类) # -> 基础伤害(或固定伤害)+追加伤害 # = 总伤害 # 6 修正总伤害 (HP_DAMAGE,SP_DAMAGE) # -> 最终伤害 # 7 收招修正使用者的HP/SP (HP_CORRECT,SP_CORRECT)(1.03) # 8 根据最终伤害修正使用者的HP/SP (HP_DRAIN,SP_DRAIN) #------------------------------------------------------------------------------ module XRXS19 #------------------------------------------------------------------------------ # 一:特殊伤害效果类的属性名称设定 #------------------------------------------------------------------------------ # 提示:本类属性名称后请添加自定义数值,然后才会生效。(数据库) #------------------------------------------------------------------------------ # 提示:本类属性请设为“不计算属性有效度”(XRXS38. 属性修正计算数限制)。 #------------------------------------------------------------------------------ # 提示:本类属性中如果存在同属性,效果也叠加。 # # 举例:一个东西同时包含HP吸收50%,HP吸收25%,实际效果为HP吸收75%. #------------------------------------------------------------------------------ AT_DAMAGE = "AT伤害" # 「修正目标的AT值(行动值)」(1.03) HP_DAMAGE = "HP伤害" # 「将本次造成的总伤害的x%修正为HP伤害」 SP_DAMAGE = "SP伤害" # 「将本次造成的总伤害的x%修正为SP伤害」 HP_DRAIN = "HP吸收" # 「根据本次最终伤害的x%修正使用者的HP」 SP_DRAIN = "SP吸收" # 「根据本次最终伤害的x%修正使用者的SP」 HP_RATE = "现HP威力" # 「根据使用者HP/MAXHP修正本次基础伤害」 SP_RATE = "现SP威力" # 「根据使用者SP/MAXSP修正本次基础伤害」 CRITICAL_HIT = "必杀" # 「会心一击」 (武器效果通用化) IGNORE_EVADE = "忽视躲闪" # 「忽视躲闪」 (特技效果武器化) ADD_VARIANCE = "分散度" # 「追加分散度」 (特技效果武器化) FIXDAMAGE = "固定伤害" # 「固定伤害值」 (特技效果武器化) #------------------------------------------------------------------------------ # 提示:本类中“固定伤害值”不能和“会心一击”、“追加分散度”叠加; # 其余效果均可叠加。 #------------------------------------------------------------------------------ AREA_EXTEND = "敌方全体" # 「敌方全体」属性名2 AREA_ACTOR = "己方单体" # 「己方单体」属性名3 AREA_ACTOR_ALL = "己方全体" # 「己方全体」属性名4 AREA_SELF = "使用者" # 「 使用者 」属性名7 AREA_WHOLE = "全域化" # 「 全域化 」属性名8 AREA_ENEMY_RAND = "敌方随机" # 「敌方随机」属性名9 AREA_ACTOR_RAND = "己方随机" # 「己方随机」属性名10 AREA_ALL_RAND = "对象随机" # 「对象随机」属性名11 SELF_INCLUSION = "诸刃" # 「 诸刃 」属性名 SELF_EXCLUSION = "自身以外" # 「自身以外」(与使用者,己方单体叠加无效) #------------------------------------------------------------------------------ # 提示:「诸刃」与 # 「使用者」,「己方单体」,「己方全体」,「己方随机」,「对象随机」叠加无效。 #------------------------------------------------------------------------------ P_STATE = "发动状态P" # 「行动时附加自身状态」属性名 M_STATE = "发动状态M" # 「行动时解除自身状态」属性名 HP_CORRECT = "收招修正H" # 「收招时修正使用者HP」属性名(1.03) SP_CORRECT = "收招修正S" # 「收招时修正使用者SP」属性名(1.03) #------------------------------------------------------------------------------ # 提示:在这个版本的战斗特殊效果属性中, # 除了"会心一击" 、"忽视躲闪"、"追加分散度" 这三个效果以外, # 其他的效果都支持负数,也就是逆转效果。 # # 举例:想设置一个“敌我皆伤”的特技,只要附带HP吸收属性,效果设为负数就OK了。 # # 举例:如果把"HP伤害负数" + "作用范围己方"设置为武器属性, # 就可以设置出回复己方HP的BT武器来。 # # 更多创意想法等你来发挥!! #------------------------------------------------------------------------------ # 二:追加伤害效果类的属性名称设定 #------------------------------------------------------------------------------ # 本类采用的英文单词缩写 # NOW(N) = 当前 ;MAX(M) = 最大;DIF(D) = 差值 ; # HP(H) = 生命 ;SP(S) = 精力 ; # TA(T) = target = 目标方;US(U) = user = 使用者 。 #------------------------------------------------------------------------------ FIXDAMAGE_NOWHPTA = "NHT" # 「目标方当前HP比例」属性名 FIXDAMAGE_MAXHPTA = "MHT" # 「目标方最大HP比例」属性名 FIXDAMAGE_DIFHPTA = "DHT" # 「目标方HP差值比例」属性名 FIXDAMAGE_NOWHPUS = "NHU" # 「使用者当前HP比例」属性名 FIXDAMAGE_MAXHPUS = "MHU" # 「使用者最大HP比例」属性名 FIXDAMAGE_DIFHPUS = "DHU" # 「使用者HP差值比例」属性名 FIXDAMAGE_NOWSPTA = "NST" # 「目标方当前SP比例」属性名 FIXDAMAGE_MAXSPTA = "MST" # 「目标方最大SP比例」属性名 FIXDAMAGE_DIFSPTA = "DST" # 「目标方SP差值比例」属性名 FIXDAMAGE_NOWSPUS = "NSU" # 「使用者当前SP比例」属性名 FIXDAMAGE_MAXSPUS = "MSU" # 「使用者最大SP比例」属性名 FIXDAMAGE_DIFSPUS = "DSU" # 「使用者SP差值比例」属性名 #------------------------------------------------------------------------------ # 提示:本类所有效果均不能互相叠加,具有唯一性; # 若特技属性中存在多个本类效果,则取最前面一个效果。 #------------------------------------------------------------------------------ # 提示:特技附加本类属性的情况下,设特技的威力(pow)为比例基数, # 武器附加本类属性的情况下,设武器攻击力(atk)为比例基数, # 因此比例基数请通过数据库来设定。 #------------------------------------------------------------------------------ # 提示:本类所有效果均为普通伤害计算之后的追加伤害; # 本类所有效果“独立计算属性有效度”,不与其他属性有效度进行混合运算。 #------------------------------------------------------------------------------ # 举例1:某特技属性附加"NHT" ,威力为20,其实际效果为: # 造成 [目标方][当前][HP][20%] 的等量伤害。 #------------------------------------------------------------------------------ # 举例2:由于威力(power)这个值可以设为负数, # 因此MHT这个属性也可用于制作比例回复HP的特技效果。 #------------------------------------------------------------------------------ end #============================================================================== # ■ Game_BattleAction #============================================================================== class Game_BattleAction attr_accessor :at_damage # 「AT伤害值」 (Numeric)(1.03) attr_accessor :hp_damage # 「HP伤害率」 (Numeric) attr_accessor :sp_damage # 「SP伤害率」 (Numeric) attr_accessor :hp_drain # 「HP吸收率」 (Numeric) attr_accessor :sp_drain # 「SP吸收率」 (Numeric) attr_accessor :hp_rate # 「现HP威力」 (true/false) attr_accessor :sp_rate # 「现SP威力」 (true/false) attr_accessor :critical_hit # 「会心一击」 (Numeric) attr_accessor :ignore_evade # 「忽视躲闪」 (true/false) attr_accessor :add_variance # 「追加分散度」 (Numeric) attr_accessor :fix_damage # 「固定伤害值」 (Numeric) attr_accessor :special_damage_kind # 「追加伤害类」 (Numeric) attr_accessor :scope_force # 「对象强制值」 (Numeric) attr_accessor :self_inclusion # 「诸刃」 (true/false) attr_accessor :self_exclusion # 「自身以外」 (true/false) attr_accessor :p_state # 「行动时附加自身状态」(Numeric) attr_accessor :m_state # 「行动时解除自身状态」(Numeric) attr_accessor :hp_correct # 「收招时修正使用者HP」(Numeric)(1.03) attr_accessor :sp_correct # 「收招时修正使用者SP」(Numeric)(1.03) def at_damage return @at_damage.nil? ? 0 : @at_damage end #-------------------------------------------------------------------------- # ● clear #-------------------------------------------------------------------------- alias xrxs19_clear clear def clear # recall xrxs19_clear # 初始化特殊效果 initialize_xrxs19_special_effect end #-------------------------------------------------------------------------- # ○ 初始化特殊效果 #-------------------------------------------------------------------------- def initialize_xrxs19_special_effect self.at_damage = 0#(1.03) self.hp_damage = 0 self.sp_damage = 0 self.hp_drain = 0 self.sp_drain = 0 self.hp_rate = false self.sp_rate = false self.critical_hit = 0 self.ignore_evade = false self.add_variance = 0 self.fix_damage = 0 self.special_damage_kind = 0 self.p_state = 0 self.m_state = 0 self.hp_correct = 0#(1.03) self.sp_correct = 0#(1.03) end #-------------------------------------------------------------------------- # ○ 特殊效果设置 #-------------------------------------------------------------------------- def set_xrxs19_special_effect(set) # AT伤害值(数值)(1.03) self.at_damage = XRXS.element_amount(set, XRXS19::AT_DAMAGE) # HP/SP伤害率(数值%) self.hp_damage = XRXS.element_percent(set, XRXS19::HP_DAMAGE) self.sp_damage = XRXS.element_percent(set, XRXS19::SP_DAMAGE) # HP/SP吸收率(数值%) self.hp_drain = XRXS.element_percent(set, XRXS19::HP_DRAIN) self.sp_drain = XRXS.element_percent(set, XRXS19::SP_DRAIN) # 现HP/SP威力 (true/false) self.hp_rate = XRXS.element_include?(set, XRXS19::HP_RATE) self.sp_rate = XRXS.element_include?(set, XRXS19::SP_RATE) # 会心一击率(数值%) returnar = XRXS.element_check(set, XRXS19::CRITICAL_HIT) percent = returnar[0] ? (returnar[2] == 0 ? 100 : returnar[2]) : 0 self.critical_hit = percent # 忽视躲闪 (true/false) self.ignore_evade = XRXS.element_include?(set, XRXS19::IGNORE_EVADE) # 追加分散度(数值) self.add_variance = XRXS.element_amount(set, XRXS19::ADD_VARIANCE) # 固定伤害值(数值) self.fix_damage = XRXS.element_amount(set, XRXS19::FIXDAMAGE) # 追加伤害类 self.special_damage_kind = XRXS.element_include?(set, XRXS19::FIXDAMAGE_NOWHPTA) ? 1 : XRXS.element_include?(set, XRXS19::FIXDAMAGE_MAXHPTA) ? 2 : XRXS.element_include?(set, XRXS19::FIXDAMAGE_DIFHPTA) ? 3 : XRXS.element_include?(set, XRXS19::FIXDAMAGE_NOWHPUS) ? 4 : XRXS.element_include?(set, XRXS19::FIXDAMAGE_MAXHPUS) ? 5 : XRXS.element_include?(set, XRXS19::FIXDAMAGE_DIFHPUS) ? 6 : XRXS.element_include?(set, XRXS19::FIXDAMAGE_NOWSPTA) ? 7 : XRXS.element_include?(set, XRXS19::FIXDAMAGE_MAXSPTA) ? 8 : XRXS.element_include?(set, XRXS19::FIXDAMAGE_DIFSPTA) ? 9 : XRXS.element_include?(set, XRXS19::FIXDAMAGE_NOWSPUS) ? 10 : XRXS.element_include?(set, XRXS19::FIXDAMAGE_MAXSPUS) ? 11 : XRXS.element_include?(set, XRXS19::FIXDAMAGE_DIFSPUS) ? 12 : 0 # 行动时附加/解除自身状态(ID) self.p_state = XRXS.element_amount(set, XRXS19::P_STATE) self.m_state = XRXS.element_amount(set, XRXS19::M_STATE) # 收招时修正使用者HP/SP(数值)(1.03) self.hp_correct = XRXS.element_amount(set, XRXS19::HP_CORRECT) self.sp_correct = XRXS.element_amount(set, XRXS19::SP_CORRECT) end #-------------------------------------------------------------------------- # ○ 特殊效果clear #-------------------------------------------------------------------------- def clear_xrxs19_special_effect self.at_damage = nil#(1.03) self.hp_damage = nil self.sp_damage = nil self.hp_drain = nil self.sp_drain = nil self.hp_rate = false self.sp_rate = false self.critical_hit = nil self.ignore_evade = false self.add_variance = nil self.fix_damage = nil self.special_damage_kind = nil self.scope_force = 0 self.self_exclusion = false self.self_inclusion = false self.p_state = nil self.m_state = nil self.hp_correct = 0#(1.03) self.sp_correct = 0#(1.03) end #-------------------------------------------------------------------------- # ○ 无效化特殊效果 #-------------------------------------------------------------------------- def nillize_xrxs19_special_effect self.scope_force = nil self.self_inclusion = nil self.self_exclusion = nil end end #============================================================================== # □□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□□ #============================================================================== # ■ Game_Battler #============================================================================== class Game_Battler #-------------------------------------------------------------------------- # ○ 公开实例变量 #-------------------------------------------------------------------------- attr_accessor :maxat # 最大AT#(1.03) attr_writer :ignore_evade #(True为忽视对方躲闪判定) attr_writer :hp_rate #(True为基础伤害根据HP/MAXHP比例修正) attr_writer :sp_rate #(True为基础伤害根据SP/MAXSP比例修正) #-------------------------------------------------------------------------- # ○特殊范围效果设定 #-------------------------------------------------------------------------- def set_xrxs19_special_scope(set) # 范围强制值 self.current_action.scope_force = XRXS.element_include?(set, XRXS19::AREA_EXTEND) ? 2 : XRXS.element_include?(set, XRXS19::AREA_ACTOR) ? 3 : XRXS.element_include?(set, XRXS19::AREA_ACTOR_ALL) ? 4 : XRXS.element_include?(set, XRXS19::AREA_SELF) ? 7 : XRXS.element_include?(set, XRXS19::AREA_WHOLE) ? 8 : XRXS.element_include?(set, XRXS19::AREA_ENEMY_RAND) ? 9 : XRXS.element_include?(set, XRXS19::AREA_ACTOR_RAND) ? 10 : XRXS.element_include?(set, XRXS19::AREA_ALL_RAND) ? 11 : 0 # 诸刃 self.current_action.self_inclusion = XRXS.element_include?(set, XRXS19::SELF_INCLUSION) # 自身以外 self.current_action.self_exclusion = XRXS.element_include?(set, XRXS19::SELF_EXCLUSION) end #-------------------------------------------------------------------------- # ● 新定义状态变化 (+) 发动状态适用 #-------------------------------------------------------------------------- def pp_state(battler, i) # 清除有效标志 effective = false # 无法防御本状态的情况下 unless self.state_guard?(i) # 这个状态如果不是 full 的话就设置有效标志 effective |= self.state_full?(i) == false # 状态为 [不能抵抗] 的情况下 if $data_states[i].nonresistance # 设置状态变化标志 @state_changed = true # 附加状态 self.state_p[battler].push(i) # 这个状态不是 full 的情况下 elsif self.state_full?(i) == false # 将状态的有效度变换为概率、与随机数比较 if rand(100) < [0,100,80,60,40,20,0][self.state_ranks[i]] # 设置状态变化标志 @state_changed = true # ステートを付加 self.add_state(i) end end end # 过程结束 return effective end #-------------------------------------------------------------------------- # ● 可以使用特技的判定 # skill_id : 特技 ID #-------------------------------------------------------------------------- alias xrxs19_skill_can_use? skill_can_use? def skill_can_use?(skill_id) # 获取特技 @skill = $data_skills[skill_id] # 范围计算 set_xrxs19_special_scope(self.skill_element_set(@skill)) $data_skills[skill_id].scope = self.current_action.scope_force if self.current_action.scope_force > 0 # 范围是「自身以外」的情况 if self.current_action.self_exclusion # 获取战斗者 battlers = (self.is_a?(Game_Actor) ? $game_party.actors : $game_troop.enemies) # 范围的分歧 case $data_skills[skill_id].scope when 3,4,10 # 获取生存的战斗者数量 n = 0 battlers.each {|battler| n += 1 unless battler.dead?} when 5,6 # 获取战斗者总数 n = battlers.size else n = 2 end # 对象不存在的情况 return false if n <= 1 end # recall return xrxs19_skill_can_use?(skill_id) end #-------------------------------------------------------------------------- # ● 判断状态 [无法回避攻击] #-------------------------------------------------------------------------- alias xrxs19_cant_evade? cant_evade? def cant_evade? return true if @ignore_evade return xrxs19_cant_evade? end #-------------------------------------------------------------------------- # ○ 特殊效果设置 #-------------------------------------------------------------------------- def set_xrxs19_special_effect(set) self.current_action.set_xrxs19_special_effect(set) end #-------------------------------------------------------------------------- # ● 应用通常攻击效果 # attacker : 攻击者 (battler) #-------------------------------------------------------------------------- alias xrxs19_attack_effect attack_effect def attack_effect(attacker) # 特殊效果:忽视躲闪 if attacker.current_action.ignore_evade self.ignore_evade = true end return xrxs19_attack_effect(attacker) end #-------------------------------------------------------------------------- # ● 应用特技效果 # user : 特技的使用者 (battler) # skill : 特技 #-------------------------------------------------------------------------- alias xrxs19_skill_effect skill_effect def skill_effect(user, skill) # 特殊效果:忽视躲闪 if user.current_action.ignore_evade self.ignore_evade = true end return xrxs19_skill_effect(user, skill) end #------------------------------------------------------------------------------ # ○ 伤害计算(属于对基本伤害的再处理) #------------------------------------------------------------------------------ # ● 基础伤害计算请在“应用通常攻击效果” 和“应用特技效果”部分定义 #------------------------------------------------------------------------------ alias xrxs19co_x1_damage_effect damage_effect def damage_effect(battler, item, skill) # recall if item == 2 or self.damage[battler].class == String return xrxs19co_x1_damage_effect(battler, item) end # 初始化 battler.current_action.at_damage = 0 if battler.current_action.at_damage.nil?#(1.03) battler.current_action.hp_damage = 0 if battler.current_action.hp_damage.nil? battler.current_action.sp_damage = 0 if battler.current_action.sp_damage.nil? battler.current_action.hp_drain = 0 if battler.current_action.hp_drain.nil? battler.current_action.sp_drain = 0 if battler.current_action.sp_drain.nil? battler.current_action.critical_hit = 0 if battler.current_action.critical_hit.nil? battler.current_action.add_variance = 0 if battler.current_action.add_variance.nil? battler.current_action.fix_damage = 0 if battler.current_action.fix_damage.nil? battler.current_action.special_damage_kind = 0 if battler.current_action.special_damage_kind.nil? battler.current_action.p_state = 0 if battler.current_action.p_state.nil? battler.current_action.m_state = 0 if battler.current_action.m_state.nil? battler.current_action.hp_correct = 0 if battler.current_action.hp_correct.nil?#(1.03) battler.current_action.sp_correct = 0 if battler.current_action.sp_correct.nil?#(1.03) # 解除忽视躲闪 self.ignore_evade = false # 基本伤害 self.damage[battler] = self.damage[battler].to_i # 特殊效果:追加分散度 if battler.current_action.add_variance > 0 and self.damage[battler].abs > 0 amp = [self.damage[battler].abs * battler.current_action.add_variance / 100, 1].max self.damage[battler] += rand(amp+1) + rand(amp+1) - amp end # 特殊效果:现HP威力 if battler.current_action.hp_rate self.damage[battler] = self.damage[battler] * battler.hp / battler.maxhp end # 特殊效果:现SP威力 if battler.current_action.sp_rate self.damage[battler] = self.damage[battler] * battler.sp / battler.maxsp end # 特殊效果:会心一击 if battler.current_action.critical_hit > 0 if self.critical[battler] self.critical[battler] = false self.damage[battler] /= 2 end # critical重新判定 if rand(100) < battler.current_action.critical_hit self.critical[battler] = true self.damage[battler] *= 2 end end # 特殊效果:固定伤害 if battler.current_action.fix_damage != 0 self.damage[battler] = battler.current_action.fix_damage.to_i self.critical[battler] = false end #------------------------------------------------------------------------------ # 特殊效果:追加伤害效果类计算 #------------------------------------------------------------------------------ case battler.current_action.special_damage_kind when 1# 「目标方当前HP比例」 if skill != nil self.damage[battler] += self.hp * skill.power / 100 else self.damage[battler] += self.hp * battler.atk / 10000 end self.damage[battler] *=self.element_rate(($data_system.elements).index(XRXS19::FIXDAMAGE_NOWHPTA))/100 when 2# 「目标方最大HP比例」 if skill != nil self.damage[battler] += self.maxhp * skill.power / 100 else self.damage[battler] += self.maxhp * battler.atk / 10000 end self.damage[battler] *=self.element_rate(($data_system.elements).index(XRXS19::FIXDAMAGE_MAXHPTA))/100 when 3# 「目标方HP差值比例」 if skill != nil self.damage[battler] += (self.maxhp - self.hp) * skill.power / 100 else self.damage[battler] += (self.maxhp - self.hp) * battler.atk / 10000 end self.damage[battler] *=self.element_rate(($data_system.elements).index(XRXS19::FIXDAMAGE_DIFHPTA))/100 when 4# 「使用者当前HP比例」 if skill != nil self.damage[battler] += battler.hp * skill.power / 100 else self.damage[battler] += battler.hp * battler.atk / 10000 end self.damage[battler] *=self.element_rate(($data_system.elements).index(XRXS19::FIXDAMAGE_NOWHPUS))/100 when 5# 「使用者最大HP比例」 if skill != nil self.damage[battler] += battler.maxhp * skill.power / 100 else self.damage[battler] += battler.maxhp * battler.atk / 10000 end self.damage[battler] *=self.element_rate(($data_system.elements).index(XRXS19::FIXDAMAGE_MAXHPUS))/100 when 6# 「使用者HP差值比例」 if skill != nil self.damage[battler] += (battler.maxhp - battler.hp) * skill.power / 100 else self.damage[battler] += (battler.maxhp - battler.hp) * battler.atk / 10000 end self.damage[battler] *=self.element_rate(($data_system.elements).index(XRXS19::FIXDAMAGE_DIFHPUS))/100 when 7# 「目标方当前SP比例」 if skill != nil self.damage[battler] += self.sp * skill.power / 100 else self.damage[battler] += self.sp * battler.atk / 10000 end self.damage[battler] *=self.element_rate(($data_system.elements).index(XRXS19::FIXDAMAGE_NOWSPTA))/100 when 8# 「目标方最大SP比例」 if skill != nil self.damage[battler] += self.maxsp * skill.power / 100 else self.damage[battler] += self.maxsp * battler.atk / 10000 end self.damage[battler] *=self.element_rate(($data_system.elements).index(XRXS19::FIXDAMAGE_MAXSPTA))/100 when 9# 「目标方SP差值比例」 if skill != nil self.damage[battler] += (self.maxsp - self.sp) * skill.power / 100 else self.damage[battler] += (self.maxsp - self.sp) * battler.atk / 10000 end self.damage[battler] *=self.element_rate(($data_system.elements).index(XRXS19::FIXDAMAGE_DIFSPTA))/100 when 10# 「使用者当前SP比例」 if skill != nil self.damage[battler] += battler.sp * skill.power / 100 else self.damage[battler] += battler.sp * battler.atk / 10000 end self.damage[battler] *=self.element_rate(($data_system.elements).index(XRXS19::FIXDAMAGE_NOWSPUS))/100 when 11# 「使用者最大SP比例」 if skill != nil self.damage[battler] += battler.maxsp * skill.power / 100 else self.damage[battler] += battler.maxsp * battler.atk / 10000 end self.damage[battler] *=self.element_rate(($data_system.elements).index(XRXS19::FIXDAMAGE_MAXSPUS))/100 when 12# 「使用者SP差值比例」 if skill != nil self.damage[battler] += (battler.maxsp - battler.sp) * skill.power / 100 else self.damage[battler] += (battler.maxsp - battler.sp) * battler.atk / 10000 end self.damage[battler] *=self.element_rate(($data_system.elements).index(XRXS19::FIXDAMAGE_DIFSPUS))/100 end #------------------------------------------------------------------------------ # 特殊效果:AT伤害值(1.03) if battler.current_action.at_damage != 0 self.at -= battler.current_action.at_damage * self.maxat / 100 self.at = 0 if self.at < 0 self.atp = 100 * self.at / self.maxat end # 特殊效果:HP伤害率 if battler.current_action.hp_damage != 0 and battler.current_action.sp_damage == 0 self.damage[battler] = self.damage[battler] * battler.current_action.hp_damage / 100 end # 特殊效果:SP伤害率 if battler.current_action.sp_damage != 0 self.damage_sp[battler] = self.damage[battler] * battler.current_action.sp_damage / 100 self.damage_sp[battler] = self.sp if self.damage_sp[battler] > self.sp self.damage_sp[battler] = "" if self.sp == 0 self.sp -= self.damage_sp[battler] if self.damage_sp[battler] != "" if battler.current_action.hp_damage != 0 # 特殊效果:HP伤害率 self.damage[battler] = self.damage[battler] * battler.current_action.hp_damage / 100 else self.damage[battler] = "" end end #------------------------------------------------------------------------------ # 特殊效果:收招修正(1.03) battler.hp = battler.current_action.hp_correct.to_i if battler.current_action.hp_correct != 0 battler.sp = battler.current_action.sp_correct.to_i if battler.current_action.sp_correct != 0 #------------------------------------------------------------------------------ # 特殊效果:HP吸收 if battler.current_action.hp_drain != 0 battler.damage[battler] = 0 if battler.damage[battler] == nil drain_point = -1 * self.damage[battler].to_i * battler.current_action.hp_drain / 100 battler.damage[battler] += drain_point battler.hp -= drain_point if battler.damage[battler] == 0 battler.damage[battler] = nil end end # 特殊效果:SP吸收 if battler.current_action.sp_drain != 0 battler.damage_sp[battler] = 0 if battler.damage_sp[battler] == nil drain_point = -1 * self.damage_sp[battler].to_i * battler.current_action.sp_drain / 100 battler.damage_sp[battler] += drain_point battler.sp -= drain_point battler.damage_sp[battler] = drain_point if battler.damage_sp[battler] == 0 battler.damage_sp[battler] = nil end end # recall xrxs19co_x1_damage_effect(battler, item) end end #============================================================================== # ■ Scene_Battle #============================================================================== class Scene_Battle #------------------------------------------------------------------------------ # ○ ATB_SETUP (ATB = AT Bar,意思不要和RTAB搞错)(1.03) #------------------------------------------------------------------------------ alias xrxs19_atb_setup atb_setup def atb_setup # recall xrxs19_atb_setup # 保存最大AT for battler in $game_party.actors + $game_troop.enemies battler.maxat = @max end end #-------------------------------------------------------------------------- # ● 主处理 #-------------------------------------------------------------------------- alias xrxs19_main main def main # 清空角色的伤害值 for actor in $game_party.actors actor.damage = nil end # recall xrxs19_main # 清空角色的特殊效果设置 for actor in $game_party.actors actor.current_action.clear_xrxs19_special_effect actor.current_action.nillize_xrxs19_special_effect end end #-------------------------------------------------------------------------- # ● 刷新画面 (主回合步骤 1 : 准备行动) #-------------------------------------------------------------------------- alias xrxs19co_x1_update_phase4_step1 update_phase4_step1 def update_phase4_step1(battler) # 清空行动者的伤害值 battler.damage.clear # recall xrxs19co_x1_update_phase4_step1(battler) end #-------------------------------------------------------------------------- # ● 刷新画面 (主回合步骤 2 : 开始行动) #-------------------------------------------------------------------------- alias xrxs19_update_phase4_step2 update_phase4_step2 def update_phase4_step2(battler) # 清空行动者的伤害值 battler.damage.clear # recall xrxs19_update_phase4_step2(battler) end #-------------------------------------------------------------------------- # ● フレーム更新 (アクターコマンドフェーズ : エネミー選択) #(武器范围定义必须) #-------------------------------------------------------------------------- def update_phase3_enemy_select # コマンド選択中に行動不能になった場合 unless @active_actor.inputable? # カメラを元に戻す if @camera == "select" @spriteset.screen_target(0, 0, 1) end @active_actor.current_action.clear command_delete # 次のアクターのコマンド入力へ phase3_next_actor return end @active_actor.set_xrxs19_special_scope(@active_actor.equip_element_set) if @skill_window == nil @active_actor.set_xrxs19_special_scope(@active_actor.skill_element_set(@skill)) if @skill_window != nil case @active_actor.current_action.scope_force when 2,4,6,7,8,9,10,11 # アクションを設定 @active_actor.current_action.kind = 0 @active_actor.current_action.basic = 0 # スキルの選択を終了 end_enemy_select # 次のアクターのコマンド入力へ phase3_next_actor when 3 # アクターアローを更新 @actor_arrow.update # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # アクターの選択を終了 end_enemy_select return end # C ボタンが押された場合 if Input.trigger?(Input::C) # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # アクションを設定 @active_actor.current_action.kind = 0 @active_actor.current_action.basic = 0 @active_actor.current_action.target_index = @actor_arrow.index # アクターの選択を終了 end_enemy_select # 次のアクターのコマンド入力へ phase3_next_actor end else # エネミーアローを更新 @enemy_arrow.update # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # カメラを元に戻す if @camera == "select" # カメラの設定 @camera = "command" plus = ($game_party.actors.size - 1) / 2.0 - @actor_index y = [(plus.abs - 1.5) * 10 , 0].min @spriteset.screen_target(plus * 50, y, 1.0 + y * 0.002) end # エネミーの選択を終了 end_enemy_select return end # C ボタンが押された場合 if Input.trigger?(Input::C) # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # アクションを設定 @active_actor.current_action.kind = 0 @active_actor.current_action.basic = 0 @active_actor.current_action.target_index = @enemy_arrow.index # スキルウィンドウ表示中の場合 if @skill_window != nil # アクションを再設定 @active_actor.current_action.kind = 1 # スキルの選択を終了 end_skill_select end # アイテムウィンドウ表示中の場合 if @item_window != nil # アクションを再設定 @active_actor.current_action.kind = 2 # アイテムの選択を終了 end_item_select end # エネミーの選択を終了 end_enemy_select # 次のアクターのコマンド入力へ phase3_next_actor end end end #-------------------------------------------------------------------------- # ● 开始选择敌人#(武器范围定义必须)(1.03修正显示BUG) #-------------------------------------------------------------------------- def start_enemy_select @active_actor.set_xrxs19_special_scope(@active_actor.equip_element_set) if @skill_window == nil @active_actor.set_xrxs19_special_scope(@active_actor.skill_element_set(@skill)) if @skill_window != nil if @active_actor.current_action.scope_force == 3 # 生成敌人箭头 @actor_arrow = Arrow_Actor.new(@spriteset.viewport2) # 关联帮助窗口 @actor_arrow.help_window = @help_window else # 生成敌人箭头 @enemy_arrow = Arrow_Enemy.new(@spriteset.viewport1) # 关联帮助窗口 @enemy_arrow.help_window = @help_window end # 无效化角色指令窗口 @actor_command_window.active = false @actor_command_window.visible = false end #-------------------------------------------------------------------------- # ● 结束选择敌人#武器范围定义必须) #-------------------------------------------------------------------------- def end_enemy_select # 释放敌人箭头 @enemy_arrow.dispose if @enemy_arrow != nil @actor_arrow.dispose if @actor_arrow != nil @enemy_arrow = nil @actor_arrow = nil # 指令为 [战斗] 的情况下 if @actor_command_window.index == 0 # 有效化角色指令窗口 @actor_command_window.active = true @actor_command_window.visible = true # 隐藏帮助窗口 @help_window.visible = false end end #-------------------------------------------------------------------------- # ● 基本アクション 準備#(武器范围定义必须) #-------------------------------------------------------------------------- def make_basic_action_preparation(battler) # 攻撃の場合 if battler.current_action.basic == 0 # アニメーション ID を設定 battler.anime1 = battler.animation1_id battler.anime2 = battler.animation2_id # 行動側バトラーがエネミーの場合 if battler.is_a?(Game_Enemy) if battler.restriction == 3 target = $game_troop.random_target_enemy elsif battler.restriction == 2 target = $game_party.random_target_actor else index = battler.current_action.target_index target = $game_party.smooth_target_actor(index) end end # 行動側バトラーがアクターの場合 battler.set_xrxs19_special_scope(battler.equip_element_set) if battler.is_a?(Game_Actor) if battler.restriction == 3 target = $game_party.random_target_actor elsif battler.restriction == 2 target = $game_troop.random_target_enemy elsif battler.current_action.scope_force == 3 # 己方单体 index = battler.current_action.target_index target = $game_party.smooth_target_actor(index) else index = battler.current_action.target_index target = $game_troop.smooth_target_enemy(index) end end # 対象側バトラーの配列を設定 case battler.current_action.scope_force when 2 # 敌方全体 for enemy in $game_troop.enemies if enemy.exist? battler.target.push(enemy) end end battler.target.push(battler) if battler.current_action.self_inclusion when 4 # 己方全体 for actor in $game_party.actors if actor.exist? battler.target.push(actor) end end battler.target -=[battler] if battler.current_action.self_exclusion when 7 # 使用者 battler.target.push(battler) when 8 # 全域化 for enemy in $game_troop.enemies if enemy.exist? battler.target.push(enemy) end end for actor in $game_party.actors if actor.exist? battler.target.push(actor) end end battler.target -=[battler] if battler.current_action.self_exclusion when 9 # 敌方随机 for enemy in $game_troop.enemies if enemy.exist? battler.target = [$game_troop.random_target_enemy] end end battler.target.push(battler) if battler.current_action.self_inclusion when 10 # 己方随机 for actor in $game_party.actors if actor.exist? battler.target.push(actor) end end battler.target -=[battler] if battler.current_action.self_exclusion battler.target = [battler.target[rand(battler.target.size)]] when 11 #对象随机 battler.target = [] for enemy in $game_troop.enemies if enemy.exist? battler.target.push(enemy) end end for actor in $game_party.actors if actor.exist? battler.target.push(actor) end end battler.target -=[battler] if battler.current_action.self_exclusion battler.target = [battler.target[rand(battler.target.size)]] else battler.target = [target] battler.target.push(battler) if battler.current_action.self_inclusion and battler.current_action.scope_force != 3 and battler.restriction != 2 and battler.restriction != 3 end return true end # 防御の場合 if battler.current_action.basic == 1 # ステップ 3 に移行 battler.phase = 3 return false end #===============0.15b(RTAB官方更新)=========================================== # 逃げるの場合 if battler.is_a?(Game_Enemy) and battler.current_action.basic == 2 # ステップ 3 に移行 battler.phase = 3 return false end #============================================================================= # 何もしないの場合 if battler.current_action.basic == 3 # ステップ 6 に移行 battler.phase = 6 return false end end #-------------------------------------------------------------------------- # ● 生成基本行动结果 #-------------------------------------------------------------------------- alias xrxs19_make_basic_action_result make_basic_action_result def make_basic_action_result(battler) # 攻击的情况 if battler.current_action.basic == 0 # 获取行动者武器附加的战斗特效 if battler.is_a?(Game_Actor) battler.set_xrxs19_special_effect(battler.equip_element_set) # 行动时附加自身状态 if battler.current_action.p_state > 0 battler.pp_state(battler,battler.current_action.p_state) end # 行动时解除自身状态 if battler.current_action.m_state > 0 battler.remove_state(battler.current_action.m_state) end end end # recall xrxs19_make_basic_action_result(battler) end #-------------------------------------------------------------------------- # ● スキルまたはアイテムの対象側バトラー設定 # scope : スキルまたはアイテムの効果範囲 # (武器范围定义必须)特技/道具的范围定义 #-------------------------------------------------------------------------- def set_target_battlers(scope, battler) #行动方战斗者是敌方的情况 if battler.is_a?(Game_Enemy) # 效果范围的分歧 case scope when 1 # 敌单体 battler.target.push(battler) if battler.current_action.self_inclusion index =battler.current_action.target_index battler.target.push($game_party.smooth_target_actor(index)) when 2 # 敌全体 battler.target.push(battler) if battler.current_action.self_inclusion for actor in $game_party.actors if actor.exist? battler.target.push(actor) end end when 3 # 己方单体 index = battler.current_action.target_index battler.target.push($game_troop.smooth_target_enemy(index)) when 4 # 己方全体 for enemy in $game_troop.enemies if enemy.exist? battler.target.push(enemy) end end battler.target -=[battler] if battler.current_action.self_exclusion when 5 # 己方单体 (HP 0) index = battler.current_action.target_index enemy = $game_troop.enemies[index] if enemy != nil# and enemy.hp0?# 复活类特技/道具对生存者有效 battler.target.push(enemy) end when 6 # 己方全体 (HP 0) for enemy in $game_troop.enemies if enemy != nil# and enemy.hp0?# 复活类特技/道具对生存者有效 battler.target.push(enemy) end end battler.target -=[battler] if battler.current_action.self_exclusion when 7 # 使用者 battler.target.push(battler) when 8 # 全域化 for enemy in $game_troop.enemies if enemy.exist? battler.target.push(enemy) end end for actor in $game_party.actors if actor.exist? battler.target.push(actor) end end battler.target -=[battler] if battler.current_action.self_exclusion when 9 # 敌方随机 battler.target.push(battler) if battler.current_action.self_inclusion for actor in $game_party.actors if actor.exist? battler.target = [$game_party.random_target_actor] end end when 10 # 己方随机 for enemy in $game_troop.enemies if enemy.exist? battler.target.push(enemy) end end battler.target -=[battler] if battler.current_action.self_exclusion battler.target = [battler.target[rand(battler.target.size)]] when 11 #对象随机 battler.target = [] for enemy in $game_troop.enemies if enemy.exist? battler.target.push(enemy) end end for actor in $game_party.actors if actor.exist? battler.target.push(actor) end end battler.target -=[battler] if battler.current_action.self_exclusion battler.target = [battler.target[rand(battler.target.size)]] end end #行动方战斗者是己方的情况 if battler.is_a?(Game_Actor) # 效果范围的分歧 case scope when 1 # 敌单体 index = battler.current_action.target_index battler.target.push($game_troop.smooth_target_enemy(index)) battler.target.push(battler) if battler.current_action.self_inclusion when 2 # 敌全体 for enemy in $game_troop.enemies if enemy.exist? battler.target.push(enemy) end end battler.target.push(battler) if battler.current_action.self_inclusion when 3 # 己方单体 index = battler.current_action.target_index battler.target.push($game_party.smooth_target_actor(index)) when 4 # 己方全体 for actor in $game_party.actors if actor.exist? battler.target.push(actor) end end battler.target -=[battler] if battler.current_action.self_exclusion when 5 # 己方单体 (HP 0) index = battler.current_action.target_index actor = $game_party.actors[index] if actor != nil# and actor.hp0?# 复活类特技/道具对生存者有效 battler.target.push(actor) end when 6 # 己方全体 (HP 0) for actor in $game_party.actors if actor != nil# and actor.hp0?# 复活类特技/道具对生存者有效 battler.target.push(actor) end end battler.target -=[battler] if battler.current_action.self_exclusion when 7 # 使用者 battler.target.push(battler) when 8 # 全域化 for enemy in $game_troop.enemies if enemy.exist? battler.target.push(enemy) end end for actor in $game_party.actors if actor.exist? battler.target.push(actor) end end battler.target -=[battler] if battler.current_action.self_exclusion when 9 # 敌方随机 for enemy in $game_troop.enemies if enemy.exist? battler.target = [$game_troop.random_target_enemy] end end battler.target.push(battler) if battler.current_action.self_inclusion when 10 # 己方随机 for actor in $game_party.actors if actor.exist? battler.target.push(actor) end end battler.target -=[battler] if battler.current_action.self_exclusion battler.target = [battler.target[rand(battler.target.size)]] when 11 #对象随机 battler.target = [] for enemy in $game_troop.enemies if enemy.exist? battler.target.push(enemy) end end for actor in $game_party.actors if actor.exist? battler.target.push(actor) end end battler.target -=[battler] if battler.current_action.self_exclusion battler.target = [battler.target[rand(battler.target.size)]] end end end #-------------------------------------------------------------------------- # ● 生成特技行动结果 #-------------------------------------------------------------------------- alias xrxs19_make_skill_action_result make_skill_action_result def make_skill_action_result(battler, plus_id) # 获取特技 @skill = $data_skills[battler.current_action.skill_id + plus_id] # 获取行动者特技附加的战斗特效 battler.set_xrxs19_special_effect(battler.skill_element_set(@skill)) # 行动时附加自身状态 if battler.current_action.p_state > 0 battler.pp_state(battler,battler.current_action.p_state) end # 行动时解除自身状态 if battler.current_action.m_state > 0 battler.remove_state(battler.current_action.m_state) end # recall xrxs19_make_skill_action_result(battler, plus_id) end #-------------------------------------------------------------------------- # ● 刷新画面 (主回合步骤 5 : 显示伤害) #-------------------------------------------------------------------------- alias xrxs19_update_phase4_step5 update_phase4_step5 def update_phase4_step5(battler) # recall xrxs19_update_phase4_step5(battler) # 行动者伤害表示(HP/SP吸收的表示用) if battler.damage[battler] != nil or battler.damage_sp[battler] != nil battler.damage_pop[battler] = true # 行动者状态栏刷新 status_refresh(battler) end end end #============================================================================== # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息 #==============================================================================
# リアルタイム・アクティブバトル(RTAB) Ver 1.16 # 配布元・サポートURL # [url]http://members.jcom.home.ne.jp/cogwheel/[/url] class Scene_Battle #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :status_window # ステータスウィンドウ attr_reader :spriteset # バトルスプライト attr_reader :scroll_time # スクリーン移動基本時間 attr_reader :zoom_rate # 敵バトラー基本位置 attr_reader :drive # カメラ駆動 attr_accessor :force # アクション強制度 attr_accessor :camera # 現在のカメラ所持者 #-------------------------------------------------------------------------- # ● ATB基礎セットアップ #-------------------------------------------------------------------------- def atb_setup # ATB初期化 # speed : バトルスピード決定。値が小さいほど早い # @active : アクティブ度設定 # 3 : 常にアクティブ状態 # 2 : スキル・アイテム選択中のみアクティブゲージが止まる # 1 : 2の状態に加え、ターゲット選択時もウェイトが掛かる # 0 : 1の状態に加え、コマンド入力時にもウェイトが掛かる # @action : 他人が行動中に自分も行動を起こすことを許すか # 3 : 自分が行動不能でない限り限り許す # 2 : 自分がダメージを受けていない限り許す # 1 : 2の状態に加え、ターゲットが行動していない限り許す # 0 : 行動を許さない。順番に行動し終えるまで待つ # @anime_wait : trueにするとバトルアニメ・ダメージ表示中はウェイトが掛かる # @damage_wait : ダメージ表示待ち時間(単位はフレーム) # @after_wait : 味方・敵全滅時、次の処理に移るまでの待ち時間 # [a, b] a は味方全滅時、b は敵全滅時(単位はフレーム) # @enemy_speed : 敵の思考速度。1なら即時行動。 # 1フレーム毎に、1/@enemy_speedの確率で行動を起こす # @force : 強制アクションでスキル使用時の強制具合 # 2:スキルは全て詠唱せず、必ず即時実行 # 1:単独スキルは詠唱し、連携スキルのみ即時実行 # 0:全スキル詠唱を行うだけ # ($scene.force = x とすることにより、通常イベントのスクリプトから変更可能) # @drive : カメラ駆動ON/OFF。trueで駆動ON、falseで駆動OFF # @scroll_time : スクリーン移動に要する基本時間 # @zoom_rate = [i, j] : エネミーのズーム率 # i が画面最上部に配置した時の拡大率 # j が画面最下部に配置した時の拡大率 # 1 倍としたいときも、1.0 と必ず小数で設定すること speed = 150 @active = 1 @action = 0 @anime_wait = false @damage_wait = 10 @after_wait = [80, 0] @enemy_speed = 40 @force = 2 @drive = true @scroll_time = 15 @zoom_rate = [0.2, 1.0] @help_time = 40 @escape == false @camera = nil @max = 0 @turn_cnt = 0 @help_wait = 0 @action_battlers = [] @synthe = [] @spell_p = {} @spell_e = {} @command_a = false @command = [] #------------------------------------------------------------------------------ #RTAB观光游第一站,去除“战斗/逃跑”选项部分 # @party = false #------------------------------------------------------------------------------ for battler in $game_party.actors + $game_troop.enemies spell_reset(battler) battler.at = battler.agi * rand(speed / 2) battler.damage_pop = {} battler.damage = {} battler.damage_sp = {} battler.critical = {} battler.recover_hp = {} battler.recover_sp = {} battler.state_p = {} battler.state_m = {} battler.animation = [] if battler.is_a?(Game_Actor) @max += battler.agi end end @max *= speed @max /= $game_party.actors.size for battler in $game_party.actors + $game_troop.enemies battler.atp = 100 * battler.at / @max end end #-------------------------------------------------------------------------- # ● ATゲージMax時SE #-------------------------------------------------------------------------- def fullat_se Audio.se_play("Audio/SE/033-switch02", 80, 100) end #-------------------------------------------------------------------------- # ● レベルアップSE #-------------------------------------------------------------------------- def levelup_se Audio.se_play("Audio/SE/056-Right02", 80, 100) end #-------------------------------------------------------------------------- # ● スキル習得SE #-------------------------------------------------------------------------- def skill_se Audio.se_play("Audio/SE/056-Right02", 80, 150) end end class Window_Base < Window #-------------------------------------------------------------------------- # ● ATG の描画 # actor : アクター # x : 描画先 X 座標 # y : 描画先 Y 座標 # width : 描画先の幅 #-------------------------------------------------------------------------- def draw_actor_atg(actor, x, y, width = 144) if @at_gauge == nil # plus_x:X座標の位置補正 rate_x:X座標の位置補正(%) plus_y:Y座標の位置補正 # plus_width:幅の補正 rate_width:幅の補正(%) height:縦幅 # align1:描画タイプ1 0:左詰め 1:中央揃え 2:右詰め # align2:描画タイプ2 0:上詰め 1:中央揃え 2:下詰め # align3:ゲージタイプ 0:左詰め 1:右詰め @plus_x = 0 @rate_x = 0 @plus_y = 16 @plus_width = 0 @rate_width = 100 @width = @plus_width + width * @rate_width / 100 @height = 16 @align1 = 0 @align2 = 1 @align3 = 0 # グラデーション設定 grade1:空ゲージ grade2:実ゲージ # (0:横にグラデーション 1:縦にグラデーション 2:斜めにグラデーション) grade1 = 1 grade2 = 0 # 色設定。color1:最外枠,color2:中枠 # color3:空枠ダークカラー,color4:空枠ライトカラー color1 = Color.new(0, 0, 0) color2 = Color.new(255, 255, 192) color3 = Color.new(0, 0, 0, 192) color4 = Color.new(0, 0, 64, 192) # ゲージの色設定 # 通常時の色設定 color5 = Color.new(0, 64, 80) color6 = Color.new(0, 128, 160) # ゲージがMAXの時の色設定 color7 = Color.new(80, 0, 0) color8 = Color.new(240, 0, 0) # 連携スキル使用時の色設定 color9 = Color.new(80, 64, 32) color10 = Color.new(240, 192, 96) # スキル詠唱時の色設定 color11 = Color.new(80, 0, 64) color12 = Color.new(240, 0, 192) # ゲージの描画 gauge_rect_at(@width, @height, @align3, color1, color2, color3, color4, color5, color6, color7, color8, color9, color10, color11, color12, grade1, grade2) end # 変数atに描画するゲージの幅を代入 if actor.rtp == 0 at = (width + @plus_width) * actor.atp * @rate_width / 10000 else at = (width + @plus_width) * actor.rt * @rate_width / actor.rtp / 100 end if at > width at = width end # ゲージの左詰・中央構え等の補正 case @align1 when 1 x += (@rect_width - width) / 2 when 2 x += @rect_width - width end case @align2 when 1 y -= @height / 2 when 2 y -= @height end self.contents.blt(x + @plus_x + width * @rate_x / 100, y + @plus_y, @at_gauge, Rect.new(0, 0, @width, @height)) if @align3 == 0 rect_x = 0 else x += @width - at - 1 rect_x = @width - at - 1 end # ゲージの色設定 if at == width # MAX時のゲージ描画 self.contents.blt(x + @plus_x + @width * @rate_x / 100, y + @plus_y, @at_gauge, Rect.new(rect_x, @height * 2, at, @height)) else if actor.rtp == 0 # 通常時のゲージ描画 self.contents.blt(x + @plus_x + @width * @rate_x / 100, y + @plus_y, @at_gauge, Rect.new(rect_x, @height, at, @height)) else if actor.spell == true # 連携スキル使用時のゲージ描画 self.contents.blt(x + @plus_x + @width * @rate_x / 100, y + @plus_y, @at_gauge, Rect.new(rect_x, @height * 3, at, @height)) else # スキル詠唱時のゲージ描画 self.contents.blt(x + @plus_x + @width * @rate_x / 100, y + @plus_y, @at_gauge, Rect.new(rect_x, @height * 4, at, @height)) end end end end end #============================================================================== # ■ Scene_Battle (分割定義 1) #------------------------------------------------------------------------------ # バトル画面の処理を行うクラスです。 #============================================================================== class Scene_Battle #-------------------------------------------------------------------------- # ● メイン処理 #-------------------------------------------------------------------------- def main # 戦闘用の各種一時データを初期化 # Graphics.frame_rate = 60 $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) atb_setup # アクターコマンドウィンドウを作成 #============================================================================== #RTAB观光游第三站,战斗菜单增加逃跑选项 #============================================================================== s1 = $data_system.words.attack s2 = $data_system.words.skill s3 = $data_system.words.guard s4 = $data_system.words.item s5 = "逃跑" @actor_command_window = Window_Command.new(160, [s1, s2, s3, s4,s5]) # @actor_command_window.y = 160 @actor_command_window.y = 128 @actor_command_window.back_opacity = 160 @actor_command_window.active = false @actor_command_window.visible = false #============================================================================== # その他のウィンドウを作成 #------------------------------------------------------------------------------ #RTAB观光游第一站,去除“战斗/逃跑”选项部分 # @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 # スプライトセットを作成 @spriteset = Spriteset_Battle.new # ウェイトカウントを初期化 @wait_count = 0 # トランジション実行 if $data_system.battle_transition == "" Graphics.transition(20) else Graphics.transition(40, "Graphics/Transitions/" + $data_system.battle_transition) end # プレバトルフェーズ開始 start_phase1 # メインループ loop do # ゲーム画面を更新 Graphics.update # 入力情報を更新 Input.update # フレーム更新 update # 画面が切り替わったらループを中断 if $scene != self break end end # マップをリフレッシュ $game_map.refresh # トランジション準備 Graphics.freeze # ウィンドウを解放 @actor_command_window.dispose #------------------------------------------------------------------------------ #RTAB观光游第一站,去除“战斗/逃跑”选项部分 # @party_command_window.dispose #------------------------------------------------------------------------------ @help_window.dispose @status_window.dispose @message_window.dispose if @skill_window != nil @skill_window.dispose end if @item_window != nil @item_window.dispose end if @result_window != nil @result_window.dispose end # スプライトセットを解放 @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 judge # 全滅判定が真、またはパーティ人数が 0 人の場合 if $game_party.all_dead? or $game_party.actors.size == 0 # 敗北可能の場合 if $game_temp.battle_can_lose # バトル開始前の BGM に戻す $game_system.bgm_play($game_temp.map_bgm) # バトル終了 battle_end(2) # true を返す return true end # ゲームオーバーフラグをセット $game_temp.gameover = true # true を返す return true end # エネミーが 1 体でも存在すれば false を返す for enemy in $game_troop.enemies if enemy.exist? return false end end # アフターバトルフェーズ開始 (勝利) start_phase5 # true を返す return true end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update # バトルイベント実行中の場合 if $game_system.battle_interpreter.running? if @command.size > 0 @command_a = false @command = [] command_delete end @status_window.at_refresh # インタプリタを更新 $game_system.battle_interpreter.update # アクションを強制されているバトラーが存在しない場合 if $game_temp.forcing_battler == nil # バトルイベントの実行が終わった場合 unless $game_system.battle_interpreter.running? # バトルイベントのセットアップを再実行 @status_window.refresh setup_battle_event end 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 #------------------------------------------------------------------------------ #RTAB观光游第一站,去除“战斗/逃跑”选项部分 # @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 $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 @help_wait > 0 @help_wait -= 1 if @help_wait == 0 # ヘルプウィンドウを隠す @help_window.visible = false end end # アクションを強制されているバトラーが存在せず、 # かつバトルイベントが実行中の場合 if $game_temp.forcing_battler == nil and $game_system.battle_interpreter.running? return end # フェーズによって分岐 case @phase when 0 # ATゲージ更新フェーズ if anime_wait_return update_phase0 end when 1 # プレバトルフェーズ update_phase1 return when 2 # パーティコマンドフェーズ update_phase2 return when 5 # アフターバトルフェーズ update_phase5 return end if $scene != self return end if @phase == 0 if @command.size != 0 # アクターコマンドフェーズ if @command_a == false start_phase3 end update_phase3 end # ウェイト中の場合 if @wait_count > 0 # ウェイトカウントを減らす @wait_count -= 1 return end update_phase4 end end #============================================================================== # ■ Scene_Battle (分割定義 2) #------------------------------------------------------------------------------ # バトル画面の処理を行うクラスです。 #============================================================================== #-------------------------------------------------------------------------- # ● フレーム更新 (ATゲージ更新フェーズ) #-------------------------------------------------------------------------- def update_phase0 if $game_temp.battle_turn == 0 $game_temp.battle_turn = 1 end # B ボタンが押された場合 # if @command_a == false and @party == false # if Input.trigger?(Input::B) # キャンセル SE を演奏 # $game_system.se_play($data_system.cancel_se) # @party = true # end # end # if @party == true and # ((@action > 0 and @action_battlers.empty?) or (@action == 0 and # (@action_battlers.empty? or @action_battlers[0].phase == 1))) # パーティコマンドフェーズへ # start_phase2 # return # end # ATゲージ増加処理 cnt = 0 for battler in $game_party.actors + $game_troop.enemies active?(battler) if battler.rtp == 0 if battler.at >= @max if battler.is_a?(Game_Actor) if battler.inputable? unless @action_battlers.include?(battler) or @command.include?(battler) or @escape == true if battler.current_action.forcing fullat_se force_action(battler) action_start(battler) else fullat_se @command.push(battler) end end else unless @action_battlers.include?(battler) or battler == @command[0] battler.current_action.clear if @command.include?(battler) @command.delete(battler) else if battler.movable? fullat_se end end action_start(battler) end end else unless @action_battlers.include?(battler) if battler.current_action.forcing force_action(battler) action_start(battler) else if @enemy_speed != 0 if rand(@enemy_speed) == 0 number = cnt - $game_party.actors.size enemy_action(number) end else number = cnt - $game_party.actors.size enemy_action(number) end end end end else battler.at += battler.agi if battler.guarding? battler.at += battler.agi end if battler.movable? battler.atp = 100 * battler.at / @max end end else if battler.rt >= battler.rtp speller = synthe?(battler) if speller != nil battler = speller[0] end unless @action_battlers.include?(battler) if battler.is_a?(Game_Actor) fullat_se end battler.rt = battler.rtp action_start(battler) end else battler.rt += battler.agi speller = synthe?(battler) if speller != nil for spell in speller if spell != battler spell.rt += battler.agi end end end end end cnt += 1 end # ATゲージをリフレッシュ @status_window.at_refresh # 逃走処理 if @escape == true and ((@action > 0 and @action_battlers.empty?) or (@action == 0 and (@action_battlers.empty? or @action_battlers[0].phase == 1))) temp = false for battler in $game_party.actors if battler.inputable? temp = true end end if temp == true for battler in $game_party.actors if battler.at < @max and battler.inputable? temp = false break end end if temp == true @escape = false for battler in $game_party.actors battler.at %= @max end $game_temp.battle_main_phase = false update_phase2_escape end end end end #------------------------------------------------------------------------------ #RTAB观光游第一站,去除“战斗/逃跑”选项部分 #-------------------------------------------------------------------------- # ● パーティコマンドフェーズ開始 #-------------------------------------------------------------------------- # def start_phase2 # フェーズ 2 に移行 # @phase = 2 # @party = false # パーティコマンドウィンドウを有効化 # @party_command_window.active = true # @party_command_window.visible = true # アクターを非選択状態に設定 # @actor_index = -1 # アクターコマンドウィンドウを無効化 # @actor_command_window.active = false # @actor_command_window.visible = false # if @command.size != 0 # アクターの明滅エフェクト OFF # if @active_actor != nil # @active_actor.blink = false # end # end # カメラセット # @camera == "party" # @spriteset.screen_target(0, 0, 1) # メインフェーズフラグをクリア # $game_temp.battle_main_phase = false # end #------------------------------------------------------------------------------ #-------------------------------------------------------------------------- # ● フレーム更新 (パーティコマンドフェーズ) #-------------------------------------------------------------------------- def update_phase2 #------------------------------------------------------------------------------ #RTAB观光游第一站,去除“战斗/逃跑”选项部分 # C ボタンが押された場合 # 去掉“战斗/逃跑”选项 # if Input.trigger?(Input::C) # パーティコマンドウィンドウのカーソル位置で分岐 # case @party_command_window.index # when 0 # 戦う # パーティコマンドウィンドウを無効化 # @party_command_window.active = false # @party_command_window.visible = false # 決定 SE を演奏 # $game_system.se_play($data_system.decision_se) #------------------------------------------------------------------------------ @escape = false @phase = 0 if $game_temp.battle_turn == 0 $game_temp.battle_turn = 1 end if @command_a == true # アクターコマンドフェーズ開始 start_phase3 else $game_temp.battle_main_phase = true end end #------------------------------------------------------------------------------ #RTAB观光游第一站,去除“战斗/逃跑”选项部分 # when 1 # 逃げる # 逃走可能ではない場合 # if $game_temp.battle_can_escape == false # ブザー SE を演奏 # $game_system.se_play($data_system.buzzer_se) # return # end # 決定 SE を演奏 # $game_system.se_play($data_system.decision_se) # @phase = 0 # パーティコマンドウィンドウを無効化 # @party_command_window.active = false # @party_command_window.visible = false # $game_temp.battle_main_phase = true # if $game_temp.battle_turn == 0 # update_phase2_escape # $game_temp.battle_turn = 1 # for battler in $game_party.actors # battler.at -= @max / 2 # end # return # end # 決定 SE を演奏 # $game_system.se_play($data_system.decision_se) # @escape = true # for battler in $game_party.actors # @command_a = false # @command.delete(battler) # @action_battlers.delete(battler) # skill_reset(battler) # end # end # return # end #end #------------------------------------------------------------------------------ #-------------------------------------------------------------------------- # ● フレーム更新 (パーティコマンドフェーズ : 逃げる) #-------------------------------------------------------------------------- def update_phase2_escape # エネミーの素早さ平均値を計算 enemies_agi = 0 enemies_number = 0 for enemy in $game_troop.enemies if enemy.exist? enemies_agi += enemy.agi enemies_number += 1 end end if enemies_number > 0 enemies_agi /= enemies_number end # アクターの素早さ平均値を計算 actors_agi = 0 actors_number = 0 for actor in $game_party.actors if actor.exist? actors_agi += actor.agi actors_number += 1 end end if actors_number > 0 actors_agi /= actors_number end # 逃走成功判定 success = rand(100) < 50 * actors_agi / enemies_agi # 逃走成功の場合 if success # 逃走 SE を演奏 $game_system.se_play($data_system.escape_se) # バトル開始前の BGM に戻す $game_system.bgm_play($game_temp.map_bgm) # バトル終了 battle_end(1) # 逃走失敗の場合 else @help_window.set_text("逃走失敗", 1) @help_wait = @help_time # パーティ全員のアクションをクリア $game_party.clear_actions # メインフェーズ開始 start_phase4 end end #-------------------------------------------------------------------------- # ● アフターバトルフェーズ開始 #-------------------------------------------------------------------------- def start_phase5 # フェーズ 5 に移行 @phase = 5 # バトル終了 ME を演奏 $game_system.me_play($game_system.battle_end_me) # バトル開始前の BGM に戻す $game_system.bgm_play($game_temp.map_bgm) # EXP、ゴールド、トレジャーを初期化 exp = 0 gold = 0 treasures = [] if @active_actor != nil @active_actor.blink = false end # メインフェーズフラグをセット $game_temp.battle_main_phase = true #------------------------------------------------------------------------------ #RTAB观光游第一站,去除“战斗/逃跑”选项部分 # パーティコマンドウィンドウを無効化 # @party_command_window.active = false # @party_command_window.visible = false #------------------------------------------------------------------------------ # アクターコマンドウィンドウを無効化 @actor_command_window.active = false @actor_command_window.visible = false if @skill_window != nil # スキルウィンドウを解放 @skill_window.dispose @skill_window = nil end if @item_window != nil # アイテムウィンドウを解放 @item_window.dispose @item_window = nil end # ヘルプウィンドウを隠す @help_window.visible = false # ループ for enemy in $game_troop.enemies # エネミーが隠れ状態でない場合 unless enemy.hidden # 獲得 EXP、ゴールドを追加 exp += enemy.exp gold += enemy.gold # トレジャー出現判定 if rand(100) < enemy.treasure_prob if enemy.item_id > 0 treasures.push($data_items[enemy.item_id]) end if enemy.weapon_id > 0 treasures.push($data_weapons[enemy.weapon_id]) end if enemy.armor_id > 0 treasures.push($data_armors[enemy.armor_id]) end end end end # トレジャーの数を 6 個までに限定 treasures = treasures[0..5] # EXP 獲得 for i in 0...$game_party.actors.size actor = $game_party.actors[i] if actor.cant_get_exp? == false last_level = actor.level actor.exp += exp if actor.level > last_level @status_window.level_up(i) actor.damage[[actor, -1]] = "Level up!" actor.up_level = actor.level - last_level end end end # ゴールド獲得 $game_party.gain_gold(gold) # トレジャー獲得 for item in treasures case item when RPG::Item $game_party.gain_item(item.id, 1) when RPG::Weapon $game_party.gain_weapon(item.id, 1) when RPG::Armor $game_party.gain_armor(item.id, 1) end end # バトルリザルトウィンドウを作成 @result_window = Window_BattleResult.new(exp, gold, treasures) # ウェイトカウントを設定 @phase5_wait_count = 100 end #-------------------------------------------------------------------------- # ● フレーム更新 (アフターバトルフェーズ) #-------------------------------------------------------------------------- def update_phase5 # ウェイトカウントが 0 より大きい場合 if @phase5_wait_count > 0 # ウェイトカウントを減らす @phase5_wait_count -= 1 # ウェイトカウントが 0 になった場合 if @phase5_wait_count == 0 # リザルトウィンドウを表示 @result_window.visible = true # メインフェーズフラグをクリア $game_temp.battle_main_phase = false # ステータスウィンドウをリフレッシュ @status_window.refresh for actor in $game_party.actors if actor.damage.include?([actor, 0]) @phase5_wait_count = 20 actor.damage_pop[[actor, 0]] = true end if actor.damage.include?([actor, -1]) @phase5_wait_count = 20 actor.damage_pop[[actor, -1]] = true for level in actor.level - actor.up_level + 1..actor.level for skill in $data_classes[actor.class_id].learnings if level == skill.level and not actor.skill_learn?(skill.id) actor.damage[[actor, 0]] = "New Skill!" break end end end end end end return end # C ボタンが押された場合 if Input.trigger?(Input::C) # バトル終了 battle_end(0) end end #============================================================================== # ■ Scene_Battle (分割定義 3) #------------------------------------------------------------------------------ # バトル画面の処理を行うクラスです。 #============================================================================== #-------------------------------------------------------------------------- # ● アクターコマンドフェーズ開始 #-------------------------------------------------------------------------- def start_phase3 if victory? return end # メインフェーズフラグをクリア $game_temp.battle_main_phase = false @command_a = true @active_actor = @command[0] cnt = 0 for actor in $game_party.actors if actor == @active_actor @actor_index = cnt end cnt += 1 end @active_actor.blink = true unless @active_actor.inputable? @active_actor.current_action.clear phase3_next_actor return end phase3_setup_command_window # カメラの設定 @camera = "command" plus = ($game_party.actors.size - 1) / 2.0 - @actor_index y = [(plus.abs - 1.5) * 10 , 0].min @spriteset.screen_target(plus * 50, y, 1.0 + y * 0.002) end #-------------------------------------------------------------------------- # ● アクターのコマンド入力終了 #-------------------------------------------------------------------------- def phase3_next_actor @command.shift @command_a = false # メインフェーズフラグをセット $game_temp.battle_main_phase = true # アクターコマンドウィンドウを無効化 @actor_command_window.active = false @actor_command_window.visible = false # アクターの明滅エフェクト OFF if @active_actor != nil @active_actor.blink = false end action_start(@active_actor) # カメラを元に戻す if @camera == "command" @spriteset.screen_target(0, 0, 1) end return end #-------------------------------------------------------------------------- # ● アクターコマンドウィンドウのセットアップ #-------------------------------------------------------------------------- def phase3_setup_command_window #------------------------------------------------------------------------------ #RTAB观光游第一站,去除“战斗/逃跑”选项部分 # パーティコマンドウィンドウを無効化 # @party_command_window.active = false # @party_command_window.visible = false #------------------------------------------------------------------------------ # アクターコマンドウィンドウを有効化 @actor_command_window.active = true @actor_command_window.visible = true # アクターコマンドウィンドウの位置を設定 @actor_command_window.x = @actor_index * 160 + (4 - $game_party.actors.size) * 80 # インデックスを 0 に設定 @actor_command_window.index = 0 end #-------------------------------------------------------------------------- # ● エネミーアクション作成 #-------------------------------------------------------------------------- def enemy_action(number) enemy = $game_troop.enemies[number] unless enemy.current_action.forcing enemy.make_action end action_start(enemy) end #-------------------------------------------------------------------------- # ● フレーム更新 (アクターコマンドフェーズ) #-------------------------------------------------------------------------- def update_phase3 if victory? and @command_a command_delete @command.push(@active_actor) return end # エネミーアローが有効の場合 if @enemy_arrow != nil update_phase3_enemy_select # アクターアローが有効の場合 elsif @actor_arrow != nil update_phase3_actor_select # スキルウィンドウが有効の場合 elsif @skill_window != nil update_phase3_skill_select # アイテムウィンドウが有効の場合 elsif @item_window != nil update_phase3_item_select # アクターコマンドウィンドウが有効の場合 elsif @actor_command_window.active update_phase3_basic_command end end #-------------------------------------------------------------------------- # ● フレーム更新 (アクターコマンドフェーズ : 基本コマンド) #-------------------------------------------------------------------------- def update_phase3_basic_command unless @active_actor.inputable? @active_actor.current_action.clear phase3_next_actor return end #-------------------------------------------------------------------------- #RTAB观光游第一站,去除“战斗/逃跑”选项部分 # B ボタンが押された場合 # if Input.trigger?(Input::B) and @party == false # キャンセル SE を演奏 # $game_system.se_play($data_system.cancel_se) # @party = true # end # if @party == true and # ((@action > 0 and @action_battlers.empty?) or (@action == 0 and # (@action_battlers.empty? or @action_battlers[0].phase == 1))) # パーティコマンドフェーズへ # start_phase2 # return # end #============================================================================== #RTAB观光游第二站,增加战斗快捷键ASD 这段是官方增加的脚本 #============================================================================== # A : SKILL if Input.trigger?(Input::X) # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # スキルの選択を開始 start_skill_select return end # S : 防御 if Input.trigger?(Input::Y) # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # アクションを設定 @active_actor.current_action.kind = 0 @active_actor.current_action.basic = 1 # 次のアクターのコマンド入力へ phase3_next_actor return end # D : ITEM if Input.trigger?(Input::Z) # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # アイテムの選択を開始 start_item_select return end #============================================================================== # C ボタンが押された場合 if Input.trigger?(Input::C) #------------------------------------------------------------------------------ #RTAB观光游第一站,去除“战斗/逃跑”选项部分 # @party = false #------------------------------------------------------------------------------ # アクターコマンドウィンドウのカーソル位置で分岐 case @actor_command_window.index when 0 # 攻撃 #============================================================================== #RTAB观光游第二站,增加战斗快捷键ASD 这段是官方增加的脚本 #============================================================================== if victory? # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return end #============================================================================== # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # エネミーの選択を開始 start_enemy_select when 1 # スキル # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # スキルの選択を開始 start_skill_select when 2 # 防御 # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # アクションを設定 @active_actor.current_action.kind = 0 @active_actor.current_action.basic = 1 # 次のアクターのコマンド入力へ phase3_next_actor when 3 # アイテム # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # アイテムの選択を開始 start_item_select #============================================================================== #RTAB观光游第三站,战斗菜单增加逃跑选项 #============================================================================== when 4 #逃跑(添加内容) if $game_temp.battle_can_escape == false # ブザー SE を演奏 $game_system.se_play($data_system.buzzer_se) return end # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) @phase = 0 # パーティコマンドウィンドウを無効化 @actor_command_window.active = false @actor_command_window.visible = false $game_temp.battle_main_phase = true if $game_temp.battle_turn == 0 update_phase2_escape $game_temp.battle_turn = 1 for battler in $game_party.actors battler.at -= @max / 2 end return end # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) @escape = true for battler in $game_party.actors @command_a = false @command.delete(battler) @action_battlers.delete(battler) skill_reset(battler) end #============================================================================== end return end # キャラチェンジ if @command.size > 1 # R ボタンが押された場合 if Input.trigger?(Input::L) $game_system.se_play($data_system.cursor_se) #------------------------------------------------------------------------------ #RTAB观光游第一站,去除“战斗/逃跑”选项部分 # @party = false #------------------------------------------------------------------------------ # アクターの明滅エフェクト OFF if @active_actor != nil @active_actor.blink = false end @command.push(@command[0]) @command.shift @command_a = false # 新たなコマンドウィンドウの立ち上げ start_phase3 end # L ボタンが押された場合 if Input.trigger?(Input::R) $game_system.se_play($data_system.cursor_se) #------------------------------------------------------------------------------ #RTAB观光游第一站,去除“战斗/逃跑”选项部分 # @party = false #------------------------------------------------------------------------------ # アクターの明滅エフェクト OFF if @active_actor != nil @active_actor.blink = false end @command.unshift(@command[@command.size - 1]) @command.delete_at(@command.size - 1) @command_a = false # 新たなコマンドウィンドウの立ち上げ start_phase3 end # 右 ボタンが押された場合 if Input.trigger?(Input::RIGHT) $game_system.se_play($data_system.cursor_se) #------------------------------------------------------------------------------ #RTAB观光游第一站,去除“战斗/逃跑”选项部分 # @party = false #------------------------------------------------------------------------------ # アクターの明滅エフェクト OFF if @active_actor != nil @active_actor.blink = false end actor = $game_party.actors[@actor_index] while actor == @command[0] or (not @command.include?(actor)) @actor_index += 1 @actor_index %= $game_party.actors.size actor = $game_party.actors[@actor_index] if actor == @command[0] break end end while actor != @command[0] @command.push(@command.shift) end @command_a = false # 新たなコマンドウィンドウの立ち上げ start_phase3 end # 左 ボタンが押された場合 if Input.trigger?(Input::LEFT) $game_system.se_play($data_system.cursor_se) #------------------------------------------------------------------------------ #RTAB观光游第一站,去除“战斗/逃跑”选项部分 # @party = false #------------------------------------------------------------------------------ # アクターの明滅エフェクト OFF if @active_actor != nil @active_actor.blink = false end actor = $game_party.actors[@actor_index] while actor == @command[0] or (not @command.include?(actor)) @actor_index -= 1 @actor_index %= $game_party.actors.size actor = $game_party.actors[@actor_index] if actor == @command[0] break end end while actor != @command[0] @command.push(@command.shift) end @command_a = false # 新たなコマンドウィンドウの立ち上げ start_phase3 end end end #-------------------------------------------------------------------------- # ● フレーム更新 (アクターコマンドフェーズ : スキル選択) #-------------------------------------------------------------------------- def update_phase3_skill_select # コマンド選択中に行動不能になった場合 unless @active_actor.inputable? @active_actor.current_action.clear command_delete # 次のアクターのコマンド入力へ phase3_next_actor return end # スキルウィンドウを可視状態にする @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_actor.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_actor.current_action.skill_id = @skill.id # スキルウィンドウを不可視状態にする @skill_window.visible = false # 効果範囲が敵単体の場合 if @skill.scope == 1 # エネミーの選択を開始 start_enemy_select # 効果範囲が味方単体の場合 elsif @skill.scope == 3 or @skill.scope == 5 # アクターの選択を開始 start_actor_select # 効果範囲が単体ではない場合 else # アクションを設定 @active_actor.current_action.kind = 1 # スキルの選択を終了 end_skill_select # 次のアクターのコマンド入力へ phase3_next_actor end return end end #-------------------------------------------------------------------------- # ● フレーム更新 (アクターコマンドフェーズ : アイテム選択) #-------------------------------------------------------------------------- def update_phase3_item_select # コマンド選択中に行動不能になった場合 unless @active_actor.inputable? @active_actor.current_action.clear command_delete # 次のアクターのコマンド入力へ phase3_next_actor return end # アイテムウィンドウを可視状態にする @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_actor.current_action.item_id = @item.id # アイテムウィンドウを不可視状態にする @item_window.visible = false # 効果範囲が敵単体の場合 if @item.scope == 1 # エネミーの選択を開始 start_enemy_select # 効果範囲が味方単体の場合 elsif @item.scope == 3 or @item.scope == 5 # アクターの選択を開始 start_actor_select # 効果範囲が単体ではない場合 else # アクションを設定 @active_actor.current_action.kind = 2 # アイテムの選択を終了 end_item_select # 次のアクターのコマンド入力へ phase3_next_actor end return end end #-------------------------------------------------------------------------- # ● フレーム更新 (アクターコマンドフェーズ : エネミー選択) #-------------------------------------------------------------------------- def update_phase3_enemy_select # コマンド選択中に行動不能になった場合 unless @active_actor.inputable? # カメラを元に戻す if @camera == "select" @spriteset.screen_target(0, 0, 1) end @active_actor.current_action.clear command_delete # 次のアクターのコマンド入力へ phase3_next_actor return end # エネミーアローを更新 @enemy_arrow.update # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # カメラを元に戻す if @camera == "select" # カメラの設定 @camera = "command" plus = ($game_party.actors.size - 1) / 2.0 - @actor_index y = [(plus.abs - 1.5) * 10 , 0].min @spriteset.screen_target(plus * 50, y, 1.0 + y * 0.002) end # エネミーの選択を終了 end_enemy_select return end # C ボタンが押された場合 if Input.trigger?(Input::C) # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # アクションを設定 @active_actor.current_action.kind = 0 @active_actor.current_action.basic = 0 @active_actor.current_action.target_index = @enemy_arrow.index # スキルウィンドウ表示中の場合 if @skill_window != nil # アクションを再設定 @active_actor.current_action.kind = 1 # スキルの選択を終了 end_skill_select end # アイテムウィンドウ表示中の場合 if @item_window != nil # アクションを再設定 @active_actor.current_action.kind = 2 # アイテムの選択を終了 end_item_select end # エネミーの選択を終了 end_enemy_select # 次のアクターのコマンド入力へ phase3_next_actor end end #-------------------------------------------------------------------------- # ● フレーム更新 (アクターコマンドフェーズ : アクター選択) #-------------------------------------------------------------------------- def update_phase3_actor_select # コマンド選択中に行動不能になった場合 unless @active_actor.inputable? @active_actor.current_action.clear command_delete # 次のアクターのコマンド入力へ phase3_next_actor return end # アクターアローを更新 @actor_arrow.update # B ボタンが押された場合 if Input.trigger?(Input::B) # キャンセル SE を演奏 $game_system.se_play($data_system.cancel_se) # アクターの選択を終了 end_actor_select return end # C ボタンが押された場合 if Input.trigger?(Input::C) # 決定 SE を演奏 $game_system.se_play($data_system.decision_se) # アクションを設定 @active_actor.current_action.kind = 0 @active_actor.current_action.basic = 0 @active_actor.current_action.target_index = @actor_arrow.index # アクターの選択を終了 end_actor_select # スキルウィンドウ表示中の場合 if @skill_window != nil # アクションを再設定 @active_actor.current_action.kind = 1 # スキルの選択を終了 end_skill_select end # アイテムウィンドウ表示中の場合 if @item_window != nil # アクションを再設定 @active_actor.current_action.kind = 2 # アイテムの選択を終了 end_item_select end # 次のアクターのコマンド入力へ phase3_next_actor end end #-------------------------------------------------------------------------- # ● エネミー選択開始 #-------------------------------------------------------------------------- alias :start_enemy_select_rtab :start_enemy_select def start_enemy_select @camera = "select" for enemy in $game_troop.enemies if enemy.exist? zoom = 1 / enemy.zoom @spriteset.screen_target(enemy.attack_x(zoom) * 0.75, enemy.attack_y(zoom) * 0.75, zoom) break end end # オリジナルの処理 start_enemy_select_rtab end #-------------------------------------------------------------------------- # ● エネミー選択終了 #-------------------------------------------------------------------------- alias :end_enemy_select_rtab :end_enemy_select def end_enemy_select # オリジナルの処理 end_enemy_select_rtab if (@action == 0 and not @action_battlers.empty?) or (@camera == "select" and (@active_actor.current_action.kind != 0 or @active_actor.animation1_id != 0)) @spriteset.screen_target(0, 0, 1) end end #-------------------------------------------------------------------------- # ● スキル選択開始 #-------------------------------------------------------------------------- def start_skill_select # スキルウィンドウを作成 @skill_window = Window_Skill.new(@active_actor) # ヘルプウィンドウを関連付け @skill_window.help_window = @help_window # アクターコマンドウィンドウを無効化 @actor_command_window.active = false @actor_command_window.visible = false end #============================================================================== # ■ Scene_Battle (分割定義 4) #------------------------------------------------------------------------------ # バトル画面の処理を行うクラスです。 #============================================================================== #-------------------------------------------------------------------------- # ● メインフェーズ開始 #-------------------------------------------------------------------------- def start_phase4 $game_temp.battle_main_phase = true end #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ) #-------------------------------------------------------------------------- def update_phase4 # アクションを強制されているバトラーが存在する場合 if $game_temp.forcing_battler != nil battler = $game_temp.forcing_battler if battler.current_action.forcing == false if @action_battlers.include?(battler) if @action > 0 or @action_battlers[0].phase == 1 @action_battlers.delete(battler) @action_battlers.push(battler) end if battler.phase == 1 battler.current_action.forcing = true force_action(battler) end else battler.current_action.forcing = true force_action(battler) action_start(battler) @action_battlers.delete(battler) @action_battlers.push(battler) end battler.at = @max battler.atp = 100 * battler.at / @max end end # action が1以上の場合、一斉に行動を起こす for battler in @action_battlers.reverse # ウェイト中の場合 if battler.wait > 0 # ウェイトカウントを減らす battler.wait -= 1 break if @action == 0 next end unless fin? and battler.phase < 3 and not $game_system.battle_interpreter.running? action_phase(battler) end break if @action == 0 end # アクションを強制されているバトラーが存在しない場合 if $game_temp.forcing_battler == nil # バトルイベントをセットアップ setup_battle_event # バトルイベント実行中の場合 if $game_system.battle_interpreter.running? return end end # 勝敗を決した際の処理 if fin? # 敗北時、指定時間ウェイト if $game_party.all_dead? and @after_wait[0] > 0 @after_wait[0] -= 1 return end # 勝利時、指定時間ウェイト if victory? and @after_wait[1] > 0 @after_wait[1] -= 1 return end # 戦闘が終了し、かつアクターが行動直前の場合はアクターの行動を消去 for battler in @action_battlers.reverse if battler.phase < 3 and not $game_system.battle_interpreter.running? @action_battlers.delete(battler) end end # 勝敗判定 if @action_battlers.empty? and not $game_system.battle_interpreter.running? judge end end end #-------------------------------------------------------------------------- # ● アクション更新 (メインフェーズ) #-------------------------------------------------------------------------- def action_phase(battler) # action が 1 の場合、バトラーが行動中かどうか確認 if @action == 1 and battler.phase <= 3 for target in battler.target speller = synthe?(target) if speller == nil # ターゲットが通常行動中の場合 if @action_battlers.include?(target) if target.phase > 2 return end end else # ターゲットが連携スキル発動中の場合 for spell in speller if @action_battlers.include?(spell) if spell.phase > 2 return end end end end end end case battler.phase when 1 update_phase4_step1(battler) when 2 update_phase4_step2(battler) when 3 update_phase4_step3(battler) when 4 update_phase4_step4(battler) when 5 update_phase4_step5(battler) when 6 update_phase4_step6(battler) end end #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 1 : アクション準備) #-------------------------------------------------------------------------- def update_phase4_step1(battler) # すでに戦闘から外されている場合 if battler.index == nil @action_battlers.delete(battler) anime_wait_return return end speller = synthe?(battler) if speller == nil # ダメージ食らい中の場合 unless battler.damage.empty? or @action > 2 return end # 行動可能かどうか判定 unless battler.movable? battler.phase = 6 return end else # ダメージ食らい中の場合 for spell in speller unless spell.damage.empty? or @action > 2 return end # 行動可能かどうか判定 unless spell.movable? battler.phase = 6 return end end end # スキル使用時、詠唱時間設定 # 強制アクションかつ @force が 2 の時はスキルを即時発動 if battler.current_action.kind == 1 and (not battler.current_action.forcing or @force != 2) if battler.rtp == 0 # スキル詠唱中ならば、解除 skill_reset(battler) # スキル詠唱時間設定 recite_time(battler) # 連携技設定 synthe_spell(battler) # スキルを詠唱する場合 if battler.rtp > 0 # 強制アクションかつ @force が 1 の時は連携スキルのみ即時発動 speller = synthe?(battler) if battler.current_action.forcing and @force > 0 and speller != nil for spell in speller spell.rt = spell.rtp end else battler.blink = true if battler.current_action.forcing $game_temp.forcing_battler = nil battler.current_action.forcing = false end @action_battlers.delete(battler) return end end end end # アクターの明滅エフェクト OFF if battler != nil battler.blink = false end speller = synthe?(battler) if speller == nil @spell_p.delete(battler) @spell_e.delete(battler) else for spell in speller spell.blink = false @spell_p.delete(spell) @spell_e.delete(spell) end end # ステップ 2 に移行 battler.phase = 2 end #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 2 : アクション開始) #-------------------------------------------------------------------------- def update_phase4_step2(battler) # 強制アクションでなければ unless battler.current_action.forcing # 制約が [敵を通常攻撃する] か [味方を通常攻撃する] の場合 if battler.restriction == 2 or battler.restriction == 3 # アクションに攻撃を設定 battler.current_action.kind = 0 battler.current_action.basic = 0 end end # アクションの種別で分岐 case battler.current_action.kind when 0 # 基本 if fin? battler.phase = 6 return end make_basic_action_result(battler) when 1 # スキル if fin? and $data_skills[battler.current_action.skill_id].scope == 1..2 battler.phase = 6 return end make_skill_action_result(battler) when 2 # アイテム if fin? and $data_items[battler.current_action.item_id].scope == 1..2 battler.phase = 6 return end make_item_action_result(battler) end if battler.phase == 2 # ステップ 3 に移行 battler.phase = 3 end end #-------------------------------------------------------------------------- # ● 基本アクション 結果作成 #-------------------------------------------------------------------------- def make_basic_action_result(battler) # 攻撃の場合 if battler.current_action.basic == 0 # アニメーション ID を設定 battler.anime1 = battler.animation1_id battler.anime2 = battler.animation2_id # 行動側バトラーがエネミーの場合 if battler.is_a?(Game_Enemy) if battler.restriction == 3 target = $game_troop.random_target_enemy elsif battler.restriction == 2 target = $game_party.random_target_actor else index = battler.current_action.target_index target = $game_party.smooth_target_actor(index) end end # 行動側バトラーがアクターの場合 if battler.is_a?(Game_Actor) if battler.restriction == 3 target = $game_party.random_target_actor elsif battler.restriction == 2 target = $game_troop.random_target_enemy else index = battler.current_action.target_index target = $game_troop.smooth_target_enemy(index) end end # 対象側バトラーの配列を設定 battler.target = [target] # 通常攻撃の効果を適用 for target in battler.target target.attack_effect(battler) end return end # 防御の場合 if battler.current_action.basic == 1 return end # 逃げるの場合 # if battler.is_a?(Game_Enemy) and battler.current_action.basic == 2 # 逃げる # @help_window.set_text("逃げる", 1) # @help_wait = @help_time # battler.escape # return # end #========RTAB 1.16===================================================== # 逃げるの場合 if battler.is_a?(Game_Enemy) and battler.current_action.basic == 2 return end #====================================================================== # 何もしないの場合 if battler.current_action.basic == 3 # ステップ 6 に移行 battler.phase = 6 return end end #-------------------------------------------------------------------------- # ● スキルまたはアイテムの対象側バトラー設定 # scope : スキルまたはアイテムの効果範囲 #-------------------------------------------------------------------------- def set_target_battlers(scope, battler) # 行動側バトラーがエネミーの場合 if battler.is_a?(Game_Enemy) # 効果範囲で分岐 case scope when 1 # 敵単体 index =battler.current_action.target_index battler.target.push($game_party.smooth_target_actor(index)) when 2 # 敵全体 for actor in $game_party.actors if actor.exist? battler.target.push(actor) end end when 3 # 味方単体 index = battler.current_action.target_index battler.target.push($game_troop.smooth_target_enemy(index)) when 4 # 味方全体 for enemy in $game_troop.enemies if enemy.exist? battler.target.push(enemy) end end when 5 # 味方単体 (HP 0) index = battler.current_action.target_index enemy = $game_troop.enemies[index] if enemy != nil and enemy.hp0? battler.target.push(enemy) end when 6 # 味方全体 (HP 0) for enemy in $game_troop.enemies if enemy != nil and enemy.hp0? battler.target.push(enemy) end end when 7 # 使用者 battler.target.push(battler) end end # 行動側バトラーがアクターの場合 if battler.is_a?(Game_Actor) # 効果範囲で分岐 case scope when 1 # 敵単体 index = battler.current_action.target_index battler.target.push($game_troop.smooth_target_enemy(index)) when 2 # 敵全体 for enemy in $game_troop.enemies if enemy.exist? battler.target.push(enemy) end end when 3 # 味方単体 index = battler.current_action.target_index battler.target.push($game_party.smooth_target_actor(index)) when 4 # 味方全体 for actor in $game_party.actors if actor.exist? battler.target.push(actor) end end when 5 # 味方単体 (HP 0) index = battler.current_action.target_index actor = $game_party.actors[index] if actor != nil and actor.hp0? battler.target.push(actor) end when 6 # 味方全体 (HP 0) for actor in $game_party.actors if actor != nil and actor.hp0? battler.target.push(actor) end end when 7 # 使用者 battler.target.push(battler) end end end #-------------------------------------------------------------------------- # ● スキルアクション 結果作成 #-------------------------------------------------------------------------- def make_skill_action_result(battler) # スキルを取得 @skill = $data_skills[battler.current_action.skill_id] # 連携スキルであるかどうか確認 speller = synthe?(battler) # 強制アクションでなければ unless battler.current_action.forcing # SP 切れなどで使用できなくなった場合 if speller == nil unless battler.skill_can_use?(@skill.id) # ステップ 6 に移行 battler.phase = 6 return end end end # SP 消費 temp = false if speller != nil for spell in speller if spell.current_action.spell_id == 0 spell.sp -= @skill.sp_cost else spell.sp -= $data_skills[spell.current_action.spell_id].sp_cost end # ステータスウィンドウをリフレッシュ status_refresh(spell) end else battler.sp -= @skill.sp_cost # ステータスウィンドウをリフレッシュ status_refresh(battler) end # アニメーション ID を設定 battler.anime1 = @skill.animation1_id battler.anime2 = @skill.animation2_id # コモンイベント ID を設定 battler.event = @skill.common_event_id # 対象側バトラーを設定 set_target_battlers(@skill.scope, battler) # スキルの効果を適用 for target in battler.target if speller != nil damage = 0 d_result = false effective = false state_p = [] state_m = [] for spell in speller if spell.current_action.spell_id != 0 @skill = $data_skills[spell.current_action.spell_id] end effective |= target.skill_effect(spell, @skill) if target.damage[spell].class != String d_result = true damage += target.damage[spell] elsif effective effect = target.damage[spell] end state_p += target.state_p[spell] state_m += target.state_m[spell] target.damage.delete(spell) target.state_p.delete(spell) target.state_m.delete(spell) end if d_result target.damage[battler] = damage elsif effective target.damage[battler] = effect else target.damage[battler] = 0 end target.state_p[battler] = state_p target.state_m[battler] = state_m else target.skill_effect(battler, @skill) end end end #-------------------------------------------------------------------------- # ● アイテムアクション 結果作成 #-------------------------------------------------------------------------- def make_item_action_result(battler) # アイテムを取得 @item = $data_items[battler.current_action.item_id] # アイテム切れなどで使用できなくなった場合 unless $game_party.item_can_use?(@item.id) # ステップ 6 に移行 battler.phase = 6 return end # 消耗品の場合 if @item.consumable # 使用したアイテムを 1 減らす $game_party.lose_item(@item.id, 1) end # アニメーション ID を設定 battler.anime1 = @item.animation1_id battler.anime2 = @item.animation2_id # コモンイベント ID を設定 battler.event = @item.common_event_id # 対象を決定 index = battler.current_action.target_index target = $game_party.smooth_target_actor(index) # 対象側バトラーを設定 set_target_battlers(@item.scope, battler) # アイテムの効果を適用 for target in battler.target target.item_effect(@item, battler) end end #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 3 : 行動側アニメーション) #-------------------------------------------------------------------------- def update_phase4_step3(battler) # ヘルプウィンドウの更新。アクションの種別で分岐 case battler.current_action.kind when 0 # 基本 if battler.current_action.basic == 1 @help_window.set_text($data_system.words.guard, 1) @help_wait = @help_time end #========RTAB 1.16================================== if battler.current_action.basic == 2 # 逃げる @help_window.set_text("逃げる", 1) @help_wait = @help_time battler.escape battler.phase = 4 return end #=================================================== when 1 # スキル skill = $data_skills[battler.current_action.skill_id] @help_window.set_text(skill.name, 1) @help_wait = @help_time when 2 # アイテム item = $data_items[battler.current_action.item_id] @help_window.set_text(item.name, 1) @help_wait = @help_time end # 行動側アニメーション (ID が 0 の場合は白フラッシュ) if battler.anime1 == 0 battler.white_flash = true battler.wait = 5 # カメラ設定 if battler.target[0].is_a?(Game_Enemy) camera_set(battler) end else battler.animation.push([battler.anime1, true]) speller = synthe?(battler) if speller != nil for spell in speller if spell != battler if spell.current_action.spell_id == 0 spell.animation.push([battler.anime1, true]) else skill = spell.current_action.spell_id spell.animation.push([$data_skills[skill].animation1_id, true]) spell.current_action.spell_id = 0 end end end end battler.wait = 2 * $data_animations[battler.anime1].frame_max - 10 end # ステップ 4 に移行 battler.phase = 4 end #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 4 : 対象側アニメーション) #-------------------------------------------------------------------------- def update_phase4_step4(battler) # カメラ設定 if battler.target[0].is_a?(Game_Enemy) and battler.anime1 != 0 camera_set(battler) end # 対象側アニメーション for target in battler.target target.animation.push([battler.anime2, (target.damage[battler] != "Miss")]) unless battler.anime2 == 0 battler.wait = 2 * $data_animations[battler.anime2].frame_max - 10 end end # ステップ 5 に移行 battler.phase = 5 end #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 5 : ダメージ表示) #-------------------------------------------------------------------------- def update_phase4_step5(battler) # ダメージ表示 for target in battler.target if target.damage[battler] != nil target.damage_pop[battler] = true target.damage_effect(battler, battler.current_action.kind) battler.wait = @damage_wait # ステータスウィンドウをリフレッシュ status_refresh(target) end end # ステップ 6 に移行 battler.phase = 6 end #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 6 : リフレッシュ) #-------------------------------------------------------------------------- def update_phase4_step6(battler) # カメラを戻す if battler.target[0].is_a?(Game_Enemy) and @camera == battler @spriteset.screen_target(0, 0, 1) end # スキルラーニング if battler.target[0].is_a?(Game_Actor) and battler.current_action.kind == 1 for target in battler.target skill_learning(target, target.class_id, battler.current_action.skill_id) end end # アクション強制対象のバトラーをクリア if battler.current_action.forcing == true and battler.current_action.force_kind == 0 and battler.current_action.force_basic == 0 and battler.current_action.force_skill_id == 0 $game_temp.forcing_battler = nil battler.current_action.forcing = false end refresh_phase(battler) speller = synthe?(battler) if speller != nil for spell in speller if spell != battler refresh_phase(spell) end end synthe_delete(speller) end # コモンイベント ID が有効の場合 if battler.event > 0 # イベントをセットアップ common_event = $data_common_events[battler.event] $game_system.battle_interpreter.setup(common_event.list, 0) end act = 0 for actor in $game_party.actors + $game_troop.enemies if actor.movable? act += 1 end end if @turn_cnt >= act and act > 0 @turn_cnt %= act $game_temp.battle_turn += 1 # バトルイベントの全ページを検索 for index in 0...$data_troops[@troop_id].pages.size # イベントページを取得 page = $data_troops[@troop_id].pages[index] # このページのスパンが [ターン] の場合 if page.span == 1 # 実行済みフラグをクリア $game_temp.battle_event_flags[index] = false end end end battler.phase = 1 @action_battlers.delete(battler) end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh_phase(battler) battler.at -= @max if battler.movable? battler.atp = 100 * battler.at / @max end spell_reset(battler) # スリップダメージ if battler.hp > 0 and battler.slip_damage? battler.slip_damage_effect battler.damage_pop["slip"] = true end # ステート自然解除 battler.remove_states_auto # ステータスウィンドウをリフレッシュ status_refresh(battler, true) unless battler.movable? return end # ターン数カウント @turn_cnt += 1 end #-------------------------------------------------------------------------- # ● バトラーアクションスタート #-------------------------------------------------------------------------- def action_start(battler) battler.phase = 1 battler.anime1 = 0 battler.anime2 = 0 battler.target = [] battler.event = 0 @action_battlers.unshift(battler) end #-------------------------------------------------------------------------- # ● ステータスウィンドウをリフレッシュ #-------------------------------------------------------------------------- def status_refresh(battler, at = false) if battler.is_a?(Game_Actor) for i in 0...$game_party.actors.size if battler == $game_party.actors[i] number = i + 1 end end @status_window.refresh(number) if at == true @status_window.at_refresh(number) end end end #-------------------------------------------------------------------------- # ● アニメウェイト判断処理 #-------------------------------------------------------------------------- def anime_wait_return if (@action_battlers.empty? or @anime_wait == false) and not $game_system.battle_interpreter.running? # エネミーアローが有効の場合 if @enemy_arrow != nil return [@active - 2, 0].min == 0 # アクターアローが有効の場合 elsif @actor_arrow != nil return [@active - 2, 0].min == 0 # スキルウィンドウが有効の場合 elsif @skill_window != nil return [@active - 3, 0].min == 0 # アイテムウィンドウが有効の場合 elsif @item_window != nil return [@active - 3, 0].min == 0 # アクターコマンドウィンドウが有効の場合 elsif @actor_command_window.active return [@active - 1, 0].min == 0 else return true end else return false end end #-------------------------------------------------------------------------- # ● アクターコマンド消去判断 #-------------------------------------------------------------------------- def command_delete # エネミーアローが有効の場合 if @enemy_arrow != nil end_enemy_select # アクターアローが有効の場合 elsif @actor_arrow != nil end_actor_select end # スキルウィンドウが有効の場合 if @skill_window != nil end_skill_select # アイテムウィンドウが有効の場合 elsif @item_window != nil end_item_select end # アクターコマンドウィンドウが有効の場合 if @actor_command_window.active @command.shift @command_a = false # メインフェーズフラグをセット $game_temp.battle_main_phase = true # アクターコマンドウィンドウを無効化 @actor_command_window.active = false @actor_command_window.visible = false # アクターの明滅エフェクト OFF if @active_actor != nil @active_actor.blink = false end end end #-------------------------------------------------------------------------- # ● 強制アクション設定 #-------------------------------------------------------------------------- def force_action(battler) battler.current_action.kind = battler.current_action.force_kind battler.current_action.basic = battler.current_action.force_basic battler.current_action.skill_id = battler.current_action.force_skill_id battler.current_action.force_kind = 0 battler.current_action.force_basic = 0 battler.current_action.force_skill_id = 0 end #-------------------------------------------------------------------------- # ● カメラセット #-------------------------------------------------------------------------- def camera_set(battler) @camera = battler if battler.target.size == 1 if battler.current_action.kind == 0 zoom = 1.2 / battler.target[0].zoom elsif synthe?(battler) == nil zoom = 1.5 / battler.target[0].zoom else zoom = 2.0 / battler.target[0].zoom end @spriteset.screen_target(battler.target[0].attack_x(zoom), battler.target[0].attack_y(zoom), zoom) else @spriteset.screen_target(0, 0, 0.75) end end #-------------------------------------------------------------------------- # ● スキル詠唱タイム作成 #-------------------------------------------------------------------------- def recite_time(battler) end #-------------------------------------------------------------------------- # ● 連携スキル判別 #-------------------------------------------------------------------------- def synthe_spell(battler) end #-------------------------------------------------------------------------- # ● スキルラーニングシステム #-------------------------------------------------------------------------- def skill_learning(actor, class_id, skill_id) end #-------------------------------------------------------------------------- # ● 行動可能判定 #-------------------------------------------------------------------------- def active?(battler) speller = synthe?(battler) if speller != nil if synthe_delete?(speller) return false end else unless battler.inputable? spell_reset(battler) unless battler.movable? battler.atp = 0 return false end end if battler.current_action.forcing spell_reset(battler) end end return true end #-------------------------------------------------------------------------- # ● 合成スキル詠唱中か? #-------------------------------------------------------------------------- def synthe?(battler) for speller in @synthe if speller.include?(battler) return speller end end return nil end #-------------------------------------------------------------------------- # ● 合成スキル消去判断 #-------------------------------------------------------------------------- def synthe_delete?(speller) for battler in speller if not battler.inputable? and dead_ok?(battler) synthe_delete(speller) return true end end return false end #-------------------------------------------------------------------------- # ● 合成スキル消去 #-------------------------------------------------------------------------- def synthe_delete(speller) for battler in speller spell_reset(battler) if dead_ok?(battler) @action_battlers.delete(battler) end end @synthe.delete(speller) end #-------------------------------------------------------------------------- # ● 連携含むスキル詠唱解除 #-------------------------------------------------------------------------- def skill_reset(battler) speller = synthe?(battler) if speller != nil synthe_delete(speller) else spell_reset(battler) end end #-------------------------------------------------------------------------- # ● スキル詠唱解除 #-------------------------------------------------------------------------- def spell_reset(battler) battler.rt = 0 battler.rtp = 0 battler.blink = false battler.spell = false battler.current_action.spell_id = 0 @spell_p.delete(battler) @spell_e.delete(battler) end #-------------------------------------------------------------------------- # ● 戦闘終了判定 #-------------------------------------------------------------------------- def fin? return (victory? or $game_party.all_dead? or $game_party.actors.size == 0) end #-------------------------------------------------------------------------- # ● 敵全滅判定 #-------------------------------------------------------------------------- def victory? for battler in $game_troop.enemies if not battler.hidden and (battler.rest_hp > 0 or battler.immortal or battler.damage_pop.size > 0) return false end end return true end #-------------------------------------------------------------------------- # ● 死亡許可判定 #-------------------------------------------------------------------------- def dead_ok?(battler) speller = synthe?(battler) if speller == nil if @action_battlers.include?(battler) if battler.phase > 2 return false end end else for battler in speller if @action_battlers.include?(battler) if battler.phase > 2 return false end end end end return true end end #============================================================================== # ■ Game_Actor #------------------------------------------------------------------------------ # アクターを扱うクラスです。このクラスは Game_Actors クラス ($game_actors) # の内部で使用され、Game_Party クラス ($game_party) からも参照されます。 #============================================================================== class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # ● バトル画面 X 座標の取得 #-------------------------------------------------------------------------- def screen_x # パーティ内の並び順から X 座標を計算して返す if self.index != nil return self.index * 160 + (4 - $game_party.actors.size) * 80 + 80 else return 0 end end end #============================================================================== # ■ Spriteset_Battle #------------------------------------------------------------------------------ # バトル画面のスプライトをまとめたクラスです。このクラスは Scene_Battle クラ # スの内部で使用されます。 #============================================================================== class Spriteset_Battle #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :real_x # x座標補正(現在値) attr_reader :real_y # y座標補正(現在値) attr_reader :real_zoom # 拡大率(現在値) #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize # ビューポートを作成 @viewport1 = Viewport.new(0, 0, 640, 480) @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 @wait = 0 @real_x = 0 @real_y = 0 @real_zoom = 1.0 @target_x = 0 @target_y = 0 @target_zoom = 1.0 @gap_x = 0 @gap_y = 0 @gap_zoom = 0.0 # バトルバックスプライトを作成 @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 = [] @actor_sprites.push(Sprite_Battler.new(@viewport2)) @actor_sprites.push(Sprite_Battler.new(@viewport2)) @actor_sprites.push(Sprite_Battler.new(@viewport2)) @actor_sprites.push(Sprite_Battler.new(@viewport2)) # 天候を作成 @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 #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update # アクタースプライトの内容を更新 (アクターの入れ替えに対応) @actor_sprites[0].battler = $game_party.actors[0] @actor_sprites[1].battler = $game_party.actors[1] @actor_sprites[2].battler = $game_party.actors[2] @actor_sprites[3].battler = $game_party.actors[3] # バトルバックのファイル名が現在のものと違う場合 if @battleback_name != $game_temp.battleback_name make_battleback end # 画面のスクロール screen_scroll # モンスターの位置補正 for enemy in $game_troop.enemies enemy.real_x = @real_x enemy.real_y = @real_y enemy.real_zoom = @real_zoom end # バトラースプライトを更新 for sprite in @enemy_sprites + @actor_sprites sprite.update end # 天候グラフィックを更新 @weather.type = $game_screen.weather_type @weather.max = $game_screen.weather_max @weather.update # ピクチャスプライトを更新 for sprite in @picture_sprites sprite.update end # タイマースプライトを更新 @timer_sprite.update # 画面の色調とシェイク位置を設定 @viewport1.tone = $game_screen.tone @viewport1.ox = $game_screen.shake # 画面のフラッシュ色を設定 @viewport4.color = $game_screen.flash_color # ビューポートを更新 @viewport1.update @viewport2.update @viewport4.update end #-------------------------------------------------------------------------- # ● バトル背景の設定 #-------------------------------------------------------------------------- def make_battleback @battleback_name = $game_temp.battleback_name if @battleback_sprite.bitmap != nil @battleback_sprite.bitmap.dispose end @battleback_sprite.bitmap = RPG::Cache.battleback(@battleback_name) if @battleback_sprite.bitmap.width == 640 and @battleback_sprite.bitmap.height == 320 @battleback_sprite.src_rect.set(0, 0, 1280, 640) @base_zoom = 2.0 @battleback_sprite.zoom_x = @base_zoom @battleback_sprite.zoom_y = @base_zoom @real_y = 4 @battleback_sprite.x = 320 @battleback_sprite.y = @real_y @battleback_sprite.ox = @battleback_sprite.bitmap.width / 2 @battleback_sprite.oy = @battleback_sprite.bitmap.height / 4 elsif @battleback_sprite.bitmap.width == 640 and @battleback_sprite.bitmap.height == 480 @battleback_sprite.src_rect.set(0, 0, 960, 720) @base_zoom = 1.5 @battleback_sprite.zoom_x = @base_zoom @battleback_sprite.zoom_y = @base_zoom @battleback_sprite.x = 320 @battleback_sprite.y = 0 @battleback_sprite.ox = @battleback_sprite.bitmap.width / 2 @battleback_sprite.oy = @battleback_sprite.bitmap.height / 4 else @battleback_sprite.src_rect.set(0, 0, @battleback_sprite.bitmap.width, @battleback_sprite.bitmap.height) @base_zoom = 1.0 @battleback_sprite.zoom_x = @base_zoom @battleback_sprite.zoom_y = @base_zoom @battleback_sprite.x = 320 @battleback_sprite.y = 0 @battleback_sprite.ox = @battleback_sprite.bitmap.width / 2 @battleback_sprite.oy = @battleback_sprite.bitmap.height / 4 end end #-------------------------------------------------------------------------- # ● 画面のスクロール目標の位置・拡大率設定 #-------------------------------------------------------------------------- def screen_target(x, y, zoom) return unless $scene.drive @wait = $scene.scroll_time @target_x = x @target_y = y @target_zoom = zoom screen_over @gap_x = @target_x - @real_x @gap_y = @target_y - @real_y @gap_zoom = @target_zoom - @real_zoom end #-------------------------------------------------------------------------- # ● 画面のスクロール #-------------------------------------------------------------------------- def screen_scroll if @wait > 0 @real_x = @target_x - @gap_x * (@wait ** 2) / ($scene.scroll_time ** 2) @real_y = @target_y - @gap_y * (@wait ** 2) / ($scene.scroll_time ** 2) @real_zoom = @target_zoom - @gap_zoom * (@wait ** 2) / ($scene.scroll_time ** 2) @battleback_sprite.x = 320 + @real_x @battleback_sprite.y = @real_y @battleback_sprite.zoom_x = @base_zoom * @real_zoom @battleback_sprite.zoom_y = @base_zoom * @real_zoom @battleback_sprite.ox = @battleback_sprite.bitmap.width / 2 @battleback_sprite.oy = @battleback_sprite.bitmap.height / 4 @wait -= 1 end end #-------------------------------------------------------------------------- # ● スクリーンが画面外に出た時の補正処理 #-------------------------------------------------------------------------- def screen_over width = @battleback_sprite.bitmap.width * @base_zoom * @target_zoom / 2 unless 324 + @target_x > width and 324 - @target_x > width if 324 + @target_x > width @target_x = width - 324 elsif 324 - @target_x > width @target_x = 324 - width end end height = @battleback_sprite.bitmap.height * @base_zoom * @target_zoom / 4 unless @target_y > height - 4 and 484 - @target_y > 3 * height if @target_y > height - 4 @target_y = height - 4 elsif 484 - @target_y > 3 * height @target_y = 484 - 3 * height end end end end #============================================================================== # ■ Game_Battler (分割定義 1) #------------------------------------------------------------------------------ # バトラーを扱うクラスです。このクラスは Game_Actor クラスと Game_Enemy クラ # スのスーパークラスとして使用されます。 #============================================================================== class Game_Battler #-------------------------------------------------------------------------- # ● 公開インスタンス変数追加 #-------------------------------------------------------------------------- attr_accessor :up_level # レベルアップ数 attr_accessor :at # AT(タイムゲージ) attr_accessor :atp # AT(表示用) attr_accessor :rt # RP(詠唱ゲージ) attr_accessor :rtp # RP(詠唱必要量) attr_accessor :spell # 合成スキル発動中 attr_accessor :recover_hp # HP回復量 attr_accessor :recover_sp # SP回復量 attr_accessor :state_p # ステータス異常配列 attr_accessor :state_m # ステータス異常配列 attr_accessor :damage_sp # SPダメージ表示フラグ attr_accessor :animation # アニメーション ID, Hitの配列 attr_accessor :phase attr_accessor :wait attr_accessor :target attr_accessor :anime1 attr_accessor :anime2 attr_accessor :event #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias :initialize_rtab :initialize def initialize initialize_rtab @damage_pop = {} @damage = {} @damage_sp = {} @critical = {} @recover_hp = {} @recover_sp = {} @state_p = {} @state_m = {} @animation = [] @phase = 1 @wait = 0 @target = [] @anime1 = 0 @anime2 = 0 @event = 0 end #-------------------------------------------------------------------------- # ● 存在判定 #-------------------------------------------------------------------------- def exist? return (not @hidden and (@hp > 0 or @immortal or @damage.size > 0)) end #-------------------------------------------------------------------------- # ● 残HP予測 #-------------------------------------------------------------------------- def rest_hp # rest_hp に現HPを代入 rest_hp = @hp # バトラーが受ける全ダメージをrest_hpに反映させる for pre_damage in @damage if pre_damage[1].is_a?(Numeric) rest_hp -= pre_damage[1] end end return rest_hp end #-------------------------------------------------------------------------- # ● ステートの解除 # state_id : ステート ID # force : 強制解除フラグ (オートステートの処理で使用) #-------------------------------------------------------------------------- def remove_state(state_id, force = false) # このステートが付加されている場合 if state?(state_id) # 強制付加されたステートで、かつ解除が強制ではない場合 if @states_turn[state_id] == -1 and not force # メソッド終了 return end # 現在の HP が 0 かつ オプション [HP 0 の状態とみなす] が有効の場合 if @hp == 0 and $data_states[state_id].zero_hp # ほかに [HP 0 の状態とみなす] ステートがあるかどうか判定 zero_hp = false for i in @states if i != state_id and $data_states[i].zero_hp zero_hp = true end end # 戦闘不能を解除してよければ、HP を 1 に変更 if zero_hp == false @hp = 1 end end unless self.movable? # ステート ID を @states 配列および @states_turn ハッシュから削除 @states.delete(state_id) @states_turn.delete(state_id) if self.movable? self.at = 0 end else # ステート ID を @states 配列および @states_turn ハッシュから削除 @states.delete(state_id) @states_turn.delete(state_id) end end # HP および SP の最大値チェック @hp = [@hp, self.maxhp].min @sp = [@sp, self.maxsp].min end #-------------------------------------------------------------------------- # ● 通常攻撃の効果適用 # attacker : 攻撃者 (バトラー) #-------------------------------------------------------------------------- def attack_effect(attacker) # クリティカルフラグをクリア self.critical[attacker] = false state_p[attacker] = [] state_m[attacker] = [] # 第一命中判定 hit_result = (rand(100) < attacker.hit) # 命中の場合 if hit_result == true # 基本ダメージを計算 atk = [attacker.atk - self.pdef / 2, 0].max self.damage[attacker] = atk * (20 + attacker.str) / 20 # 属性修正 self.damage[attacker] *= elements_correct(attacker.element_set) self.damage[attacker] /= 100 # ダメージの符号が正の場合 if self.damage[attacker] > 0 # クリティカル修正 if rand(100) < 4 * attacker.dex / self.agi self.damage[attacker] *= 2 self.critical[attacker] = true end # 防御修正 if self.guarding? self.damage[attacker] /= 2 end end # 分散 if self.damage[attacker].abs > 0 amp = [self.damage[attacker].abs * 15 / 100, 1].max self.damage[attacker] += rand(amp+1) + rand(amp+1) - amp end # 第二命中判定 eva = 8 * self.agi / attacker.dex + self.eva hit = self.damage[attacker] < 0 ? 100 : 100 - eva hit = self.cant_evade? ? 100 : hit hit_result = (rand(100) < hit) end # 命中の場合 if hit_result == true # ステート衝撃解除 remove_states_shock # HP からダメージを減算 # ステート変化 @state_changed = false states_plus(attacker, attacker.plus_state_set) states_minus(attacker, attacker.minus_state_set) # ミスの場合 else # ダメージに "Miss" を設定 self.damage[attacker] = "Miss" # クリティカルフラグをクリア self.critical[attacker] = false end # メソッド終了 return true end #-------------------------------------------------------------------------- # ● スキルの効果適用 # user : スキルの使用者 (バトラー) # skill : スキル #-------------------------------------------------------------------------- def skill_effect(user, skill) # クリティカルフラグをクリア self.critical[user] = false state_p[user] = [] state_m[user] = [] # スキルの効果範囲が HP 1 以上の味方で、自分の HP が 0、 # またはスキルの効果範囲が HP 0 の味方で、自分の HP が 1 以上の場合 if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0)# or # ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1) # メソッド終了 return false end # 有効フラグをクリア effective = false # コモンイベント ID が有効の場合は有効フラグをセット effective |= skill.common_event_id > 0 # 第一命中判定 hit = skill.hit if skill.atk_f > 0 hit *= user.hit / 100 end hit_result = (rand(100) < hit) # 不確実なスキルの場合は有効フラグをセット effective |= hit < 100 # 命中の場合 if hit_result == true # 威力を計算 power = skill.power + user.atk * skill.atk_f / 100 if power > 0 power -= self.pdef * skill.pdef_f / 200 power -= self.mdef * skill.mdef_f / 200 power = [power, 0].max end # 倍率を計算 rate = 20 rate += (user.str * skill.str_f / 100) rate += (user.dex * skill.dex_f / 100) rate += (user.agi * skill.agi_f / 100) rate += (user.int * skill.int_f / 100) # 基本ダメージを計算 self.damage[user] = power * rate / 20 # 属性修正 self.damage[user] *= elements_correct(skill.element_set) self.damage[user] /= 100 # ダメージの符号が正の場合 if self.damage[user] > 0 # 防御修正 if self.guarding? self.damage[user] /= 2 end end # 分散 if skill.variance > 0 and self.damage[user].abs > 0 amp = [self.damage[user].abs * skill.variance / 100, 1].max self.damage[user] += rand(amp+1) + rand(amp+1) - amp end # 第二命中判定 eva = 8 * self.agi / user.dex + self.eva hit = self.damage[user] < 0 ? 100 : 100 - eva * skill.eva_f / 100 hit = self.cant_evade? ? 100 : hit hit_result = (rand(100) < hit) # 不確実なスキルの場合は有効フラグをセット effective |= hit < 100 end # 命中の場合 if hit_result == true # 威力 0 以外の物理攻撃の場合 if skill.power != 0 and skill.atk_f > 0 # ステート衝撃解除 remove_states_shock # 有効フラグをセット effective = true end # HP の変動判定 last_hp = [[self.hp - self.damage[user], self.maxhp].min, 0].max # 効果判定 effective |= self.hp != last_hp # ステート変化 @state_changed = false effective |= states_plus(user, skill.plus_state_set) effective |= states_minus(user, skill.minus_state_set) unless $game_temp.in_battle self.damage_effect(user, 1, skill) end # 威力が 0 の場合 if skill.power == 0 # ダメージに空文字列を設定 self.damage[user] = "" # ステートに変化がない場合 unless @state_changed # ダメージに "Miss" を設定 self.damage[user] = "Miss" end end # ミスの場合 else # ダメージに "Miss" を設定 self.damage[user] = "Miss" end # 戦闘中でない場合 unless $game_temp.in_battle # ダメージに nil を設定 self.damage[user] = nil end # メソッド終了 return effective end #-------------------------------------------------------------------------- # ● アイテムの効果適用 # item : アイテム #-------------------------------------------------------------------------- def item_effect(item, user = $game_party.actors[0]) # クリティカルフラグをクリア self.critical[user] = false state_p[user] = [] state_m[user] = [] self.recover_hp[user] = 0 self.recover_sp[user] = 0 # アイテムの効果範囲が HP 1 以上の味方で、自分の HP が 0、 # またはアイテムの効果範囲が HP 0 の味方で、自分の HP が 1 以上の場合 if ((item.scope == 3 or item.scope == 4) and self.hp == 0)# or # ((item.scope == 5 or item.scope == 6) and self.hp >= 1) # メソッド終了 return false end # 有効フラグをクリア effective = false # コモンイベント ID が有効の場合は有効フラグをセット effective |= item.common_event_id > 0 # 命中判定 hit_result = (rand(100) < item.hit) # 不確実なスキルの場合は有効フラグをセット effective |= item.hit < 100 # 命中の場合 if hit_result == true # 回復量を計算 self.recover_hp[user] = maxhp * item.recover_hp_rate / 100 + item.recover_hp self.recover_sp[user] = maxsp * item.recover_sp_rate / 100 + item.recover_sp if self.recover_hp[user] < 0 self.recover_hp[user] += self.pdef * item.pdef_f / 20 self.recover_hp[user] += self.mdef * item.mdef_f / 20 self.recover_hp[user] = [self.recover_hp[user], 0].min end # 属性修正 self.recover_hp[user] *= elements_correct(item.element_set) self.recover_hp[user] /= 100 self.recover_sp[user] *= elements_correct(item.element_set) self.recover_sp[user] /= 100 # 分散 if item.variance > 0 and self.recover_hp[user].abs > 0 amp = [self.recover_hp[user].abs * item.variance / 100, 1].max self.recover_hp[user] += rand(amp+1) + rand(amp+1) - amp end if item.variance > 0 and self.recover_sp[user].abs > 0 amp = [self.recover_sp[user].abs * item.variance / 100, 1].max self.recover_sp[user] += rand(amp+1) + rand(amp+1) - amp end # 回復量の符号が負の場合 if self.recover_hp[user] < 0 # 防御修正 if self.guarding? self.recover_hp[user] /= 2 end end # HP 回復量の符号を反転し、ダメージの値に設定 self.damage[user] = -self.recover_hp[user] # HP および SP の変動判定 last_hp = [[self.hp + self.recover_hp[user], self.maxhp].min, 0].max last_sp = [[self.sp + self.recover_sp[user], self.maxsp].min, 0].max effective |= self.hp != last_hp effective |= self.sp != last_sp # ステート変化 @state_changed = false effective |= states_plus(user, item.plus_state_set) effective |= states_minus(user, item.minus_state_set) unless $game_temp.in_battle self.damage_effect(user, 2, nil) end # パラメータ上昇値が有効の場合 if item.parameter_type > 0 and item.parameter_points != 0 # パラメータで分岐 case item.parameter_type when 1 # MaxHP @maxhp_plus += item.parameter_points when 2 # MaxSP @maxsp_plus += item.parameter_points when 3 # 腕力 @str_plus += item.parameter_points when 4 # 器用さ @dex_plus += item.parameter_points when 5 # 素早さ @agi_plus += item.parameter_points when 6 # 魔力 @int_plus += item.parameter_points end # 有効フラグをセット effective = true end # HP 回復率と回復量が 0 の場合 if item.recover_hp_rate == 0 and item.recover_hp == 0 # ダメージに空文字列を設定 self.damage[user] = "" # SP 回復率と回復量が 0、パラメータ上昇値が無効の場合 if item.recover_sp_rate == 0 and item.recover_sp == 0 and (item.parameter_type == 0 or item.parameter_points == 0) # ステートに変化がない場合 unless @state_changed # ダメージに "Miss" を設定 self.damage[user] = "Miss" end end end # ミスの場合 else # ダメージに "Miss" を設定 self.damage[user] = "Miss" end # 戦闘中でない場合 unless $game_temp.in_battle # ダメージに nil を設定 self.damage[user] = nil end # メソッド終了 return effective end #-------------------------------------------------------------------------- # ● ステート変化 (+) の適用 # plus_state_set : ステート変化 (+) #-------------------------------------------------------------------------- def states_plus(battler, plus_state_set) # 有効フラグをクリア effective = false # ループ (付加するステート) for i in plus_state_set # このステートが防御されていない場合 unless self.state_guard?(i) # このステートがフルでなければ有効フラグをセット effective |= self.state_full?(i) == false # ステートが [抵抗しない] の場合 if $data_states[i].nonresistance # ステート変化フラグをセット @state_changed = true # ステートを付加 self.state_p[battler].push(i) # このステートがフルではない場合 elsif self.state_full?(i) == false # ステート有効度を確率に変換し、乱数と比較 if rand(100) < [0,100,80,60,40,20,0][self.state_ranks[i]] # ステート変化フラグをセット @state_changed = true # ステートを付加 self.state_p[battler].push(i) end end end end # メソッド終了 return effective end #-------------------------------------------------------------------------- # ● ステート変化 (-) の適用 # minus_state_set : ステート変化 (-) #-------------------------------------------------------------------------- def states_minus(battler, minus_state_set) # 有効フラグをクリア effective = false # ループ (解除するステート) for i in minus_state_set # このステートが付加されていれば有効フラグをセット effective |= self.state?(i) # ステート変化フラグをセット @state_changed = true # ステートを解除 self.state_m[battler].push(i) end # メソッド終了 return effective end #-------------------------------------------------------------------------- # ● ダメージ演算 #-------------------------------------------------------------------------- def damage_effect(battler, item) if item == 2 self.hp += self.recover_hp[battler] self.sp += self.recover_sp[battler] if self.recover_sp[battler] != 0 self.damage_sp[battler] = -self.recover_sp[battler] end self.recover_hp.delete(battler) self.recover_sp.delete(battler) else if self.damage[battler].class != String self.hp -= self.damage[battler] end end for i in self.state_p[battler] add_state(i) end for i in self.state_m[battler] remove_state(i) end end #-------------------------------------------------------------------------- # ● スリップダメージの効果適用 #-------------------------------------------------------------------------- def slip_damage_effect # ダメージを設定 self.damage["slip"] = self.maxhp / 10 # 分散 if self.damage["slip"].abs > 0 amp = [self.damage["slip"].abs * 15 / 100, 1].max self.damage["slip"] += rand(amp+1) + rand(amp+1) - amp end # HP からダメージを減算 self.hp -= self.damage["slip"] # メソッド終了 return true end end #============================================================================== # ■ Game_BattleAction #------------------------------------------------------------------------------ # アクション (戦闘中の行動) を扱うクラスです。このクラスは Game_Battler クラ # スの内部で使用されます。 #============================================================================== class Game_BattleAction #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :spell_id # 合体魔法用スキル ID attr_accessor :force_kind # 種別 (基本 / スキル / アイテム) attr_accessor :force_basic # 基本 (攻撃 / 防御 / 逃げる) attr_accessor :force_skill_id # スキル ID #-------------------------------------------------------------------------- # ● 有効判定 #-------------------------------------------------------------------------- def valid? return (not (@force_kind == 0 and @force_basic == 3)) end end #============================================================================== # ■ Game_Actor #------------------------------------------------------------------------------ # アクターを扱うクラスです。このクラスは Game_Actors クラス ($game_actors) # の内部で使用され、Game_Party クラス ($game_party) からも参照されます。 #============================================================================== class Game_Actor < Game_Battler def skill_can_use?(skill_id) return super end end #============================================================================== # ■ Game_Enemy #------------------------------------------------------------------------------ # エネミーを扱うクラスです。このクラスは Game_Troop クラス ($game_troop) の # 内部で使用されます。 #============================================================================== class Game_Enemy < Game_Battler #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :height # 画像の高さ attr_accessor :real_x # X座標補正 attr_accessor :real_y # Y座標補正 attr_accessor :real_zoom # 拡大率 #-------------------------------------------------------------------------- # ● オブジェクト初期化 # troop_id : トループ ID # member_index : トループメンバーのインデックス #-------------------------------------------------------------------------- def initialize(troop_id, member_index) super() @troop_id = troop_id @member_index = member_index troop = $data_troops[@troop_id] @enemy_id = troop.members[@member_index].enemy_id enemy = $data_enemies[@enemy_id] @battler_name = enemy.battler_name @battler_hue = enemy.battler_hue @hp = maxhp @sp = maxsp @real_x = 0 @real_y = 0 @real_zoom = 1.0 @fly = 0 enemy.name.sub(/\\[Ff]\[([0-9]+)\]/) {@fly = $1.to_i} @hidden = troop.members[@member_index].hidden @immortal = troop.members[@member_index].immortal end alias :true_x :screen_x alias :true_y :screen_y #-------------------------------------------------------------------------- # ● バトル画面 X 座標の取得 #-------------------------------------------------------------------------- def screen_x return 320 + (true_x - 320) * @real_zoom + @real_x end #-------------------------------------------------------------------------- # ● バトル画面 Y 座標の取得 #-------------------------------------------------------------------------- def screen_y return true_y * @real_zoom + @real_y end #-------------------------------------------------------------------------- # ● バトル画面 Z 座標の取得 #-------------------------------------------------------------------------- def screen_z return true_y + @fly end #-------------------------------------------------------------------------- # ● バトル画面 拡大率の取得 #-------------------------------------------------------------------------- def zoom return ($scene.zoom_rate[1] - $scene.zoom_rate[0]) * (true_y + @fly) / 320 + $scene.zoom_rate[0] end #-------------------------------------------------------------------------- # ● 攻撃用、バトル画面 X 座標の取得 #-------------------------------------------------------------------------- def attack_x(z) return (320 - true_x) * z * 0.75 end #-------------------------------------------------------------------------- # ● 攻撃用、バトル画面 Y 座標の取得 #-------------------------------------------------------------------------- def attack_y(z) return (160 - (true_y + @fly / 4) * z + @height * zoom * z / 2) * 0.75 end #-------------------------------------------------------------------------- # ● アクション作成 #-------------------------------------------------------------------------- def make_action # カレントアクションをクリア self.current_action.clear # 動けない場合 unless self.inputable? # メソッド終了 return end # 現在有効なアクションを抽出 available_actions = [] rating_max = 0 for action in self.actions # ターン 条件確認 n = $game_temp.battle_turn a = action.condition_turn_a b = action.condition_turn_b if (b == 0 and n != a) or (b > 0 and (n < 1 or n < a or n % b != a % b)) next end # HP 条件確認 if self.hp * 100.0 / self.maxhp > action.condition_hp next end # レベル 条件確認 if $game_party.max_level < action.condition_level next end # スイッチ 条件確認 switch_id = action.condition_switch_id if switch_id > 0 and $game_switches[switch_id] == false next end # スキル使用可能 条件確認 if action.kind == 1 unless self.skill_can_use?(action.skill_id) next end end # 条件に該当 : このアクションを追加 available_actions.push(action) if action.rating > rating_max rating_max = action.rating end end # 最大のレーティング値を 3 として合計を計算 (0 以下は除外) ratings_total = 0 for action in available_actions if action.rating > rating_max - 3 ratings_total += action.rating - (rating_max - 3) end end # レーティングの合計が 0 ではない場合 if ratings_total > 0 # 乱数を作成 value = rand(ratings_total) # 作成した乱数に対応するものをカレントアクションに設定 for action in available_actions if action.rating > rating_max - 3 if value < action.rating - (rating_max - 3) self.current_action.kind = action.kind self.current_action.basic = action.basic self.current_action.skill_id = action.skill_id self.current_action.decide_random_target_for_enemy return else value -= action.rating - (rating_max - 3) end end end end end end #============================================================================== # ■ Game_Party #------------------------------------------------------------------------------ # パーティを扱うクラスです。ゴールドやアイテムなどの情報が含まれます。このク # ラスのインスタンスは $game_party で参照されます。 #============================================================================== class Game_Party #-------------------------------------------------------------------------- # ● 全滅判定 #-------------------------------------------------------------------------- def all_dead? # パーティ人数が 0 人の場合 if $game_party.actors.size == 0 return false end # HP 0 以上のアクターがパーティにいる場合 for actor in @actors if actor.rest_hp > 0 return false end end # 全滅 return true end #-------------------------------------------------------------------------- # ● 対象アクターのランダムな決定 # hp0 : HP 0 のアクターに限る #-------------------------------------------------------------------------- # オリジナルのターゲット決定ルーチンを smooth_target_actor_rtab と名前変更 alias :random_target_actor_rtab :random_target_actor def random_target_actor(hp0 = false) # ルーレットを初期化 roulette = [] # ループ for actor in @actors # 条件に該当する場合 if (not hp0 and actor.exist? and actor.rest_hp > 0) or (hp0 and actor.hp0?) # アクターのクラスの [位置] を取得 position = $data_classes[actor.class_id].position # 前衛のとき n = 4、中衛のとき n = 3、後衛のとき n = 2 n = 4 - position # ルーレットにアクターを n 回追加 n.times do roulette.push(actor) end end end # ルーレットのサイズが 0 の場合 if roulette.size == 0 return random_target_actor_rtab(hp0) end # ルーレットを回し、アクターを決定 return roulette[rand(roulette.size)] end #-------------------------------------------------------------------------- # ● 対象アクターのスムーズな決定 # actor_index : アクターインデックス #-------------------------------------------------------------------------- # オリジナルのターゲット決定ルーチンを smooth_target_actor_rtab と名前変更 alias :smooth_target_actor_rtab :smooth_target_actor def smooth_target_actor(actor_index) # アクターを取得 actor = @actors[actor_index] # アクターが存在する場合 if actor != nil and actor.exist? and actor.rest_hp > 0 return actor end # ループ for actor in @actors # アクターが存在する場合 if actor.exist? and actor.rest_hp > 0 return actor end end # 味方が全滅している場合、オリジナルのターゲット決定ルーチンを実行する return smooth_target_actor_rtab(actor_index) end end #============================================================================== # ■ Game_Troop #------------------------------------------------------------------------------ # トループを扱うクラスです。このクラスのインスタンスは $game_troop で参照さ # れます。 #============================================================================== class Game_Troop #-------------------------------------------------------------------------- # ● 対象エネミーのランダムな決定 # hp0 : HP 0 のエネミーに限る #-------------------------------------------------------------------------- # オリジナルのターゲット決定ルーチンを random_target_enemy_rtab と名前変更 alias :random_target_enemy_rtab :random_target_enemy def random_target_enemy(hp0 = false) # ルーレットを初期化 roulette = [] # ループ for enemy in @enemies # 条件に該当する場合 if (not hp0 and enemy.exist? and enemy.rest_hp > 0) or (hp0 and enemy.hp0?) # ルーレットにエネミーを追加 roulette.push(enemy) end end # ルーレットのサイズが 0 の場合 if roulette.size == 0 return random_target_enemy_rtab(hp0) end # ルーレットを回し、エネミーを決定 return roulette[rand(roulette.size)] end #-------------------------------------------------------------------------- # ● 対象エネミーのスムーズな決定 # enemy_index : エネミーインデックス #-------------------------------------------------------------------------- # オリジナルのターゲット決定ルーチンを smooth_target_enemy_rtab と名前変更 alias :smooth_target_enemy_rtab :smooth_target_enemy def smooth_target_enemy(enemy_index) # エネミーを取得 enemy = @enemies[enemy_index] # エネミーが存在する場合 if enemy != nil and enemy.exist? and enemy.rest_hp > 0 return enemy end # ループ for enemy in @enemies # エネミーが存在する場合 if enemy.exist? and enemy.rest_hp > 0 return enemy end end # 敵が全滅している場合、再度敵の検索を行う return smooth_target_enemy_rtab(enemy_index) end end #============================================================================== # ■ Sprite_Battler #------------------------------------------------------------------------------ # バトラー表示用のスプライトです。Game_Battler クラスのインスタンスを監視し、 # スプライトの状態を自動的に変化させます。 #============================================================================== class Sprite_Battler < RPG::Sprite #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super # バトラーが nil の場合 if @battler == nil self.bitmap = nil loop_animation(nil) return end # ファイル名か色相が現在のものと異なる場合 if @battler.battler_name != @battler_name or @battler.battler_hue != @battler_hue # ビットマップを取得、設定 @battler_name = @battler.battler_name @battler_hue = @battler.battler_hue self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue) @width = bitmap.width @height = bitmap.height self.ox = @width / 2 self.oy = @height if @battler.is_a?(Game_Enemy) @battler.height = @height end # 戦闘不能または隠れ状態なら不透明度を 0 にする if @battler.dead? or @battler.hidden self.opacity = 0 end end # アニメーション ID が現在のものと異なる場合 if @battler.state_animation_id != @state_animation_id @state_animation_id = @battler.state_animation_id loop_animation($data_animations[@state_animation_id]) end # 表示されるべきアクターの場合 if @battler.is_a?(Game_Actor) and @battler_visible # メインフェーズでないときは不透明度をやや下げる if $game_temp.battle_main_phase self.opacity += 3 if self.opacity < 255 else self.opacity -= 3 if self.opacity > 207 end end # 明滅 if @battler.blink blink_on else blink_off end # 不可視の場合 unless @battler_visible # 出現 if not @battler.hidden and not @battler.dead? and (@battler.damage.size < 2 or @battler.damage_pop.size < 2) appear @battler_visible = true end end # ダメージ for battler in @battler.damage_pop if battler[0].class == Array if battler[0][1] >= 0 $scene.skill_se else $scene.levelup_se end damage(@battler.damage[battler[0]], false, 2) else damage(@battler.damage[battler[0]], @battler.critical[battler[0]]) end if @battler.damage_sp.include?(battler[0]) damage(@battler.damage_sp[battler[0]], @battler.critical[battler[0]], 1) @battler.damage_sp.delete(battler[0]) end @battler.damage_pop.delete(battler[0]) @battler.damage.delete(battler[0]) @battler.critical.delete(battler[0]) 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 # アニメーション unless @battler.animation.empty? for animation in @battler.animation.reverse animation($data_animations[animation[0]], animation[1]) @battler.animation.delete(animation) end end # コラプス if @battler.damage.empty? and @battler.dead? if $scene.dead_ok?(@battler) if @battler.is_a?(Game_Enemy) $game_system.se_play($data_system.enemy_collapse_se) else $game_system.se_play($data_system.actor_collapse_se) end collapse @battler_visible = false end end end # スプライトの座標を設定 self.x = @battler.screen_x self.y = @battler.screen_y self.z = @battler.screen_z if @battler.is_a?(Game_Enemy) self.zoom_x = @battler.real_zoom * @battler.zoom self.zoom_y = @battler.real_zoom * @battler.zoom end end end #============================================================================== # ■ Window_Base #------------------------------------------------------------------------------ # ゲーム中のすべてのウィンドウのスーパークラスです。 #============================================================================== class Window_Base < Window #-------------------------------------------------------------------------- # ● ゲージの描画 #-------------------------------------------------------------------------- def gauge_rect_at(width, height, align3, color1, color2, color3, color4, color5, color6, color7, color8, color9, color10, color11, color12, grade1, grade2) # 枠描画 @at_gauge = Bitmap.new(width, height * 5) @at_gauge.fill_rect(0, 0, width, height, color1) @at_gauge.fill_rect(1, 1, width - 2, height - 2, color2) if (align3 == 1 and grade1 == 0) or grade1 > 0 color = color3 color3 = color4 color4 = color end if (align3 == 1 and grade2 == 0) or grade2 > 0 color = color5 color5 = color6 color6 = color color = color7 color7 = color8 color8 = color color = color9 color9 = color10 color10 = color color = color11 color11 = color12 color12 = color end if align3 == 0 if grade1 == 2 grade1 = 3 end if grade2 == 2 grade2 = 3 end end # 空ゲージの描画 縦にグラデーション表示 @at_gauge.gradation_rect(2, 2, width - 4, height - 4, color3, color4, grade1) # 実ゲージの描画 @at_gauge.gradation_rect(2, height + 2, width- 4, height - 4, color5, color6, grade2) @at_gauge.gradation_rect(2, height * 2 + 2, width- 4, height - 4, color7, color8, grade2) @at_gauge.gradation_rect(2, height * 3 + 2, width- 4, height - 4, color9, color10, grade2) @at_gauge.gradation_rect(2, height * 4 + 2, width- 4, height - 4, color11, color12, grade2) end end #============================================================================== # ■ Window_Help #------------------------------------------------------------------------------ # スキルやアイテムの説明、アクターのステータスなどを表示するウィンドウです。 #============================================================================== class Window_Help < Window_Base #-------------------------------------------------------------------------- # ● エネミー設定 # enemy : 名前とステートを表示するエネミー #-------------------------------------------------------------------------- def set_enemy(enemy) text = enemy.name.sub(/\\[Ff]\[([0-9]+)\]/) {""} state_text = make_battler_state_text(enemy, 112, false) if state_text != "" text += " " + state_text end set_text(text, 1) end end #============================================================================== # ■ Window_BattleStatus #------------------------------------------------------------------------------ # バトル画面でパーティメンバーのステータスを表示するウィンドウです。 #============================================================================== class Window_BattleStatus < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize x = (4 - $game_party.actors.size) * 80 width = $game_party.actors.size * 160 super(x, 320, width, 160) self.back_opacity = 160 @actor_window = [] for i in 0...$game_party.actors.size @actor_window.push(Window_ActorStatus.new(i, x + i * 160)) end @level_up_flags = [false, false, false, false] refresh end #-------------------------------------------------------------------------- # ● 解放 #-------------------------------------------------------------------------- def dispose for window in @actor_window window.dispose end super end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh(number = 0) if number == 0 cnt = 0 for window in @actor_window window.refresh(@level_up_flags[cnt]) cnt += 1 end else @actor_window[number - 1].refresh(@level_up_flags[number - 1]) end end #-------------------------------------------------------------------------- # ● ATゲージリフレッシュ #-------------------------------------------------------------------------- def at_refresh(number = 0) if number == 0 for window in @actor_window window.at_refresh end else @actor_window[number - 1].at_refresh end end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super if self.x != (4 - $game_party.actors.size) * 80 self.x = (4 - $game_party.actors.size) * 80 self.width = $game_party.actors.size * 160 for window in @actor_window window.dispose end @actor_window = [] for i in 0...$game_party.actors.size @actor_window.push(Window_ActorStatus.new(i, x + i * 160)) end refresh end for window in @actor_window window.update end end end #============================================================================== # ■ Window_ActorStatus #------------------------------------------------------------------------------ # バトル画面でパーティメンバーのステータスをそれぞれ表示するウィンドウです。 #============================================================================== class Window_ActorStatus < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(id, x) @actor_num = id super(x, 320, 160, 160) self.contents = Bitmap.new(width - 32, height - 32) self.opacity = 0 self.back_opacity = 0 actor = $game_party.actors[@actor_num] @actor_nm = actor.name @actor_mhp = actor.maxhp @actor_msp = actor.maxsp @actor_hp = actor.hp @actor_sp = actor.sp @actor_st = make_battler_state_text(actor, 120, true) @status_window = [] for i in 0...5 @status_window.push(Window_DetailsStatus.new(actor, i, x)) end refresh(false) end #-------------------------------------------------------------------------- # ● 解放 #-------------------------------------------------------------------------- def dispose for i in 0...5 @status_window[i].dispose end super end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh(level_up_flags) self.contents.clear actor = $game_party.actors[@actor_num] @status_window[0].refresh(actor) if @actor_nm != actor.name @status_window[1].refresh(actor) if @actor_mhp != actor.maxhp or @actor_hp != actor.hp @status_window[2].refresh(actor) if @actor_msp != actor.maxsp or @actor_sp != actor.sp @status_window[3].refresh(actor, level_up_flags) if @actor_st != make_battler_state_text(actor, 120, true) or level_up_flags @actor_nm = actor.name @actor_mhp = actor.maxhp @actor_msp = actor.maxsp @actor_hp = actor.hp @actor_sp = actor.sp @actor_st = make_battler_state_text(actor, 120, true) end #-------------------------------------------------------------------------- # ● ATゲージリフレッシュ #-------------------------------------------------------------------------- def at_refresh @status_window[4].refresh($game_party.actors[@actor_num]) end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update for window in @status_window window.update end end end #============================================================================== # ■ Window_DetailsStatus #------------------------------------------------------------------------------ # バトル画面でアクターのステータスを個々に表示するウィンドウです。 #============================================================================== class Window_DetailsStatus < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(actor, id, x) @status_id = id super(x, 320 + id * 26, 160, 64) self.contents = Bitmap.new(width - 32, height - 32) self.opacity = 0 self.back_opacity = 0 refresh(actor, false) end #-------------------------------------------------------------------------- # ● 解放 #-------------------------------------------------------------------------- def dispose super end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh(actor, level_up_flags = false) self.contents.clear case @status_id when 0 draw_actor_name(actor, 4, 0) when 1 draw_actor_hp(actor, 4, 0, 120) when 2 draw_actor_sp(actor, 4, 0, 120) when 3 if level_up_flags self.contents.font.color = normal_color self.contents.draw_text(4, 0, 120, 32, "LEVEL UP!") else draw_actor_state(actor, 4, 0) end when 4 draw_actor_atg(actor, 4, 0, 120) end end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update # メインフェーズのときは不透明度をやや下げる if $game_temp.battle_main_phase self.contents_opacity -= 4 if self.contents_opacity > 191 else self.contents_opacity += 4 if self.contents_opacity < 255 end end end #============================================================================== # ■ Arrow_Base #------------------------------------------------------------------------------ # バトル画面で使用するアローカーソル表示用のスプライトです。このクラスは # Arrow_Enemy クラスと Arrow_Actor クラスのスーパークラスとして使用されます。 #============================================================================== class Arrow_Base < Sprite #-------------------------------------------------------------------------- # ● オブジェクト初期化 # viewport : ビューポート #-------------------------------------------------------------------------- def initialize(viewport) super(viewport) self.bitmap = RPG::Cache.windowskin($game_system.windowskin_name) self.ox = 16 self.oy = 32 self.z = 2500 @blink_count = 0 @index = 0 @help_window = nil update end end #============================================================================== # ■ Arrow_Enemy #------------------------------------------------------------------------------ # エネミーを選択させるためのアローカーソルです。このクラスは Arrow_Base クラ # スを継承します。 #============================================================================== class Arrow_Enemy < Arrow_Base #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super # 存在しないエネミーを指していたら飛ばす $game_troop.enemies.size.times do break if self.enemy.exist? @index += 1 @index %= $game_troop.enemies.size end # カーソル右 if Input.repeat?(Input::RIGHT) $game_system.se_play($data_system.cursor_se) $game_troop.enemies.size.times do @index += 1 @index %= $game_troop.enemies.size break if self.enemy.exist? end $scene.camera = "select" zoom = 1 / self.enemy.zoom $scene.spriteset.screen_target(self.enemy.attack_x(zoom) * 0.75, self.enemy.attack_y(zoom) * 0.75, zoom) end # カーソル左 if Input.repeat?(Input::LEFT) $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.enemy.exist? end $scene.camera = "select" zoom = 1 / self.enemy.zoom $scene.spriteset.screen_target(self.enemy.attack_x(zoom) * 0.75, self.enemy.attack_y(zoom) * 0.75, zoom) end # スプライトの座標を設定 if self.enemy != nil self.x = self.enemy.screen_x self.y = self.enemy.screen_y end end end #============================================================================== # ■ Interpreter #------------------------------------------------------------------------------ # イベントコマンドを実行するインタプリタです。このクラスは Game_System クラ # スや Game_Event クラスの内部で使用されます。 #============================================================================== class Interpreter #-------------------------------------------------------------------------- # ● アクターの入れ替え #-------------------------------------------------------------------------- def command_129 # アクターを取得 actor = $game_actors[@parameters[0]] # アクターが有効の場合 if actor != nil # 操作で分岐 if @parameters[1] == 0 if @parameters[2] == 1 $game_actors[@parameters[0]].setup(@parameters[0]) end $game_party.add_actor(@parameters[0]) if $game_temp.in_battle $game_actors[@parameters[0]].at = 0 $game_actors[@parameters[0]].atp = 0 $scene.spell_reset($game_actors[@parameters[0]]) $game_actors[@parameters[0]].damage_pop = {} $game_actors[@parameters[0]].damage = {} $game_actors[@parameters[0]].damage_sp = {} $game_actors[@parameters[0]].critical = {} $game_actors[@parameters[0]].recover_hp = {} $game_actors[@parameters[0]].recover_sp = {} $game_actors[@parameters[0]].state_p = {} $game_actors[@parameters[0]].state_m = {} $game_actors[@parameters[0]].animation = [] end else $game_party.remove_actor(@parameters[0]) end end if $game_temp.in_battle $scene.status_window.update end # 継続 return true end #-------------------------------------------------------------------------- # ● HP の増減 #-------------------------------------------------------------------------- alias :command_311_rtab :command_311 def command_311 command_311_rtab if $game_temp.in_battle $scene.status_window.refresh end end #-------------------------------------------------------------------------- # ● SP の増減 #-------------------------------------------------------------------------- alias :command_312_rtab :command_312 def command_312 command_312_rtab if $game_temp.in_battle $scene.status_window.refresh end end #-------------------------------------------------------------------------- # ● ステートの変更 #-------------------------------------------------------------------------- alias :command_313_rtab :command_313 def command_313 command_313_rtab if $game_temp.in_battle $scene.status_window.refresh end end #-------------------------------------------------------------------------- # ● 全回復 #-------------------------------------------------------------------------- alias :command_314_rtab :command_314 def command_314 command_314_rtab if $game_temp.in_battle $scene.status_window.refresh end end #-------------------------------------------------------------------------- # ● EXP の増減 #-------------------------------------------------------------------------- alias :command_315_rtab :command_315 def command_315 command_315_rtab if $game_temp.in_battle $scene.status_window.refresh end end #-------------------------------------------------------------------------- # ● レベルの増減 #-------------------------------------------------------------------------- alias :command_316_rtab :command_316 def command_316 command_316_rtab if $game_temp.in_battle $scene.status_window.refresh end end #-------------------------------------------------------------------------- # ● パラメータの増減 #-------------------------------------------------------------------------- alias :command_317_rtab :command_317 def command_317 command_317_rtab if $game_temp.in_battle $scene.status_window.refresh end end #-------------------------------------------------------------------------- # ● 装備の変更 #-------------------------------------------------------------------------- alias :command_319_rtab :command_319 def command_319 command_319_rtab if $game_temp.in_battle $scene.status_window.refresh end end #-------------------------------------------------------------------------- # ● アクターの名前変更 #-------------------------------------------------------------------------- alias :command_320_rtab :command_320 def command_320 command_320_rtab if $game_temp.in_battle $scene.status_window.refresh end end #-------------------------------------------------------------------------- # ● アクターのクラス変更 #-------------------------------------------------------------------------- alias :command_321_rtab :command_321 def command_321 command_321_rtab if $game_temp.in_battle $scene.status_window.refresh end end #-------------------------------------------------------------------------- # ● アニメーションの表示 #-------------------------------------------------------------------------- def command_337 # イテレータで処理 iterate_battler(@parameters[0], @parameters[1]) do |battler| # バトラーが存在する場合 if battler.exist? # アニメーション ID を設定 battler.animation.push([@parameters[2], true]) end end # 継続 return true end #-------------------------------------------------------------------------- # ● ダメージの処理 #-------------------------------------------------------------------------- def command_338 # 操作する値を取得 value = operate_value(0, @parameters[2], @parameters[3]) # イテレータで処理 iterate_battler(@parameters[0], @parameters[1]) do |battler| # バトラーが存在する場合 if battler.exist? # HP を変更 battler.hp -= value # 戦闘中なら if $game_temp.in_battle # ダメージを設定 battler.damage["event"] = value battler.damage_pop["event"] = true end end end if $game_temp.in_battle $scene.status_window.refresh end # 継続 return true end #-------------------------------------------------------------------------- # ● アクションの強制 #-------------------------------------------------------------------------- def command_339 # 戦闘中でなければ無視 unless $game_temp.in_battle return true end # ターン数が 0 なら無視 if $game_temp.battle_turn == 0 return true end # イテレータで処理 (便宜的なもので、複数になることはない) iterate_battler(@parameters[0], @parameters[1]) do |battler| # バトラーが存在する場合 if battler.exist? # アクションを設定 battler.current_action.force_kind = @parameters[2] if battler.current_action.force_kind == 0 battler.current_action.force_basic = @parameters[3] else battler.current_action.force_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 # アクションが有効かつ [すぐに実行] の場合 if battler.current_action.valid? and @parameters[5] == 1 # 強制対象のバトラーを設定 $game_temp.forcing_battler = battler # インデックスを進める @index += 1 # 終了 return false elsif battler.current_action.valid? and @parameters[5] == 0 battler.current_action.forcing = true end end end # 継続 return true end end #============================================================================== # ■ Spriteモジュール #------------------------------------------------------------------------------ # アニメーションの管理を行うモジュールです。 #============================================================================== module RPG class Sprite < ::Sprite def initialize(viewport = nil) super(viewport) @_whiten_duration = 0 @_appear_duration = 0 @_escape_duration = 0 @_collapse_duration = 0 @_damage = [] @_animation = [] @_animation_duration = 0 @_blink = false end def damage(value, critical, type = 0) if value.is_a?(Numeric) damage_string = value.abs.to_s else damage_string = value.to_s end bitmap = Bitmap.new(160, 48) bitmap.font.name = "Arial Black" bitmap.font.size = 32 bitmap.font.color.set(0, 0, 0) bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1) bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1) bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1) bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1) if value.is_a?(Numeric) and value < 0 if type == 0 bitmap.font.color.set(176, 255, 144) else bitmap.font.color.set(176, 144, 255) end else if type == 0 bitmap.font.color.set(255, 255, 255) else bitmap.font.color.set(255, 176, 144) end end if type == 2 bitmap.font.color.set(255, 224, 128) end bitmap.draw_text(0, 12, 160, 36, damage_string, 1) if critical string = "CRITICAL" bitmap.font.size = 20 bitmap.font.color.set(0, 0, 0) bitmap.draw_text(-1, -1, 160, 20, string, 1) bitmap.draw_text(+1, -1, 160, 20, string, 1) bitmap.draw_text(-1, +1, 160, 20, string, 1) bitmap.draw_text(+1, +1, 160, 20, string, 1) bitmap.font.color.set(255, 255, 255) bitmap.draw_text(0, 0, 160, 20, string, 1) end num = @_damage.size if type != 2 @_damage.push([::Sprite.new, 40, 0, rand(40) - 20, rand(30) + 50]) else @_damage.push([::Sprite.new, 40, 0, rand(20) - 10, rand(20) + 60]) end @_damage[num][0].bitmap = bitmap @_damage[num][0].ox = 80 + self.viewport.ox @_damage[num][0].oy = 20 + self.viewport.oy if self.battler.is_a?(Game_Actor) @_damage[num][0].x = self.x @_damage[num][0].y = self.y - self.oy / 2 else @_damage[num][0].x = self.x + self.viewport.rect.x - self.ox + self.src_rect.width / 2 @_damage[num][0].y = self.y - self.oy * self.zoom_y / 2 + self.viewport.rect.y @_damage[num][0].zoom_x = self.zoom_x @_damage[num][0].zoom_y = self.zoom_y @_damage[num][0].z = 3000 end end def animation(animation, hit) return if animation == nil num = @_animation.size @_animation.push([animation, hit, animation.frame_max, []]) bitmap = RPG::Cache.animation(animation.animation_name, animation.animation_hue) if @@_reference_count.include?(bitmap) @@_reference_count[bitmap] += 1 else @@_reference_count[bitmap] = 1 end if @_animation[num][0].position != 3 or not @@_animations.include?(animation) for i in 0..15 sprite = ::Sprite.new sprite.bitmap = bitmap sprite.visible = false @_animation[num][3].push(sprite) end unless @@_animations.include?(animation) @@_animations.push(animation) end end update_animation(@_animation[num]) end def loop_animation(animation) return if animation == @_loop_animation dispose_loop_animation @_loop_animation = animation return if @_loop_animation == nil @_loop_animation_index = 0 animation_name = @_loop_animation.animation_name animation_hue = @_loop_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 = [] for i in 0..15 sprite = ::Sprite.new sprite.bitmap = bitmap sprite.visible = false @_loop_animation_sprites.push(sprite) end # update_loop_animation end def dispose_damage for damage in @_damage.reverse damage[0].bitmap.dispose damage[0].dispose @_damage.delete(damage) end end def dispose_animation for anime in @_animation.reverse sprite = anime[3][0] if sprite != nil @@_reference_count[sprite.bitmap] -= 1 if @@_reference_count[sprite.bitmap] == 0 sprite.bitmap.dispose end end for sprite in anime[3] sprite.dispose end @_animation.delete(anime) end end def effect? @_whiten_duration > 0 or @_appear_duration > 0 or @_escape_duration > 0 or @_collapse_duration > 0 or @_damage.size == 0 or @_animation.size == 0 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 for damage in @_damage if damage[1] > 0 damage[1] -= 1 damage[4] -= 3 damage[2] -= damage[4] if self.battler.is_a?(Game_Actor) damage[0].x = self.x + (40 - damage[1]) * damage[3] / 10 damage[0].y = self.y - self.oy / 2 + damage[2] / 10 else damage[0].x = self.x + self.viewport.rect.x - self.ox + self.src_rect.width / 2 + (40 - damage[1]) * damage[3] / 10 damage[0].y = self.y - self.oy * self.zoom_y / 2 + self.viewport.rect.y + damage[2] / 10 damage[0].zoom_x = self.zoom_x damage[0].zoom_y = self.zoom_y end damage[0].z = 2960 + damage[1] damage[0].opacity = 256 - (12 - damage[1]) * 32 if damage[1] == 0 damage[0].bitmap.dispose damage[0].dispose @_damage.delete(damage) end end end for anime in @_animation if (Graphics.frame_count % 2 == 0) anime[2] -= 1 update_animation(anime) end end if @_loop_animation != nil and (Graphics.frame_count % 2 == 0) update_loop_animation @_loop_animation_index += 1 @_loop_animation_index %= @_loop_animation.frame_max 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(anime) if anime[2] > 0 frame_index = anime[0].frame_max - anime[2] cell_data = anime[0].frames[frame_index].cell_data position = anime[0].position animation_set_sprites(anime[3], cell_data, position) for timing in anime[0].timings if timing.frame == frame_index animation_process_timing(timing, anime[1]) end end else @@_reference_count[anime[3][0].bitmap] -= 1 if @@_reference_count[anime[3][0].bitmap] == 0 anime[3][0].bitmap.dispose end for sprite in anime[3] sprite.dispose end @_animation.delete(anime) end end def animation_set_sprites(sprites, cell_data, position) for i in 0..15 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 if $game_temp.in_battle and self.battler.is_a?(Game_Enemy) sprite.y = self.viewport.rect.height - 320 else sprite.y = self.viewport.rect.height - 160 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 if $game_temp.in_battle and self.battler.is_a?(Game_Enemy) 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 else sprite.y = self.y + self.viewport.rect.y - self.oy + self.src_rect.height / 2 sprite.y -= self.src_rect.height / 4 if position == 0 sprite.y += self.src_rect.height / 4 if position == 2 end end sprite.x += cell_data[i, 1] sprite.y += cell_data[i, 2] 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 if position != 3 sprite.zoom_x *= self.zoom_x sprite.zoom_y *= self.zoom_y end sprite.angle = cell_data[i, 4] sprite.mirror = (cell_data[i, 5] == 1) sprite.opacity = cell_data[i, 6] * self.opacity / 255.0 sprite.blend_type = cell_data[i, 7] end end def x=(x) sx = x - self.x if sx != 0 for anime in @_animation if anime[3] != nil for i in 0..15 anime[3][i].x += sx end end end if @_loop_animation_sprites != nil for i in 0..15 @_loop_animation_sprites[i].x += sx end end end super end def y=(y) sy = y - self.y if sy != 0 for anime in @_animation if anime[3] != nil for i in 0..15 anime[3][i].y += sy end end end if @_loop_animation_sprites != nil for i in 0..15 @_loop_animation_sprites[i].y += sy end end end super end end end #------------------------------------------------------------------------------ # Bitmapクラスに新たな機能を追加します。 #============================================================================== class Bitmap #-------------------------------------------------------------------------- # ● 矩形をグラデーション表示 # color1 : スタートカラー # color2 : エンドカラー # align : 0:横にグラデーション # 1:縦にグラデーション # 2:斜めにグラデーション(激重につき注意) #-------------------------------------------------------------------------- def gradation_rect(x, y, width, height, color1, color2, align = 0) if align == 0 for i in x...x + width red = color1.red + (color2.red - color1.red) * (i - x) / (width - 1) green = color1.green + (color2.green - color1.green) * (i - x) / (width - 1) blue = color1.blue + (color2.blue - color1.blue) * (i - x) / (width - 1) alpha = color1.alpha + (color2.alpha - color1.alpha) * (i - x) / (width - 1) color = Color.new(red, green, blue, alpha) fill_rect(i, y, 1, height, color) end elsif align == 1 for i in y...y + height red = color1.red + (color2.red - color1.red) * (i - y) / (height - 1) green = color1.green + (color2.green - color1.green) * (i - y) / (height - 1) blue = color1.blue + (color2.blue - color1.blue) * (i - y) / (height - 1) alpha = color1.alpha + (color2.alpha - color1.alpha) * (i - y) / (height - 1) color = Color.new(red, green, blue, alpha) fill_rect(x, i, width, 1, color) end elsif align == 2 for i in x...x + width for j in y...y + height red = color1.red + (color2.red - color1.red) * ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2 green = color1.green + (color2.green - color1.green) * ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2 blue = color1.blue + (color2.blue - color1.blue) * ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2 alpha = color1.alpha + (color2.alpha - color1.alpha) * ((i - x) / (width - 1.0) + (j - y) / (height - 1.0)) / 2 color = Color.new(red, green, blue, alpha) set_pixel(i, j, color) end end elsif align == 3 for i in x...x + width for j in y...y + height red = color1.red + (color2.red - color1.red) * ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2 green = color1.green + (color2.green - color1.green) * ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2 blue = color1.blue + (color2.blue - color1.blue) * ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2 alpha = color1.alpha + (color2.alpha - color1.alpha) * ((x + width - i) / (width - 1.0) + (j - y) / (height - 1.0)) / 2 color = Color.new(red, green, blue, alpha) set_pixel(i, j, color) end end end end end
=begin #-------------------------------------------------------------------------- # ● 人物行走图做战斗图像(附加动画) ver1.02 #-------------------------------------------------------------------------- 制作者 らい 翻译:忧郁的涟漪 图像文件的规格 ● 巴特勒图像(似乎指的是战斗图像) 使用步行图片。 ● 武器的图像 就是武器图标的图像(ICO图) ############################################################################### 行走图横版战斗: ------------------------------------------------------------------------------ 经过了两次的修改,终于完全实现了远距离攻击的效果(弓箭、铳类) 另外,也实现了简单的回旋攻击(类似回力镖的攻击)和攻击道具(类似石头或炸弹) 这个脚本的更动分为2部分: 1)战斗动作 - 新加了数个动作,如:“弓箭攻击”、“远距离发动”等等 2)战斗动画 - 基本上是脚本原带的。只是这个功能被隐藏起来了。现在已恢复。 用法: 在相应的脚本行加入武器/技能/道具的数据库id(id之间要用“,”来分开) 如果不要某些功能的话就随便填一个外太空id就行了(没有用到的id) 1)战斗动作(角色/行走图的动作) 脚本355行: 远程武器的id (普通攻击时使用远程射击) 脚本357行: 回旋武器的id (普通攻击时会飞回手上的武器,如:回力镖) 脚本370行: 远程技能的id (使用技能时是远程射击) 脚本372行: 回旋技能的id (使用技能时,飞出的武器会飞回手上) 2)战斗动画(显示‘对象方的动画’之前先显示‘飞行武器射去敌人身上’的动画) 脚本453行: 回旋武器的id (攻击时会显示一段类似回力镖的动画) 脚本455行: 弓箭武器的id (攻击时会显示箭射去敌人身上的动画) 脚本457行: 铳类武器的id (攻击时会显示子弹射去敌人身上的动画) 脚本470行: 回旋技能的id (技能使用时会显示一段类似回力镖的动画) 脚本472行: 弓箭技能的id (技能使用时会显示箭射去敌人身上的动画) 脚本474行: 铳类技能的id (技能使用时会显示子弹射去敌人身上的动画) 脚本486行: 抛击道具的id (使用该道具时,道具被丢到敌人身上) 〉注意: 〉‘飞行武器射去敌人身上’的动画是在设定id之后的那句脚本里面设置 〉例子:(脚本第455和456行) 〉 when 17,18,19,20 #远程武器1(弓箭类)的id 〉 return [101,32,false,false] 〉这样,武器17~20(都是弓箭)在显示‘对象方的动画’之前会先显示第101号动画 〉而动画的轨道是从使用者身上直到敌人身上(实现子弹射出的效果) 还有: 战斗队伍的画面位置已经被修改过, 让角色的位置与默认的战斗背景图不会有视觉上的冲突。 如果要更改请去脚本第113-116行改改就行了。 脚本‘Arrow_Enemy’和‘Arrow_Actor’被稍微修改过(可以无视) 这个范例附带了 一张经过修改的战斗背景图(027-castle03),其他的战斗背景图可以使用默认的。 一套横版的默认敌人的战斗图(从行走图改过来的) =end #modify by darkten ############################################################################### module Side_view #-------------------------------------------------------------------------- # ● 是否与RATB并用 ☆自动识别(这到是不错~省了~) # 在Scene_Battle计算方法是否是方法synthe? # 在自动不想认识的时候,请重写。 #-------------------------------------------------------------------------- if Scene_Battle.method_defined?("synthe?") RTAB = true else RTAB = false end #-------------------------------------------------------------------------- # ● 改正RATB中的位置误差 ☆自动识别 # 在自动不想认识的时候,请重写。 #-------------------------------------------------------------------------- def camera_correctness return false if !RTAB begin return $scene.drive rescue return false end end #-------------------------------------------------------------------------- # ● 队伍中的最大人数 #-------------------------------------------------------------------------- Party_max = 4 #-------------------------------------------------------------------------- # ● 战斗图的扩大率(1.0的时候是保持原有大小) #-------------------------------------------------------------------------- CHAR_ZOOM = 1.0 #-------------------------------------------------------------------------- # ● 光标的位置修正(基本不需要改~) #-------------------------------------------------------------------------- ARROW_OX = 0 ARROW_OY = 64 #-------------------------------------------------------------------------- # ● 名状态作为飞行管理的排列(不知道什么意思....) #-------------------------------------------------------------------------- FLY_STATES = ["飛行"] #-------------------------------------------------------------------------- # ● 战斗画面的位置 #-------------------------------------------------------------------------- PARTY_X = 455 # 队伍 X 位置 PARTY_Y = 200 # 队伍 Y 位置 FORMATION_X = 15 # 各个角色之间的间隔 X FORMATION_Y = 35 # 各个角色之间的间隔 Y #-------------------------------------------------------------------------- # ● 自定义常数 #-------------------------------------------------------------------------- NORMAL = "NORMAL" WALK_R = "WALK_R" WALK_L = "WALK_L" ATTACK = "ATTACK" ATTACK_R = "ATTACK_R" ATTACK_L = "ATTACK_L" MAGIC = "MAGIC" ITEM = "ITEM" # 动画的设定 ANIME = { # [画像ID,是否循环,アニメスピード,动画速度,不能指向动画,武器放在右手or左手] NORMAL => [1,true , 0,false, true ,"" ], # 通常待击 WALK_R => [2,true , 2,false, false,"" ], # 右移动 WALK_L => [1,true , 2,false, false,"" ], # 左移动 ATTACK_R => [1,false, 2,true , false,"右手"], # 右手攻击 ATTACK_L => [1,false, 2,true , false,"左手"], # 左手攻击 MAGIC => [1,false, 2,false, false,"" ], # 右手攻击 ITEM => [1,false, 2,false, false,"" ], # 左手攻击 } # 债务不履行声明价值的设定(一个字一个字翻译的,不知道啥意思) ANIME.default = [1,false,12,false,"",""] # 在行动设定的时候 右手攻击 or 左手攻击 辨别を(这个不知道什么意思)的ANIME # "角色动画变更#ATTACK"在玩了と(还是不知道啥意思..)的时候,辨别ATTACK_R或者ATTACK_L DUAL_WEAPONS_ANIME = [ATTACK] #-------------------------------------------------------------------------- # ● 摇晃的设定 #-------------------------------------------------------------------------- SHAKE_FILE = "摇晃" # 文件名 SHAKE_POWER = 5 # 强度 SHAKE_SPEED = 5 # 速度 SHAKE_DURATION = 5 # 时间 #-------------------------------------------------------------------------- # ● 上下反转地的设定 #-------------------------------------------------------------------------- UPSIDE_DOWN_FILE = "上下反转" # 文件名 #-------------------------------------------------------------------------- # ● 左右反转地的设定 #-------------------------------------------------------------------------- REVERSE_FILE = "左右反转" # 文件名 #-------------------------------------------------------------------------- # ● 回转地的设定 #-------------------------------------------------------------------------- TURNING_FILE = "回转" # 文件名 TURNING_DIRECTION = 1 # 方向(1.逆时针,-1.顺时针)(|||-_-汗..怎么还有用-1做带入值的...) TURNING_SPEED = 40 # 速度 TURNING_DURATION = 1 # 回转数 #-------------------------------------------------------------------------- # ● 移动的设定 #-------------------------------------------------------------------------- MOVE_FILE = "移动" # 文件名 MOVE_RETURN = 1 # 回到原来的位置吗?(光写了个1,也不知道不回到该怎么写?0?) MOVE_SPEED = 32 # 速度 MOVE_COORDINATES = [0,-640] # 原来位置的相对坐标 #-------------------------------------------------------------------------- # ● 动画追加的设定 #-------------------------------------------------------------------------- ADD_ANIME_FILE = "动画追加" # 文件名 ADD_ANIME_ID = 0 # 动画的ID #-------------------------------------------------------------------------- # ● 债务不履行声明和RTAB的数据转换 #-------------------------------------------------------------------------- def convert_battler return RTAB ? @active_actor : @active_battler end #-------------------------------------------------------------------------- # ● 债务不履行声明和RTAB的数据转换2 #-------------------------------------------------------------------------- def convert_battler2(*arg) return RTAB ? arg[0] : @active_battler end end #-------------------------------------------------------------------------- # ● 行动設定 #-------------------------------------------------------------------------- module BattleActions # 下のものはあくまでも一例なので # 独自に作ってください。 Actions = { "通常攻撃" => [ "閃きアニメ", "アクターアニメ変更#WALK_L", "移動#target,32,0,64,0", "行動アニメ", "アクターアニメ変更#ATTACK", "遠距離アニメ", "対象アニメ", "アクターアニメ変更#WALK_L", "SEの演奏#016-Jump02,80,100", "移動#self,0,0,48,32", "終了" ], "エネミー攻撃" => [ "閃きアニメ", "アクターアニメ変更#WALK_L", "移動#self,-36,0,12,0", "行動アニメ", "アクターアニメ変更#ATTACK", "遠距離アニメ", "対象アニメ", "アクターアニメ変更#WALK_L", "移動#self,0,0,12,0", "終了" ], "術発動" => [ "閃きアニメ", "アクターアニメ変更#WALK_L", "移動#self,-32,0,4,0", "アクターアニメ変更#MAGIC", "行動アニメ", "ウエイト#15", "遠距離アニメ", "対象アニメ", "アクターアニメ変更#WALK_L", "移動#self,0,0,4,2", "終了" ], "アイテム使用" => [ "閃きアニメ", "アクターアニメ変更#WALK_L", "移動#self,-32,0,4,0", "行動アニメ", "アクターアニメ変更#ITEM", "ウエイト#15", "遠距離アニメ", "対象アニメ", "アクターアニメ変更#WALK_L", "移動#self,0,0,4,2", "終了" ], "払い抜け" => [ "閃きアニメ", "アクターアニメ変更#WALK_L", "移動#target_near,50,0,48,30", "左右反転", "アクターアニメ固定#ATTACK#3", "行動アニメ", "SEの演奏#135-Light01,100,100", "アニメーションの表示#self,42", "ウエイト#15", "左右反転", "残像表示", "移動#target_far,-50,0,48,0", "対象アニメ", "残像消去", "アニメ固定解除", "アクターアニメ変更#WALK_L", "移動#self,0,0,48,1,0", "終了" ], "弓箭攻撃" => [ "閃きアニメ", "アクターアニメ変更#WALK_L", "移動#self,-32,0,4,0", "行動アニメ", "アクターアニメ変更#ATTACK", "遠距離アニメ", "対象アニメ", "アクターアニメ変更#WALK_L", "移動#self,0,0,4,2", "終了" ], "回旋攻撃" => [ "閃きアニメ", "アクターアニメ変更#WALK_L", "移動#self,-32,0,4,0", "行動アニメ", "アクターアニメ変更#STAND_L", "遠距離アニメ", "対象アニメ", "アクターアニメ変更#WALK_L", "移動#self,0,0,4,2", "終了" ], "远距离発動" => [ "閃きアニメ", "アクターアニメ変更#WALK_L", "移動#self,-32,0,4,0", "アクターアニメ変更#MAGIC", "行動アニメ", "アクターアニメ変更#ATTACK", "遠距離アニメ", "対象アニメ", "アクターアニメ変更#WALK_L", "移動#self,0,0,4,2", "終了" ], "回旋発動" => [ "閃きアニメ", "アクターアニメ変更#WALK_L", "移動#self,-32,0,4,0", "アクターアニメ変更#MAGIC", "行動アニメ", "アクターアニメ変更#STAND_L", "遠距離アニメ", "対象アニメ", "アクターアニメ変更#WALK_L", "移動#self,0,0,4,2", "終了" ], } # ここで終わり 消さないでください end module RPG class Weapon #-------------------------------------------------------------------------- # ● アクション設定 #-------------------------------------------------------------------------- def battle_actions case @id when 17,18,19,20,21,22,23,24 # 远程武器的id回旋攻撃 return BattleActions::Actions["弓箭攻撃"] when 34 # 回旋武器的id return BattleActions::Actions["回旋攻撃"] end else return BattleActions::Actions["通常攻撃"] end end class Skill #-------------------------------------------------------------------------- # ● アクション設定 #-------------------------------------------------------------------------- def battle_actions case @id when 73,74,75,76,77,78,79,80 # 远程技能的id return BattleActions::Actions["远距离発動"] when 82 # 回旋技能的id return BattleActions::Actions["回旋発動"] end else if self.magic? return BattleActions::Actions["術発動"] else return BattleActions::Actions["払い抜け"] end end end class Item #-------------------------------------------------------------------------- # ● アクション設定 #-------------------------------------------------------------------------- def battle_actions return BattleActions::Actions["アイテム使用"] end end end class Game_Enemy < Game_Battler #-------------------------------------------------------------------------- # ● アクション設定 #-------------------------------------------------------------------------- def battle_actions return BattleActions::Actions["エネミー攻撃"] end end =begin #-------------------------------------------------------------------------- # ● 遠距離アニメーション #-------------------------------------------------------------------------- ☆ 説明 行動者から対象者にアニメを飛ばします。 飛ばすアニメを データベース‐アニメーション で作ります。 [アニメーションID, スピード, 往復するか?,直線(false)or曲線(true)] で指定します。 ● カスタマイズ方法 case @id when 17,18,19,20 return [101,32,false,false] when 21,22,23,24 return [102,32,false,false] end return 0 のように描くとID別に指定可能です。 ● アニメーションID 飛ばすアニメーションIDです。短い場合は繰り返しで表示されます。 ● スピード 大きいほうが早い(0だとアニメは移動しません) 1 = 1フレームで1ドット進むと考えてください。 ● 往復するか? true とした場合、ブーメランのようにアニメが戻ります。 ● 直線(false)or曲線(true) true = 対象に向かって曲線で、アニメが飛びます。(修正の余地ありですが・・・) false = 対象に向かって直線で、アニメが飛びます。 =end module RPG class Weapon #-------------------------------------------------------------------------- # ● 遠距離アニメーション #-------------------------------------------------------------------------- def flying_anime # ID 指定 の例(武器的id,分类是根据飞行武器的动画id) case @id when 34 #回旋武器(类似回力镖)的id return [103,32,true,true] when 17,18,19,20 #远程武器1(弓箭类)的id return [101,32,false,false] when 21,22,23,24 #远程武器2(铳类)的id return [102,32,false,false] end return [0,0,false,false] end end class Skill #-------------------------------------------------------------------------- # ● 遠距離アニメーション #-------------------------------------------------------------------------- def flying_anime # ID 指定 の例(技能的id,分类是根据飞行武器的动画id) case @id when 82 #回旋技能(类似回力镖)的id return [103,32,true,true] when 73,74,75,76 #远程技能1(弓箭类)的id return [101,32,false,false] when 77,78,79,80 #远程技能2(铳类)的id return [102,32,false,false] end return [0,0,false,false] end end class Item #-------------------------------------------------------------------------- # ● 遠距離アニメーション #-------------------------------------------------------------------------- def flying_anime case @id when 34 #抛击类道具(如炸弹一类)的id return [104,32,false,true] end return [0,0,false,false] end end end class Game_Enemy < Game_Battler #-------------------------------------------------------------------------- # ● 遠距離アニメーション #-------------------------------------------------------------------------- def flying_anime return [0,0,false,false] end end #============================================================================== # ■ Game_Battler #============================================================================== class Game_Battler include Side_view #-------------------------------------------------------------------------- # ● 追加・公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :height # 画像の高さ attr_accessor :real_x # X座標補正 attr_accessor :real_y # Y座標補正 attr_accessor :real_zoom # 拡大率 attr_accessor :wait_count # アニメーション 待ち時間 attr_accessor :wait_count2 # アニメーション 待ち時間2 attr_accessor :pattern # アニメーション カウント(キャラ) attr_accessor :shake # シェイク開始フラッグ attr_accessor :reverse # 左右反転フラッグ attr_accessor :shadow # 残像フラッグ attr_accessor :flash_flag # 閃きフラッグ attr_reader :ox # X座標補正 attr_reader :oy # Y座標補正 attr_reader :flying_x # 遠距離アニメX座標 attr_reader :flying_y # 遠距離アニメY座標 attr_reader :flying_anime # 遠距離アニメ attr_reader :animation1_on # 行動アニメ開始フラッグ attr_reader :animation2_on # 対象アニメ開始フラッグ #-------------------------------------------------------------------------- # ● デフォルトのアニメーション待ち時間を取得 #-------------------------------------------------------------------------- def animation_duration=(animation_duration) @_animation_duration = animation_duration end #-------------------------------------------------------------------------- # ● バトル開始時のセットアップ #-------------------------------------------------------------------------- def start_battle @height = 0 @real_x = 0 @real_y = 0 @real_zoom = 1.0 @battler_condition = "" @action = nil @battle_actions = [] @battler_action = false @step = 0 @anime_on = false @wait_count = 0 @wait_count2 = 0 @ox = 0 @oy = 0 @pattern = 0 @pattern_log = true @pattern_freeze = false @condition_freeze = false @active = false @move_distance = nil @move_wait = 0 @move_coordinates = [0,0,0,0] @flying_distance = nil @flying_wait = 0 @flying_x = 0 @flying_y = 0 @flash_flag = {} self.flying_clear end #-------------------------------------------------------------------------- # ● 移動中判定 #-------------------------------------------------------------------------- def moving? # X座標補正または、Y座標補正が0でなければ、移動中 return (@ox != 0 or @oy != 0) end #-------------------------------------------------------------------------- # ● 移動終了判定 #-------------------------------------------------------------------------- def move_end? return (@ox == @move_coordinates[0] and @oy == @move_coordinates[1]) end #-------------------------------------------------------------------------- # ● アクション開始設定 #-------------------------------------------------------------------------- def action(flag = true) @battler_action = flag @animation1_on = false @animation2_on = false @step = "setup" end #-------------------------------------------------------------------------- # ● アクション中判定 #-------------------------------------------------------------------------- def action? return @battler_action end #-------------------------------------------------------------------------- # ● 閃き判定 #-------------------------------------------------------------------------- def flash? return @flash_flg end #-------------------------------------------------------------------------- # ● 戦闘不能判定 #-------------------------------------------------------------------------- def anime_dead? if $game_temp.in_battle and !RTAB if [2,3,4,5].include?($scene.phase4_step) return @last_dead end end return @last_dead = self.dead? end #-------------------------------------------------------------------------- # ● ピンチ状態判定 #-------------------------------------------------------------------------- def crisis? if $game_temp.in_battle and !RTAB if [2,3,4,5].include?($scene.phase4_step) return @last_crisis end end return @last_crisis = (self.hp <= self.maxhp / 4 or badstate?) end #-------------------------------------------------------------------------- # ● バッドステート判定 #-------------------------------------------------------------------------- def badstate? for i in @states unless $data_states[i].nonresistance return true end end return false end #-------------------------------------------------------------------------- # ● 飛行 #-------------------------------------------------------------------------- def fly if @fly != nil return @fly end for id in @states if FLY_STATES.include?($data_states[id].name) return 60 end end return 0 end #-------------------------------------------------------------------------- # ● 遠距離アニメ目標座標の計算 #-------------------------------------------------------------------------- def flying_setup # 二度目は実行しない return if @flying_distance != nil && !camera_correctness if RTAB targets = @target else targets = $scene.target_battlers end # 目的座標を計算 @f_target_x = 0 @f_target_y = 0 for t in targets @f_target_x += t.screen_x @f_target_y += t.screen_y end if targets != [] @f_target_x /= targets.size @f_target_y /= targets.size else @flying_distance = 0 return end # 距離の計算 @flying_distance = (self.screen_x - @f_target_x).abs + (self.screen_y - @f_target_y).abs end #-------------------------------------------------------------------------- # ● 遠距離アニメ #-------------------------------------------------------------------------- def flying_animation # 戻る if @step != "flying" or @flying_distance.nil? return [false,true] end # あらかじめ計算 self_x = self.screen_x self_y = self.screen_y @flying_distance = @flying_distance == 0 ? 1 : @flying_distance n1 = @flying_wait / @flying_distance.to_f if @flying_distance - @flying_wait > @flying_distance / 2 n2 = 1.0 + 10.0 * @flying_wait / @flying_distance.to_f else n2 = 1.0 + 10.0 * (@flying_distance - @flying_wait) / @flying_distance.to_f end if !@flying_anime[4] # 直線移動 x = (self_x + 1.0 * (@f_target_x - self_x) * n1).to_i y = (self_y + 1.0 * (@f_target_y - self_y) * n1).to_i else # 曲線移動 if !@flying_proceed_end x = (self_x + 1.0 * (@f_target_x - self_x) * n1).to_i y = (self_y + 1.0 * (@f_target_y - self_y) * n1 - n2**2).to_i else x = (self_x + 1.0 * (@f_target_x - self_x) * n1).to_i y = (self_y + 1.0 * (@f_target_y - self_y) * n1 + n2**2).to_i end end # 座標代入 @flying_x = x @flying_y = y # ウエイト if !@flying_proceed_end # 開始 @flying_proceed_start = @flying_wait == 0 @flying_wait += @flying_anime[1] @flying_wait = [@flying_wait,@flying_distance].min @flying_proceed_end = @flying_wait == @flying_distance else # 開始 @flying_return_start = @flying_wait == @flying_distance @flying_wait -= @flying_anime[1] @flying_wait = [@flying_wait,0].max @flying_return_end = @flying_wait == 0 end if @flying_anime[1] == 0 @flying_end = true elsif !@flying_anime[2] @flying_end = @flying_proceed_end else @flying_end = @flying_return_end end # 値を返す(アニメ開始,アニメ終了) return [@flying_proceed_start,@flying_end] end #-------------------------------------------------------------------------- # ● 遠距離アニメ初期化 #-------------------------------------------------------------------------- def flying_clear @flying_proceed_start = false @flying_proceed_end = false @flying_return_start = false @flying_return_end = false @flying_end = false @flying_anime = [0,0,false] end #-------------------------------------------------------------------------- # ● 移動 #-------------------------------------------------------------------------- def move # 距離の計算 @move_distance = (@move_coordinates[2] - @move_coordinates[0]).abs + (@move_coordinates[3] - @move_coordinates[1]).abs if @move_distance > 0 return if @ox == @move_coordinates[0] and @oy == @move_coordinates[1] array = @move_coordinates # ジャンプ補正値の計算 if @move_distance - @move_wait > @move_distance / 2 jump = (@move_action[4] * @move_wait / @move_distance.to_f)**2 else jump = (@move_action[4] * (@move_distance - @move_wait) / @move_distance.to_f)**2 end jump = @move_action[4] > 0 ? -jump : jump @ox = (array[2] + 1.0 * (array[0] - array[2]) * (@move_distance - @move_wait) / @move_distance.to_f).to_i @oy = (array[3] + 1.0 * (array[1] - array[3]) * (@move_distance - @move_wait) / @move_distance.to_f + jump).to_i # ウエイト @move_wait -= @move_action[3] @move_wait = [@move_wait,0].max end end #-------------------------------------------------------------------------- # ● 移動アクションの取得 #-------------------------------------------------------------------------- def get_move_action string = @action.split(/#/)[1] string = string.split(/,/) @move_action = [string[0],string[1].to_i,string[2].to_i,string[3].to_i,string[4].to_i,string[5].to_i] end #-------------------------------------------------------------------------- # ● アクションの取得 #-------------------------------------------------------------------------- def get_step if @action.nil? @step = "finish" return end string = @action.split(/#/)[0] if string =~ "移動" @step = "moving_setup" elsif string =~ "アクターアニメ実行" @step = "action" elsif string =~ "遠距離アニメ" @step = "flying" elsif string =~ "アクターアニメ変更" @step = "change" elsif string =~ "行動アニメ" @step = "animation1" elsif string =~ "対象アニメ" @step = "animation2" elsif string =~ "ウエイト" @step = "wait" elsif string =~ "左右反転" @step = "reverse" elsif string =~ "閃きアニメ" @step = "flash" elsif string =~ "残像表示" @step = "shadow_on" elsif string =~ "残像消去" @step = "shadow_off" elsif string =~ "アクターアニメ固定" @step = "freeze" elsif string =~ "アニメ固定解除" @step = "freeze_lifting" elsif string =~ "アニメーションの表示" @step = "animation_start" elsif string =~ "SEの演奏" @step = "play_se" else @step = "finish" end end #-------------------------------------------------------------------------- # ● フレーム更新 (次のアクションへ) #-------------------------------------------------------------------------- def update_next @action = @battle_actions.shift @step = get_step end #-------------------------------------------------------------------------- # ● フレーム更新 (動作取得) #-------------------------------------------------------------------------- def update_setup # アクションの取得 self.get_actions @action = @battle_actions.shift @step = get_step end #-------------------------------------------------------------------------- # ● フレーム更新 (移動取得) #-------------------------------------------------------------------------- def update_moving_setup # 移動アクションの取得 self.get_move_action # 移動目標の設定 self.move_setup @step = "moving" end #-------------------------------------------------------------------------- # ● フレーム更新 (移動) #-------------------------------------------------------------------------- def update_moving # 移動 self.move self.condition = @battler_condition # 移動完了したら次のステップへ if move_end? @wait_count = 2 @action = @battle_actions.shift @step = get_step end end #-------------------------------------------------------------------------- # ● フレーム更新 (アニメ実行) #-------------------------------------------------------------------------- def update_action con = @action.split(/#/)[1] # 右手・左手を分ける if DUAL_WEAPONS_ANIME.include?(con) if !@first_weapon and @second_weapon con = con + "_L" else con = con + "_R" end end # アニメ変更 self.condition = con # ループか否か if !ANIME[@battler_condition][1] self.anime_on end @action = @battle_actions.shift @step = get_step end #-------------------------------------------------------------------------- # ● フレーム更新 (遠距離アニメ) #-------------------------------------------------------------------------- def update_flying # 目標の設定 self.flying_setup # 遠距離アニメ終了 if @flying_end self.flying_clear @action = @battle_actions.shift @step = get_step end end #-------------------------------------------------------------------------- # ● フレーム更新 (アニメ変更) #-------------------------------------------------------------------------- def update_change con = @action.split(/#/)[1] # 右手・左手を分ける if DUAL_WEAPONS_ANIME.include?(con) if !@first_weapon and @second_weapon con = con + "_L" else con = con + "_R" end end # アニメ変更 self.condition = con # ループか否か if !ANIME[@battler_condition][1] self.anime_on end @action = @battle_actions.shift @step = get_step end #-------------------------------------------------------------------------- # ● フレーム更新 (行動アニメ) #-------------------------------------------------------------------------- def update_animation1 @animation1_on = true # 行動アニメの後に行動を開始する if $scene.phase4_step == 3 id = RTAB ? @anime1 : $scene.animation1_id animation = $data_animations[id] frame_max = animation != nil ? animation.frame_max : 0 @wait_count2 = frame_max * 2 return end @action = @battle_actions.shift @step = get_step end #-------------------------------------------------------------------------- # ● フレーム更新 (対象アニメ) #-------------------------------------------------------------------------- def update_animation2 @animation2_on = true # 行動アニメの後に行動を開始する if $scene.phase4_step == 4 id = RTAB ? @anime2 : $scene.animation2_id animation = $data_animations[id] frame_max = animation != nil ? animation.frame_max : 0 @wait_count2 = frame_max * 2 return end @action = @battle_actions.shift @step = get_step end #-------------------------------------------------------------------------- # ● フレーム更新 (ウエイト) #-------------------------------------------------------------------------- def update_wait @wait_count2 = @action.split(/#/)[1].to_i @action = @battle_actions.shift @step = get_step end #-------------------------------------------------------------------------- # ● フレーム更新 (残像表示) #-------------------------------------------------------------------------- def update_shadow_on @shadow = true @action = @battle_actions.shift @step = get_step end #-------------------------------------------------------------------------- # ● フレーム更新 (残像消去) #-------------------------------------------------------------------------- def update_shadow_off @shadow = false @action = @battle_actions.shift @step = get_step end #-------------------------------------------------------------------------- # ● フレーム更新 (左右反転) #-------------------------------------------------------------------------- def update_reverse @reverse = @reverse ? false : true @action = @battle_actions.shift @step = get_step end #-------------------------------------------------------------------------- # ● フレーム更新 (閃きアニメ) #-------------------------------------------------------------------------- def update_flash # 閃きアニメの後に行動を開始する if @flash_flag["normal"] @wait_count = $scene.flash_duration @flash_flag["normal"] = false return end @action = @battle_actions.shift @step = get_step end #-------------------------------------------------------------------------- # ● フレーム更新 (SEの演奏) #-------------------------------------------------------------------------- def update_play_se data = @action.split(/#/)[1] data = data.split(/,/) # SE を演奏 Audio.se_play("Audio/SE/" + data[0], data[1].to_i, data[2].to_i) @action = @battle_actions.shift @step = get_step end #-------------------------------------------------------------------------- # ● フレーム更新 (アクターアニメ固定) #-------------------------------------------------------------------------- def update_freeze con = @action.split(/#/)[1] # 右手・左手を分ける if DUAL_WEAPONS_ANIME.include?(con) if !@first_weapon and @second_weapon con = con + "_L" else con = con + "_R" end end # アニメ変更 self.condition = con @pattern = @action.split(/#/)[2].to_i @pattern_freeze = true @condition_freeze = true @action = @battle_actions.shift @step = get_step end #-------------------------------------------------------------------------- # ● フレーム更新 (アクターアニメ固定解除) #-------------------------------------------------------------------------- def update_freeze_lifting @pattern_freeze = false @condition_freeze = false @action = @battle_actions.shift @step = get_step end #-------------------------------------------------------------------------- # ● フレーム更新 (アニメーションの表示) #-------------------------------------------------------------------------- def update_animation_start data = @action.split(/#/)[1] data = data.split(/,/) target = data[0] animation_id = data[1].to_i if RTAB case target when "self" @animation.push([animation_id,true]) when "target" for tar in @target tar.animation.push([animation_id, true]) end end else case target when "self" @animation_id = animation_id @animation_hit = true when "target" for tar in $scene.target_battlers tar.animation_id = animation_id tar.animation_hit = true end end end @action = @battle_actions.shift @step = get_step end #-------------------------------------------------------------------------- # ● フレーム更新 (動作終了) #-------------------------------------------------------------------------- def update_finish # 動作終了 @battler_action = false @step = "setup" end #-------------------------------------------------------------------------- # ● バトラーの状態 変更(バトラーグラフィックのタイプ) #-------------------------------------------------------------------------- def condition=(condition) return if @condition_freeze @battler_condition = condition @wait_count = ANIME[condition][2] end #-------------------------------------------------------------------------- # ● バトラーの状態(バトラーグラフィックのタイプ) #-------------------------------------------------------------------------- def condition return @battler_condition end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update # ウェイト中の場合 if @wait_count > 0 return end # パターン更新 self.char_animation # ウェイト中の場合 if @wait_count2 > 0 return end # 行動アニメーション if @battler_action method("update_" + @step).call return end # データ初期化 @animation1_on = false @animation2_on = false @action = nil @battle_actions = [] @move_wait = 0 @move_distance = nil @flying_wait = 0 @flying_distance = nil @flash = false # RTAB対応 # 通常・待機 return self.condition = NORMAL end #-------------------------------------------------------------------------- # ● アクションの取得 #-------------------------------------------------------------------------- def get_actions skill = $data_skills[self.current_action.skill_id] item = $data_items[self.current_action.item_id] kind = self.current_action.kind # 動作取得 @battle_actions = [] # スキル if skill != nil && kind == 1 @battle_actions = skill.battle_actions.dup @flying_anime = skill.flying_anime # アイテム elsif item != nil && kind == 2 @battle_actions = item.battle_actions.dup @flying_anime = item.flying_anime # 左手攻撃 elsif !@first_weapon and @second_weapon and self.is_a?(Game_Actor) @battle_actions = self.battle_actions2.dup @flying_anime = self.flying_anime2 # 右手攻撃 elsif self.current_action.basic == 0 and self.is_a?(Game_Actor) and self.current_action.kind == 0 @battle_actions = self.battle_actions1.dup @flying_anime = self.flying_anime1 # 通常攻撃 elsif self.current_action.basic == 0 and self.current_action.kind == 0 @battle_actions = self.battle_actions.dup @flying_anime = self.flying_anime else @battle_actions = ["終了"] @flying_anime = [0,0,false,false] end end #-------------------------------------------------------------------------- # ● ループしないアニメのセット #-------------------------------------------------------------------------- def anime_on @pattern = 0 @pattern_log = true return end #-------------------------------------------------------------------------- # ● パターン更新 #-------------------------------------------------------------------------- def char_animation # パタン固定の場合もどる return if @pattern_freeze # ループしないアニメの場合 1234 で止まる if !ANIME[@battler_condition][1] && @pattern == 3 return end # アニメさせない場合 1 で止まる if ANIME[@battler_condition][4] @pattern = 0 return end @pattern = (@pattern + 1) % 4 end #-------------------------------------------------------------------------- # ● アニメタイプ #-------------------------------------------------------------------------- def anime_type return ANIME[self.condition] != nil ? ANIME[self.condition][0] : 0 end end #============================================================================== # ■ Game_Actor #============================================================================== class Game_Actor < Game_Battler include Side_view #-------------------------------------------------------------------------- # ● セットアップ #-------------------------------------------------------------------------- alias side_view_setup setup def setup(actor_id) side_view_setup(actor_id) start_battle end #-------------------------------------------------------------------------- # ● 二刀武器のID取得 ※エラー回避用 #-------------------------------------------------------------------------- def weapon2_id return @weapon2_id != nil ? @weapon2_id : 0 end #-------------------------------------------------------------------------- # ● X方向 ポジション 取得 (陣形スクリプト拡張用) #-------------------------------------------------------------------------- def position return $data_classes[@class_id].position end #-------------------------------------------------------------------------- # ● Y方向 ポジション 取得 (陣形スクリプト拡張用) #-------------------------------------------------------------------------- def position2 return self.index end #-------------------------------------------------------------------------- # ● 武器アニメタイプ #-------------------------------------------------------------------------- def weapon_anime_type(type) file_name = weapon_anime_type0(type) visible = weapon_anime_type1(type) z = weapon_anime_type2(type) return [file_name,visible,z] end # 武器アイコン取得 def weapon_anime_type0(type) type = ANIME[type][5] return weapon_anime1 if type == "右手" return weapon_anime2 if type == "左手" return nil end # 表示・非表示の取得 def weapon_anime_type1(type) return ANIME[type][3] end # バトラーより上に表示するかどうか def weapon_anime_type2(type) type = ANIME[type][5] return true if type == "左手" return false end #-------------------------------------------------------------------------- # ● バトル画面 X 座標の取得(カメラ補正無し) #-------------------------------------------------------------------------- def true_x return PARTY_X + position * FORMATION_X + @ox end #-------------------------------------------------------------------------- # ● バトル画面 Y 座標の取得(カメラ補正無し) #-------------------------------------------------------------------------- def true_y # パーティ内の並び順から Y 座標を計算して返す if self.index != nil y = position2 * FORMATION_Y + PARTY_Y + @oy - @height / 2 return y else return 0 end end #-------------------------------------------------------------------------- # ● バトル画面 X 座標の取得 #-------------------------------------------------------------------------- def screen_x(true_x = self.true_x) return 320 + (true_x - 320) * @real_zoom + @real_x end #-------------------------------------------------------------------------- # ● バトル画面 Y 座標の取得 #-------------------------------------------------------------------------- def screen_y(true_y = self.true_y) return true_y * @real_zoom + @real_y end #-------------------------------------------------------------------------- # ● バトル画面 Z 座標の取得 #-------------------------------------------------------------------------- def screen_z return screen_y + 1000 end #-------------------------------------------------------------------------- # ● バトル画面 X 座標の取得(移動などしていない場合) #-------------------------------------------------------------------------- def base_x return 320 + (true_x - @ox - 320) * @real_zoom + @real_x end #-------------------------------------------------------------------------- # ● バトル画面 Y 座標の取得 #-------------------------------------------------------------------------- def base_y return (true_y - @oy) * @real_zoom + @real_y end #-------------------------------------------------------------------------- # ● バトル画面 拡大率の取得 #-------------------------------------------------------------------------- def zoom return ($scene.zoom_rate[1] - $scene.zoom_rate[0]) * (true_x + @fly) / 480 + $scene.zoom_rate[0] end #-------------------------------------------------------------------------- # ● 攻撃用、バトル画面 X 座標の取得 #-------------------------------------------------------------------------- def attack_x(z) return (320 - true_x) * z * 0.75 end #-------------------------------------------------------------------------- # ● 攻撃用、バトル画面 Y 座標の取得 #-------------------------------------------------------------------------- def attack_y(z) return (160 - (true_y + fly / 4) * z + @height * zoom * z / 2) * 0.75 end #-------------------------------------------------------------------------- # ● 閃き待ち時間 #-------------------------------------------------------------------------- def flash_duration return $scene.flash_duration end #-------------------------------------------------------------------------- # ● アニメーション取得 #-------------------------------------------------------------------------- def battle_actions1 weapon = $data_weapons[@weapon_id] return weapon != nil ? weapon.battle_actions : BattleActions::Actions["通常攻撃"] end #-------------------------------------------------------------------------- # ● アニメーション取得 #-------------------------------------------------------------------------- def battle_actions2 weapon = $data_weapons[@weapon2_id] return weapon != nil ? weapon.battle_actions : BattleActions::Actions["通常攻撃"] end #-------------------------------------------------------------------------- # ● 武器アニメーション取得 #-------------------------------------------------------------------------- def weapon_anime1 weapon = $data_weapons[@weapon_id] return weapon != nil ? weapon.icon_name : "" end #-------------------------------------------------------------------------- # ● 武器アニメーション取得 #-------------------------------------------------------------------------- def weapon_anime2 weapon = $data_weapons[@weapon2_id] return weapon != nil ? weapon.icon_name : "" end #-------------------------------------------------------------------------- # ● 遠距離アニメーション取得 #-------------------------------------------------------------------------- def flying_anime1 weapon = $data_weapons[@weapon_id] return weapon != nil ? weapon.flying_anime : [0,0,false,false] end #-------------------------------------------------------------------------- # ● 遠距離アニメーション取得 #-------------------------------------------------------------------------- def flying_anime2 weapon = $data_weapons[@weapon2_id] return weapon != nil ? weapon.flying_anime : [0,0,false,false] end #-------------------------------------------------------------------------- # ● 移動目標座標の計算 #-------------------------------------------------------------------------- def move_setup if RTAB targets = @target else targets = $scene.target_battlers end case @move_action[0] when "self" # 自分 @target_x = self.base_x @target_y = self.base_y when "target_near" # 一番近くのターゲット targets.sort!{|a,b| a.screen_x<=>b.screen_x } targets.reverse! if targets != [] @target_x = targets[0].screen_x @target_y = targets[0].screen_y else @target_x = self.base_x @target_y = self.base_y end when "target_far" # 一番遠くのターゲット targets.sort!{|a,b| a.screen_x<=>b.screen_x } if targets != [] @target_x = targets[0].screen_x @target_y = targets[0].screen_y else @target_x = self.base_x @target_y = self.base_y end when "target" # ターゲット中央 @target_x = 0 @target_y = 0 for t in targets @target_x += t.screen_x @target_y += t.screen_y end if targets != [] @target_x /= targets.size @target_y /= targets.size end when "troop" # "トループ中央" @target_x = 0 @target_y = 0 for t in $game_troop.enemies @target_x += t.screen_x @target_y += t.screen_y end if $game_troop.enemies != [] @target_x /= $game_troop.enemies.size @target_y /= $game_troop.enemies.size end when "party" # "パーティ中央" @target_x = 0 @target_y = 0 for t in $game_party.actors @target_x += t.screen_x @target_y += t.screen_y end if $game_party.actors != [] @target_x /= $game_party.actors.size @target_y /= $game_party.actors.size end when "screen" # "画面" @target_x = self.base_x @target_y = self.base_y end # 補正 @target_x += @move_action[1] - self.base_x @target_y += @move_action[2] - self.base_y # 移動目標の座標をセット @move_coordinates = [@target_x.to_i,@target_y.to_i,@move_coordinates[0],@move_coordinates[1]] # 距離の計算(ウエイトの設定) @move_wait = (@move_coordinates[2] - @move_coordinates[0]).abs + (@move_coordinates[3] - @move_coordinates[1]).abs end end #============================================================================== # ■ Game_Enemy #============================================================================== class Game_Enemy < Game_Battler #-------------------------------------------------------------------------- # ● セットアップ #-------------------------------------------------------------------------- alias side_view_initialize initialize def initialize(troop_id, member_index) side_view_initialize(troop_id, member_index) start_battle end #-------------------------------------------------------------------------- # ● 移動 #-------------------------------------------------------------------------- def move # 距離の計算 @move_distance = (@move_coordinates[2] - @move_coordinates[0]).abs + (@move_coordinates[3] - @move_coordinates[1]).abs if @move_distance > 0 return if @ox == @move_coordinates[0] and @oy == @move_coordinates[1] array = @move_coordinates # ジャンプ補正値の計算 if @move_distance - @move_wait > @move_distance / 2 jump = (@move_action[4] * @move_wait / @move_distance.to_f)**2 else jump = (@move_action[4] * (@move_distance - @move_wait) / @move_distance.to_f)**2 end jump = @move_action[4] > 0 ? -jump : jump @ox = (array[2] + 1.0 * (array[0] - array[2]) * (@move_distance - @move_wait) / @move_distance.to_f).to_i @oy = (array[3] + 1.0 * (array[1] - array[3]) * (@move_distance - @move_wait) / @move_distance.to_f + jump).to_i # ウエイト @move_wait -= @move_action[3] @move_wait = [@move_wait,0].max end end #-------------------------------------------------------------------------- # ● 移動目標座標の計算 #-------------------------------------------------------------------------- def move_setup if RTAB targets = @target else targets = $scene.target_battlers end case @move_action[0] when "self" # 自分 @target_x = self.base_x @target_y = self.base_y when "target_near" # 一番近くのターゲット targets.sort!{|a,b| a.screen_x<=>b.screen_x } if targets != [] @target_x = targets[0].screen_x @target_y = targets[0].screen_y else @target_x = self.base_x @target_y = self.base_y end when "target_far" # 一番遠くのターゲット targets.sort!{|a,b| a.screen_x<=>b.screen_x } targets.reverse! if targets != [] @target_x = targets[0].screen_x @target_y = targets[0].screen_y else @target_x = self.base_x @target_y = self.base_y end when "target" # ターゲット中央 @target_x = 0 @target_y = 0 for t in targets @target_x += t.screen_x @target_y += t.screen_y end if targets != [] @target_x /= targets.size @target_y /= targets.size end when "party" # "トループ中央" @target_x = 0 @target_y = 0 for t in $game_troop.enemies @target_x += t.screen_x @target_y += t.screen_y end if $game_troop.enemies != [] @target_x /= $game_troop.enemies.size @target_y /= $game_troop.enemies.size end when "troop" # "パーティ中央" @target_x = 0 @target_y = 0 for t in $game_party.actors @target_x += t.screen_x @target_y += t.screen_y end if $game_party.actors != [] @target_x /= $game_party.actors.size @target_y /= $game_party.actors.size end when "screen" # "画面" @target_x = self.base_x @target_y = self.base_y end # 補正 @target_x -= @move_action[1] + self.base_x @target_y -= @move_action[2] + self.base_y # 移動目標の座標をセット @move_coordinates = [@target_x.to_i,@target_y.to_i,@move_coordinates[0],@move_coordinates[1]] # 距離の計算(ウエイトの設定) @move_wait = (@move_coordinates[2] - @move_coordinates[0]).abs + (@move_coordinates[3] - @move_coordinates[1]).abs end if RTAB alias original_x true_x alias original_y true_y else alias original_x screen_x alias original_y screen_y end #-------------------------------------------------------------------------- # ● バトル画面 X 座標の取得(カメラ補正無し) #-------------------------------------------------------------------------- def true_x return original_x + @ox end #-------------------------------------------------------------------------- # ● バトル画面 Y 座標の取得(カメラ補正無し) #-------------------------------------------------------------------------- def true_y return original_y - @height / 2 + @oy end #-------------------------------------------------------------------------- # ● バトル画面 X 座標の取得 #-------------------------------------------------------------------------- def screen_x(true_x = self.true_x) return true_x * @real_zoom + @real_x end #-------------------------------------------------------------------------- # ● バトル画面 Y 座標の取得 #-------------------------------------------------------------------------- def screen_y(true_y = self.true_y) return true_y * @real_zoom + @real_y end #-------------------------------------------------------------------------- # ● バトル画面 X 座標の取得(移動などしていない場合) #-------------------------------------------------------------------------- def base_x(true_x = self.true_x) return (true_x - @ox) * @real_zoom + @real_x end #-------------------------------------------------------------------------- # ● バトル画面 Y 座標の取得(移動などしていない場合) #-------------------------------------------------------------------------- def base_y(true_y = self.true_y) return (true_y - @oy) * @real_zoom + @real_y end end #============================================================================== # ■ Game_Party #============================================================================== class Game_Party #-------------------------------------------------------------------------- # ● アクターを加える # actor_id : アクター ID #-------------------------------------------------------------------------- alias side_view_add_actor add_actor def add_actor(actor_id) # アクターを取得 actor = $game_actors[actor_id] # サイドビューデータの初期化 actor.start_battle # 戻す side_view_add_actor(actor_id) end end #============================================================================== # ■ Scene_Battle #============================================================================== class Scene_Battle include Side_view #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :phase # フェーズ attr_reader :phase4_step # フェーズ4ステップ attr_reader :active_battler # 対象の配列 attr_reader :target_battlers # 対象の配列 attr_reader :animation1_id # 行動アニメID attr_reader :animation2_id # 対象アニメID #-------------------------------------------------------------------------- # ● メイン処理 #-------------------------------------------------------------------------- alias side_view_main main def main # バトラー初期化 for battler in $game_party.actors + $game_troop.enemies battler.start_battle end # 戻す side_view_main end #-------------------------------------------------------------------------- # ● 閃き判定 #-------------------------------------------------------------------------- def flash? return @flash_flag ? true : false end #-------------------------------------------------------------------------- # ● 閃きアニメ待ち時間取得 #-------------------------------------------------------------------------- def flash_duration animation = nil if FLASH_ANIME animation = $data_animations[FLASH_ANIMATION_ID] end return animation != nil ? animation.frame_max * 2 + 2 : 0 end #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 2 : アクション開始) #-------------------------------------------------------------------------- alias side_view_update_phase4_step2 update_phase4_step2 def update_phase4_step2(*arg) battler = convert_battler2(*arg) battler.action side_view_update_phase4_step2(*arg) end #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 3 : 行動側アニメーション) #-------------------------------------------------------------------------- alias side_view_update_phase4_step3 update_phase4_step3 def update_phase4_step3(*arg) battler = convert_battler2(*arg) return if !battler.animation1_on and battler.action? and !battler.flash? if battler.flash? and FLASH_ANIME battler.flash_flag["normal"] = true end side_view_update_phase4_step3(*arg) end #-------------------------------------------------------------------------- # ● フレーム更新 (メインフェーズ ステップ 4 : 対象側アニメーション) #-------------------------------------------------------------------------- alias side_view_update_phase4_step4 update_phase4_step4 def update_phase4_step4(*arg) battler = convert_battler2(*arg) targets = RTAB ? battler.target : @target_battlers return if !battler.animation2_on and battler.action? side_view_update_phase4_step4(*arg) for target in targets if RTAB value = nil if target.damage_sp.include?(battler) value = target.damage_sp[battler] end if target.damage.include?(battler) if value == nil or value == "Miss" value = target.damage[battler] elsif value.is_a?(Numeric) && value > 0 value = target.damage[battler] == "Miss" ? value : target.damage[battler] end end else value = target.damage end if target.is_a?(Game_Actor) # ダメージの場合 if value.is_a?(Numeric) && value > 0 # シェイクを開始 target.shake = true end elsif target.is_a?(Game_Enemy) # ダメージの場合 if value.is_a?(Numeric) && value > 0 # シェイクを開始 target.shake = true end end end end #-------------------------------------------------------------------------- # ● プレバトルフェーズ開始 #-------------------------------------------------------------------------- alias start_phase1_correct start_phase1 def start_phase1 # カメラの設定 # 元々フロントビュー向けの数値になっているため @zoom_rate = [1.0, 1.0] start_phase1_correct end #-------------------------------------------------------------------------- # ● アクターコマンドフェーズ開始 #-------------------------------------------------------------------------- alias start_phase3_correct start_phase3 def start_phase3 battler = convert_battler start_phase3_correct if RTAB # カメラの設定 # 元々フロントビュー向けの数値になっているため @camera = "command" @spriteset.screen_target(0, 0, 1.0) end end end class Spriteset_Battle include Side_view #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias side_veiw_initialize initialize def initialize side_veiw_initialize # アクタースプライトを解放 for sprite in @actor_sprites sprite.dispose end # アクタースプライトを作成 @actor_sprites = [] for i in 1..Party_max @actor_sprites.push(Sprite_Battler.new(@viewport1)) end update end #-------------------------------------------------------------------------- # ● 画面のスクロール #-------------------------------------------------------------------------- if method_defined?("screen_scroll") alias side_view_screen_scroll screen_scroll def screen_scroll side_view_screen_scroll # アクターの位置補正 for actor in $game_party.actors actor.real_x = @real_x actor.real_y = @real_y actor.real_zoom = @real_zoom end end end end class Sprite_Battler < RPG::Sprite include Side_view #-------------------------------------------------------------------------- # ● オブジェクト初期化 # viewport : ビューポート # battler : バトラー (Game_Battler) #-------------------------------------------------------------------------- def initialize(viewport, battler = nil) super(viewport) @battler = battler @battler_visible = false @weapon = Sprite_Weapon.new(viewport, battler) @flying = Sprite_Flying.new(viewport, battler) @shadow = [] @fly = 0 @fly_direction = 1 @rand = rand(10) self.effect_clear end #-------------------------------------------------------------------------- # ● 解放 #-------------------------------------------------------------------------- alias side_view_dispose dispose def dispose side_view_dispose @weapon.dispose @flying.dispose if @_target_sprite != nil @_target_sprite.bitmap.dispose @_target_sprite.dispose @_target_sprite = nil end end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super # バトラーが nil の場合 if @battler == nil self.bitmap = nil @weapon.bitmap = nil loop_animation(nil) return end # バトラー更新 @battler.update # バトラーアニメのデータ取得 @anime_type = @battler.anime_type # ファイル名か色相が現在のものと異なる場合 if @battler.is_a?(Game_Actor) change = (@battler.character_name != @battler_name or @battler.character_hue != @battler_hue) elsif @battler.is_a?(Game_Enemy) change = (@battler.battler_name != @battler_name or @battler.battler_hue != @battler_hue) else return end if change # ビットマップを取得、設定 if @battler.is_a?(Game_Actor) @battler_name = @battler.character_name @battler_hue = @battler.character_hue self.bitmap = RPG::Cache.character(@battler_name, @battler_hue) @width = bitmap.width / 4 @height = bitmap.height / 4 else @battler_name = @battler.battler_name @battler_hue = @battler.battler_hue self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue) @width = bitmap.width @height = bitmap.height end self.ox = @width / 2 self.oy = @height / 2 @battler.height = @height @flag = true # 戦闘不能または隠れ状態なら不透明度を 0 にする if @battler.dead? or @battler.hidden self.opacity = 0 end end if @battler.is_a?(Game_Actor) and (@battler.anime_type != @anime_type or @battler.pattern != @pattern or @flag) # ビットマップを取得、設定 @pattern = @battler.pattern self.ox = @width / 2 self.oy = @height / 2 @sx = @pattern * @width @sy = @anime_type % 4 * @height self.src_rect.set(@sx, @sy, @width, @height) self.zoom_x = CHAR_ZOOM self.zoom_y = CHAR_ZOOM @battler.height = @height @flag = false end # 飛行 update_fly # シェイク update_shake # 回転 update_turning # 反転 update_reverse # 移動 update_moving # 追加アニメ update_add_anime # エフェクト効果の適用 update_effect # アニメーション ID が現在のものと異なる場合 flag = RTAB ? true : @battler.damage == nil if flag and @battler.state_animation_id != @state_animation_id @state_animation_id = @battler.state_animation_id loop_animation($data_animations[@state_animation_id]) end # シェイク if @battler.shake self.start_shake(5, 5, 5) @battler.shake = false end # 明滅 if @battler.blink blink_on else blink_off end # 不可視の場合 unless @battler_visible flag = RTAB ? (@battler.damage.size < 2 or @battler.damage_pop.size < 2) : (@battler.damage == nil or @battler.damage_pop) # 出現 if not @battler.hidden and not @battler.dead? and flag appear @battler_visible = true end end if RTAB # ダメージ for battler in @battler.damage_pop if battler[0].class == Array if battler[0][1] >= 0 $scene.skill_se else $scene.levelup_se end damage(@battler.damage[battler[0]], false, 2) else damage(@battler.damage[battler[0]], @battler.critical[battler[0]]) end if @battler.damage_sp.include?(battler[0]) damage(@battler.damage_sp[battler[0]], @battler.critical[battler[0]], 1) @battler.damage_sp.delete(battler[0]) end @battler.damage_pop.delete(battler[0]) @battler.damage.delete(battler[0]) @battler.critical.delete(battler[0]) end end # 可視の場合 if @battler_visible # 武器アニメ @weapon.battler = @battler @weapon.update # 遠距離アニメ @flying.battler = @battler @flying.update # 逃走 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 RTAB # アニメーション if !@battler.animation.empty? for animation in @battler.animation.reverse if animation[2] animation($data_animations[animation[0]], animation[1], true) else animation($data_animations[animation[0]], animation[1]) end @battler.animation.delete(animation) end end else # アニメーション if @battler.animation_id != 0 animation = $data_animations[@battler.animation_id] animation(animation, @battler.animation_hit) @battler.animation_id = 0 end end # ダメージ if !RTAB and @battler.damage_pop damage(@battler.damage, @battler.critical) @battler.damage = nil @battler.critical = false @battler.damage_pop = false end flag = RTAB ? (@battler.damage.empty? and $scene.dead_ok?(@battler)) : @battler.damage == nil # コラプス if flag and @battler.dead? if @battler.is_a?(Game_Actor) $game_system.se_play($data_system.actor_collapse_se) elsif @battler.is_a?(Game_Enemy) $game_system.se_play($data_system.enemy_collapse_se) end collapse @battler_visible = false end end # スプライトの座標を設定 self.x = @battler.screen_x + @effect_ox self.y = @battler.screen_y + @effect_oy self.z = @battler.screen_z self.zoom_x = @battler.real_zoom self.zoom_y = @battler.real_zoom # ウェイトカウントを減らす @battler.wait_count -= 1 @battler.wait_count2 -= 1 # アニメーション待ち時間取得 @battler.animation_duration = @_animation_duration if @battler.is_a?(Game_Actor) self.zoom_x *= CHAR_ZOOM self.zoom_y *= CHAR_ZOOM @weapon.x = self.x + 2 @weapon.y = self.y + 6 @weapon.angle = 75 - (4 - @battler.pattern) * 45 if self.mirror @weapon.angle += @weapon.angle - 180 end end # 残像 if @battler.shadow if Graphics.frame_count % 2 == 0 shadow = ::Sprite.new(self.viewport) shadow.bitmap = self.bitmap.dup shadow.x = self.x shadow.y = self.y shadow.ox = self.ox shadow.oy = self.oy shadow.mirror = self.mirror shadow.angle = self.angle shadow.opacity = 160 shadow.zoom_x = self.zoom_x shadow.zoom_y = self.zoom_y if @battler.is_a?(Game_Actor) shadow.src_rect.set(@sx, @sy, @width, @height) else shadow.src_rect.set(0, 0, @width, @height) end @shadow.push([shadow,duration = 10,@battler.true_x + @effect_ox,@battler.true_y + @effect_oy]) end end for s in @shadow if !s[0].disposed? s[0].update s[1] -= 1 if s[1] < 1 if s[0].bitmap != nil s[0].bitmap.dispose end s[0].dispose else s[0].x = @battler.screen_x(s[2]) s[0].y = @battler.screen_y(s[3]) end else s = nil end end @shadow.compact! end #-------------------------------------------------------------------------- # ● エフェクトによる座標系の更新 #-------------------------------------------------------------------------- def update_effect # 角度の修正 if @_upside_down self.angle = (@_turning + 180) % 360 else self.angle = @_turning end # X 座標の修正値 @effect_ox = @_shake + @_moving[0] # Y 座標の修正値 @effect_oy = -@fly + @_moving[1] if @_animation == nil or (RTAB and @_animation.empty?) self.effect_clear end end #-------------------------------------------------------------------------- # ● シェイク更新 #-------------------------------------------------------------------------- def update_shake if @_shake_duration >= 1 or @_shake != 0 delta = (@_shake_power * @_shake_speed * @_shake_direction) / 10.0 if @_shake_duration <= 1 and @_shake * (@_shake + delta) < 0 @_shake = 0 else @_shake += delta end if @_shake > @_shake_power * 2 @_shake_direction = -1 end if @_shake < - @_shake_power * 2 @_shake_direction = 1 end if @_shake_duration >= 1 @_shake_duration -= 1 end end end #-------------------------------------------------------------------------- # ● 飛行更新 #-------------------------------------------------------------------------- def update_fly if @rand > 0 @rand -= 1 return end if @battler.fly != 0 if @fly < @battler.fly / 4 @fly_direction = 1 elsif @fly > @battler.fly / 2 @fly_direction = -1 end @fly += 0.5 * @fly_direction end end #-------------------------------------------------------------------------- # ● 回転更新 #-------------------------------------------------------------------------- def update_turning if @_turning_duration > 0 or @_turning != 0 @_turning += @_turning_direction * @_turning_speed / 2.0 # 残り回転数を減らす if @_turning_direction == -1 if @_turning_duration > 0 and @_turning < 0 @_turning_duration -= 1 end elsif @_turning_direction == 1 if @_turning_duration > 0 and @_turning >= 360 @_turning_duration -= 1 end end # 以下補正 while @_turning < 0 @_turning += 360 end if @_turning_duration <= 0 @_turning = 0 end @_turning %= 360 end end #-------------------------------------------------------------------------- # ● 左右反転更新 #-------------------------------------------------------------------------- def update_reverse if @last_reverse != (@_reverse or @battler.reverse) self.mirror = (@_reverse or @battler.reverse) @last_reverse = (@_reverse or @battler.reverse) end end #-------------------------------------------------------------------------- # ● 移動更新 #-------------------------------------------------------------------------- def update_moving @move_distance = (@_move_coordinates[2] - @_move_coordinates[0]).abs + (@_move_coordinates[3] - @_move_coordinates[1]).abs if @move_distance > 0 return if @_moving[0] == @_move_coordinates[0] and @_moving[1] == @_move_coordinates[1] array = @_move_coordinates x = (array[2] + 1.0 * (array[0] - array[2]) * (@move_distance - @_move_duration) / @move_distance.to_f).to_i y = (array[3] + 1.0 * (array[1] - array[3]) * (@move_distance - @_move_duration) / @move_distance.to_f).to_i @_moving = [x, y] if @_move_quick_return and @_move_duration == 0 @_move_coordinates = [0,0,array[0],array[1]] @_move_duration = @move_distance end @_move_duration -= @_move_speed @_move_duration = [@_move_duration, 0].max end end #-------------------------------------------------------------------------- # ● 追加アニメ更新 (RTAB限定機能) #-------------------------------------------------------------------------- def update_add_anime if RTAB # アニメーション if @_add_anime_id != 0 animation = $data_animations[@_add_anime_id] animation(animation, true) @_add_anime_id = 0 end end end #-------------------------------------------------------------------------- # ● エフェクト初期化 #-------------------------------------------------------------------------- def effect_clear @_effect_ox = 0 @_effect_oy = 0 @_shake_power = 0 @_shake_speed = 0 @_shake_duration = 0 @_shake_direction = 1 @_shake = 0 @_upside_down = false @_reverse = false @_turning_direction = 1 @_turning_speed = 0 @_turning_duration = 0 @_turning = 0 @_move_quick_return = true @_move_speed = 0 @_move_coordinates = [0,0,0,0] @_move_jump = false @_move_duration = 0 @_moving = [0,0] @_add_anime_id = 0 end #-------------------------------------------------------------------------- # ● シェイクの開始 # power : 強さ # speed : 速さ # duration : 時間 #-------------------------------------------------------------------------- def start_shake(power, speed, duration) @_shake_power = power @_shake_speed = speed @_shake_duration = duration end #-------------------------------------------------------------------------- # ● 上下反転を開始 #-------------------------------------------------------------------------- def start_upside_down @_upside_down = @_upside_down ? false : true end #-------------------------------------------------------------------------- # ● 左右反転を開始 #-------------------------------------------------------------------------- def start_reverse @_reverse = @_reverse ? false : true end #-------------------------------------------------------------------------- # ● 回転を開始 # direction: 方向 # speed : 速さ # duration : 時間 #-------------------------------------------------------------------------- def start_turning(direction, speed, duration) @_turning_direction = direction @_turning_speed = speed @_turning_duration = duration @_turning = @_turning_direction == 1 ? 0 : 360 end #-------------------------------------------------------------------------- # ● 移動を開始 # quick_return : 戻るかどうか # speed : 速さ # x : X 座標 # y : Y 座標 #-------------------------------------------------------------------------- def start_moving(quick_return, speed, x, y) @_move_quick_return = quick_return == 0 ? false : true @_move_speed = speed @_move_coordinates = [x,y,@_move_coordinates[0],@_move_coordinates[1]] distance = (@_move_coordinates[2] - @_move_coordinates[0]).abs + (@_move_coordinates[3] - @_move_coordinates[1]).abs @_move_duration = distance end #-------------------------------------------------------------------------- # ● アニメ追加を開始 # id : ID # hit : 命中フラッグ #-------------------------------------------------------------------------- def start_add_anime(id) @_add_anime_id = id end #-------------------------------------------------------------------------- # ● 各種エフェクトの開始判定 #-------------------------------------------------------------------------- if !method_defined?("side_view_animation_process_timing") alias side_view_animation_process_timing animation_process_timing end def animation_process_timing(timing, hit) side_view_animation_process_timing(timing, hit) if (timing.condition == 0) or (timing.condition == 1 and hit == true) or (timing.condition == 2 and hit == false) if timing.se.name =~ SHAKE_FILE names = timing.se.name.split(/#/) power = names[1].nil? ? SHAKE_POWER : names[1].to_i speed = names[2].nil? ? SHAKE_SPEED : names[2].to_i duration = names[3].nil? ? SHAKE_DURATION : names[3].to_i # シェイクを開始 self.start_shake(power, speed, duration) end if timing.se.name == UPSIDE_DOWN_FILE # 上下反転を開始 self.start_upside_down end if timing.se.name == REVERSE_FILE # 左右反転を開始 self.start_reverse end if timing.se.name =~ TURNING_FILE names = timing.se.name.split(/#/) direction = names[1].nil? ? TURNING_DIRECTION : names[1].to_i speed = names[2].nil? ? TURNING_SPEED : names[2].to_i duration = names[3].nil? ? TURNING_DURATION : names[3].to_i # 回転を開始 self.start_turning(direction, speed, duration) end if timing.se.name =~ MOVE_FILE names = timing.se.name.split(/#/) quick_return= names[1].nil? ? MOVE_RETURN : names[1].to_i speed = names[2].nil? ? MOVE_SPEED : names[2].to_i x = names[3].nil? ? MOVE_COORDINATES[0] : names[3].to_i y = names[3].nil? ? MOVE_COORDINATES[1] : names[4].to_i # 移動を開始 self.start_moving(quick_return, speed, x, y) end if timing.se.name =~ ADD_ANIME_FILE names = timing.se.name.split(/#/) id = names[1].nil? ? ADD_ANIME_ID : names[1].to_i # アニメ追加を開始 self.start_add_anime(id) end end end end #============================================================================== # ■ Sprite_Weapon #------------------------------------------------------------------------------ # バトラー表示用のスプライトです。Game_Battler クラスのインスタンスを監視し、 # スプライトの状態を自動的に変化させます。 #============================================================================== class Sprite_Weapon < RPG::Sprite include Side_view #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :battler # バトラー attr_reader :cw # グラフィックの幅 attr_reader :ch # グラフィックの高さ #-------------------------------------------------------------------------- # ● オブジェクト初期化 # viewport : ビューポート # battler : バトラー (Game_Battler) #-------------------------------------------------------------------------- def initialize(viewport, battler = nil) super(viewport) @battler = battler @battler_visible = false end #-------------------------------------------------------------------------- # ● 解放 #-------------------------------------------------------------------------- def dispose if self.bitmap != nil self.bitmap.dispose end super end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super # バトラーが nil の場合 if @battler == nil or !@battler.is_a?(Game_Actor) self.bitmap = nil return end # ウエポンアニメのデータ取得 @weapon_anime_type = @battler.weapon_anime_type(@battler.condition) # 設定が「非表示」の場合 if !@weapon_anime_type[1] or @weapon_anime_type[0].nil? self.visible = false return else self.visible = true end # ファイル名が現在のものと異なる場合 if @weapon_anime_type[0] != @weapon_name @weapon_name = @weapon_anime_type[0] # ビットマップを取得、設定 self.bitmap = RPG::Cache.icon(@weapon_name) @width = bitmap.width @height = bitmap.height @flag = true end # 現在アニメパターンが現在のものと異なる場合 if @pattern != @battler.pattern or @flag or @condition != @battler.condition @pattern = @battler.pattern @condition = @battler.condition self.ox = @width self.oy = @height self.z = battler.screen_z self.zoom_x = @battler.real_zoom * CHAR_ZOOM self.zoom_y = @battler.real_zoom * CHAR_ZOOM self.src_rect.set(0, 0, @width, @height) self.opacity = 255 # バトラーより手前に表示 if @weapon_anime_type[2] self.z += 10 # バトラーより奥に表示 else self.z -= 10 end @flag = false end end end #============================================================================== # ■ Sprite_Flying #------------------------------------------------------------------------------ # バトラー表示用のスプライトです。Game_Battler クラスのインスタンスを監視し、 # スプライトの状態を自動的に変化させます。 #============================================================================== class Sprite_Flying < RPG::Sprite include Side_view #-------------------------------------------------------------------------- # ● 公開インスタンス変数 #-------------------------------------------------------------------------- attr_accessor :battler # バトラー #-------------------------------------------------------------------------- # ● オブジェクト初期化 # viewport : ビューポート # battler : バトラー (Game_Battler) #-------------------------------------------------------------------------- def initialize(viewport, battler = nil) super(viewport) @battler = battler @battler_visible = false end #-------------------------------------------------------------------------- # ● 解放 #-------------------------------------------------------------------------- def dispose if self.bitmap != nil self.bitmap.dispose end super end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- def update super # バトラーが nil の場合 if @battler == nil self.bitmap = nil loop_animation(nil) return end # 遠距離アニメ flying_animation = @battler.flying_animation flying_start = flying_animation[0] flying_end = flying_animation[1] # アニメーション ID が現在のものと異なる場合 if @anime_id != @battler.flying_anime[0] @anime_id = @battler.flying_anime[0] @animation = $data_animations[@anime_id] end # アニメーション 開始 if flying_start loop_animation(@animation) elsif flying_end loop_animation(nil) end self.x = @battler.flying_x self.y = @battler.flying_y self.z = @battler.screen_z + 1000 end end module RPG class Skill #-------------------------------------------------------------------------- # ● 魔法かどうかの判断 #-------------------------------------------------------------------------- def magic? if @atk_f == 0 return true else return false end end end end # アローカーソルの位置修正 class Arrow_Actor < Arrow_Base include Side_view #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- alias side_view_update update def update side_view_update # スプライトの座標を設定 if self.actor != nil && (self.x != self.actor.screen_x + ARROW_OX or self.y != self.actor.screen_y + ARROW_OY) self.x = self.actor.screen_x + ARROW_OX self.y = self.actor.screen_y + ARROW_OY end end end class Arrow_Enemy < Arrow_Base include Side_view #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- alias side_view_update update def update side_view_update # スプライトの座標を設定 if self.enemy != nil && self.y != self.enemy.screen_y + self.enemy.height/2 self.x = self.enemy.screen_x self.y = self.enemy.screen_y + self.enemy.height/2 end end end
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |