전투

오버드라이브

by 키라링 posted Jan 23, 2009
?

단축키

Prev이전 문서

Next다음 문서

ESC닫기

크게 작게 위로 아래로 댓글로 가기 인쇄

#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/    ◆ オーバードライブ - KGC_OverDrive ◆
#_/    ◇ Last update : 2007/09/08 ◇
#_/----------------------------------------------------------------------------
#_/  専用のゲージがMAXになったときのみ使用可能になるスキルを作成します。
#_/============================================================================
#_/  ≪SP消費改造[SPCostAlter]≫より下
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

#==============================================================================
# ★ カスタマイズ項目 - Customize ★
#==============================================================================

module KGC
  # ◆OverDriveゲージ最大値
  #  (通常はこのままでOK。どうしてもバランスがおかしくなる場合のみ変更)
  OD_GAUGE_MAX = 1000
  # ◆OverDriveゲージ増加率
  #  増加率が高いほどゲージが溜まりやすい。
  #  順番(INDEX)および条件は以下の通り。
  # 【0..攻撃  1..被ダメージ  2..勝利  3..逃走  4..孤独  5..行動  6..瀕死】
  #  ↑これらのINDEXは、アクターのドライブタイプと対応。
  #  0,1 は、ダメージ量に応じて増加量が変動。
  OD_GAIN_RATE = [10, 30, 200, 100, 160, 40, 160]

  # ◆死亡(HP 0)時にOverDriveゲージを 0 にする
  OD_EMPTY_ON_DEAD = true

  # ◆OverDriveゲージを表示しないアクター
  #  ゲージを隠すアクターのIDを配列に格納。
  OD_GAUGE_HIDE_ACTOR = []

  # ◆OverDriveゲージを斜めにする
  OD_GAUGE_SLANT = true
  # ◆非戦闘時OverDriveゲージ位置 [x, y]
  #  大きいほど名前から離れた位置に描画。
  OD_GAUGE_OFF        = [0, 26]
  # ◆戦闘時OverDriveゲージ位置 [x, y]
  OD_GAUGE_OFF_BATTLE = [0, 26]
  # ◆非戦闘時はゲージを隠す
  OD_GAUGE_HIDE_NOT_IN_BATTLE = false
end

class Window_Base < Window
  # ◆OverDriveゲージ画像
  @@_od_gauge = RPG::Cache.picture("od_gauge.png")
end

#### OD_GAUGE_MAX
### Over-drive gauge maximum.

####OD_GAIN_RATE
### Over-drive gauge gain rate.
#  Order(index) and conditions are as follows:
#  << 0..Attack  1..Damage  2..Victory  3..Escape  4..Alone
#     5..Action  6..Fatal >>
#  The accumulation speed of '0' and '1' changes by amount of damage.
#  The higher rate is, the faster overdrive gauge accumulates.


#### OD_EMPTY_ON_DEAD
### Empties over-drive gauge when actor die.


#### OD_GAUGE_HIDE_ACTOR
### Actor who hide own over-drive gauge.
#  Puts actor's IDs whose gauge are hidden in the array.


#### OD_GAUGE_SLANT
### Draws over-drive gauge diagonally.

#### OD_GAUGE_OFF
### Over-drive gauge position. [x, y] (not in battle)

#### OD_GAUGE_OFF_BATTLE
### Over-drive gauge position in battle. [x, y]

#### OD_GAUGE_HIDE_NOT_IN_BATTLE
### Hides over-drive gauge. (not in battle)


#### @@_od_gauge
### Image of over-drive gauge.

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

$imported = {} if $imported == nil
$imported["OverDrive"] = true

if $game_special_elements == nil
  $game_special_elements = {}
  $data_system = load_data("Data/System.rxdata")
end
# OverDrive属性 - Element of OverDrive.
$game_special_elements["overdrive"] =
  $data_system.elements.index("オーバードライブ")
if $game_special_elements["overdrive"] == nil
  $game_special_elements["overdrive"] = $data_system.elements.index("OverDrive")
end

# OD条件
module ODType
  ATTACK  = 0
  DAMAGE  = 1
  VICTORY = 2
  ESCAPE  = 3
  ALONE   = 4
  ACTION  = 5
  FATAL   = 6
end

#==============================================================================
# ■ Game_Battler (分割定義 3)
#==============================================================================

class Game_Battler
  attr_accessor :base_damage
  #--------------------------------------------------------------------------
  # ● 通常攻撃の効果適用
  #--------------------------------------------------------------------------
  alias attack_effect_KGC_OverDrive attack_effect
  def attack_effect(attacker)
    @base_damage = nil

    result = attack_effect_KGC_OverDrive(attacker)

    if @base_damage == nil
      # 基本ダメージ値を保存
      @base_damage = [attacker.atk - self.pdef / 2, 0].max *
        (20 + attacker.str) / 20
    end
    # ダメージを受けた場合
    if result && self.damage.is_a?(Numeric)
      overdrive_increase(attacker)
    end
    return result
  end
  #--------------------------------------------------------------------------
  # ● ODゲージ増加処理
  #--------------------------------------------------------------------------
  def overdrive_increase(attacker)
    # 攻撃時増加判定
    if attacker.is_a?(Game_Actor) && self.is_a?(Game_Enemy) &&
        attacker.overdrive_type.include?(ODType::ATTACK) &&
        self.base_damage > 0
      od_up = self.damage * KGC::OD_GAIN_RATE[ODType::ATTACK] * 10 / self.base_damage
      attacker.overdrive += [[od_up, 1].max, 160].min
    # 被ダメージ時増加判定
    elsif attacker.is_a?(Game_Enemy) && self.is_a?(Game_Actor) &&
        self.overdrive_type.include?(ODType::DAMAGE) &&
        self.base_damage > 0
      od_up = self.damage * KGC::OD_GAIN_RATE[ODType::DAMAGE] * 10 / self.maxhp
      self.overdrive += [od_up, 1].max
    end
    # 死亡判定
    if KGC::OD_EMPTY_ON_DEAD && self.is_a?(Game_Actor) && self.dead?
      self.overdrive = 0
    end
  end
  #--------------------------------------------------------------------------
  # ● スキルの効果適用
  #--------------------------------------------------------------------------
  alias skill_effect_KGC_OverDrive skill_effect
  def skill_effect(user, skill)
    @base_damage = nil

    result = skill_effect_KGC_OverDrive(user, skill)

    if @base_damage == nil
      # 威力を計算
      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)
      # 基本ダメージを保存
      @base_damage = power * rate / 20
    end
    # ダメージを受けた場合
    if result && self.damage.is_a?(Numeric)
      overdrive_increase(user)
    end
    # オーバードライブスキルを使用した場合
    if user.is_a?(Game_Actor) &&
        skill.element_set.include?($game_special_elements["overdrive"])
      user.overdrive = 0
    end
    return result
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Game_Actor
#==============================================================================

KGC_Game_Actor_first = "OverDrive" unless defined?(KGC_Game_Actor)

module KGC_Game_Actor
  #--------------------------------------------------------------------------
  # ● スキルの使用可能判定
  #--------------------------------------------------------------------------
  if defined?(skill_can_use?) && !@_skill_can_use_overdrive
    alias skill_can_use_KGC_OverDrive skill_can_use?
  else
    @_skill_can_use_overdrive = true
  end
  def skill_can_use?(skill_id)
    result = true
    skill = $data_skills[skill_id]
    if skill != nil &&
        skill.element_set.include?($game_special_elements["overdrive"])
      result = self.overdrive == KGC::OD_GAUGE_MAX
    end
    if defined?(skill_can_use_KGC_OverDrive)
      return result & skill_can_use_KGC_OverDrive(skill_id)
    else
      return result & super
    end
  end
  module_function :skill_can_use?
  public :skill_can_use?
end

class Game_Actor < Game_Battler
  include KGC_Game_Actor

  attr_writer :overdrive_type
  #--------------------------------------------------------------------------
  # ● セットアップ
  #--------------------------------------------------------------------------
  alias setup_KGC_OverDrive setup
  def setup(actor_id)
    setup_KGC_OverDrive(actor_id)

    @overdrive = 0
    @overdrive_type = [0]
  end
  #--------------------------------------------------------------------------
  # ● OverDriveゲージの取得
  #--------------------------------------------------------------------------
  def overdrive
    @overdrive = 0 if @overdrive == nil
    return @overdrive
  end
  #--------------------------------------------------------------------------
  # ● OverDriveゲージの操作
  #--------------------------------------------------------------------------
  def overdrive=(value)
    @overdrive = [[value, 0].max, KGC::OD_GAUGE_MAX].min
  end
  #--------------------------------------------------------------------------
  # ● OverDriveタイプの取得
  #--------------------------------------------------------------------------
  def overdrive_type
    @overdrive_type = [0] if !@overdrive_type.is_a?(Array)
    return @overdrive_type
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Window_Base
#==============================================================================

class Window_Base < Window
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  alias initialize_KGC_OverDrive_Base initialize
  def initialize(x, y, width, height)
    @od_gauge = @@_od_gauge
    @od_g_width = @od_gauge.width / 3
    @od_g_height = (@od_gauge.height - 2) / 3

    initialize_KGC_OverDrive_Base(x, y, width, height)
  end
  #--------------------------------------------------------------------------
  # ● ゲージ画像(マスター)を取得
  #--------------------------------------------------------------------------
  def _od_gauge
    return @@_od_gauge
  end
  #--------------------------------------------------------------------------
  # ● ゲージ画像(マスター)を設定
  #--------------------------------------------------------------------------
  def _od_gauge=(new_bitmap)
    @@_od_gauge.dispose
    @@_od_gauge = new_bitmap
  end
  #--------------------------------------------------------------------------
  # ● ゲージ画像を取得
  #--------------------------------------------------------------------------
  def od_gauge
    return @od_gauge
  end
  #--------------------------------------------------------------------------
  # ● ゲージ画像を設定
  #--------------------------------------------------------------------------
  def od_gauge=(new_bitmap)
    @od_gauge = new_bitmap
  end
  #--------------------------------------------------------------------------
  # ● 名前の描画
  #--------------------------------------------------------------------------
  alias draw_actor_name_KGC_OverDrive draw_actor_name
  def draw_actor_name(actor, x, y)
    if !$game_temp.in_battle && !KGC::OD_GAUGE_HIDE_NOT_IN_BATTLE
      draw_actor_od_gauge(actor, x, y, 120)
    end

    draw_actor_name_KGC_OverDrive(actor, x, y)
  end
  #--------------------------------------------------------------------------
  # ● OverDrive ゲージの描画
  #--------------------------------------------------------------------------
  def draw_actor_od_gauge(actor, x, y, width)
    return if KGC::OD_GAUGE_HIDE_ACTOR.include?(actor.id)
    # ゲージ幅計算
    dx = dy = gw = 0
    maximum = false
    if $game_temp.in_battle && self.is_a?(Window_BattleStatus)
      @gs_od[actor.index] = actor.overdrive if @gs_od[actor.index] == nil
      begin
        dx = actor.battle_status_x - @od_g_width + 52
      rescue
        dx = actor.index * 160 + 4
      end
      #dx += -@od_g_width + 52
      dy = y
      dx -= 16 if $imported["HPSPAlter"] && !KGC::HPSP_DRAW_NAME_LUMP
      gw = @gs_od[actor.index] * @od_g_width / KGC::OD_GAUGE_MAX
      maximum = (@gs_od[actor.index] == KGC::OD_GAUGE_MAX)
    else
      @gauge_x = 0
      dx = x + width - @od_g_width - 13
      dy = y
      gw = actor.overdrive * @od_g_width / KGC::OD_GAUGE_MAX
      maximum = (actor.overdrive == KGC::OD_GAUGE_MAX)
    end
    dx += ($game_temp.in_battle ? KGC::OD_GAUGE_OFF_BATTLE[0] :
      KGC::OD_GAUGE_OFF[0])
    dy += ($game_temp.in_battle ? KGC::OD_GAUGE_OFF_BATTLE[1] :
      KGC::OD_GAUGE_OFF[1])
    # 斜め描画
    if KGC::OD_GAUGE_SLANT
      self.contents.fill_rect(dx, dy, @od_g_width + 7, 6, Color.new(0, 0, 0, 0))
      # 枠描画
      gy = @od_g_height + 1
      (@od_g_height + 2).times { |i|
        self.contents.blt(dx + i, dy + gy - i, @od_gauge,
          Rect.new(0, gy - i, @od_g_width + 2, 1))
      }
      # 本体描画
      gy -= 1
      gy2 = @od_g_height * (maximum ? 3 : 2) + 1
      @od_g_height.times { |i|
        self.contents.blt(dx + i + 2, dy + gy - i, @od_gauge,
          Rect.new(@gauge_x, gy2 - i, gw, 1))
      }
    # 通常描画
    else
      self.contents.fill_rect(dx, dy, @od_g_width + 2, @od_g_height + 2,
        Color.new(0, 0, 0, 0))
      self.contents.blt(dx, dy, @od_gauge, Rect.new(0, 0, @od_g_width + 2,
        @od_g_height + 2))
      gy2 = @od_g_height * (maximum ? 2 : 1) + 2
      self.contents.blt(dx + 1, dy + 1, @od_gauge,
        Rect.new(@gauge_x, gy2, gw, @od_g_height))
    end
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Window_BattleStatus
#==============================================================================

class Window_BattleStatus < Window_Base
  #--------------------------------------------------------------------------
  # ● オブジェクト初期化
  #--------------------------------------------------------------------------
  alias initialize_KGC_OverDrive initialize
  def initialize
    @gauge_x = 0
    @gs_od = []
    @od_g_width = @@_od_gauge.width / 3
    @od_g_height = (@@_od_gauge.height - 2) / 3

    initialize_KGC_OverDrive
  end
  #--------------------------------------------------------------------------
  # ● リフレッシュ
  #--------------------------------------------------------------------------
  alias refresh_KGC_OverDrive refresh
  def refresh
    refresh_KGC_OverDrive

    $game_party.actors.each_with_index { |actor, i|
      @gs_od[i] = actor.overdrive
      draw_actor_od_gauge(actor, 0, 0, 120)
    }
  end
  #--------------------------------------------------------------------------
  # ● フレーム更新
  #--------------------------------------------------------------------------
  alias update_KGC_OverDrive update
  def update
    update_KGC_OverDrive

    # ゲージ画像を流す
    unless $imported["HPSPAlter"]
      @gauge_x -= [@od_g_width / 20, 1].max
      @gauge_x = @od_g_width * 2 if @gauge_x < 0
    end
    $game_party.actors.each { |actor|
      draw_actor_od_gauge(actor, 0, 0, 120)
    }
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Scene_Battle (分割定義 1)
#==============================================================================

class Scene_Battle
  #--------------------------------------------------------------------------
  # ● バトル終了
  #     result : 結果 (0:勝利 1:逃走 2:敗北)
  #--------------------------------------------------------------------------
  alias battle_end_KGC_OverDrive battle_end
  def battle_end(result)
    case result
    when 0  # 勝利
      $game_party.actors.each { |actor|
        # ドライブタイプが「勝利」の場合は加算
        if actor.exist? && actor.overdrive_type.include?(ODType::VICTORY)
          actor.overdrive += KGC::OD_GAIN_RATE[ODType::VICTORY]
        end
      }
    when 1  # 逃走
      $game_party.actors.each { |actor|
        # ドライブタイプが「逃走」の場合は加算
        if actor.exist? && actor.overdrive_type.include?(ODType::ESCAPE)
          actor.overdrive += KGC::OD_GAIN_RATE[ODType::ESCAPE]
        end
      }
    end

    battle_end_KGC_OverDrive(result)
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Scene_Battle (分割定義 4)
#==============================================================================

class Scene_Battle
  #--------------------------------------------------------------------------
  # ● フレーム更新 (メインフェーズ ステップ 2 : アクション開始)
  #--------------------------------------------------------------------------
  alias update_phase4_step2_KGC_OverDrive update_phase4_step2
  def update_phase4_step2
    if @active_battler.is_a?(Game_Actor)
      overdrive_increase(@active_battler, $game_party.actors)
    end

    update_phase4_step2_KGC_OverDrive
  end
  #--------------------------------------------------------------------------
  # ● ODゲージ増加処理
  #--------------------------------------------------------------------------
  def overdrive_increase(battler, battler_list)
    od_gain = 0
    # ゲージ増加判定
    type = battler.overdrive_type
    if type.include?(ODType::ALONE)  # 孤独戦闘
      alone = true
      battler_list.each { |b|
        # 生存者がいる場合は孤独ではない
        if !b.equal?(battler) && b.exist?
          alone = false
          break
        end
      }
      if alone
        od_gain += KGC::OD_GAIN_RATE[ODType::ALONE]
      end
    end
    if type.include?(ODType::ACTION)  # 行動時
      od_gain += KGC::OD_GAIN_RATE[ODType::ACTION]
    end
    if type.include?(ODType::FATAL)  # 瀕死
      if battler.hp <= battler.maxhp / 4
        od_gain += KGC::OD_GAIN_RATE[ODType::FATAL]
      end
    end
    battler.overdrive += od_gain
  end
end
--------

OD_GAUGE_MAX = 1000 오버드라이브 양조절
첨부파일 od_gauge.png를 Graphics->Pictures에 넣으세요
데이터베이스 시스템 속성에 속성한개만들고 이름을 OverDrive

jpg보세용