Hoje vamos disponibilizar um minigame feito no RPG Maker XP criado para demonstrar o script do KGC, OverDrive.
Basicamente, ele adiciona um contador (semelhante aqueles medidores de combo dos jogos de luta) nas batalhas, que permite o herói a utilizar um skill especial.
Pode ser bem interessante pro seu projeto.
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ #_/ ◆オーバードライブ - KGC_OverDrive◆ #_/---------------------------------------------------------------------------- #_/ 専用のゲージがMAXになったときのみ使用可能になるスキルを作成します。 #_/============================================================================ #_/ ≪SP消費改造[SPCostAlter]≫より下 #_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ #============================================================================== # ★ カスタマイズ項目 ★ #============================================================================== module KGC # ◆OverDriveゲージ最大値 # (通常はこのままでOK。どうしてもバランスがおかしくなる場合のみ変更) OD_GAUGE_MAX = 1000 # ◆OverDriveゲージ増加率 # 高いほどゲージが溜まりやすい。 # 順番(INDEX)および条件は以下の通り。 # 【0..攻撃 1..被ダメージ 2..勝利 3..逃走 4..孤独 5..行動 6..瀕死】 # ↑これらのINDEXは、アクターのドライブタイプと対応。 # 0,1 は、ダメージ量に応じて増加量が変動。 OD_GAIN_RATE = [10, 60, 200, 100, 160, 40, 160] end class Window_Base < Window # ◆OverDriveゲージ画像 @@_od_gauge = RPG::Cache.picture("od_gauge.png") # ◆OverDriveゲージを斜めにする OD_GAUGE_SLANT = true # ◆非戦闘時OverDriveゲージ位置 # 大きいほど名前から離れた位置に描画される。 OD_GAUGE_OFF_Y = 26 # ◆戦闘時OverDriveゲージ位置 OD_GAUGE_OFF_Y_BATTLE = 26 # ◆非戦闘時はゲージを隠す OD_GAUGE_HIDE = false end #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★ $imported["OverDrive"] = true # OverDrive属性 $game_special_elements["overdrive"] = $data_system.elements.index("OverDrive") #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★ #============================================================================== # ■ 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["overdrive"]) 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
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!