king-exit/Scripts/_.76.rb
2024-08-31 14:17:23 -05:00

195 lines
No EOL
5.6 KiB
Ruby
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#==============================================================================
# ■ RGSS3 戦闘終了後回復効果 Ver1.00 by 星潟
#------------------------------------------------------------------------------
# 戦闘終了時に自動的にHP/MP/TP回復と
# ステート解除を行う効果を特徴に設定できるようになります。
#==============================================================================
# ★設定例(アクター・職業・ステート・装備等のメモ欄)
#------------------------------------------------------------------------------
# <戦闘終了後HP回復:50>
#
# 戦闘終了後にHPを50回復する。
#------------------------------------------------------------------------------
# <戦闘終了後HP回復:mhp/5>
#
# 戦闘終了後にHPを最大HPの20回復する。
#------------------------------------------------------------------------------
# <戦闘終了後MP回復:10>
#
# 戦闘終了後にMPを10回復する。
#------------------------------------------------------------------------------
# <戦闘終了後MP回復:mmp/10>
#
# 戦闘終了後にMPを最大MPの10回復する。
#------------------------------------------------------------------------------
# <戦闘終了後TP回復:5>
#
# 戦闘終了後にTPを5回復する。
#------------------------------------------------------------------------------
# <戦闘終了後TP回復:max_tp/20>
#
# 戦闘終了後にTPを最大TPの5回復する。
#------------------------------------------------------------------------------
# <戦闘終了後ステート解除:2>
#
# 戦闘終了後にステートID2を解除する。
#==============================================================================
module BEHEAL
#戦闘不能が戦闘不能で自動解除されない仕様であっても
#戦闘不能者もHPを回復させるか
T1 = true
#敗北時/逃走時も回復するか?
T2 = true
#キーワード設定。
#空の配列を用意。
W = []
#配列にそれぞれのキーワードを格納。
#戦闘終了後のHP回復設定用キーワードを指定。
W[0] = "戦闘終了後HP回復"
#戦闘終了後のMP回復設定用キーワードを指定。
W[1] = "戦闘終了後MP回復"
#戦闘終了後のTP回復設定用キーワードを指定。
W[2] = "戦闘終了後TP回復"
#戦闘終了後のステート解除設定用キーワードを指定。
W[3] = "戦闘終了後ステート解除"
end
class Game_Temp
attr_accessor :battle_end_result
end
class << BattleManager
#--------------------------------------------------------------------------
# 戦闘終了
#--------------------------------------------------------------------------
alias battle_end_beheal battle_end
def battle_end(result)
#勝敗判定を格納。
$game_temp.battle_end_result = result
#本来の処理を実行。
battle_end_beheal(result)
#勝敗判定を消去。
$game_temp.battle_end_result = nil
end
end
class Game_Battler < Game_BattlerBase
#--------------------------------------------------------------------------
# 戦闘終了後のステート解除
#--------------------------------------------------------------------------
alias remove_battle_states_beheal remove_battle_states
def remove_battle_states
#本来の処理を実行。
remove_battle_states_beheal
#敗北時/逃走時も回復するか否かの設定に応じてここで処理を中断する。
return if !BEHEAL::T2 && $game_temp.battle_end_result != 0
#戦闘終了後の回復処理を実行。
battle_end_heal
end
#--------------------------------------------------------------------------
# 戦闘終了後の回復処理
#--------------------------------------------------------------------------
def battle_end_heal
#設定次第で、戦闘不能の場合の処理を行わない。
return if !BEHEAL::T1 && dead?
#ハッシュを用意。
h = {0 => 0,1 => 0,2 => 0,3 => []}
#特徴別に処理。
feature_objects.each{|f|
#4回処理。
4.times {|i1|
#回数に応じて然るべき場所に加算/追加。
f.battle_end_heal[i1].each {|i2|
case i1
when 0..2;h[i1] += eval(i2)
when 3;h[i1].push(eval(i2))
end}}}
#各ステートの解除を実行。
h[3].each {|i| remove_state(i)}
#HP/MP/TPの回復を実行。
p h
self.hp += h[0].to_i
self.mp += h[1].to_i
self.tp += h[2].to_i
end
end
class RPG::BaseItem
#--------------------------------------------------------------------------
# 戦闘終了後の回復処理用データ
#--------------------------------------------------------------------------
def battle_end_heal
#キャッシュが存在する場合はキャッシュを返す。
return @battle_end_heal if @battle_end_heal
#空のハッシュを用意。
@battle_end_heal = {}
#ハッシュに4つの空の配列を用意。
4.times {|i| @battle_end_heal[i] = []}
#メモ欄の各行別に処理。
self.note.each_line {|l|
#各キーワード別に処理。
BEHEAL::W.each_with_index {|t,i|
#データを取得。
data = /<#{t}[:](\S+)>/ =~ l ? $1.to_s : nil
#データを取得できた場合のみ配列に格納。
@battle_end_heal[i].push(data) if data}}
#ハッシュを返す。
@battle_end_heal
end
end