#============================================================================== # ◆ FF13風 「TP」システムスクリプト #--------------------------------------------------------------------------- # version 1.12 (2013年1月10日) # 作:倉坂悠 #--------------------------------------------------------------------------- # ※動作には「コアスクリプト」が必須です。 #--------------------------------------------------------------------------- # FF13のような、パーティ全体で共有する必殺技ゲージのようなものを設定します。 # 詳細はサンプル付属のreadmeを参照してください。 #============================================================================== if $ukra_system == nil $ukra_system = {} end $ukra_system[5] = true #============================================================================== # ◆ カスタマイズポイント #============================================================================== module UKRA_005_CUSTOM # ◆TPゲージのデフォルト本数 # ゲーム開始時のTPゲージの最大数を設定します。 START_TP_BOTTLE = 5 # ◆ゲーム全体でのTPゲージ上限 # ゲーム全体を通しての、TPゲージ本数の上限を設定します。 TP_BOTTLE_LIMIT = 10 # ◆ゲージ本数に対応したTP回復率の設定 # TPゲージが溜まっている量に応じて、TP回復量を補正します。 # [TP回復量] = [TP回復力] × (1000 ÷ X) # (Xは下の配列で指定した数値。一番左から、「0本時」「1本時」「2本時」… # ゲージ本数上限に対して配列の要素が足りていない場合、一番右の数値を採用) TP_RECOV_RATE = [ 500, 800,1500, 2000, 2500, 3000, 3500, 4000] # ◆各アクターのTP増加基礎値の設定 TPG_ACTORBASE = [] TPG_ACTORBASE[0] = [ 0, 0, 0, 0, 0, 0, 0, 0, 0] # TPG_ACTORBASE[actor_id] = [ 0, 0, 0, 0, 0, 0, 0, 0] と記述して設定。 # どの数字が対応しているかは、次の「TPゲージの上がり方」の順番に同じ。 TPG_ACTORBASE[1] = [ 15, 0, 10,-50, 0, 10, 10, 0, 0] TPG_ACTORBASE[3] = [ 0, 20, 0, 15, 20, 20, 0, 0, 0] # ◆TP増加値 # TPゲージの溜まり方について設定します。 TP_REC = [ 40, # 00 対象にダメージを与える 20, # 01 自分がダメージを受ける 80, # 02 敵を倒す 40, # 03 自身が戦闘不能になる 20, # 04 対象のHPを回復する 15, # 05 対象にステータス変化を与える ※一度に与えた数だけ重複 200, # 06 戦闘に勝利する 0, # 07 戦闘から逃走成功する 10 # 08 戦闘のターンが経過する ] # ← 消さない # ◆戦闘中に表示するTPゲージのタイトル NAME_TP_BT = "TP" # ◆TPゲージの名称 NAME_TP_GAUGE = "TP" # ◆TPが回復する時のメッセージ # %s に「TPゲージの名前」が挿入されます。 MES_TP_REC = "パーティの%sが増加した!" MES_TP_DMG = "パーティの%sが減少した!" end #============================================================================== # ◆ module UKRA_005 #============================================================================== module UKRA_005 #-------------------------------------------------------------------------- # 正規表現 #-------------------------------------------------------------------------- TP_GAIN_UP = /\\tp_gain_up\[([+-]?[\d]+)\]/i TP_BASE_UP = /\\tp_base_up\[([\d]+)\s*,\s*([+-]?[\d]+)\]/i TP_RECOVER = /\\tp_recover\[([+-]?[\d]+)\]/i TP_SKILL = /\\tp_skill\[([\d]+)\]/i TP_PLUS = /\\tp_plus\[([+-]?[\d]+)\]/i TPIT_ANIME = /\\tp_anime/i #-------------------------------------------------------------------------- # ○ ゲージ本数に応じたTP回復率の取得 #-------------------------------------------------------------------------- def self.get_tp_recover_rate(n) a = n / 1000 f = UKRA_005_CUSTOM::TP_RECOV_RATE.dup b = f[a] if b == nil b = f.pop end return b end #-------------------------------------------------------------------------- # ○ TP増加量の増幅 #-------------------------------------------------------------------------- def tp_gain_up n = 0 @note.gsub(/#{TP_GAIN_UP}/) do n += $1.to_i end return n end #-------------------------------------------------------------------------- # ○ TP回復量の基礎値増幅 #-------------------------------------------------------------------------- def tp_base_up n = [0, 0, 0, 0, 0, 0, 0, 0, 0] @note.gsub(/#{TP_BASE_UP}/) do n[$1.to_i] += $2.to_i end return n end #-------------------------------------------------------------------------- # ○ TP回復量(アイテム等) #-------------------------------------------------------------------------- def tp_recover n = 0 @note.gsub(/#{TP_RECOVER}/) do n += $1.to_i end return n end #-------------------------------------------------------------------------- # ○ TP消費スキル #-------------------------------------------------------------------------- def tp_skill n = 0 @note.gsub(/#{TP_SKILL}/) do n = $1.to_i end return n end #-------------------------------------------------------------------------- # ○ 最大TP増加 #-------------------------------------------------------------------------- def tp_plus n = 0 @note.gsub(/#{TP_PLUS}/) do n += $1.to_i end return n end #-------------------------------------------------------------------------- # ○ TP回復用アイテムアニメ #-------------------------------------------------------------------------- def tp_item_anime n = false @note.gsub(/#{TPIT_ANIME}/) do n = true end return n end end module Vocab TpGauge = UKRA_005_CUSTOM::NAME_TP_GAUGE TpRecover = UKRA_005_CUSTOM::MES_TP_REC TpDamaged = UKRA_005_CUSTOM::MES_TP_DMG end class RPG::BaseItem include UKRA_005 end class RPG::State include UKRA_005 end #============================================================================== # ■ Game_Party #------------------------------------------------------------------------------ #  パーティを扱うクラスです。ゴールドやアイテムなどの情報が含まれます。 #============================================================================== class Game_Party < Game_Unit #-------------------------------------------------------------------------- # ○ 公開インスタンス変数 #-------------------------------------------------------------------------- attr_reader :tp attr_reader :tp_max #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- alias ukra005_pt_tp_initialize initialize def initialize ukra005_pt_tp_initialize @tp = 0 @tp_max = UKRA_005_CUSTOM::START_TP_BOTTLE * 1000 end #-------------------------------------------------------------------------- # ○ TPの増減 #-------------------------------------------------------------------------- def tp=(new_tp) @tp = [[new_tp, maxtp].min, 0].max end #-------------------------------------------------------------------------- # ○ TP最大値の増減 #-------------------------------------------------------------------------- def tp_max=(new_tp_max) @tp_max = [[new_tp_max, UKRA_005_CUSTOM::TP_BOTTLE_LIMIT * 1000].min, 0].max end #-------------------------------------------------------------------------- # ○ 最大TP #-------------------------------------------------------------------------- def maxtp n = @tp_max for member in members do n += member.maxtp_plus end return (n - n % 1000) end #-------------------------------------------------------------------------- # ○ 最大TP #-------------------------------------------------------------------------- def tmax? return @tp == maxtp end #-------------------------------------------------------------------------- # ○ TP増減値の算出 #-------------------------------------------------------------------------- def calc_tp_gain(base_point) f = UKRA_005.get_tp_recover_rate(@tp) n = base_point * 1000 / f return [n, 0].max end #-------------------------------------------------------------------------- # ○ 戦闘勝利時のTP回復 #-------------------------------------------------------------------------- def tp_gain_victory n = UKRA_005_CUSTOM::TP_REC[6] for member in existing_members n += member.tp_base_rate[6] * member.tp_gain_rate / 100 end self.tp += [calc_tp_gain(n), 0].max end #-------------------------------------------------------------------------- # ○ 逃走時のTP回復 #-------------------------------------------------------------------------- def tp_gain_escape n = UKRA_005_CUSTOM::TP_REC[7] for member in existing_members n += member.tp_base_rate[7] * member.tp_gain_rate / 100 end self.tp += [calc_tp_gain(n), 0].max end #-------------------------------------------------------------------------- # ○ ターン経過時のTP回復 #-------------------------------------------------------------------------- def tp_gain_turns n = UKRA_005_CUSTOM::TP_REC[8] for member in existing_members n += member.tp_base_rate[8] * member.tp_gain_rate / 100 end self.tp += [calc_tp_gain(n), 0].max end end #============================================================================== # ■ Game_Battler #------------------------------------------------------------------------------ #  バトラーを扱うクラスです。 #============================================================================== class Game_Battler #-------------------------------------------------------------------------- # ○ TP増加倍率 #-------------------------------------------------------------------------- def tp_gain_rate return 100 end #-------------------------------------------------------------------------- # ○ TP増加基礎値の取得 #-------------------------------------------------------------------------- def tp_base_rate return [ 0, 0, 0, 0, 0, 0, 0, 0, 0] end #-------------------------------------------------------------------------- # ○ TP増加処理 #-------------------------------------------------------------------------- def tp_gain_action(user, obj = nil) return unless $game_temp.in_battle # 戦闘中でなければ処理をしない if obj # TP消費スキルではTPは回復しない return if obj.tp_skill > 0 end n = 0 # 行動結果による増加基礎値の合計 f = UKRA_005_CUSTOM::TP_REC # カスタマイズポイントで設定した増加基礎値 a = user.tp_base_rate # 攻撃側のTP回復率 b = self.tp_base_rate # 防御側のTP回復率 if user.is_a?(Game_Actor) #【アクターの行動結果】 if @hp_damage > 0 or @mp_damage > 0 # HP/MPダメージを与えた n += f[0] + a[0] + b[1] if self.is_a?(Game_Enemy) end if dead? # 敵を戦闘不能にした n += f[2] + a[2] + b[3] if self.is_a?(Game_Enemy) end if @hp_damage < 0 or @mp_damage < 0 # HP/MPを回復した n += f[4] + a[4] if self.is_a?(Game_Actor) end if @added_states.size > 0 # ステート変化を与えた n += (f[5] + a[5]) * @added_states.size end elsif user.is_a?(Game_Enemy) #【エネミーの行動結果】 if @hp_damage > 0 or @mp_damage > 0 # HP/MPダメージを受けた n += f[1] + b[1] + a[0] if self.is_a?(Game_Actor) end if dead? # 自分が戦闘不能にされた n += f[3] + b[3] + a[2] if self.is_a?(Game_Actor) end if @hp_damage < 0 or @mp_damage < 0 # HP/MPを回復(吸収)した n += f[4] + a[4] if self.is_a?(Game_Actor) end end m = n * user.tp_gain_rate * self.tp_gain_rate / 10000 $game_party.tp += $game_party.calc_tp_gain(m) end #-------------------------------------------------------------------------- # ● 通常攻撃の効果適用 # attacker : 攻撃者 #-------------------------------------------------------------------------- alias ukra005_attack_effect attack_effect def attack_effect(attacker) ukra005_attack_effect(attacker) tp_gain_action(attacker) end #-------------------------------------------------------------------------- # ● スキルの効果適用 # user : スキルの使用者 # skill : スキル #-------------------------------------------------------------------------- alias ukra005_skill_effect skill_effect def skill_effect(user, skill) ukra005_skill_effect(user, skill) tp_gain_action(user, skill) end #-------------------------------------------------------------------------- # ● アイテムの効果適用 # user : スキルの使用者 # skill : スキル #-------------------------------------------------------------------------- alias ukra005_item_effect item_effect def item_effect(user, item) ukra005_item_effect(user, item) tp_gain_action(user, item) end end #============================================================================== # ■ Game_Actor #------------------------------------------------------------------------------ #  アクターを扱うクラスです。 #============================================================================== class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # ● スキルの使用可能判定 # skill : スキル #-------------------------------------------------------------------------- alias ukra005_ac_tp_skill_can_use? skill_can_use? def skill_can_use?(skill) return false if skill.tp_skill > ($game_party.tp / 1000) ukra005_ac_tp_skill_can_use?(skill) end #-------------------------------------------------------------------------- # ● 装備の変更 (オブジェクトで指定) # equip_type : 装備部位 (0..4) # item : 武器 or 防具 (nil なら装備解除) # test : テストフラグ (戦闘テスト、または装備画面での一時装備) #-------------------------------------------------------------------------- alias ukra005_ac_change_equip change_equip def change_equip(equip_type, item, test = false) ukra005_ac_change_equip(equip_type, item, test) $game_party.tp += 0 end #-------------------------------------------------------------------------- # ○ 最大TP増加装備 #-------------------------------------------------------------------------- def maxtp_plus n = 0 for item in equips.compact do n += item.tp_plus end return n end #-------------------------------------------------------------------------- # ○ TP回復率の取得 #-------------------------------------------------------------------------- def tp_gain_rate n = 100 for obj in call_action_obj do n += obj.tp_gain_up end return n end #-------------------------------------------------------------------------- # ○ TP増加基礎値の取得 #-------------------------------------------------------------------------- def tp_base_rate f = UKRA_005_CUSTOM::TPG_ACTORBASE n = (f[@actor_id] != nil ? f[@actor_id] : f[0]) for obj in call_action_obj for i in 0...n.size do n[i] += obj.tp_base_up[i] end end return n end end #============================================================================== # ■ Game_Enemy #------------------------------------------------------------------------------ #  エネミーを扱うクラスです。 #============================================================================== class Game_Enemy < Game_Battler #-------------------------------------------------------------------------- # ○ TP回復率の取得 #-------------------------------------------------------------------------- def tp_gain_rate n = super enemy.note.gsub(/#{UKRA_005::TP_GAIN_UP}/) do n = $1.to_i end return n end end #============================================================================== # ■ Window_Tp #------------------------------------------------------------------------------ #  戦闘中に、TPの現在値とゲージ量を表示するウィンドウです。 #============================================================================== class Window_Tp < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 # x : ウィンドウの X 座標 # y : ウィンドウの Y 座標 #-------------------------------------------------------------------------- def initialize(x, y) super(x, y, 332, WLH + 32) self.back_opacity = 0 self.opacity = 0 self.z = 90 refresh end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh self.contents.clear draw_tp_contents end #-------------------------------------------------------------------------- # ○ 内容の描画 #-------------------------------------------------------------------------- def draw_tp_contents draw_tp_gauge draw_tp_level end #-------------------------------------------------------------------------- # ○ TPレベル描画 #-------------------------------------------------------------------------- def draw_tp_level a = ($game_party.tp / 1000).to_s b = ($game_party.tp % 1000).to_s c = UKRA_005_CUSTOM::NAME_TP_BT loop do break if b.size >= 3 b = "0" + b end self.contents.font.size = 12 b_length = contents.text_size(b).width self.contents.font.size = 16 a_length = contents.text_size(a).width self.contents.font.color = system_color self.contents.draw_text(0, WLH-25, 300-a_length-b_length-10, 18, c, 2) self.contents.font.size = 16 self.contents.font.color = normal_color self.contents.draw_text(0, WLH-25, 300-b_length-5, 18, a, 2) self.contents.font.size = 12 self.contents.draw_text(0, WLH-24, 300, 18, "."+b, 2) end #-------------------------------------------------------------------------- # ○ TPゲージ描画 #-------------------------------------------------------------------------- def draw_tp_gauge # 5->13 6->14 width = 300 div = width / ($game_party.maxtp / 1000) width = div * ($game_party.maxtp / 1000) gw1 = width * $game_party.tp / $game_party.maxtp gw2 = width * ($game_party.tp / 1000) / ($game_party.maxtp / 1000) gc1 = text_color(5) gc2 = text_color(13) gc3 = text_color(6) gc4 = text_color(14) self.contents.fill_rect(0, WLH-8, width, 6, gauge_back_color) self.contents.gradient_fill_rect(0, WLH-8, gw1, 6, gc1, gc2) self.contents.gradient_fill_rect(0, WLH-8, gw2, 6, gc3, gc4) for i in 1...($game_party.maxtp/1000) color = ($game_party.tp >= i * 1000 ? gauge_back_color : text_color(8)) self.contents.fill_rect(i*div, WLH-8, 1, 6, color) end end end #============================================================================== # ■ Window_Skill #------------------------------------------------------------------------------ #  スキル画面などで、使用できるスキルの一覧を表示するウィンドウです。 #============================================================================== class Window_Skill < Window_Selectable #-------------------------------------------------------------------------- # ● 項目の描画 ※再定義 # index : 項目番号 #-------------------------------------------------------------------------- def draw_item(index) rect = item_rect(index) self.contents.clear_rect(rect) skill = @data[index] if skill != nil rect.width -= 4 enabled = @actor.skill_can_use?(skill) draw_item_name(skill, rect.x, rect.y, enabled) if skill.tp_skill > 0 case @actor.calc_mp_cost(skill) when 0 text = "TP" + skill.tp_skill.to_s else text = @actor.calc_mp_cost(skill).to_s + "/TP" + skill.tp_skill.to_s end else text = @actor.calc_mp_cost(skill).to_s end self.contents.draw_text(rect, text, 2) end end end #============================================================================== # ■ Window_Menu_Tp #------------------------------------------------------------------------------ #  メニュー画面で、TPゲージを表示するウィンドウです。 #============================================================================== class Window_Menu_Tp < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 # x : ウィンドウの X 座標 # y : ウィンドウの Y 座標 #-------------------------------------------------------------------------- def initialize(x, y) super(x, y, 160, WLH + 32) self.z = 90 refresh end #-------------------------------------------------------------------------- # ● リフレッシュ #-------------------------------------------------------------------------- def refresh self.contents.clear draw_tp_contents end #-------------------------------------------------------------------------- # ○ 内容の描画 #-------------------------------------------------------------------------- def draw_tp_contents draw_tp_gauge draw_tp_level end #-------------------------------------------------------------------------- # ○ TPレベル描画 #-------------------------------------------------------------------------- def draw_tp_level a = ($game_party.tp / 1000).to_s b = ($game_party.tp % 1000).to_s c = UKRA_005_CUSTOM::NAME_TP_BT loop do break if b.size >= 3 b = "0" + b end self.contents.font.size = 12 b_length = contents.text_size(b).width self.contents.font.size = 16 a_length = contents.text_size(a).width self.contents.font.color = system_color self.contents.draw_text(0, WLH-25, 128-a_length-b_length-10, 18, c, 2) self.contents.font.size = 16 self.contents.font.color = normal_color self.contents.draw_text(0, WLH-25, 128-b_length-5, 18, a, 2) self.contents.font.size = 12 self.contents.draw_text(0, WLH-24, 128, 18, "."+b, 2) end #-------------------------------------------------------------------------- # ○ TPゲージ描画 #-------------------------------------------------------------------------- def draw_tp_gauge # 5->13 6->14 width = 128 div = width / ($game_party.maxtp / 1000) width = div * ($game_party.maxtp / 1000) gw1 = width * $game_party.tp / $game_party.maxtp gw2 = width * ($game_party.tp / 1000) / ($game_party.maxtp / 1000) gc1, gc2 = text_color(5), text_color(13) gc3, gc4 = text_color(6), text_color(14) self.contents.fill_rect(0, WLH-8, width, 6, gauge_back_color) self.contents.gradient_fill_rect(0, WLH-8, gw1, 6, gc1, gc2) self.contents.gradient_fill_rect(0, WLH-8, gw2, 6, gc3, gc4) for i in 0..($game_party.maxtp/1000) color = ($game_party.tp >= i * 1000 ? gauge_back_color : text_color(8)) self.contents.fill_rect(i*div, WLH-8, 1, 6, color) end end end #============================================================================== # ■ Scene_Battle #------------------------------------------------------------------------------ #  バトル画面の処理を行うクラスです。 #============================================================================== class Scene_Battle #-------------------------------------------------------------------------- # ● 開始処理 #-------------------------------------------------------------------------- alias ukra005_bt_start start def start ukra005_bt_start @tp_window = Window_Tp.new(Graphics.width-332, @message_window.y - (Window_Base::WLH+32) + 12) end #-------------------------------------------------------------------------- # ● 終了処理 #-------------------------------------------------------------------------- alias ukra005_bt_terminate terminate def terminate @tp_window.dispose ukra005_bt_terminate end #-------------------------------------------------------------------------- # ● 基本更新処理 # main : メインの update メソッドからの呼び出し #-------------------------------------------------------------------------- alias ukra005_bt_update_basic update_basic def update_basic(main = false) ukra005_bt_update_basic(main) @tp_window.refresh end #-------------------------------------------------------------------------- # ● 戦闘終了 # result : 結果 (0:勝利 1:逃走 2:敗北) #-------------------------------------------------------------------------- alias ukra005_bt_battle_end battle_end def battle_end(result) ukra005_bt_battle_end(result) case result when 0 $game_party.tp_gain_victory when 1 $game_party.tp_gain_escape end end #-------------------------------------------------------------------------- # ● 戦闘行動の実行 : スキル #-------------------------------------------------------------------------- def execute_action_skill skill = @active_battler.action.skill text = @active_battler.name + skill.message1 @message_window.add_instant_text(text) unless skill.message2.empty? wait(10) @message_window.add_instant_text(skill.message2) end targets = @active_battler.action.make_targets display_animation(targets, skill.animation_id) @active_battler.mp -= @active_battler.calc_mp_cost(skill) if @active_battler.is_a?(Game_Actor) $game_party.tp -= skill.tp_skill * 1000 # ※ 変更点 end $game_temp.common_event_id = skill.common_event_id for target in targets target.skill_effect(@active_battler, skill) display_action_effects(target, skill) end if skill.tp_recover != 0 if skill.scope == 0 && skill.tp_item_anime display_animation([@active_battler], skill.animation_id) end $game_party.tp += skill.tp_recover mes = (skill.tp_recover > 0 ? Vocab::TpRecover : Vocab::TpDamaged) text = sprintf(mes, Vocab::TpGauge) @message_window.add_instant_text(text) wait(30) end end #-------------------------------------------------------------------------- # ● 戦闘行動の実行 : アイテム #-------------------------------------------------------------------------- alias ukra005_bt_execute_action_item execute_action_item def execute_action_item ukra005_bt_execute_action_item item = @active_battler.action.item if item.tp_recover != 0 if item.scope == 0 && item.tp_item_anime display_animation([@active_battler], item.animation_id) end $game_party.tp += item.tp_recover mes = (item.tp_recover > 0 ? Vocab::TpRecover : Vocab::TpDamaged) text = sprintf(mes, Vocab::TpGauge) @message_window.add_instant_text(text) wait(30) end end #-------------------------------------------------------------------------- # ● ターン終了 #-------------------------------------------------------------------------- alias ukra005_bt_turn_end turn_end def turn_end $game_party.tp_gain_turns ukra005_bt_turn_end end end class Scene_Menu < Scene_Base #-------------------------------------------------------------------------- # ● 開始処理 #-------------------------------------------------------------------------- alias ukra005_mn_start start def start ukra005_mn_start @tp_window = Window_Menu_Tp.new(0, 360 - (Window_Base::WLH + 32)) end #-------------------------------------------------------------------------- # ● 終了処理 #-------------------------------------------------------------------------- alias ukra005_mn_terminate terminate def terminate ukra005_mn_terminate @tp_window.dispose end #-------------------------------------------------------------------------- # ● フレーム更新 #-------------------------------------------------------------------------- alias ukra005_mn_update update def update ukra005_mn_update @tp_window.update end end class Scene_Item < Scene_Base #-------------------------------------------------------------------------- # ● アイテムの使用 (味方対象以外の使用効果を適用) #-------------------------------------------------------------------------- alias ukra005_it_use_item_nontarget use_item_nontarget def use_item_nontarget ukra005_it_use_item_nontarget if @item.tp_recover != 0 $game_party.tp += @item.tp_recover end end end #============================================================================== # ■ Scene_Skill #------------------------------------------------------------------------------ #  スキル画面の処理を行うクラスです。 #============================================================================== class Scene_Skill < Scene_Base #-------------------------------------------------------------------------- # ● アイテムの使用 (味方対象以外の使用効果を適用) #-------------------------------------------------------------------------- alias ukra005_sk_use_skill_nontarget use_skill_nontarget def use_skill_nontarget ukra005_sk_use_skill_nontarget if @skill.tp_skill > 0 $game_party.tp -= @skill.tp_skill * 1000 end if @skill.tp_recover != 0 $game_party.tp += @skill.tp_recover end @skill_window.refresh end end