Project1

标题: 请问RTAB战斗系统的脚本怎么用 [打印本页]

作者: uijk777    时间: 2008-7-13 00:10
标题: 请问RTAB战斗系统的脚本怎么用
请问大家......RTAB战斗系统的脚本怎么用!?我知道怎么插入这脚本,但进如游戏后,一碰怪系统就提示脚本1412行出错,请高手指点一下(下面是这个的脚本)
[LINE]1,#dddddd[/LINE]此贴于 2008-7-29 7:29:07 被版主darkten提醒,请楼主看到后对本贴做出回应。 [LINE]1,#dddddd[/LINE]此贴于 2008-8-2 14:04:41 被版主darkten提醒,请楼主看到后对本贴做出回应。 [LINE]1,#dddddd[/LINE]版务信息:本贴由楼主自主结贴~
作者: uijk777    时间: 2008-7-13 00:18
对不起,因为脚本太长,所以请高手进入这空间里看这脚本了:
http://hi.baidu.com/uijk777
作者: chenyin    时间: 2008-7-13 00:38
我是来提醒楼主的,脚本用这个
  1. [code]
复制代码
[/code]
还有,发错区了……
水一下~……
作者: uijk777    时间: 2008-7-13 00:45
米办法,还是太长,只能分这写了。
[code]
脚本内容

# ————————————————————————————————————
# 本脚本来自www.66rpg.com,转载请保留此信息
# ————————————————————————————————————

# リアルタイム・アクティブバトル(RTAB) Ver 1.05
# 配布元・サポートURL
# http://members.jcom.home.ne.jp/cogwheel/

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 : ダメージ表示待ち時間(単位はフレーム)
    # @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 = 2
    @anime_wait = false
    @damage_wait = 10
    @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 = []
    @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

作者: uijk777    时间: 2008-7-13 00:47
# 第一命中判定
    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)
      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] = []
    # アイテムの効果範囲が 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)
      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.nonresistance
          # ステート変化フラグをセット
          @state_changed = true
          # ステートを付加
          add_state(i)
        # このステートがフルではない場合
        elsif self.state_full?(i) == false
          # ステート有効度を確率に変換し、乱数と比較
          if rand(100) < [0,100,80,60,40,20,0][self.state_ranks]
            # ステート変化フラグをセット
            @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
    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

作者: uijk777    时间: 2008-7-13 00:47
# ダメージを設定
    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.hp > 0 or actor.damage.size > 0
        return false
      end
    end
    # 全滅
    return true
  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

作者: uijk777    时间: 2008-7-13 00:48
  #--------------------------------------------------------------------------
  # ● 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.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 クラスの内部で使用されます。

作者: uijk777    时间: 2008-7-13 00:48
#==============================================================================

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] != 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
        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].x += sx
            end
          end
        end
        if @_loop_animation_sprites != nil
          for i in 0..15
            @_loop_animation_sprites.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].y += sy
            end
          end
        end
        if @_loop_animation_sprites != nil
          for i in 0..15
            @_loop_animation_sprites.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


作者: uijk777    时间: 2008-7-13 00:49
最后回复:
各位管理员,不是我想赚积分,是实在没办法,这脚本太长了{/gg}
作者: chenyin    时间: 2008-7-13 00:54
楼主,我在说一遍,用
代码复制
  1.  
这个的中间写上脚本内容……{/gg}
作者: uijk777    时间: 2008-7-13 01:10
囧......对不起,偶刚来这论坛,不然你帮我写?
作者: chenyin    时间: 2008-7-13 01:25
脚本内容


  1. # ————————————————————————————————————
  2. # 本脚本来自www.66rpg.com,转载请保留此信息
  3. # ————————————————————————————————————

  4. # リアルタイム・アクティブバトル(RTAB) Ver 1.05
  5. # 配布元・サポートURL
  6. # http://members.jcom.home.ne.jp/cogwheel/

  7. class Scene_Battle
  8. #--------------------------------------------------------------------------
  9. # ● 公開インスタンス変数
  10. #--------------------------------------------------------------------------
  11. attr_reader   :status_window            # ステータスウィンドウ
  12. attr_reader   :spriteset                # バトルスプライト
  13. attr_reader   :scroll_time              # スクリーン移動基本時間
  14. attr_reader   :zoom_rate                # 敵バトラー基本位置
  15. attr_reader   :drive                    # カメラ駆動
  16. attr_accessor :force                    # アクション強制度
  17. attr_accessor :camera                   # 現在のカメラ所持者
  18. #--------------------------------------------------------------------------
  19. # ● ATB基礎セットアップ
  20. #--------------------------------------------------------------------------
  21. def atb_setup
  22.    # ATB初期化
  23.    # speed   : バトルスピード決定。値が小さいほど早い
  24.    # @active : アクティブ度設定
  25.    #           3 : 常にアクティブ状態
  26.    #           2 : スキル・アイテム選択中のみアクティブゲージが止まる
  27.    #           1 : 2の状態に加え、ターゲット選択時もウェイトが掛かる
  28.    #           0 : 1の状態に加え、コマンド入力時にもウェイトが掛かる
  29.    # @action : 他人が行動中に自分も行動を起こすことを許すか
  30.    #           3 : 自分が行動不能でない限り限り許す
  31.    #           2 : 自分がダメージを受けていない限り許す
  32.    #           1 : 2の状態に加え、ターゲットが行動していない限り許す
  33.    #           0 : 行動を許さない。順番に行動し終えるまで待つ
  34.    # @anime_wait : trueにするとバトルアニメ・ダメージ表示中はウェイトが掛かる
  35.    # @damage_wait : ダメージ表示待ち時間(単位はフレーム)
  36.    # @enemy_speed : 敵の思考速度。1なら即時行動。
  37.    #                1フレーム毎に、1/@enemy_speedの確率で行動を起こす
  38.    # @force : 強制アクションでスキル使用時の強制具合
  39.    #          2:スキルは全て詠唱せず、必ず即時実行
  40.    #          1:単独スキルは詠唱し、連携スキルのみ即時実行
  41.    #          0:全スキル詠唱を行うだけ
  42.    # ($scene.force = x とすることにより、通常イベントのスクリプトから変更可能)
  43.    # @drive : カメラ駆動ON/OFF。trueで駆動ON、falseで駆動OFF
  44.    # @scroll_time : スクリーン移動に要する基本時間
  45.    # @zoom_rate = [i, j] : エネミーのズーム率
  46.    #                       i が画面最上部に配置した時の拡大率
  47.    #                       j が画面最下部に配置した時の拡大率
  48.    #                       1 倍としたいときも、1.0 と必ず小数で設定すること
  49.    speed = 150
  50.    @active = 1
  51.    @action = 2
  52.    @anime_wait = false
  53.    @damage_wait = 10
  54.    @enemy_speed = 40
  55.    @force = 2
  56.    @drive = true
  57.    @scroll_time = 15
  58.    @zoom_rate = [0.2, 1.0]
  59.    @help_time = 40
  60.    @escape == false
  61.    @camera = nil
  62.    @max = 0
  63.    @turn_cnt = 0
  64.    @help_wait = 0
  65.    @action_battlers = []
  66.    @synthe = []
  67.    @spell_p = {}
  68.    @spell_e = {}
  69.    @command_a = false
  70.    @command = []
  71.    @party = false
  72.    for battler in $game_party.actors + $game_troop.enemies
  73.      spell_reset(battler)
  74.      battler.at = battler.agi * rand(speed / 2)
  75.      battler.damage_pop = {}
  76.      battler.damage = {}
  77.      battler.damage_sp = {}
  78.      battler.critical = {}
  79.      battler.recover_hp = {}
  80.      battler.recover_sp = {}
  81.      battler.state_p = {}
  82.      battler.state_m = {}
  83.      battler.animation = []
  84.      if battler.is_a?(Game_Actor)
  85.        @max += battler.agi
  86.      end
  87.    end
  88.    @max *= speed
  89.    @max /= $game_party.actors.size
  90.    for battler in $game_party.actors + $game_troop.enemies
  91.      battler.atp = 100 * battler.at / @max
  92.    end
  93. end
  94. #--------------------------------------------------------------------------
  95. # ● ATゲージMax時SE
  96. #--------------------------------------------------------------------------
  97. def fullat_se
  98.    Audio.se_play("Audio/SE/033-switch02", 80, 100)
  99. end
  100. #--------------------------------------------------------------------------
  101. # ● レベルアップSE
  102. #--------------------------------------------------------------------------
  103. def levelup_se
  104.    Audio.se_play("Audio/SE/056-Right02", 80, 100)
  105. end
  106. #--------------------------------------------------------------------------
  107. # ● スキル習得SE
  108. #--------------------------------------------------------------------------
  109. def skill_se
  110.    Audio.se_play("Audio/SE/056-Right02", 80, 150)
  111. end
  112. end

  113. class Window_Base < Window
  114. #--------------------------------------------------------------------------
  115. # ● ATG の描画
  116. #     actor : アクター
  117. #     x     : 描画先 X 座標
  118. #     y     : 描画先 Y 座標
  119. #     width : 描画先の幅
  120. #--------------------------------------------------------------------------
  121. def draw_actor_atg(actor, x, y, width = 144)
  122.    if @at_gauge == nil
  123.      # plus_x:X座標の位置補正 rate_x:X座標の位置補正(%) plus_y:Y座標の位置補正
  124.      # plus_width:幅の補正 rate_width:幅の補正(%) height:縦幅
  125.      # align1:描画タイプ1 0:左詰め 1:中央揃え 2:右詰め
  126.      # align2:描画タイプ2 0:上詰め 1:中央揃え 2:下詰め
  127.      # align3:ゲージタイプ 0:左詰め 1:右詰め
  128.      @plus_x = 0
  129.      @rate_x = 0
  130.      @plus_y = 16
  131.      @plus_width = 0
  132.      @rate_width = 100




  133. # 第一命中判定
  134.    hit_result = (rand(100) < attacker.hit)
  135.    # 命中の場合
  136.    if hit_result == true
  137.      # 基本ダメージを計算
  138.      atk = [attacker.atk - self.pdef / 2, 0].max
  139.      self.damage[attacker] = atk * (20 + attacker.str) / 20
  140.      # 属性修正
  141.      self.damage[attacker] *= elements_correct(attacker.element_set)
  142.      self.damage[attacker] /= 100
  143.      # ダメージの符号が正の場合
  144.      if self.damage[attacker] > 0
  145.        # クリティカル修正
  146.        if rand(100) < 4 * attacker.dex / self.agi
  147.          self.damage[attacker] *= 2
  148.          self.critical[attacker] = true
  149.        end
  150.        # 防御修正
  151.        if self.guarding?
  152.          self.damage[attacker] /= 2
  153.        end
  154.      end
  155.      # 分散
  156.      if self.damage[attacker].abs > 0
  157.        amp = [self.damage[attacker].abs * 15 / 100, 1].max
  158.        self.damage[attacker] += rand(amp+1) + rand(amp+1) - amp
  159.      end
  160.      # 第二命中判定
  161.      eva = 8 * self.agi / attacker.dex + self.eva
  162.      hit = self.damage[attacker] < 0 ? 100 : 100 - eva
  163.      hit = self.cant_evade? ? 100 : hit
  164.      hit_result = (rand(100) < hit)
  165.    end
  166.    # 命中の場合
  167.    if hit_result == true
  168.      # ステート衝撃解除
  169.      remove_states_shock
  170.      # HP からダメージを減算
  171.      # ステート変化
  172.      @state_changed = false
  173.      states_plus(attacker, attacker.plus_state_set)
  174.      states_minus(attacker, attacker.minus_state_set)
  175.    # ミスの場合
  176.    else
  177.      # ダメージに "Miss" を設定
  178.      self.damage[attacker] = "Miss"
  179.      # クリティカルフラグをクリア
  180.      self.critical[attacker] = false
  181.    end
  182.    # メソッド終了
  183.    return true
  184. end
  185. #--------------------------------------------------------------------------
  186. # ● スキルの効果適用
  187. #     user  : スキルの使用者 (バトラー)
  188. #     skill : スキル
  189. #--------------------------------------------------------------------------
  190. def skill_effect(user, skill)
  191.    # クリティカルフラグをクリア
  192.    self.critical[user] = false
  193.    state_p[user] = []
  194.    state_m[user] = []
  195.    # スキルの効果範囲が HP 1 以上の味方で、自分の HP が 0、
  196.    # またはスキルの効果範囲が HP 0 の味方で、自分の HP が 1 以上の場合
  197.    if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
  198.       ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
  199.      # メソッド終了
  200.      return false
  201.    end
  202.    # 有効フラグをクリア
  203.    effective = false
  204.    # コモンイベント ID が有効の場合は有効フラグをセット
  205.    effective |= skill.common_event_id > 0
  206.    # 第一命中判定
  207.    hit = skill.hit
  208.    if skill.atk_f > 0
  209.      hit *= user.hit / 100
  210.    end
  211.    hit_result = (rand(100) < hit)
  212.    # 不確実なスキルの場合は有効フラグをセット
  213.    effective |= hit < 100
  214.    # 命中の場合
  215.    if hit_result == true
  216.      # 威力を計算
  217.      power = skill.power + user.atk * skill.atk_f / 100
  218.      if power > 0
  219.        power -= self.pdef * skill.pdef_f / 200
  220.        power -= self.mdef * skill.mdef_f / 200
  221.        power = [power, 0].max
  222.      end
  223.      # 倍率を計算
  224.      rate = 20
  225.      rate += (user.str * skill.str_f / 100)
  226.      rate += (user.dex * skill.dex_f / 100)
  227.      rate += (user.agi * skill.agi_f / 100)
  228.      rate += (user.int * skill.int_f / 100)
  229.      # 基本ダメージを計算
  230.      self.damage[user] = power * rate / 20
  231.      # 属性修正
  232.      self.damage[user] *= elements_correct(skill.element_set)
  233.      self.damage[user] /= 100
  234.      # ダメージの符号が正の場合
  235.      if self.damage[user] > 0
  236.        # 防御修正
  237.        if self.guarding?
  238.          self.damage[user] /= 2
  239.        end
  240.      end
  241.      # 分散
  242.      if skill.variance > 0 and self.damage[user].abs > 0
  243.        amp = [self.damage[user].abs * skill.variance / 100, 1].max
  244.        self.damage[user] += rand(amp+1) + rand(amp+1) - amp
  245.      end
  246.      # 第二命中判定
  247.      eva = 8 * self.agi / user.dex + self.eva
  248.      hit = self.damage[user] < 0 ? 100 : 100 - eva * skill.eva_f / 100
  249.      hit = self.cant_evade? ? 100 : hit
  250.      hit_result = (rand(100) < hit)
  251.      # 不確実なスキルの場合は有効フラグをセット
  252.      effective |= hit < 100
  253.    end
  254.    # 命中の場合
  255.    if hit_result == true
  256.      # 威力 0 以外の物理攻撃の場合
  257.      if skill.power != 0 and skill.atk_f > 0
  258.        # ステート衝撃解除
  259.        remove_states_shock
  260.        # 有効フラグをセット
  261.        effective = true
  262.      end
  263.      # HP の変動判定
  264.      last_hp = [[self.hp - self.damage[user], self.maxhp].min, 0].max
  265.      # 効果判定
  266.      effective |= self.hp != last_hp
  267.      # ステート変化
  268.      @state_changed = false
  269.      effective |= states_plus(user, skill.plus_state_set)
  270.      effective |= states_minus(user, skill.minus_state_set)
  271.      unless $game_temp.in_battle
  272.        self.damage_effect(user, 1)
  273.      end
  274.      # 威力が 0 の場合
  275.      if skill.power == 0
  276.        # ダメージに空文字列を設定
  277.        self.damage[user] = ""
  278.        # ステートに変化がない場合
  279.        unless @state_changed
  280.          # ダメージに "Miss" を設定
  281.          self.damage[user] = "Miss"
  282.        end
  283.      end
  284.    # ミスの場合
  285.    else
  286.      # ダメージに "Miss" を設定
  287.      self.damage[user] = "Miss"
  288.    end
  289.    # 戦闘中でない場合
  290.    unless $game_temp.in_battle
  291.      # ダメージに nil を設定
  292.      self.damage[user] = nil
  293.    end
  294.    # メソッド終了
  295.    return effective
  296. end
  297. #--------------------------------------------------------------------------
  298. # ● アイテムの効果適用
  299. #     item : アイテム
  300. #--------------------------------------------------------------------------
  301. def item_effect(item, user = $game_party.actors[0])
  302.    # クリティカルフラグをクリア
  303.    self.critical[user] = false
  304.    state_p[user] = []
  305.    state_m[user] = []
  306.    # アイテムの効果範囲が HP 1 以上の味方で、自分の HP が 0、
  307.    # またはアイテムの効果範囲が HP 0 の味方で、自分の HP が 1 以上の場合
  308.    if ((item.scope == 3 or item.scope == 4) and self.hp == 0) or
  309.       ((item.scope == 5 or item.scope == 6) and self.hp >= 1)
  310.      # メソッド終了
  311.      return false
  312.    end
  313.    # 有効フラグをクリア
  314.    effective = false
  315.    # コモンイベント ID が有効の場合は有効フラグをセット
  316.    effective |= item.common_event_id > 0
  317.    # 命中判定
  318.    hit_result = (rand(100) < item.hit)
  319.    # 不確実なスキルの場合は有効フラグをセット
  320.    effective |= item.hit < 100
  321.    # 命中の場合
  322.    if hit_result == true
  323.      # 回復量を計算
  324.      self.recover_hp[user] = maxhp * item.recover_hp_rate / 100 +
  325.                              item.recover_hp
  326.      self.recover_sp[user] = maxsp * item.recover_sp_rate / 100 +
  327.                              item.recover_sp
  328.      if self.recover_hp[user] < 0
  329.        self.recover_hp[user] += self.pdef * item.pdef_f / 20
  330.        self.recover_hp[user] += self.mdef * item.mdef_f / 20
  331.        self.recover_hp[user] = [self.recover_hp[user], 0].min
  332.      end
  333.      # 属性修正
  334.      self.recover_hp[user] *= elements_correct(item.element_set)
  335.      self.recover_hp[user] /= 100
  336.      self.recover_sp[user] *= elements_correct(item.element_set)
  337.      self.recover_sp[user] /= 100
  338.      # 分散
  339.      if item.variance > 0 and self.recover_hp[user].abs > 0
  340.        amp = [self.recover_hp[user].abs * item.variance / 100, 1].max
  341.        self.recover_hp[user] += rand(amp+1) + rand(amp+1) - amp
  342.      end
  343.      if item.variance > 0 and self.recover_sp[user].abs > 0
  344.        amp = [self.recover_sp[user].abs * item.variance / 100, 1].max
  345.        self.recover_sp[user] += rand(amp+1) + rand(amp+1) - amp
  346.      end
  347.      # 回復量の符号が負の場合
  348.      if self.recover_hp[user] < 0
  349.        # 防御修正
  350.        if self.guarding?
  351.          self.recover_hp[user] /= 2
  352.        end
  353.      end
  354.      # HP 回復量の符号を反転し、ダメージの値に設定
  355.      self.damage[user] = -self.recover_hp[user]
  356.      # HP および SP の変動判定
  357.      last_hp = [[self.hp + self.recover_hp[user], self.maxhp].min, 0].max
  358.      last_sp = [[self.sp + self.recover_sp[user], self.maxsp].min, 0].max
  359.      effective |= self.hp != last_hp
  360.      effective |= self.sp != last_sp
  361.      # ステート変化
  362.      @state_changed = false
  363.      effective |= states_plus(user, item.plus_state_set)
  364.      effective |= states_minus(user, item.minus_state_set)
  365.      unless $game_temp.in_battle
  366.        self.damage_effect(user, 2)
  367.      end
  368.      # パラメータ上昇値が有効の場合
  369.      if item.parameter_type > 0 and item.parameter_points != 0
  370.        # パラメータで分岐
  371.        case item.parameter_type
  372.        when 1  # MaxHP
  373.          @maxhp_plus += item.parameter_points
  374.        when 2  # MaxSP
  375.          @maxsp_plus += item.parameter_points
  376.        when 3  # 腕力
  377.          @str_plus += item.parameter_points
  378.        when 4  # 器用さ
  379.          @dex_plus += item.parameter_points
  380.        when 5  # 素早さ
  381.          @agi_plus += item.parameter_points
  382.        when 6  # 魔力
  383.          @int_plus += item.parameter_points
  384.        end
  385.        # 有効フラグをセット
  386.        effective = true
  387.      end
  388.      # HP 回復率と回復量が 0 の場合
  389.      if item.recover_hp_rate == 0 and item.recover_hp == 0
  390.        # ダメージに空文字列を設定
  391.        self.damage[user] = ""
  392.        # SP 回復率と回復量が 0、パラメータ上昇値が無効の場合
  393.        if item.recover_sp_rate == 0 and item.recover_sp == 0 and
  394.           (item.parameter_type == 0 or item.parameter_points == 0)
  395.          # ステートに変化がない場合
  396.          unless @state_changed
  397.            # ダメージに "Miss" を設定
  398.            self.damage[user] = "Miss"
  399.          end
  400.        end
  401.      end
  402.    # ミスの場合
  403.    else
  404.      # ダメージに "Miss" を設定
  405.      self.damage[user] = "Miss"
  406.    end
  407.    # 戦闘中でない場合
  408.    unless $game_temp.in_battle
  409.      # ダメージに nil を設定
  410.      self.damage[user] = nil
  411.    end
  412.    # メソッド終了
  413.    return effective
  414. end
  415. #--------------------------------------------------------------------------
  416. # ● ステート変化 (+) の適用
  417. #     plus_state_set  : ステート変化 (+)
  418. #--------------------------------------------------------------------------
  419. def states_plus(battler, plus_state_set)
  420.    # 有効フラグをクリア
  421.    effective = false
  422.    # ループ (付加するステート)
  423.    for i in plus_state_set
  424.      # このステートが防御されていない場合
  425.      unless self.state_guard?(i)
  426.        # このステートがフルでなければ有効フラグをセット
  427.        effective |= self.state_full?(i) == false
  428.        # ステートが [抵抗しない] の場合
  429.        if $data_states[i].nonresistance
  430.          # ステート変化フラグをセット
  431.          @state_changed = true
  432.          # ステートを付加
  433.          add_state(i)
  434.        # このステートがフルではない場合
  435.        elsif self.state_full?(i) == false
  436.          # ステート有効度を確率に変換し、乱数と比較
  437.          if rand(100) < [0,100,80,60,40,20,0][self.state_ranks[i]]
  438.            # ステート変化フラグをセット
  439.            @state_changed = true
  440.            # ステートを付加
  441.            self.state_p[battler].push(i)
  442.          end
  443.        end
  444.      end
  445.    end
  446.    # メソッド終了
  447.    return effective
  448. end
  449. #--------------------------------------------------------------------------
  450. # ● ステート変化 (-) の適用
  451. #     minus_state_set : ステート変化 (-)
  452. #--------------------------------------------------------------------------
  453. def states_minus(battler, minus_state_set)
  454.    # 有効フラグをクリア
  455.    effective = false
  456.    # ループ (解除するステート)
  457.    for i in minus_state_set
  458.      # このステートが付加されていれば有効フラグをセット
  459.      effective |= self.state?(i)
  460.      # ステート変化フラグをセット
  461.      @state_changed = true
  462.      # ステートを解除
  463.      self.state_m[battler].push(i)
  464.    end
  465.    # メソッド終了
  466.    return effective
  467. end
  468. #--------------------------------------------------------------------------
  469. # ● ダメージ演算
  470. #--------------------------------------------------------------------------
  471. def damage_effect(battler, item)
  472.    if item == 2
  473.      self.hp += self.recover_hp[battler]
  474.      self.sp += self.recover_sp[battler]
  475.      if self.recover_sp[battler] != 0
  476.        self.damage_sp[battler] = -self.recover_sp[battler]
  477.      end
  478.    else
  479.      if self.damage[battler].class != String
  480.        self.hp -= self.damage[battler]
  481.      end
  482.    end
  483.    for i in self.state_p[battler]
  484.      add_state(i)
  485.    end
  486.    for i in self.state_m[battler]
  487.      remove_state(i)
  488.    end
  489. end
  490. #--------------------------------------------------------------------------
  491. # ● スリップダメージの効果適用
  492. #--------------------------------------------------------------------------
  493. def slip_damage_effect


  494. # ダメージを設定
  495.    self.damage["slip"] = self.maxhp / 10
  496.    # 分散
  497.    if self.damage["slip"].abs > 0
  498.      amp = [self.damage["slip"].abs * 15 / 100, 1].max
  499.      self.damage["slip"] += rand(amp+1) + rand(amp+1) - amp
  500.    end
  501.    # HP からダメージを減算
  502.    self.hp -= self.damage["slip"]
  503.    # メソッド終了
  504.    return true
  505. end
  506. end

  507. #==============================================================================
  508. # ■ Game_BattleAction
  509. #------------------------------------------------------------------------------
  510. #  アクション (戦闘中の行動) を扱うクラスです。このクラスは Game_Battler クラ
  511. # スの内部で使用されます。
  512. #==============================================================================

  513. class Game_BattleAction
  514. #--------------------------------------------------------------------------
  515. # ● 公開インスタンス変数
  516. #--------------------------------------------------------------------------
  517. attr_accessor :spell_id                 # 合体魔法用スキル ID
  518. attr_accessor :force_kind               # 種別 (基本 / スキル / アイテム)
  519. attr_accessor :force_basic              # 基本 (攻撃 / 防御 / 逃げる)
  520. attr_accessor :force_skill_id           # スキル ID
  521. #--------------------------------------------------------------------------
  522. # ● 有効判定
  523. #--------------------------------------------------------------------------
  524. def valid?
  525.    return (not (@force_kind == 0 and @force_basic == 3))
  526. end
  527. end

  528. #==============================================================================
  529. # ■ Game_Actor
  530. #------------------------------------------------------------------------------
  531. #  アクターを扱うクラスです。このクラスは Game_Actors クラス ($game_actors)
  532. # の内部で使用され、Game_Party クラス ($game_party) からも参照されます。
  533. #==============================================================================

  534. class Game_Actor < Game_Battler
  535. def skill_can_use?(skill_id)
  536.    return super
  537. end
  538. end

  539. #==============================================================================
  540. # ■ Game_Enemy
  541. #------------------------------------------------------------------------------
  542. #  エネミーを扱うクラスです。このクラスは Game_Troop クラス ($game_troop) の
  543. # 内部で使用されます。
  544. #==============================================================================

  545. class Game_Enemy < Game_Battler
  546. #--------------------------------------------------------------------------
  547. # ● 公開インスタンス変数
  548. #--------------------------------------------------------------------------
  549. attr_accessor :height                  # 画像の高さ
  550. attr_accessor :real_x                  # X座標補正
  551. attr_accessor :real_y                  # Y座標補正
  552. attr_accessor :real_zoom               # 拡大率
  553. #--------------------------------------------------------------------------
  554. # ● オブジェクト初期化
  555. #     troop_id     : トループ ID
  556. #     member_index : トループメンバーのインデックス
  557. #--------------------------------------------------------------------------
  558. def initialize(troop_id, member_index)
  559.    super()
  560.    @troop_id = troop_id
  561.    @member_index = member_index
  562.    troop = $data_troops[@troop_id]
  563.    @enemy_id = troop.members[@member_index].enemy_id
  564.    enemy = $data_enemies[@enemy_id]
  565.    @battler_name = enemy.battler_name
  566.    @battler_hue = enemy.battler_hue
  567.    @hp = maxhp
  568.    @sp = maxsp
  569.    @real_x = 0
  570.    @real_y = 0
  571.    @real_zoom = 1.0
  572.    @fly = 0
  573.    enemy.name.sub(/\\[Ff]\[([0-9]+)\]/) {@fly = $1.to_i}
  574.    @hidden = troop.members[@member_index].hidden
  575.    @immortal = troop.members[@member_index].immortal
  576. end
  577. alias :true_x :screen_x
  578. alias :true_y :screen_y
  579. #--------------------------------------------------------------------------
  580. # ● バトル画面 X 座標の取得
  581. #--------------------------------------------------------------------------
  582. def screen_x
  583.    return 320 + (true_x - 320) * @real_zoom + @real_x
  584. end
  585. #--------------------------------------------------------------------------
  586. # ● バトル画面 Y 座標の取得
  587. #--------------------------------------------------------------------------
  588. def screen_y
  589.    return true_y * @real_zoom + @real_y
  590. end
  591. #--------------------------------------------------------------------------
  592. # ● バトル画面 Z 座標の取得
  593. #--------------------------------------------------------------------------
  594. def screen_z
  595.    return true_y + @fly
  596. end
  597. #--------------------------------------------------------------------------
  598. # ● バトル画面 拡大率の取得
  599. #--------------------------------------------------------------------------
  600. def zoom
  601.    return ($scene.zoom_rate[1] - $scene.zoom_rate[0]) *
  602.                          (true_y + @fly) / 320 + $scene.zoom_rate[0]
  603. end
  604. #--------------------------------------------------------------------------
  605. # ● 攻撃用、バトル画面 X 座標の取得
  606. #--------------------------------------------------------------------------
  607. def attack_x(z)
  608.    return (320 - true_x) * z * 0.75
  609. end
  610. #--------------------------------------------------------------------------
  611. # ● 攻撃用、バトル画面 Y 座標の取得
  612. #--------------------------------------------------------------------------
  613. def attack_y(z)
  614.    return (160 - (true_y + @fly / 4) * z + @height * zoom * z / 2) * 0.75
  615. end
  616. #--------------------------------------------------------------------------
  617. # ● アクション作成
  618. #--------------------------------------------------------------------------
  619. def make_action
  620.    # カレントアクションをクリア
  621.    self.current_action.clear
  622.    # 動けない場合
  623.    unless self.inputable?
  624.      # メソッド終了
  625.      return
  626.    end
  627.    # 現在有効なアクションを抽出
  628.    available_actions = []
  629.    rating_max = 0
  630.    for action in self.actions
  631.      # ターン 条件確認
  632.      n = $game_temp.battle_turn
  633.      a = action.condition_turn_a
  634.      b = action.condition_turn_b
  635.      if (b == 0 and n != a) or
  636.         (b > 0 and (n < 1 or n < a or n % b != a % b))
  637.        next
  638.      end
  639.      # HP 条件確認
  640.      if self.hp * 100.0 / self.maxhp > action.condition_hp
  641.        next
  642.      end
  643.      # レベル 条件確認
  644.      if $game_party.max_level < action.condition_level
  645.        next
  646.      end
  647.      # スイッチ 条件確認
  648.      switch_id = action.condition_switch_id
  649.      if switch_id > 0 and $game_switches[switch_id] == false
  650.        next
  651.      end
  652.      # スキル使用可能 条件確認
  653.      if action.kind == 1
  654.        unless self.skill_can_use?(action.skill_id)
  655.          next
  656.        end
  657.      end
  658.      # 条件に該当 : このアクションを追加
  659.      available_actions.push(action)
  660.      if action.rating > rating_max
  661.        rating_max = action.rating
  662.      end
  663.    end
  664.    # 最大のレーティング値を 3 として合計を計算 (0 以下は除外)
  665.    ratings_total = 0
  666.    for action in available_actions
  667.      if action.rating > rating_max - 3
  668.        ratings_total += action.rating - (rating_max - 3)
  669.      end
  670.    end
  671.    # レーティングの合計が 0 ではない場合
  672.    if ratings_total > 0
  673.      # 乱数を作成
  674.      ;value = rand(ratings_total)
  675.      # 作成した乱数に対応するものをカレントアクションに設定
  676.      for action in available_actions
  677.        if action.rating > rating_max - 3
  678.          if value < action.rating - (rating_max - 3)
  679.            self.current_action.kind = action.kind
  680.            self.current_action.basic = action.basic
  681.            self.current_action.skill_id = action.skill_id
  682.            self.current_action.decide_random_target_for_enemy
  683.            return
  684.          else
  685.            ;value -= action.rating - (rating_max - 3)
  686.          end
  687.        end
  688.      end
  689.    end
  690. end
  691. end

  692. #==============================================================================
  693. # ■ Game_Party
  694. #------------------------------------------------------------------------------
  695. #  パーティを扱うクラスです。ゴールドやアイテムなどの情報が含まれます。このク
  696. # ラスのインスタンスは $game_party で参照されます。
  697. #==============================================================================

  698. class Game_Party
  699. #--------------------------------------------------------------------------
  700. # ● 全滅判定
  701. #--------------------------------------------------------------------------
  702. def all_dead?
  703.    # パーティ人数が 0 人の場合
  704.    if $game_party.actors.size == 0
  705.      return false
  706.    end
  707.    # HP 0 以上のアクターがパーティにいる場合
  708.    for actor in @actors
  709.      if actor.hp > 0 or actor.damage.size > 0
  710.        return false
  711.      end
  712.    end
  713.    # 全滅
  714.    return true
  715. end
  716. end

  717. #==============================================================================
  718. # ■ Sprite_Battler
  719. #------------------------------------------------------------------------------
  720. #  バトラー表示用のスプライトです。Game_Battler クラスのインスタンスを監視し、
  721. # スプライトの状態を自動的に変化させます。
  722. #==============================================================================

  723. class Sprite_Battler < RPG::Sprite
  724. #--------------------------------------------------------------------------
  725. # ● フレーム更新
  726. #--------------------------------------------------------------------------
  727. def update
  728.    super
  729.    # バトラーが nil の場合
  730.    if @battler == nil
  731.      self.bitmap = nil
  732.      loop_animation(nil)
  733.      return
  734.    end
  735.    # ファイル名か色相が現在のものと異なる場合
  736.    if @battler.battler_name != @battler_name or
  737.       @battler.battler_hue != @battler_hue
  738.      # ビットマップを取得、設定
  739.      @battler_name = @battler.battler_name
  740.      @battler_hue = @battler.battler_hue
  741.      self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
  742.      @width = bitmap.width
  743.      @height = bitmap.height
  744.      self.ox = @width / 2
  745.      self.oy = @height
  746.      if @battler.is_a?(Game_Enemy)
  747.        @battler.height = @height
  748.      end
  749.      # 戦闘不能または隠れ状態なら不透明度を 0 にする
  750.      if @battler.dead? or @battler.hidden
  751.        self.opacity = 0
  752.      end
  753.    end
  754.    # アニメーション ID が現在のものと異なる場合
  755.    if @battler.state_animation_id != @state_animation_id
  756.      @state_animation_id = @battler.state_animation_id
  757.      loop_animation($data_animations[@state_animation_id])
  758.    end
  759.    # 表示されるべきアクターの場合
  760.    if @battler.is_a?(Game_Actor) and @battler_visible
  761.      # メインフェーズでないときは不透明度をやや下げる
  762.      if $game_temp.battle_main_phase
  763.        self.opacity += 3 if self.opacity < 255
  764.      else
  765.        self.opacity -= 3 if self.opacity > 207
  766.      end
  767.    end
  768.    # 明滅
  769.    if @battler.blink
  770.      blink_on
  771.    else
  772.      blink_off
  773.    end
  774.    # 不可視の場合
  775.    unless @battler_visible
  776.      # 出現
  777.      if not @battler.hidden and not @battler.dead? and
  778.         (@battler.damage.size < 2 or @battler.damage_pop.size < 2)
  779.        appear
  780.        @battler_visible = true
  781.      end
  782.    end
  783.    # ダメージ
  784.    for battler in @battler.damage_pop
  785.      if battler[0].class == Array
  786.        if battler[0][1] >= 0
  787.          $scene.skill_se
  788.        else
  789.          $scene.levelup_se
  790.        end
  791.        damage(@battler.damage[battler[0]], false, 2)
  792.      else
  793.        damage(@battler.damage[battler[0]], @battler.critical[battler[0]])
  794.      end
  795.      if @battler.damage_sp.include?(battler[0])
  796.        damage(@battler.damage_sp[battler[0]],
  797.                @battler.critical[battler[0]], 1)
  798.        @battler.damage_sp.delete(battler[0])
  799.      end
  800.      @battler.damage_pop.delete(battler[0])
  801.      @battler.damage.delete(battler[0])
  802.      @battler.critical.delete(battler[0])
  803.    end
  804.    # 可視の場合
  805.    if @battler_visible
  806.      # 逃走
  807.      if @battler.hidden
  808.        $game_system.se_play($data_system.escape_se)
  809.        escape
  810.        @battler_visible = false
  811.      end
  812.      # 白フラッシュ
  813.      if @battler.white_flash
  814.        whiten
  815.        @battler.white_flash = false
  816.      end
  817.      # アニメーション
  818.      unless @battler.animation.empty?
  819.        for animation in @battler.animation.reverse
  820.          animation($data_animations[animation[0]], animation[1])
  821.          @battler.animation.delete(animation)
  822.        end
  823.      end
  824.      # コラプス
  825.      if @battler.damage.empty? and @battler.dead?
  826.        if $scene.dead_ok?(@battler)
  827.          if @battler.is_a?(Game_Enemy)
  828.            $game_system.se_play($data_system.enemy_collapse_se)
  829.          else
  830.            $game_system.se_play($data_system.actor_collapse_se)
  831.          end
  832.          collapse
  833.          @battler_visible = false
  834.        end
  835.      end
  836.    end
  837.    # スプライトの座標を設定
  838.    self.x = @battler.screen_x
  839.    self.y = @battler.screen_y
  840.    self.z = @battler.screen_z
  841.    if @battler.is_a?(Game_Enemy)
  842.      self.zoom_x = @battler.real_zoom * @battler.zoom
  843.      self.zoom_y = @battler.real_zoom * @battler.zoom
  844.    end
  845. end
  846. end

  847. #==============================================================================
  848. # ■ Window_Base
  849. #------------------------------------------------------------------------------
  850. #  ゲーム中のすべてのウィンドウのスーパークラスです。
  851. #==============================================================================

  852. class Window_Base < Window
  853. #--------------------------------------------------------------------------
  854. # ● ゲージの描画
  855. #--------------------------------------------------------------------------
  856. def gauge_rect_at(width, height, align3,
  857.                    color1, color2, color3, color4, color5, color6, color7,
  858.                    color8, color9, color10, color11, color12, grade1, grade2)
  859.    # 枠描画
  860.    @at_gauge = Bitmap.new(width, height * 5)
  861.    @at_gauge.fill_rect(0, 0, width, height, color1)
  862.    @at_gauge.fill_rect(1, 1, width - 2, height - 2, color2)
  863.    if (align3 == 1 and grade1 == 0) or grade1 > 0
  864.      color = color3
  865.      color3 = color4
  866.      color4 = color
  867.    end
  868.    if (align3 == 1 and grade2 == 0) or grade2 > 0
  869.      color = color5
  870.      color5 = color6
  871.      color6 = color
  872.      color = color7
  873.      color7 = color8
  874.      color8 = color
  875.      color = color9
  876.      color9 = color10
  877.      color10 = color
  878.      color = color11
  879.      color11 = color12
  880.      color12 = color
  881.    end
  882.    if align3 == 0
  883.      if grade1 == 2
  884.        grade1 = 3
  885.      end
  886.      if grade2 == 2
  887.        grade2 = 3
  888.      end
  889.    end
  890.    # 空ゲージの描画 縦にグラデーション表示
  891.    @at_gauge.gradation_rect(2, 2, width - 4, height - 4,
  892.                                  color3, color4, grade1)
  893.    # 実ゲージの描画
  894.    @at_gauge.gradation_rect(2, height + 2, width- 4, height - 4,
  895.                                  color5, color6, grade2)
  896.    @at_gauge.gradation_rect(2, height * 2 + 2, width- 4, height - 4,
  897.                                  color7, color8, grade2)
  898.    @at_gauge.gradation_rect(2, height * 3 + 2, width- 4, height - 4,
  899.                                  color9, color10, grade2)
  900.    @at_gauge.gradation_rect(2, height * 4 + 2, width- 4, height - 4,
  901.                                  color11, color12, grade2)
  902. end
  903. end
复制代码


[LINE]1,#dddddd[/LINE]系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~
作者: chenyin    时间: 2008-7-13 01:27
  1. # ————————————————————————————————————
  2. # 本脚本来自www.66rpg.com,转载请保留此信息
  3. # ————————————————————————————————————

  4. # リアルタイム・アクティブバトル(RTAB) Ver 1.05
  5. # 配布元・サポートURL
  6. # http://members.jcom.home.ne.jp/cogwheel/

  7. class Scene_Battle
  8. #--------------------------------------------------------------------------
  9. # ● 公開インスタンス変数
  10. #--------------------------------------------------------------------------
  11. attr_reader   :status_window            # ステータスウィンドウ
  12. attr_reader   :spriteset                # バトルスプライト
  13. attr_reader   :scroll_time              # スクリーン移動基本時間
  14. attr_reader   :zoom_rate                # 敵バトラー基本位置
  15. attr_reader   :drive                    # カメラ駆動
  16. attr_accessor :force                    # アクション強制度
  17. attr_accessor :camera                   # 現在のカメラ所持者
  18. #--------------------------------------------------------------------------
  19. # ● ATB基礎セットアップ
  20. #--------------------------------------------------------------------------
  21. def atb_setup
  22.    # ATB初期化
  23.    # speed   : バトルスピード決定。値が小さいほど早い
  24.    # @active : アクティブ度設定
  25.    #           3 : 常にアクティブ状態
  26.    #           2 : スキル・アイテム選択中のみアクティブゲージが止まる
  27.    #           1 : 2の状態に加え、ターゲット選択時もウェイトが掛かる
  28.    #           0 : 1の状態に加え、コマンド入力時にもウェイトが掛かる
  29.    # @action : 他人が行動中に自分も行動を起こすことを許すか
  30.    #           3 : 自分が行動不能でない限り限り許す
  31.    #           2 : 自分がダメージを受けていない限り許す
  32.    #           1 : 2の状態に加え、ターゲットが行動していない限り許す
  33.    #           0 : 行動を許さない。順番に行動し終えるまで待つ
  34.    # @anime_wait : trueにするとバトルアニメ・ダメージ表示中はウェイトが掛かる
  35.    # @damage_wait : ダメージ表示待ち時間(単位はフレーム)
  36.    # @enemy_speed : 敵の思考速度。1なら即時行動。
  37.    #                1フレーム毎に、1/@enemy_speedの確率で行動を起こす
  38.    # @force : 強制アクションでスキル使用時の強制具合
  39.    #          2:スキルは全て詠唱せず、必ず即時実行
  40.    #          1:単独スキルは詠唱し、連携スキルのみ即時実行
  41.    #          0:全スキル詠唱を行うだけ
  42.    # ($scene.force = x とすることにより、通常イベントのスクリプトから変更可能)
  43.    # @drive : カメラ駆動ON/OFF。trueで駆動ON、falseで駆動OFF
  44.    # @scroll_time : スクリーン移動に要する基本時間
  45.    # @zoom_rate = [i, j] : エネミーのズーム率
  46.    #                       i が画面最上部に配置した時の拡大率
  47.    #                       j が画面最下部に配置した時の拡大率
  48.    #                       1 倍としたいときも、1.0 と必ず小数で設定すること
  49.    speed = 150
  50.    @active = 1
  51.    @action = 2
  52.    @anime_wait = false
  53.    @damage_wait = 10
  54.    @enemy_speed = 40
  55.    @force = 2
  56.    @drive = true
  57.    @scroll_time = 15
  58.    @zoom_rate = [0.2, 1.0]
  59.    @help_time = 40
  60.    @escape == false
  61.    @camera = nil
  62.    @max = 0
  63.    @turn_cnt = 0
  64.    @help_wait = 0
  65.    @action_battlers = []
  66.    @synthe = []
  67.    @spell_p = {}
  68.    @spell_e = {}
  69.    @command_a = false
  70.    @command = []
  71.    @party = false
  72.    for battler in $game_party.actors + $game_troop.enemies
  73.      spell_reset(battler)
  74.      battler.at = battler.agi * rand(speed / 2)
  75.      battler.damage_pop = {}
  76.      battler.damage = {}
  77.      battler.damage_sp = {}
  78.      battler.critical = {}
  79.      battler.recover_hp = {}
  80.      battler.recover_sp = {}
  81.      battler.state_p = {}
  82.      battler.state_m = {}
  83.      battler.animation = []
  84.      if battler.is_a?(Game_Actor)
  85.        @max += battler.agi
  86.      end
  87.    end
  88.    @max *= speed
  89.    @max /= $game_party.actors.size
  90.    for battler in $game_party.actors + $game_troop.enemies
  91.      battler.atp = 100 * battler.at / @max
  92.    end
  93. end
  94. #--------------------------------------------------------------------------
  95. # ● ATゲージMax時SE
  96. #--------------------------------------------------------------------------
  97. def fullat_se
  98.    Audio.se_play("Audio/SE/033-switch02", 80, 100)
  99. end
  100. #--------------------------------------------------------------------------
  101. # ● レベルアップSE
  102. #--------------------------------------------------------------------------
  103. def levelup_se
  104.    Audio.se_play("Audio/SE/056-Right02", 80, 100)
  105. end
  106. #--------------------------------------------------------------------------
  107. # ● スキル習得SE
  108. #--------------------------------------------------------------------------
  109. def skill_se
  110.    Audio.se_play("Audio/SE/056-Right02", 80, 150)
  111. end
  112. end

  113. class Window_Base < Window
  114. #--------------------------------------------------------------------------
  115. # ● ATG の描画
  116. #     actor : アクター
  117. #     x     : 描画先 X 座標
  118. #     y     : 描画先 Y 座標
  119. #     width : 描画先の幅
  120. #--------------------------------------------------------------------------
  121. def draw_actor_atg(actor, x, y, width = 144)
  122.    if @at_gauge == nil
  123.      # plus_x:X座標の位置補正 rate_x:X座標の位置補正(%) plus_y:Y座標の位置補正
  124.      # plus_width:幅の補正 rate_width:幅の補正(%) height:縦幅
  125.      # align1:描画タイプ1 0:左詰め 1:中央揃え 2:右詰め
  126.      # align2:描画タイプ2 0:上詰め 1:中央揃え 2:下詰め
  127.      # align3:ゲージタイプ 0:左詰め 1:右詰め
  128.      @plus_x = 0
  129.      @rate_x = 0
  130.      @plus_y = 16
  131.      @plus_width = 0
  132.      @rate_width = 100




  133. # 第一命中判定
  134.    hit_result = (rand(100) < attacker.hit)
  135.    # 命中の場合
  136.    if hit_result == true
  137.      # 基本ダメージを計算
  138.      atk = [attacker.atk - self.pdef / 2, 0].max
  139.      self.damage[attacker] = atk * (20 + attacker.str) / 20
  140.      # 属性修正
  141.      self.damage[attacker] *= elements_correct(attacker.element_set)
  142.      self.damage[attacker] /= 100
  143.      # ダメージの符号が正の場合
  144.      if self.damage[attacker] > 0
  145.        # クリティカル修正
  146.        if rand(100) < 4 * attacker.dex / self.agi
  147.          self.damage[attacker] *= 2
  148.          self.critical[attacker] = true
  149.        end
  150.        # 防御修正
  151.        if self.guarding?
  152.          self.damage[attacker] /= 2
  153.        end
  154.      end
  155.      # 分散
  156.      if self.damage[attacker].abs > 0
  157.        amp = [self.damage[attacker].abs * 15 / 100, 1].max
  158.        self.damage[attacker] += rand(amp+1) + rand(amp+1) - amp
  159.      end
  160.      # 第二命中判定
  161.      eva = 8 * self.agi / attacker.dex + self.eva
  162.      hit = self.damage[attacker] < 0 ? 100 : 100 - eva
  163.      hit = self.cant_evade? ? 100 : hit
  164.      hit_result = (rand(100) < hit)
  165.    end
  166.    # 命中の場合
  167.    if hit_result == true
  168.      # ステート衝撃解除
  169.      remove_states_shock
  170.      # HP からダメージを減算
  171.      # ステート変化
  172.      @state_changed = false
  173.      states_plus(attacker, attacker.plus_state_set)
  174.      states_minus(attacker, attacker.minus_state_set)
  175.    # ミスの場合
  176.    else
  177.      # ダメージに "Miss" を設定
  178.      self.damage[attacker] = "Miss"
  179.      # クリティカルフラグをクリア
  180.      self.critical[attacker] = false
  181.    end
  182.    # メソッド終了
  183.    return true
  184. end
  185. #--------------------------------------------------------------------------
  186. # ● スキルの効果適用
  187. #     user  : スキルの使用者 (バトラー)
  188. #     skill : スキル
  189. #--------------------------------------------------------------------------
  190. def skill_effect(user, skill)
  191.    # クリティカルフラグをクリア
  192.    self.critical[user] = false
  193.    state_p[user] = []
  194.    state_m[user] = []
  195.    # スキルの効果範囲が HP 1 以上の味方で、自分の HP が 0、
  196.    # またはスキルの効果範囲が HP 0 の味方で、自分の HP が 1 以上の場合
  197.    if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
  198.       ((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
  199.      # メソッド終了
  200.      return false
  201.    end
  202.    # 有効フラグをクリア
  203.    effective = false
  204.    # コモンイベント ID が有効の場合は有効フラグをセット
  205.    effective |= skill.common_event_id > 0
  206.    # 第一命中判定
  207.    hit = skill.hit
  208.    if skill.atk_f > 0
  209.      hit *= user.hit / 100
  210.    end
  211.    hit_result = (rand(100) < hit)
  212.    # 不確実なスキルの場合は有効フラグをセット
  213.    effective |= hit < 100
  214.    # 命中の場合
  215.    if hit_result == true
  216.      # 威力を計算
  217.      power = skill.power + user.atk * skill.atk_f / 100
  218.      if power > 0
  219.        power -= self.pdef * skill.pdef_f / 200
  220.        power -= self.mdef * skill.mdef_f / 200
  221.        power = [power, 0].max
  222.      end
  223.      # 倍率を計算
  224.      rate = 20
  225.      rate += (user.str * skill.str_f / 100)
  226.      rate += (user.dex * skill.dex_f / 100)
  227.      rate += (user.agi * skill.agi_f / 100)
  228.      rate += (user.int * skill.int_f / 100)
  229.      # 基本ダメージを計算
  230.      self.damage[user] = power * rate / 20
  231.      # 属性修正
  232.      self.damage[user] *= elements_correct(skill.element_set)
  233.      self.damage[user] /= 100
  234.      # ダメージの符号が正の場合
  235.      if self.damage[user] > 0
  236.        # 防御修正
  237.        if self.guarding?
  238.          self.damage[user] /= 2
  239.        end
  240.      end
  241.      # 分散
  242.      if skill.variance > 0 and self.damage[user].abs > 0
  243.        amp = [self.damage[user].abs * skill.variance / 100, 1].max
  244.        self.damage[user] += rand(amp+1) + rand(amp+1) - amp
  245.      end
  246.      # 第二命中判定
  247.      eva = 8 * self.agi / user.dex + self.eva
  248.      hit = self.damage[user] < 0 ? 100 : 100 - eva * skill.eva_f / 100
  249.      hit = self.cant_evade? ? 100 : hit
  250.      hit_result = (rand(100) < hit)
  251.      # 不確実なスキルの場合は有効フラグをセット
  252.      effective |= hit < 100
  253.    end
  254.    # 命中の場合
  255.    if hit_result == true
  256.      # 威力 0 以外の物理攻撃の場合
  257.      if skill.power != 0 and skill.atk_f > 0
  258.        # ステート衝撃解除
  259.        remove_states_shock
  260.        # 有効フラグをセット
  261.        effective = true
  262.      end
  263.      # HP の変動判定
  264.      last_hp = [[self.hp - self.damage[user], self.maxhp].min, 0].max
  265.      # 効果判定
  266.      effective |= self.hp != last_hp
  267.      # ステート変化
  268.      @state_changed = false
  269.      effective |= states_plus(user, skill.plus_state_set)
  270.      effective |= states_minus(user, skill.minus_state_set)
  271.      unless $game_temp.in_battle
  272.        self.damage_effect(user, 1)
  273.      end
  274.      # 威力が 0 の場合
  275.      if skill.power == 0
  276.        # ダメージに空文字列を設定
  277.        self.damage[user] = ""
  278.        # ステートに変化がない場合
  279.        unless @state_changed
  280.          # ダメージに "Miss" を設定
  281.          self.damage[user] = "Miss"
  282.        end
  283.      end
  284.    # ミスの場合
  285.    else
  286.      # ダメージに "Miss" を設定
  287.      self.damage[user] = "Miss"
  288.    end
  289.    # 戦闘中でない場合
  290.    unless $game_temp.in_battle
  291.      # ダメージに nil を設定
  292.      self.damage[user] = nil
  293.    end
  294.    # メソッド終了
  295.    return effective
  296. end
  297. #--------------------------------------------------------------------------
  298. # ● アイテムの効果適用
  299. #     item : アイテム
  300. #--------------------------------------------------------------------------
  301. def item_effect(item, user = $game_party.actors[0])
  302.    # クリティカルフラグをクリア
  303.    self.critical[user] = false
  304.    state_p[user] = []
  305.    state_m[user] = []
  306.    # アイテムの効果範囲が HP 1 以上の味方で、自分の HP が 0、
  307.    # またはアイテムの効果範囲が HP 0 の味方で、自分の HP が 1 以上の場合
  308.    if ((item.scope == 3 or item.scope == 4) and self.hp == 0) or
  309.       ((item.scope == 5 or item.scope == 6) and self.hp >= 1)
  310.      # メソッド終了
  311.      return false
  312.    end
  313.    # 有効フラグをクリア
  314.    effective = false
  315.    # コモンイベント ID が有効の場合は有効フラグをセット
  316.    effective |= item.common_event_id > 0
  317.    # 命中判定
  318.    hit_result = (rand(100) < item.hit)
  319.    # 不確実なスキルの場合は有効フラグをセット
  320.    effective |= item.hit < 100
  321.    # 命中の場合
  322.    if hit_result == true
  323.      # 回復量を計算
  324.      self.recover_hp[user] = maxhp * item.recover_hp_rate / 100 +
  325.                              item.recover_hp
  326.      self.recover_sp[user] = maxsp * item.recover_sp_rate / 100 +
  327.                              item.recover_sp
  328.      if self.recover_hp[user] < 0
  329.        self.recover_hp[user] += self.pdef * item.pdef_f / 20
  330.        self.recover_hp[user] += self.mdef * item.mdef_f / 20
  331.        self.recover_hp[user] = [self.recover_hp[user], 0].min
  332.      end
  333.      # 属性修正
  334.      self.recover_hp[user] *= elements_correct(item.element_set)
  335.      self.recover_hp[user] /= 100
  336.      self.recover_sp[user] *= elements_correct(item.element_set)
  337.      self.recover_sp[user] /= 100
  338.      # 分散
  339.      if item.variance > 0 and self.recover_hp[user].abs > 0
  340.        amp = [self.recover_hp[user].abs * item.variance / 100, 1].max
  341.        self.recover_hp[user] += rand(amp+1) + rand(amp+1) - amp
  342.      end
  343.      if item.variance > 0 and self.recover_sp[user].abs > 0
  344.        amp = [self.recover_sp[user].abs * item.variance / 100, 1].max
  345.        self.recover_sp[user] += rand(amp+1) + rand(amp+1) - amp
  346.      end
  347.      # 回復量の符号が負の場合
  348.      if self.recover_hp[user] < 0
  349.        # 防御修正
  350.        if self.guarding?
  351.          self.recover_hp[user] /= 2
  352.        end
  353.      end
  354.      # HP 回復量の符号を反転し、ダメージの値に設定
  355.      self.damage[user] = -self.recover_hp[user]
  356.      # HP および SP の変動判定
  357.      last_hp = [[self.hp + self.recover_hp[user], self.maxhp].min, 0].max
  358.      last_sp = [[self.sp + self.recover_sp[user], self.maxsp].min, 0].max
  359.      effective |= self.hp != last_hp
  360.      effective |= self.sp != last_sp
  361.      # ステート変化
  362.      @state_changed = false
  363.      effective |= states_plus(user, item.plus_state_set)
  364.      effective |= states_minus(user, item.minus_state_set)
  365.      unless $game_temp.in_battle
  366.        self.damage_effect(user, 2)
  367.      end
  368.      # パラメータ上昇値が有効の場合
  369.      if item.parameter_type > 0 and item.parameter_points != 0
  370.        # パラメータで分岐
  371.        case item.parameter_type
  372.        when 1  # MaxHP
  373.          @maxhp_plus += item.parameter_points
  374.        when 2  # MaxSP
  375.          @maxsp_plus += item.parameter_points
  376.        when 3  # 腕力
  377.          @str_plus += item.parameter_points
  378.        when 4  # 器用さ
  379.          @dex_plus += item.parameter_points
  380.        when 5  # 素早さ
  381.          @agi_plus += item.parameter_points
  382.        when 6  # 魔力
  383.          @int_plus += item.parameter_points
  384.        end
  385.        # 有効フラグをセット
  386.        effective = true
  387.      end
  388.      # HP 回復率と回復量が 0 の場合
  389.      if item.recover_hp_rate == 0 and item.recover_hp == 0
  390.        # ダメージに空文字列を設定
  391.        self.damage[user] = ""
  392.        # SP 回復率と回復量が 0、パラメータ上昇値が無効の場合
  393.        if item.recover_sp_rate == 0 and item.recover_sp == 0 and
  394.           (item.parameter_type == 0 or item.parameter_points == 0)
  395.          # ステートに変化がない場合
  396.          unless @state_changed
  397.            # ダメージに "Miss" を設定
  398.            self.damage[user] = "Miss"
  399.          end
  400.        end
  401.      end
  402.    # ミスの場合
  403.    else
  404.      # ダメージに "Miss" を設定
  405.      self.damage[user] = "Miss"
  406.    end
  407.    # 戦闘中でない場合
  408.    unless $game_temp.in_battle
  409.      # ダメージに nil を設定
  410.      self.damage[user] = nil
  411.    end
  412.    # メソッド終了
  413.    return effective
  414. end
  415. #--------------------------------------------------------------------------
  416. # ● ステート変化 (+) の適用
  417. #     plus_state_set  : ステート変化 (+)
  418. #--------------------------------------------------------------------------
  419. def states_plus(battler, plus_state_set)
  420.    # 有効フラグをクリア
  421.    effective = false
  422.    # ループ (付加するステート)
  423.    for i in plus_state_set
  424.      # このステートが防御されていない場合
  425.      unless self.state_guard?(i)
  426.        # このステートがフルでなければ有効フラグをセット
  427.        effective |= self.state_full?(i) == false
  428.        # ステートが [抵抗しない] の場合
  429.        if $data_states[i].nonresistance
  430.          # ステート変化フラグをセット
  431.          @state_changed = true
  432.          # ステートを付加
  433.          add_state(i)
  434.        # このステートがフルではない場合
  435.        elsif self.state_full?(i) == false
  436.          # ステート有効度を確率に変換し、乱数と比較
  437.          if rand(100) < [0,100,80,60,40,20,0][self.state_ranks[i]]
  438.            # ステート変化フラグをセット
  439.            @state_changed = true
  440.            # ステートを付加
  441.            self.state_p[battler].push(i)
  442.          end
  443.        end
  444.      end
  445.    end
  446.    # メソッド終了
  447.    return effective
  448. end
  449. #--------------------------------------------------------------------------
  450. # ● ステート変化 (-) の適用
  451. #     minus_state_set : ステート変化 (-)
  452. #--------------------------------------------------------------------------
  453. def states_minus(battler, minus_state_set)
  454.    # 有効フラグをクリア
  455.    effective = false
  456.    # ループ (解除するステート)
  457.    for i in minus_state_set
  458.      # このステートが付加されていれば有効フラグをセット
  459.      effective |= self.state?(i)
  460.      # ステート変化フラグをセット
  461.      @state_changed = true
  462.      # ステートを解除
  463.      self.state_m[battler].push(i)
  464.    end
  465.    # メソッド終了
  466.    return effective
  467. end
  468. #--------------------------------------------------------------------------
  469. # ● ダメージ演算
  470. #--------------------------------------------------------------------------
  471. def damage_effect(battler, item)
  472.    if item == 2
  473.      self.hp += self.recover_hp[battler]
  474.      self.sp += self.recover_sp[battler]
  475.      if self.recover_sp[battler] != 0
  476.        self.damage_sp[battler] = -self.recover_sp[battler]
  477.      end
  478.    else
  479.      if self.damage[battler].class != String
  480.        self.hp -= self.damage[battler]
  481.      end
  482.    end
  483.    for i in self.state_p[battler]
  484.      add_state(i)
  485.    end
  486.    for i in self.state_m[battler]
  487.      remove_state(i)
  488.    end
  489. end
  490. #--------------------------------------------------------------------------
  491. # ● スリップダメージの効果適用
  492. #--------------------------------------------------------------------------
  493. def slip_damage_effect


  494. # ダメージを設定
  495.    self.damage["slip"] = self.maxhp / 10
  496.    # 分散
  497.    if self.damage["slip"].abs > 0
  498.      amp = [self.damage["slip"].abs * 15 / 100, 1].max
  499.      self.damage["slip"] += rand(amp+1) + rand(amp+1) - amp
  500.    end
  501.    # HP からダメージを減算
  502.    self.hp -= self.damage["slip"]
  503.    # メソッド終了
  504.    return true
  505. end
  506. end

  507. #==============================================================================
  508. # ■ Game_BattleAction
  509. #------------------------------------------------------------------------------
  510. #  アクション (戦闘中の行動) を扱うクラスです。このクラスは Game_Battler クラ
  511. # スの内部で使用されます。
  512. #==============================================================================

  513. class Game_BattleAction
  514. #--------------------------------------------------------------------------
  515. # ● 公開インスタンス変数
  516. #--------------------------------------------------------------------------
  517. attr_accessor :spell_id                 # 合体魔法用スキル ID
  518. attr_accessor :force_kind               # 種別 (基本 / スキル / アイテム)
  519. attr_accessor :force_basic              # 基本 (攻撃 / 防御 / 逃げる)
  520. attr_accessor :force_skill_id           # スキル ID
  521. #--------------------------------------------------------------------------
  522. # ● 有効判定
  523. #--------------------------------------------------------------------------
  524. def valid?
  525.    return (not (@force_kind == 0 and @force_basic == 3))
  526. end
  527. end

  528. #==============================================================================
  529. # ■ Game_Actor
  530. #------------------------------------------------------------------------------
  531. #  アクターを扱うクラスです。このクラスは Game_Actors クラス ($game_actors)
  532. # の内部で使用され、Game_Party クラス ($game_party) からも参照されます。
  533. #==============================================================================

  534. class Game_Actor < Game_Battler
  535. def skill_can_use?(skill_id)
  536.    return super
  537. end
  538. end

  539. #==============================================================================
  540. # ■ Game_Enemy
  541. #------------------------------------------------------------------------------
  542. #  エネミーを扱うクラスです。このクラスは Game_Troop クラス ($game_troop) の
  543. # 内部で使用されます。
  544. #==============================================================================

  545. class Game_Enemy < Game_Battler
  546. #--------------------------------------------------------------------------
  547. # ● 公開インスタンス変数
  548. #--------------------------------------------------------------------------
  549. attr_accessor :height                  # 画像の高さ
  550. attr_accessor :real_x                  # X座標補正
  551. attr_accessor :real_y                  # Y座標補正
  552. attr_accessor :real_zoom               # 拡大率
  553. #--------------------------------------------------------------------------
  554. # ● オブジェクト初期化
  555. #     troop_id     : トループ ID
  556. #     member_index : トループメンバーのインデックス
  557. #--------------------------------------------------------------------------
  558. def initialize(troop_id, member_index)
  559.    super()
  560.    @troop_id = troop_id
  561.    @member_index = member_index
  562.    troop = $data_troops[@troop_id]
  563.    @enemy_id = troop.members[@member_index].enemy_id
  564.    enemy = $data_enemies[@enemy_id]
  565.    @battler_name = enemy.battler_name
  566.    @battler_hue = enemy.battler_hue
  567.    @hp = maxhp
  568.    @sp = maxsp
  569.    @real_x = 0
  570.    @real_y = 0
  571.    @real_zoom = 1.0
  572.    @fly = 0
  573.    enemy.name.sub(/\\[Ff]\[([0-9]+)\]/) {@fly = $1.to_i}
  574.    @hidden = troop.members[@member_index].hidden
  575.    @immortal = troop.members[@member_index].immortal
  576. end
  577. alias :true_x :screen_x
  578. alias :true_y :screen_y
  579. #--------------------------------------------------------------------------
  580. # ● バトル画面 X 座標の取得
  581. #--------------------------------------------------------------------------
  582. def screen_x
  583.    return 320 + (true_x - 320) * @real_zoom + @real_x
  584. end
  585. #--------------------------------------------------------------------------
  586. # ● バトル画面 Y 座標の取得
  587. #--------------------------------------------------------------------------
  588. def screen_y
  589.    return true_y * @real_zoom + @real_y
  590. end
  591. #--------------------------------------------------------------------------
  592. # ● バトル画面 Z 座標の取得
  593. #--------------------------------------------------------------------------
  594. def screen_z
  595.    return true_y + @fly
  596. end
  597. #--------------------------------------------------------------------------
  598. # ● バトル画面 拡大率の取得
  599. #--------------------------------------------------------------------------
  600. def zoom
  601.    return ($scene.zoom_rate[1] - $scene.zoom_rate[0]) *
  602.                          (true_y + @fly) / 320 + $scene.zoom_rate[0]
  603. end
  604. #--------------------------------------------------------------------------
  605. # ● 攻撃用、バトル画面 X 座標の取得
  606. #--------------------------------------------------------------------------
  607. def attack_x(z)
  608.    return (320 - true_x) * z * 0.75
  609. end
  610. #--------------------------------------------------------------------------
  611. # ● 攻撃用、バトル画面 Y 座標の取得
  612. #--------------------------------------------------------------------------
  613. def attack_y(z)
  614.    return (160 - (true_y + @fly / 4) * z + @height * zoom * z / 2) * 0.75
  615. end
  616. #--------------------------------------------------------------------------
  617. # ● アクション作成
  618. #--------------------------------------------------------------------------
  619. def make_action
  620.    # カレントアクションをクリア
  621.    self.current_action.clear
  622.    # 動けない場合
  623.    unless self.inputable?
  624.      # メソッド終了
  625.      return
  626.    end
  627.    # 現在有効なアクションを抽出
  628.    available_actions = []
  629.    rating_max = 0
  630.    for action in self.actions
  631.      # ターン 条件確認
  632.      n = $game_temp.battle_turn
  633.      a = action.condition_turn_a
  634.      b = action.condition_turn_b
  635.      if (b == 0 and n != a) or
  636.         (b > 0 and (n < 1 or n < a or n % b != a % b))
  637.        next
  638.      end
  639.      # HP 条件確認
  640.      if self.hp * 100.0 / self.maxhp > action.condition_hp
  641.        next
  642.      end
  643.      # レベル 条件確認
  644.      if $game_party.max_level < action.condition_level
  645.        next
  646.      end
  647.      # スイッチ 条件確認
  648.      switch_id = action.condition_switch_id
  649.      if switch_id > 0 and $game_switches[switch_id] == false
  650.        next
  651.      end
  652.      # スキル使用可能 条件確認
  653.      if action.kind == 1
  654.        unless self.skill_can_use?(action.skill_id)
  655.          next
  656.        end
  657.      end
  658.      # 条件に該当 : このアクションを追加
  659.      available_actions.push(action)
  660.      if action.rating > rating_max
  661.        rating_max = action.rating
  662.      end
  663.    end
  664.    # 最大のレーティング値を 3 として合計を計算 (0 以下は除外)
  665.    ratings_total = 0
  666.    for action in available_actions
  667.      if action.rating > rating_max - 3
  668.        ratings_total += action.rating - (rating_max - 3)
  669.      end
  670.    end
  671.    # レーティングの合計が 0 ではない場合
  672.    if ratings_total > 0
  673.      # 乱数を作成
  674.      ;value = rand(ratings_total)
  675.      # 作成した乱数に対応するものをカレントアクションに設定
  676.      for action in available_actions
  677.        if action.rating > rating_max - 3
  678.          if value < action.rating - (rating_max - 3)
  679.            self.current_action.kind = action.kind
  680.            self.current_action.basic = action.basic
  681.            self.current_action.skill_id = action.skill_id
  682.            self.current_action.decide_random_target_for_enemy
  683.            return
  684.          else
  685.            ;value -= action.rating - (rating_max - 3)
  686.          end
  687.        end
  688.      end
  689.    end
  690. end
  691. end

  692. #==============================================================================
  693. # ■ Game_Party
  694. #------------------------------------------------------------------------------
  695. #  パーティを扱うクラスです。ゴールドやアイテムなどの情報が含まれます。このク
  696. # ラスのインスタンスは $game_party で参照されます。
  697. #==============================================================================

  698. class Game_Party
  699. #--------------------------------------------------------------------------
  700. # ● 全滅判定
  701. #--------------------------------------------------------------------------
  702. def all_dead?
  703.    # パーティ人数が 0 人の場合
  704.    if $game_party.actors.size == 0
  705.      return false
  706.    end
  707.    # HP 0 以上のアクターがパーティにいる場合
  708.    for actor in @actors
  709.      if actor.hp > 0 or actor.damage.size > 0
  710.        return false
  711.      end
  712.    end
  713.    # 全滅
  714.    return true
  715. end
  716. end

  717. #==============================================================================
  718. # ■ Sprite_Battler
  719. #------------------------------------------------------------------------------
  720. #  バトラー表示用のスプライトです。Game_Battler クラスのインスタンスを監視し、
  721. # スプライトの状態を自動的に変化させます。
  722. #==============================================================================

  723. class Sprite_Battler < RPG::Sprite
  724. #--------------------------------------------------------------------------
  725. # ● フレーム更新
  726. #--------------------------------------------------------------------------
  727. def update
  728.    super
  729.    # バトラーが nil の場合
  730.    if @battler == nil
  731.      self.bitmap = nil
  732.      loop_animation(nil)
  733.      return
  734.    end
  735.    # ファイル名か色相が現在のものと異なる場合
  736.    if @battler.battler_name != @battler_name or
  737.       @battler.battler_hue != @battler_hue
  738.      # ビットマップを取得、設定
  739.      @battler_name = @battler.battler_name
  740.      @battler_hue = @battler.battler_hue
  741.      self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
  742.      @width = bitmap.width
  743.      @height = bitmap.height
  744.      self.ox = @width / 2
  745.      self.oy = @height
  746.      if @battler.is_a?(Game_Enemy)
  747.        @battler.height = @height
  748.      end
  749.      # 戦闘不能または隠れ状態なら不透明度を 0 にする
  750.      if @battler.dead? or @battler.hidden
  751.        self.opacity = 0
  752.      end
  753.    end
  754.    # アニメーション ID が現在のものと異なる場合
  755.    if @battler.state_animation_id != @state_animation_id
  756.      @state_animation_id = @battler.state_animation_id
  757.      loop_animation($data_animations[@state_animation_id])
  758.    end
  759.    # 表示されるべきアクターの場合
  760.    if @battler.is_a?(Game_Actor) and @battler_visible
  761.      # メインフェーズでないときは不透明度をやや下げる
  762.      if $game_temp.battle_main_phase
  763.        self.opacity += 3 if self.opacity < 255
  764.      else
  765.        self.opacity -= 3 if self.opacity > 207
  766.      end
  767.    end
  768.    # 明滅
  769.    if @battler.blink
  770.      blink_on
  771.    else
  772.      blink_off
  773.    end
  774.    # 不可視の場合
  775.    unless @battler_visible
  776.      # 出現
  777.      if not @battler.hidden and not @battler.dead? and
  778.         (@battler.damage.size < 2 or @battler.damage_pop.size < 2)
  779.        appear
  780.        @battler_visible = true
  781.      end
  782.    end
  783.    # ダメージ
  784.    for battler in @battler.damage_pop
  785.      if battler[0].class == Array
  786.        if battler[0][1] >= 0
  787.          $scene.skill_se
  788.        else
  789.          $scene.levelup_se
  790.        end
  791.        damage(@battler.damage[battler[0]], false, 2)
  792.      else
  793.        damage(@battler.damage[battler[0]], @battler.critical[battler[0]])
  794.      end
  795.      if @battler.damage_sp.include?(battler[0])
  796.        damage(@battler.damage_sp[battler[0]],
  797.                @battler.critical[battler[0]], 1)
  798.        @battler.damage_sp.delete(battler[0])
  799.      end
  800.      @battler.damage_pop.delete(battler[0])
  801.      @battler.damage.delete(battler[0])
  802.      @battler.critical.delete(battler[0])
  803.    end
  804.    # 可視の場合
  805.    if @battler_visible
  806.      # 逃走
  807.      if @battler.hidden
  808.        $game_system.se_play($data_system.escape_se)
  809.        escape
  810.        @battler_visible = false
  811.      end
  812.      # 白フラッシュ
  813.      if @battler.white_flash
  814.        whiten
  815.        @battler.white_flash = false
  816.      end
  817.      # アニメーション
  818.      unless @battler.animation.empty?
  819.        for animation in @battler.animation.reverse
  820.          animation($data_animations[animation[0]], animation[1])
  821.          @battler.animation.delete(animation)
  822.        end
  823.      end
  824.      # コラプス
  825.      if @battler.damage.empty? and @battler.dead?
  826.        if $scene.dead_ok?(@battler)
  827.          if @battler.is_a?(Game_Enemy)
  828.            $game_system.se_play($data_system.enemy_collapse_se)
  829.          else
  830.            $game_system.se_play($data_system.actor_collapse_se)
  831.          end
  832.          collapse
  833.          @battler_visible = false
  834.        end
  835.      end
  836.    end
  837.    # スプライトの座標を設定
  838.    self.x = @battler.screen_x
  839.    self.y = @battler.screen_y
  840.    self.z = @battler.screen_z
  841.    if @battler.is_a?(Game_Enemy)
  842.      self.zoom_x = @battler.real_zoom * @battler.zoom
  843.      self.zoom_y = @battler.real_zoom * @battler.zoom
  844.    end
  845. end
  846. end

  847. #==============================================================================
  848. # ■ Window_Base
  849. #------------------------------------------------------------------------------
  850. #  ゲーム中のすべてのウィンドウのスーパークラスです。
  851. #==============================================================================

  852. class Window_Base < Window
  853. #--------------------------------------------------------------------------
  854. # ● ゲージの描画
  855. #--------------------------------------------------------------------------
  856. def gauge_rect_at(width, height, align3,
  857.                    color1, color2, color3, color4, color5, color6, color7,
  858.                    color8, color9, color10, color11, color12, grade1, grade2)
  859.    # 枠描画
  860.    @at_gauge = Bitmap.new(width, height * 5)
  861.    @at_gauge.fill_rect(0, 0, width, height, color1)
  862.    @at_gauge.fill_rect(1, 1, width - 2, height - 2, color2)
  863.    if (align3 == 1 and grade1 == 0) or grade1 > 0
  864.      color = color3
  865.      color3 = color4
  866.      color4 = color
  867.    end
  868.    if (align3 == 1 and grade2 == 0) or grade2 > 0
  869.      color = color5
  870.      color5 = color6
  871.      color6 = color
  872.      color = color7
  873.      color7 = color8
  874.      color8 = color
  875.      color = color9
  876.      color9 = color10
  877.      color10 = color
  878.      color = color11
  879.      color11 = color12
  880.      color12 = color
  881.    end
  882.    if align3 == 0
  883.      if grade1 == 2
  884.        grade1 = 3
  885.      end
  886.      if grade2 == 2
  887.        grade2 = 3
  888.      end
  889.    end
  890.    # 空ゲージの描画 縦にグラデーション表示
  891.    @at_gauge.gradation_rect(2, 2, width - 4, height - 4,
  892.                                  color3, color4, grade1)
  893.    # 実ゲージの描画
  894.    @at_gauge.gradation_rect(2, height + 2, width- 4, height - 4,
  895.                                  color5, color6, grade2)
  896.    @at_gauge.gradation_rect(2, height * 2 + 2, width- 4, height - 4,
  897.                                  color7, color8, grade2)
  898.    @at_gauge.gradation_rect(2, height * 3 + 2, width- 4, height - 4,
  899.                                  color9, color10, grade2)
  900.    @at_gauge.gradation_rect(2, height * 4 + 2, width- 4, height - 4,
  901.                                  color11, color12, grade2)
  902. end
  903. end
复制代码

作者: QQ幻術師    时间: 2008-7-13 05:35
提示: 作者被禁止或删除 内容自动屏蔽
作者: 灯泡没我亮    时间: 2008-7-13 05:40
以下引用uijk777于2008-7-12 16:18:30的发言:

对不起,因为脚本太长,所以请高手进入这空间里看这脚本了:
http://hi.baidu.com/uijk777


作者: uijk777    时间: 2008-7-13 20:16
哈(水一下)因为空间的文章传不上,请见谅(最麻烦的一次提问TAT){/dk}
作者: 凌冰    时间: 2008-7-31 08:53
除了RTAB还用了什么= =




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1