KGC_Over Drive [RMXP]

25 de novembro de 2012

KGC_Over Drive é um script, desenvolvido por KGC, que adiciona a função Limit Break em um jogo do RPG Maker XP.

As habilidades com o atributo Limit Break somente serão acessíveis quando a barra de Limit Break estiver cheia, igual ao Final Fantasy 7, 8 e 9.

Utilização E Instalação

Crie um atributo chamado Limit Break no database. Na janela de habilidades, coloque o atributo Limit Break na habilidade que deseja.

Arrume uma figura para ser o medidor, salve como od_gauge.png e copie na pasta Graphics/Pictures do seu projeto.

Para instalar o script no seu projeto, você vai ter que criar duas novas classes, na janela de scripts do RMXP. Primeiro, crie uma chamada Module_KGC, acima do Main, e copie o código abaixo:

module KGC
$game_special_elements = {} 
$imported = {} 
$data_states = load_data("Data/States.rxdata") 
$data_system = load_data("Data/System.rxdata")
end

Depois, novamente acima da Main, crie outra classe, chamada KGC_Over_Drive, e copiar e colar o código abaixo:

###################################################################
##################### KGC_Over Drive ##############################
###################################################################
# O script adiciona a função Limit Break
# As habilidades com o atributo Limit Break somente serão acessíveis
# quando a barra de Limit Break estiver cheia, igual a
# Final Fantasy 7.
#============================================================================
# 1 - Crie um atributo chamado Limit Break no database
# 2 - Na janela de habilidades coloque o atributo Limit Break na
# habilidade que deseja.
#==============================================================================
#==============================================================================

module KGC
# Defina aqui o tamanho do Limit Break.
OD_GAUGE_MAX = 1000
OD_GAIN_RATE = [10, 60, 200, 100, 160, 40, 160]
end

class Window_Base < Window
@@_od_gauge = RPG::Cache.picture("od_gauge.png")
OD_GAUGE_SLANT = true
OD_GAUGE_OFF_Y = 26
OD_GAUGE_OFF_Y_BATTLE = 26
OD_GAUGE_HIDE = false
end

$imported["OverDrive"] = true

$game_special_elements["Limit Break"] = $data_system.elements.index("Limit Break")

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

class Game_Battler
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_accessor :base_damage # 基本ダメージ値
#--------------------------------------------------------------------------
# ● スキルの使用可能判定
#--------------------------------------------------------------------------
alias skill_can_use_KGC_OverDrive skill_can_use?
def skill_can_use?(skill_id)
# OverDriveスキル判定
if self.is_a?(Game_Actor)
skill = $data_skills[skill_id]
if skill != nil && skill.element_set.include?($game_special_elements["Limit Break"])
if self.overdrive < KGC::OD_GAUGE_MAX
return false
end
end
end

# 元の処理を実行
return skill_can_use_KGC_OverDrive(skill_id)
end
#--------------------------------------------------------------------------
# ● 通常攻撃の効果適用
#--------------------------------------------------------------------------
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)
# 攻撃時増加判定
if attacker.is_a?(Game_Actor) && self.is_a?(Game_Enemy) &&
attacker.overdrive_type == 0 && self.base_damage > 0
# ODゲージ増加量計算
od_up = [[self.damage * KGC::OD_GAIN_RATE[0] * 10 / self.base_damage, 1].max, 160].min
# ODゲージ増加
attacker.overdrive += od_up
# 被ダメージ時増加判定
elsif attacker.is_a?(Game_Enemy) && self.is_a?(Game_Actor) &&
self.overdrive_type == 1 && self.base_damage > 0
od_up = [self.damage * KGC::OD_GAIN_RATE[1] * 10 / self.maxhp, 1].max
self.overdrive += od_up
end
end
return result
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)
# 攻撃時増加判定
if user.is_a?(Game_Actor) && self.is_a?(Game_Enemy) &&
user.overdrive_type == 0 && self.base_damage > 0
# ODゲージ増加量計算
od_up = [[self.damage * KGC::OD_GAIN_RATE[0] * 10 / self.base_damage, 1].max, 160].min
# ODゲージ増加
user.overdrive += od_up
# 被ダメージ時増加判定
elsif user.is_a?(Game_Enemy) && self.is_a?(Game_Actor) &&
self.overdrive_type == 1 && self.base_damage > 0
od_up = [self.damage * KGC::OD_GAIN_RATE[1] * 10 / self.maxhp, 1].max
self.overdrive += od_up
end
end
return result
end
end

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

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

class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# ● セットアップ
#--------------------------------------------------------------------------
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 = 0 if @overdrive == nil
@overdrive = [[value, 0].max, KGC::OD_GAUGE_MAX].min
end
#--------------------------------------------------------------------------
# ● OverDriveタイプの取得
#--------------------------------------------------------------------------
def overdrive_type
@overdrive_type = 0 if @overdrive_type == nil
return @overdrive_type
end
#--------------------------------------------------------------------------
# ● OverDriveタイプの操作
#--------------------------------------------------------------------------
def overdrive_type=(value)
@overdrive_type = 0 if @overdrive_type == nil
@overdrive_type = value
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)
unless (!$game_temp.in_battle && OD_GAUGE_HIDE)
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)
# ゲージ幅計算
if $game_temp.in_battle && self.is_a?(Window_BattleStatus)
@gs_od[actor.index] = actor.overdrive if @gs_od[actor.index] == nil
dx = actor.screen_x + 52 - @od_g_width
dy = y + ($game_temp.in_battle ? OD_GAUGE_OFF_Y_BATTLE : OD_GAUGE_OFF_Y)
# dx -= 16 if $imported["HPSPAlter"] && !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 + ($game_temp.in_battle ? OD_GAUGE_OFF_Y_BATTLE : OD_GAUGE_OFF_Y)
gw = actor.overdrive * @od_g_width / KGC::OD_GAUGE_MAX
maximum = actor.overdrive == KGC::OD_GAUGE_MAX
end
# 斜め描画
if 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
for i in 0...(@od_g_height + 2)
self.contents.blt(dx + i, dy + gy - i, @od_gauge, Rect.new(0, gy - i, @od_g_width + 2, 1))
end
# 本体描画
gy -= 1
gy2 = @od_g_height * (maximum ? 3 : 2) + 1
for i in 0...@od_g_height
self.contents.blt(dx + i + 2, dy + gy - i, @od_gauge, Rect.new(@gauge_x, gy2 - i, gw, 1))
end
# 通常描画
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, @gs_od = 0, []
@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

for i in 0...$game_party.actors.size
@gs_od[i] = $game_party.actors[i].overdrive
end
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
for i in 0...$game_party.actors.size
draw_actor_od_gauge($game_party.actors[i], 0, 0, 120)
end
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 # 勝利
for actor in $game_party.actors
next unless actor.exist?
# ドライブタイプが「勝利」の場合は加算
if actor.overdrive_type == 2
actor.overdrive += KGC::OD_GAIN_RATE[2]
end
end
when 1 # 逃走
for actor in $game_party.actors
next unless actor.exist?
# ドライブタイプが「逃走」の場合は加算
if actor.overdrive_type == 3
actor.overdrive += KGC::OD_GAIN_RATE[3]
end
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)
# ゲージ増加判定
case @active_battler.overdrive_type
when 4 # 孤独戦闘
alone = true
for actor in $game_party.actors
next if actor == @active_battler
# 生存者がいる場合は孤独ではない
if actor.exist?
alone = false
break
end
end
od_up = alone ? KGC::OD_GAIN_RATE[4] : 0
when 5 # 行動時
od_up = KGC::OD_GAIN_RATE[5]
when 6 # 瀕死
od_up = @active_battler.hp <= @active_battler.maxhp / 4 ? KGC::OD_GAIN_RATE[6] : 0
else
od_up = 0
end
@active_battler.overdrive += od_up
end

# 元の処理を実行
update_phase4_step2_KGC_OverDrive
end
#--------------------------------------------------------------------------
# ● スキルアクション 結果作成
#--------------------------------------------------------------------------
alias make_skill_action_result_KGC_OverDrive make_skill_action_result
def make_skill_action_result
# 元の処理を実行
make_skill_action_result_KGC_OverDrive

# オーバードライブスキルを使用した場合
if @active_battler.is_a?(Game_Actor) && @skill.element_set.include?($game_special_elements["overdrive"])
@active_battler.overdrive = 0
end
end
end

Informações adicionais

Observação: se você gostou deste post ou ele lhe foi útil de alguma forma, por favor considere apoiar financeiramente a Gaming Room. Fico feliz só de ajudar, mas a contribuição do visitante é muito importante para que este site continua existindo e para que eu possa continuar provendo este tipo de conteúdo e melhorar cada vez mais. Acesse aqui e saiba como. Obrigado!

Deixe um comentário

Inscreva-se na nossa newsletter!