#============================================================================== # ■リミットゲージ for RGSS3 Ver1.08-β # □作成者 kure #============================================================================== $kure_integrate_script = {} if $kure_integrate_script == nil $kure_integrate_script[:limit] = 107 p "リミットゲージ" module KURE module PTLimit #表示に関する設定------------------------------------------------------------ #ゲージの名前 GAUGE_NAME = "Limit" #属性表示ウィンドウのY座標 VIEW_WINDOW_Y = 250 #動作に関する設定------------------------------------------------------------ #LIMIT最大値 MAX_LIMIT = 100 #指定IDのスイッチがONの場合のみゲージが出現します。(常時は0を設定) SWITH = 0 end end #============================================================================== # ■ RPG::UsableItem(追加定義) #============================================================================== class RPG::UsableItem < RPG::BaseItem #-------------------------------------------------------------------------- # ☆ LIMITゲージの増減 #-------------------------------------------------------------------------- def limit_point @note.match(/<リミット変動\s?([-]?\d+)\s?>/) return $1 ? $1.to_i : 0 end #-------------------------------------------------------------------------- # ☆ 必要なリミット値 #-------------------------------------------------------------------------- def limit_cost @note.match(/<消費リミット\s?([-]?\d+)\s?>/) return $1 ? $1.to_i : 0 end end #============================================================================== # ■ Game_Party #============================================================================== class Game_Party < Game_Unit attr_accessor :pt_limit_refresh # 情報更新フラグ #-------------------------------------------------------------------------- # ● リミット値を呼び出す #-------------------------------------------------------------------------- def party_limit @party_limit ||= 0 @party_limit end #-------------------------------------------------------------------------- # ● プレリミット値を呼び出す #-------------------------------------------------------------------------- def pre_party_limit result = 0 return result unless @pre_party_limit @pre_party_limit.each{|value| result += value if value} return result end #-------------------------------------------------------------------------- # ● 特定アクターのプレリミット値を呼び出す #-------------------------------------------------------------------------- def pre_actor_limit(id) return 0 unless @pre_party_limit return 0 unless @pre_party_limit[id] return @pre_party_limit[id] end #-------------------------------------------------------------------------- # ● リミット値を操作する(加算) #-------------------------------------------------------------------------- def add_party_limit(value) return unless $game_party.limit_system_able? @party_limit ||= 0 @party_limit = [[0, @party_limit + value].max , KURE::PTLimit::MAX_LIMIT].min @pt_limit_refresh = true end #-------------------------------------------------------------------------- # ● リミット値を操作する(固定値) #-------------------------------------------------------------------------- def set_party_limit(value) return unless $game_party.limit_system_able? @party_limit ||= 0 @party_limit = [[0, value].max , KURE::PTLimit::MAX_LIMIT].min @pt_limit_refresh = true end #-------------------------------------------------------------------------- # ● プレリミット値を操作する #-------------------------------------------------------------------------- def add_pre_limit(id, value) @pre_party_limit ||= [] @pre_party_limit[id] = value @pt_limit_refresh = true end #-------------------------------------------------------------------------- # ● プレリミットをクリアする #-------------------------------------------------------------------------- def clear_pre_limit @pre_party_limit = [] @pt_limit_refresh = true end #-------------------------------------------------------------------------- # ● リミットレート値を呼び出す #-------------------------------------------------------------------------- def party_limit_rate party_limit.to_f / KURE::PTLimit::MAX_LIMIT end #-------------------------------------------------------------------------- # ● リミットシステムの動作有効判定 #-------------------------------------------------------------------------- def limit_system_able? return true if KURE::PTLimit::SWITH == 0 return true if $game_switches[KURE::PTLimit::SWITH] return false end end #============================================================================== # ■ Game_Battler #============================================================================== class Game_Battler < Game_BattlerBase #-------------------------------------------------------------------------- # ☆ スキル使用コストの支払い可能判定(エイリアス再定義) #-------------------------------------------------------------------------- alias k_pt_limit_before_skill_cost_payable? skill_cost_payable? def skill_cost_payable?(skill) return false unless limit_cost_payable?(skill) k_pt_limit_before_skill_cost_payable?(skill) end #-------------------------------------------------------------------------- # ☆リミットのコスト支払い可能判定(追加定義) #-------------------------------------------------------------------------- def limit_cost_payable?(skill) #リミット値が足りない場合はfalseを返す return true unless actor? return false if skill.limit_cost > $game_party.party_limit - $game_party.pre_party_limit + $game_party.pre_actor_limit(self.id) return true end #-------------------------------------------------------------------------- # ☆ スキル使用コストの支払い処理(エイリアス再定義) #-------------------------------------------------------------------------- alias k_pt_limit_before_pay_skill_cost pay_skill_cost def pay_skill_cost(skill) pay_limit_cost(skill) k_pt_limit_before_pay_skill_cost(skill) end #-------------------------------------------------------------------------- # ☆ リミットのコスト支払い処理(追加定義) #-------------------------------------------------------------------------- def pay_limit_cost(skill) return unless actor? point = skill.limit_point - skill.limit_cost $game_party.add_party_limit(point) $game_party.add_pre_limit(self.id, 0) end end #============================================================================== # ■ Game_Action #============================================================================== class Game_Action #-------------------------------------------------------------------------- # ● スキルを設定(エイリアス再定義) #-------------------------------------------------------------------------- alias k_pt_limit_before_set_skill set_skill def set_skill(skill_id) if @subject.actor? $game_party.add_pre_limit(@subject.id, $data_skills[skill_id].limit_cost) end k_pt_limit_before_set_skill(skill_id) end #-------------------------------------------------------------------------- # ● アイテムを設定(エイリアス再定義) #-------------------------------------------------------------------------- alias k_pt_limit_before_set_item set_item def set_item(item_id) if @subject.actor? $game_party.add_pre_limit(@subject.id, $data_items[item_id].limit_cost) end k_pt_limit_before_set_item(item_id) end end #============================================================================== # ■ Scene_Battle #============================================================================== class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # ● 全ウィンドウの作成(エイリアス再定義) #-------------------------------------------------------------------------- alias k_pt_limit_before_create_all_windows create_all_windows def create_all_windows k_pt_limit_before_create_all_windows create_party_limit_window end #-------------------------------------------------------------------------- # ● パーティーリミットウィンドウの作成(追加定義) #-------------------------------------------------------------------------- def create_party_limit_window wy = KURE::PTLimit::VIEW_WINDOW_Y @party_limit_window = Window_PT_Limit.new(0, wy, Graphics.width, 48) @party_limit_window.opacity = 0 #リミットシステム停止時はリミット値を0で固定 $game_party.clear_pre_limit $game_party.set_party_limit(0) unless $game_party.limit_system_able? end #-------------------------------------------------------------------------- # ● ステータスウィンドウの情報を更新(エイリアス再定義) #-------------------------------------------------------------------------- alias k_pt_limit_refresh_status refresh_status def refresh_status k_pt_limit_refresh_status @party_limit_window.refresh if $game_party.pt_limit_refresh end #-------------------------------------------------------------------------- # ● アクターコマンド選択の開始(エイリアス再定義) #-------------------------------------------------------------------------- alias k_pt_limit_before_start_actor_command_selection start_actor_command_selection def start_actor_command_selection $game_party.add_pre_limit(BattleManager.actor.id, 0) k_pt_limit_before_start_actor_command_selection end #-------------------------------------------------------------------------- # ● 次のコマンド入力へ(エイリアス再定義) #-------------------------------------------------------------------------- alias k_pt_limit_before_next_command next_command def next_command @party_limit_window.refresh k_pt_limit_before_next_command end #-------------------------------------------------------------------------- # ● 前のコマンド入力へ(エイリアス再定義) #-------------------------------------------------------------------------- alias k_pt_limit_before_prior_command prior_command def prior_command k_pt_limit_before_prior_command @party_limit_window.refresh end #-------------------------------------------------------------------------- # ● ターン終了(エイリアス再定義) #-------------------------------------------------------------------------- alias k_pt_limit_before_turn_end turn_end def turn_end $game_party.clear_pre_limit k_pt_limit_before_turn_end end end #============================================================================== # ■ Window_PT_Limit #============================================================================== class Window_PT_Limit < Window_Base #-------------------------------------------------------------------------- # ● オブジェクト初期化 #-------------------------------------------------------------------------- def initialize(x, y, width, height) super refresh end #-------------------------------------------------------------------------- # ● 描画 #-------------------------------------------------------------------------- def refresh contents.clear return unless $game_party.limit_system_able? draw_limit_gauge(30, 0, contents.width - 60, $game_party.party_limit_rate, mp_gauge_color1, mp_gauge_color2) change_color(crisis_color) draw_text(30, 0, 80, line_height, KURE::PTLimit::GAUGE_NAME) draw_txt = $game_party.party_limit.to_s + "(" + $game_party.pre_party_limit.to_s + ")" + " / " + KURE::PTLimit::MAX_LIMIT.to_s draw_text(30, 0, contents.width - 60, line_height, draw_txt, 2) change_color(normal_color) $game_party.pt_limit_refresh = false end #-------------------------------------------------------------------------- # ● リミットゲージの描画 #-------------------------------------------------------------------------- def draw_limit_gauge(x, y, width, rate, color1, color2) fill_w = [width, (width * rate).to_i].min gauge_y = y + line_height - 8 contents.fill_rect(x - 2, gauge_y - 2, width + 4 , 10, gauge_back_color) contents.gradient_fill_rect(x, gauge_y, fill_w, 6, color1, color2) end end #============================================================================== # ■ Game_Interpreter #============================================================================== class Game_Interpreter #-------------------------------------------------------------------------- # ● リミット値を操作する(加算) #-------------------------------------------------------------------------- def add_limit(value) $game_party.add_party_limit(value) end #-------------------------------------------------------------------------- # ● リミット値を操作する(固定値) #-------------------------------------------------------------------------- def set_limit(value) $game_party.set_party_limit(value) end end #============================================================================== # ■ Window_SkillList #============================================================================== class Window_SkillList < Window_Selectable #-------------------------------------------------------------------------- # ◎ スキルの使用コストを描画(エイリアス再定義) #-------------------------------------------------------------------------- def draw_skill_cost(rect, skill) #統合ベーススクリプト導入時の処理 if $kure_integrate_script[:integrate] #ディレイが存在する場合はディレイを表示 if @actor.delay_time(skill) != 0 change_color(power_down_color) draw_text(rect, "Delay " + @actor.delay_time(skill).to_s, 2) return end end x = rect.x + rect.width - 30 y = rect.y #TPコスト if @actor.skill_tp_cost(skill) > 0 change_color(tp_cost_color, enable?(skill)) draw_text(x, y, 30, line_height, @actor.skill_tp_cost(skill), 2) x -= 33 end #MPコスト if @actor.skill_mp_cost(skill) > 0 change_color(mp_cost_color, enable?(skill)) draw_text(x, y, 30, line_height, @actor.skill_mp_cost(skill), 2) x -= 33 end #リミットコスト if skill.limit_cost > 0 change_color(crisis_color, enable?(skill)) draw_text(x, y, 30, line_height, skill.limit_cost, 2) x -= 33 end #HPコスト if $kure_integrate_script[:integrate] && @actor.skill_hp_cost(skill) > 0 change_color(hp_gauge_color1, enable?(skill)) draw_text(x, y, 30, line_height, @actor.skill_hp_cost(skill), 2) end end end