=begin
RGSS3
★ 断末魔 ★
戦闘不能になる直前に指定のスキルを発動するエネミーを作れます。
● 仕様 ●==========================================================
断末魔を発動したエネミーは、
自身を断末魔スキルの効果対象にすることはできません。
====================================================================
● 使い方 ●========================================================
エネミーのメモ欄に「断末魔:n」と記述してください。
nには断末魔として発動させるスキルIDを指定してください。
====================================================================
ver1.00
Last Update : 2015/05/13
5/13 : RGSS2にあったものを移植
ろかん http://kaisou-ryouiki.sakura.ne.jp/
=end
$rsi ||= {}
$rsi["断末魔"] = true
class RPG::Enemy < RPG::BaseItem
def death_throes_id
unless @death_throes_id
@death_throes_id = 0
self.note.each_line{|line|
if line =~ /断末魔:(\d+)/i
@death_throes_id = $1.to_i
break
end
}
end
@death_throes_id
end
end
class << BattleManager
#--------------------------------------------------------------------------
# ● ターン終了
#--------------------------------------------------------------------------
alias death_throes_turn_end turn_end
def turn_end
death_throes_turn_end if @phase
end
end
class Game_Battler < Game_BattlerBase
#--------------------------------------------------------------------------
# ● 断末魔をあげるバトラーであるか
#--------------------------------------------------------------------------
def death_throes?
false
end
end
class Game_Action
#--------------------------------------------------------------------------
# ● 断末魔のターゲットの配列作成
#--------------------------------------------------------------------------
def make_targets_with_death_throes
if item.for_opponent?
targets_for_opponents
elsif item.for_friend?
targets_for_friends_with_death_throes
else
[]
end
end
#--------------------------------------------------------------------------
# ● 味方に対するターゲット
#--------------------------------------------------------------------------
def targets_for_friends_with_death_throes
if item.for_user?
[]
elsif item.for_dead_friend?
if item.for_one?
[friends_unit.smooth_dead_target(@target_index)]
else
friends_unit.dead_members
end
elsif item.for_friend?
result = friends_unit.alive_members
result.delete(@subject)
if item.for_one?
result.empty? ? [] : [result.sample]
else
result
end
end
end
end
class Game_Enemy < Game_Battler
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_accessor :gave_death_throes
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
alias death_throes_initialize initialize
def initialize(index, enemy_id)
death_throes_initialize(index, enemy_id)
@gave_death_throes = false # 既に断末魔をあげたかの判断に利用
end
#--------------------------------------------------------------------------
# ● 断末魔をあげるバトラーであるか
#--------------------------------------------------------------------------
def death_throes?
@result.added_states.include?(death_state_id) && !death_throes_id.zero? && !@gave_death_throes
end
#--------------------------------------------------------------------------
# ● 断末魔で発動するスキルID
#--------------------------------------------------------------------------
def death_throes_id
enemy.death_throes_id
end
#--------------------------------------------------------------------------
# ● 戦闘不能から復活
#--------------------------------------------------------------------------
def revive
super
@gave_death_throes = false
end
#--------------------------------------------------------------------------
# ● 戦闘不能判定
#--------------------------------------------------------------------------
def dead?
(!death_throes_id.zero? && !@gave_death_throes) ? false : super
end
#--------------------------------------------------------------------------
# ● 生存判定
#--------------------------------------------------------------------------
def alive?
(!death_throes_id.zero? && !@gave_death_throes) ? true : super
end
#--------------------------------------------------------------------------
# ● 断末魔行動の作成
#--------------------------------------------------------------------------
def make_death_throes_actions
clear_actions
action = Game_Action.new(self, true)
action.set_skill(death_throes_id)
@actions.push(action)
end
end
class Window_BattleLog < Window_Selectable
#--------------------------------------------------------------------------
# ● 断末魔用メソッドの設定
#--------------------------------------------------------------------------
def method_death_throes=(method)
@method_death_throes = method
end
#--------------------------------------------------------------------------
# ● 影響を受けたステータスの表示
#--------------------------------------------------------------------------
alias death_throes_display_affected_status display_affected_status
def display_affected_status(target, item)
if target.death_throes?
wait_and_clear
last_added_states = target.result.added_states.dup
@method_death_throes.call(target)
target.result.added_states = last_added_states
death_throes_display_affected_status(target, item)
wait_and_clear
BattleManager.judge_win_loss
else
death_throes_display_affected_status(target, item)
end
end
end
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# ● ログウィンドウの作成
#--------------------------------------------------------------------------
alias death_throes_create_log_window create_log_window
def create_log_window
death_throes_create_log_window
@log_window.method_death_throes = method(:process_death_throes)
end
#--------------------------------------------------------------------------
# ● 断末魔の処理
#--------------------------------------------------------------------------
def process_death_throes(user)
last_subject = @subject
@subject = user
@subject.make_death_throes_actions
targets = @subject.current_action.make_targets_with_death_throes.compact
unless targets.empty?
if @subject.current_action
@status_window.open
use_death_throes(targets)
@subject.remove_current_action
process_action_end
end
end
@subject.gave_death_throes = true
@subject = last_subject
update_for_wait
end
#--------------------------------------------------------------------------
# ● 断末魔の使用
#--------------------------------------------------------------------------
def use_death_throes(targets)
@subject.sprite_effect_type = :whiten
item = @subject.current_action.item
@log_window.display_use_item(@subject, item)
@subject.use_item(item)
refresh_status
show_animation(targets, item.animation_id)
targets.each {|target| item.repeats.times { invoke_item(target, item) } }
@log_window.wait_and_clear
end
end