#============================================================================== # ■ RGSS3 サプリメントシステム Ver1.00 by 星潟 #------------------------------------------------------------------------------ # ★本スクリプトはSeraphic Blueのサプリメントシステムを参考にしています。 # # メニュー画面でサプリメント値を使用したダメージの回復が出来ます。 # また、戦闘終了時に自動でサプリメント値を使用して回復する # オートフィルシステムも併せて実装します。 # HP/MP/TP個別にサプリメントで回復で使用する値は違います。 # 初期値は0なので、最大値を設定した後、回復しないと使用出来ません。 #============================================================================== # 以下、イベントコマンドのスクリプトで使用します。 #============================================================================== # supplement_heal_execute # # サプリメントによる回復をパーティ全体に対して行います。 #------------------------------------------------------------------------------ # supplement_heal_execute(1) # # サプリメントによる回復をID1のアクターに対して行います。 #------------------------------------------------------------------------------ # supplement_charge # # サプリメントを全て最大値まで補充します。 #------------------------------------------------------------------------------ # supplement_charge(1) # # HPのサプリメントを全て最大値まで補充します。 #------------------------------------------------------------------------------ # supplement_charge(2) # # MPのサプリメントを全て最大値まで補充します。 #------------------------------------------------------------------------------ # supplement_charge(3) # # TPのサプリメントを全て最大値まで補充します。 #============================================================================== module Supplement #サプリメントシステムの名称を指定。 #コマンド名として使用します。 Name1 = "サプリメント" #オートフィルシステムの名称を指定。 #戦闘終了後のウィンドウへの表示名として使用します。 Name2 = "オートフィル" #サプリメント用ハッシュデータを作成。 Hash = {} #HPのサプリメントを指定します。 #例.Hash[:h] = {:f => true,:v => 91,:mv => 92} #この場合、HPのサプリメントを有効にします。 #変数91の値をサプリメントの基本値、 #変数92の値をサプリメントの最大値とします。 #最大値の変数IDの値を変更する事でサプリメントの上限を引き上げられます。 Hash[:h] = {:f => true,:v => 91,:mv => 92} #MPのサプリメントを指定します。 #例.Hash[:m] = {:f => true,:v => 93,:mv => 94} #この場合、MPのサプリメントを有効にします。 #変数93の値をサプリメントの基本値、 #変数94の値をサプリメントの最大値とします。 #最大値の変数IDの値を変更する事でサプリメントの上限を引き上げられます。 Hash[:m] = {:f => true,:v => 93,:mv => 94} #TPのサプリメントを指定します。 #例.Hash[:t] = {:f => false,:v => 95,:mv => 96} #この場合、TPのサプリメントを無効にします。 #変数95の値をサプリメントの基本値、 #変数96の値をサプリメントの最大値とします。 #最大値の変数IDの値を変更する事でサプリメントの上限を引き上げられます。 Hash[:t] = {:f => false,:v => 95,:mv => 96} #戦闘不能時も回復するかどうかを指定します。 #trueの場合は回復可能、falseの場合は回復出来ません。 Dead = true #オートフィルの有効化スイッチを指定します。 #指定したIDのスイッチがONの時、オートフィルが有効になります。 Autofill = 100 #戦闘終了後のオートフィルの結果を表示するウィンドウの #表示ウェイトを指定します。 #決定キーを押す事で表示を終了させられる他 #CTRLを押しっぱなしにしていると飛ばす事が出来ます。 AfTime = 120 #メニュー用サプリメントウィンドウ #例.MRect = [0,296,160,72] #この場合、X座標0、Y座標296に幅160、高さ72で表示します。 #高さは表示数(最大でもHP・MP・TPの3種)*24+24の値が最適です。 MRect = [0,296,160,72] #戦闘用サプリメントウィンドウ #例.BRect = [160,120] #この場合、画面中央に幅160、高さ120で表示します。 #高さは表示数(最大でもHP・MP・TPの3種)*24+72の値が最適です。 BRect = [200,120] #オートフィルの全回復時のメッセージを指定します。 #なお、Deadがfalseの時、戦闘不能の為回復できなかった場合でも #「回復出来るキャラクターは全回復」している為 #全回復と表示されます。 Text1 = "全回復" #オートフィルで完全回復できなかった場合のメッセージを指定します。 Text2 = "サプリメント不足" end class Game_Interpreter #-------------------------------------------------------------------------- # サプリメント #-------------------------------------------------------------------------- def supplement_heal_execute(aid = nil) return if aid && !$game_actors[aid] (aid ? [$game_actors[aid]] : $game_party.all_members).each {|m| m.supplement_heal_execute} end #-------------------------------------------------------------------------- # サプリメント補充 #-------------------------------------------------------------------------- def supplement_charge(type = 0) hash = Supplement::Hash if type == 0 or type == 1 h = hash[:h] $game_variables[h[:v]] = $game_variables[h[:mv]] if h[:f] && $game_variables[h[:v]] < $game_variables[h[:mv]] end if type == 0 or type == 2 m = hash[:m] $game_variables[m[:v]] = $game_variables[m[:mv]] if m[:f] && $game_variables[m[:v]] < $game_variables[m[:mv]] end if type == 0 or type == 3 t = hash[:t] $game_variables[t[:v]] = $game_variables[t[:mv]] if t[:f] && $game_variables[t[:v]] < $game_variables[t[:mv]] end end end class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # サプリメント使用可能か? #-------------------------------------------------------------------------- def supplement_usable? hash = Supplement::Hash return false if !Supplement::Dead && self.dead? h = hash[:h] return true if h[:f] && self.hp < self.mhp && $game_variables[h[:v]] > 0 m = hash[:m] return true if m[:f] && self.mp < self.mmp && $game_variables[m[:v]] > 0 t = hash[:t] return true if t[:f] && self.tp.to_i < self.max_tp && $game_variables[t[:v]] > 0 return false end #-------------------------------------------------------------------------- # 戦闘終了処理 #-------------------------------------------------------------------------- alias on_battle_end_supplement on_battle_end unless $! def on_battle_end on_battle_end_supplement supplement_heal_execute if $game_switches[Supplement::Autofill] end #-------------------------------------------------------------------------- # サプリメント #-------------------------------------------------------------------------- def supplement_heal_execute hash = Supplement::Hash h = hash[:h] m = hash[:m] t = hash[:t] return false if !Supplement::Dead && self.dead? hd = h[:f] ? [self.mhp - self.hp,$game_variables[h[:v]]].min : 0 md = m[:f] ? [self.mmp - self.mp,$game_variables[m[:v]]].min : 0 td = t[:f] ? [self.max_tp - self.tp.to_i,$game_variables[t[:v]]].min : 0 if hd > 0 if self.dead? remove_state(death_state_id) self.hp += hd - 1 else self.hp += hd end $game_variables[h[:v]] -= hd end if md > 0 self.mp += md $game_variables[m[:v]] -= md end if td > 0 self.tp += td $game_variables[t[:v]] -= td end end end class Scene_Menu < Scene_MenuBase #-------------------------------------------------------------------------- # 開始処理 #-------------------------------------------------------------------------- alias start_supplement start def start start_supplement create_supplement_window end #-------------------------------------------------------------------------- # サプリメントウィンドウの作成 #-------------------------------------------------------------------------- def create_supplement_window @supplement_window = Window_Supplement.new end #-------------------------------------------------------------------------- # コマンドウィンドウの作成 #-------------------------------------------------------------------------- alias create_command_window_supplement create_command_window def create_command_window create_command_window_supplement @command_window.set_handler(:supplement,method(:command_personal)) end #-------------------------------------------------------------------------- # 個人コマンド[決定] #-------------------------------------------------------------------------- alias on_personal_ok_supplement on_personal_ok def on_personal_ok return supplement_execute if @command_window.current_symbol == :supplement on_personal_ok_supplement end #-------------------------------------------------------------------------- # サプリメント使用 #-------------------------------------------------------------------------- def supplement_execute hash = Supplement::Hash h = hash[:h] m = hash[:m] t = hash[:t] lh = $game_variables[h[:v]] if h[:f] lm = $game_variables[m[:v]] if m[:f] lt = $game_variables[t[:v]] if t[:f] $game_party.members[@status_window.index].supplement_heal_execute f = false f = true if h[:f] && $game_variables[h[:v]] != lh f = true if !f && m[:f] && $game_variables[m[:v]] != lm f = true if !f && t[:f] && $game_variables[t[:v]] != lt f ? Sound.play_recovery : Sound.play_buzzer @supplement_window.refresh @status_window.refresh @status_window.activate end #-------------------------------------------------------------------------- # サプリメントウィンドウの作成 #-------------------------------------------------------------------------- def supplement_mode? @command_window.current_symbol == :supplement end end class Window_MenuCommand < Window_Command #-------------------------------------------------------------------------- # 独自コマンドの追加用 #-------------------------------------------------------------------------- alias add_original_commands_supplement add_original_commands def add_original_commands add_original_commands_supplement add_command(Supplement::Name1,:supplement,main_commands_enabled) end end class Window_MenuStatus < Window_Selectable #-------------------------------------------------------------------------- # 選択項目の有効状態を取得 #-------------------------------------------------------------------------- alias current_item_enabled_supplement? current_item_enabled? def current_item_enabled? return false unless current_item_enabled_supplement? SceneManager.scene.supplement_mode? ? $game_party.members[index].supplement_usable? : true end end class Window_Supplement < Window_Base #-------------------------------------------------------------------------- # 初期化 #-------------------------------------------------------------------------- def initialize r = Supplement::MRect super(r[0],r[1],r[2],r[3]) refresh end #-------------------------------------------------------------------------- # リフレッシュ #-------------------------------------------------------------------------- def refresh create_contents l = 0 Supplement::Hash.each_value {|v| next unless v[:f] n = $data_system.variables[v[:v]] d = $game_variables[v[:v]] draw_supplement(0,l * line_height,n,d) l += 1} end #-------------------------------------------------------------------------- # 描写 #-------------------------------------------------------------------------- def draw_supplement(x,y,n,d) change_color(system_color) draw_text(x,y,contents_width,line_height,n) change_color(normal_color) draw_text(x,y,contents_width,line_height,d,2) end end class Window_SupplementBattleEnd < Window_Base #-------------------------------------------------------------------------- # 初期化 #-------------------------------------------------------------------------- def initialize r = Supplement::BRect super(0,0,r[0],r[1]) self.visible = false self.x = (Graphics.width - self.width) / 2 self.y = (Graphics.height - self.height) / 2 end #-------------------------------------------------------------------------- # リフレッシュ #-------------------------------------------------------------------------- def refresh create_contents l = 2 hash = Supplement::Hash f = false h = hash[:h] m = hash[:m] t = hash[:t] $game_party.members.each {|i| next if i.dead? && !Supplement::Dead f = true if h[:f] && i.hp < i.mhp f = true if m[:f] && i.mp < i.mmp f = true if t[:f] && i.tp < i.max_tp} change_color(system_color) draw_text(0,0,contents_width,line_height,Supplement::Name2,1) change_color(f ? normal_color : text_color(14)) draw_text(0,line_height,contents_width,line_height,(f ? Supplement::Text2 : Supplement::Text1),1) hash.each_value {|v| next unless v[:f] n = $data_system.variables[v[:v]] d = $game_variables[v[:v]] draw_supplement(0,l * (line_height),n,d) l += 1} end #-------------------------------------------------------------------------- # 描写 #-------------------------------------------------------------------------- def draw_supplement(x,y,n,d) change_color(system_color) draw_text(x,y,contents_width,line_height,n) change_color(normal_color) draw_text(x,y,contents_width,line_height,d,2) end end class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # 全ウィンドウの作成 #-------------------------------------------------------------------------- alias create_all_windows_supplement create_all_windows def create_all_windows create_all_windows_supplement create_supplement_window end def create_supplement_window @supplement_window = Window_SupplementBattleEnd.new end #-------------------------------------------------------------------------- # 終了処理 #-------------------------------------------------------------------------- alias pre_terminate_supplement pre_terminate def pre_terminate @supplement_window.refresh if $game_switches[Supplement::Autofill] @supplement_window.visible = true Supplement::AfTime.times do update_basic break if Input.trigger?(:C) or Input.press?(:CTRL) end @supplement_window.visible = false end pre_terminate_supplement end end