#============================================================================== # ■ RGSS2 自動蘇生装備/ステート/エネミー Ver1.00 by 星潟 #------------------------------------------------------------------------------ # 自動蘇生効果を持つ装備/ステート/エネミーを作成します。 # # 設定例(装備/ステート/エネミー共通でメモ欄に記載) # # <自動蘇生:1,50,42,100> # 50%の確率で、HP1の状態で、アニメーションID42と共に蘇生します。 # そして、100%の確率で装備品の場合は破壊され、ステートの場合は消滅します。 # (エネミーの場合は消滅処理が行われません) # # <自動蘇生:rand(self.maxhp)+1,100,50,25> # 100%の確率で、1〜最大HPの間の乱数の値のHPで、アニメーションID50と共に蘇生します。 # そして、25%の確率で装備品の場合は破壊され、ステートの場合は消滅します。 # (エネミーの場合は消滅処理が行われません) # # <自動蘇生:self.maxhp,35,60,70> # 35%の確率で、HPが最大まで回復した状態で、アニメーションID60と共に蘇生します。 # そして、70%の確率で装備品の場合は破壊され、ステートの場合は消滅します。 # (エネミーの場合は消滅処理が行われません) # # エネミーが自動蘇生する際にアニメーションが表示されないという方は # Sprite_Baseの189行目にある、「* self.opacity / 255.0」の部分だけを # 消すかコメントアウトする事で、正常に表示されるようになると思われます。 #============================================================================== module AUTO_RESURRECT #自動蘇生設定用のキーワードを指定。 WORD = "自動蘇生" #装備品を破損させる際に下の部位からチェックするか? REVE = true #装備が破損した場合のフォーマットを指定。 TEXT = "%sの%sが砕け散った!" #自動蘇生後のウェイトを設定。 WAIT = 30 end class Game_Temp attr_accessor :auto_resurrect_array #-------------------------------------------------------------------------- # 初期化 #-------------------------------------------------------------------------- alias initialize_auto_resurrect initialize def initialize #本来の処理を実行。 initialize_auto_resurrect #自動蘇生用配列を作成。 @auto_resurrect_array = [] end end class Game_Battler #-------------------------------------------------------------------------- # 自動蘇生を発生しうる項目の配列 #-------------------------------------------------------------------------- def auto_resurrect_feature #アクターはステートと装備品、エネミーはステートと自分自身 states + (self.actor? ? (AUTO_RESURRECT::REVE ? equips.reverse : equips) : [enemy]) end #-------------------------------------------------------------------------- # 各項目の自動蘇生率 #-------------------------------------------------------------------------- def auto_resurrectable(itemdata) #文字列を変換して計算する。 eval(itemdata.auto_resurrect[1]) end #-------------------------------------------------------------------------- # 自動蘇生 #-------------------------------------------------------------------------- def auto_resurrect(itemdata) #行動結果を抹消しておく。 clear_action_results #ステート1を消去する。 remove_state(1) @removed_states.push(1) #もしも自動蘇生の項目がステートであるならば #ここで消滅判定を行う。 if itemdata.is_a?(RPG::State) && auto_resurrect_break(itemdata) > rand(100) remove_state(itemdata.id) @removed_states.push(itemdata.id) end #自分のHPを自動蘇生のHPにする。 self.hp = [eval(itemdata.auto_resurrect[0]), 1].max @hp_damage = -self.hp end #-------------------------------------------------------------------------- # 各項目の破損or解除率 #-------------------------------------------------------------------------- def auto_resurrect_break(itemdata) #文字列を変換して計算する。 eval(itemdata.auto_resurrect[3]) end end class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # 付加ステートの表示 #-------------------------------------------------------------------------- alias display_added_states_auto_resurrect display_added_states def display_added_states(target, obj = nil) #本来の処理を実行。 display_added_states_auto_resurrect(target, obj) #付与されたステートの中にステートID1が含まれている場合は #自動蘇生発動判定を行う。 if target.added_states.include?($data_states[1]) #自動蘇生効果を持ち得る項目全てを調べる。 target.auto_resurrect_feature.each do |f| #項目が存在しない場合は飛ばす。 next if f == nil #項目の自動蘇生確率が条件を満たさない場合は飛ばす。 next if target.auto_resurrectable(f) <= rand(100) #自動蘇生対象配列に自身と項目で形成された配列を加え #以降の処理を中断する。 $game_temp.auto_resurrect_array.push([target,f]) break end end end #-------------------------------------------------------------------------- # 勝敗判定 #-------------------------------------------------------------------------- alias judge_win_loss_auto_resurrect judge_win_loss def judge_win_loss #自動蘇生処理を実行。 auto_resurrect_execute_all #本来の処理を実行。 judge_win_loss_auto_resurrect end #-------------------------------------------------------------------------- # 自動蘇生処理 #-------------------------------------------------------------------------- def auto_resurrect_execute_all #自動蘇生対象がいない場合は飛ばす。 return if $game_temp.auto_resurrect_array.empty? #自動蘇生対象がいる場合は順次蘇生させる。 $game_temp.auto_resurrect_array.each {|a_r_data| auto_resurrect_execute(a_r_data)} #自動蘇生対象配列を空にする。 $game_temp.auto_resurrect_array = [] end #-------------------------------------------------------------------------- # 対象者の個別自動蘇生実行 #-------------------------------------------------------------------------- def auto_resurrect_execute(a_r_data) #自動蘇生によるアニメーションを行う。 display_normal_animation([a_r_data[0]], a_r_data[1].auto_resurrect[2]) wait_for_animation #自動蘇生による戦闘不能解除とHP回復を行う。 a_r_data[0].auto_resurrect(a_r_data[1]) #HP回復と戦闘不能解除の表示を行う。 display_hp_damage(a_r_data[0]) display_removed_states(a_r_data[0]) #行動結果を抹消する。 a_r_data[0].clear_action_results #項目が装備品であり、なおかつ消滅率が条件を満たす場合は #その装備品を消滅させその旨を表示する。 if (a_r_data[1].is_a?(RPG::Weapon) or a_r_data[1].is_a?(RPG::Armor)) && a_r_data[0].auto_resurrect_break(a_r_data[1]) > rand(100) #装備を破棄し、その旨を表示する。 a_r_data[0].discard_equip(a_r_data[1]) display_a_r_break_equipment(a_r_data) end wait(AUTO_RESURRECT::WAIT) end #-------------------------------------------------------------------------- # 装備破壊の表示 #-------------------------------------------------------------------------- def display_a_r_break_equipment(a_r_data) #装備破壊フォーマットに対象者の名前と装備名を入れる。 text = sprintf(AUTO_RESURRECT::TEXT, a_r_data[0].name, a_r_data[1].name) #メッセージとして表示する。 $game_message.texts.push(text) end end module AUTO_RESURRECT def auto_resurrect #キャッシュがあればキャッシュを返す。 return @auto_resurrect if @auto_resurrect != nil #メモ欄からデータを取得。 data = @note.scan(/<#{WORD}[::](\S+),(\S+),(\S+),(\S+)>/).flatten #蘇生用データを生成。 @auto_resurrect = data != nil && data.size == 4 ? data : ["0"] * 4 #配列の3番目(アニメーションID)を数字に変える。 @auto_resurrect[2] = @auto_resurrect[2].to_i #データを返す。 return @auto_resurrect end end class RPG::Weapon < RPG::BaseItem include AUTO_RESURRECT end class RPG::Armor < RPG::BaseItem include AUTO_RESURRECT end class RPG::State include AUTO_RESURRECT end class RPG::Enemy include AUTO_RESURRECT end