interrupt_message = ""
define_interrupt_message = false
note.each_line { |line|
if line =~ KGC::Counter::Regexp::BEGIN_COUNTER
match = $~.clone
# カウンター定義開始
action = Game_CounterAction.new
if match[1] != nil
action.kind = COUNTER_KINDS[match[1].upcase]
end
case action.kind
when KIND_SKILL
next if match[2] == nil
action.skill_id = match[2][/\d+/].to_i
when KIND_ITEM
next if match[2] == nil
action.item_id = match[2][/\d+/].to_i
end
if match[3] != nil
action.execute_prob = match[3][/\d+/].to_i
end
counter_flag = true
if match[4] != nil
# そのまま定義終了
result << action
counter_flag = false
end
end
next unless counter_flag
# 割り込みメッセージ定義中
if define_interrupt_message
if line =~ /\s*([^\"]*)(\")?/
action.interrupt_message += $1.chomp
define_interrupt_message = ($2 == nil)
end
next
end
case line
when KGC::Counter::Regexp::END_COUNTER
# カウンター定義終了
result << action
counter_flag = false
when KGC::Counter::Regexp::KIND
# 行動種別
match = $~.clone
action.condition.kind = COUNTER_KINDS[match[1].upcase]
if action.condition.kind == KIND_BASIC
action.condition.basic = COUNTER_BASIC[match[1].upcase]
if action.condition.basic == nil
action.condition.basic = KGC::Counter::BASIC_ATTACK
end
end
if match[2] != nil
ids = []
match[2].scan(/\d+/).each { |num| ids << num.to_i }
case action.condition.kind
when KIND_SKILL
action.condition.skill_ids = ids
when KIND_ITEM
action.condition.item_ids = ids
end
end
when KGC::Counter::Regexp::ATTACK_TYPE
# 攻撃タイプ
action.condition.type = COUNTER_TYPES[$1.upcase]
when KGC::Counter::Regexp::ELEMENT
# 属性
elements = []
$1.scan(/\d+/).each { |num| elements << num.to_i }
action.condition.element_set |= elements
when KGC::Counter::Regexp::ATK_F
# 打撃関係度
action.condition.atk_f = $1.to_i
when KGC::Counter::Regexp::SPI_F
# 精神関係度
action.condition.spi_f = $1.to_i
when KGC::Counter::Regexp::REMAIN_HPMP
type = REMAIN_TYPE_OVER
case $3.upcase
when "UNDER", "以下"
type = REMAIN_TYPE_UNDER
end
case $1.upcase
when "HP" # 残存 HP
action.condition.remain_hp = $2.to_i
action.condition.remain_hp_type = type
when "MP" # 残存 MP
action.condition.remain_mp = $2.to_i
action.condition.remain_mp_type = type
end
when KGC::Counter::Regexp::IGNORE_TARGET
# ターゲット無視
action.condition.ignore_target = true
when KGC::Counter::Regexp::INTERRUPT
# 行動割り込み
action.condition.interrupt = true
when KGC::Counter::Regexp::INTERRUPT_MESSAGE
# 割り込みメッセージ
define_interrupt_message = true
action.interrupt_message += $1.chomp
define_interrupt_message = ($2 == nil)
end
}
return result
end
end
end
class RPG::BaseItem
#--------------------------------------------------------------------------
# ○ カウンター行動リスト
#--------------------------------------------------------------------------
def counter_actions
if @__counter_actions == nil
@__counter_actions = KGC::Counter.create_counter_action_list(self.note)
end
return @__counter_actions
end
end
class RPG::Enemy
#--------------------------------------------------------------------------
# ○ カウンター行動リスト
#--------------------------------------------------------------------------
def counter_actions
if @__counter_actions == nil
@__counter_actions = KGC::Counter.create_counter_action_list(self.note)
end
return @__counter_actions
end
end
class RPG::State
#--------------------------------------------------------------------------
# ○ カウンター行動リスト
#--------------------------------------------------------------------------
def counter_actions
if @__counter_actions == nil
@__counter_actions = KGC::Counter.create_counter_action_list(self.note)
end
return @__counter_actions
end
end
class Game_BattleAction
#--------------------------------------------------------------------------
# ○ 公開インスタンス変数
#--------------------------------------------------------------------------
attr_accessor :made_targets # 作成済みターゲット
#--------------------------------------------------------------------------
# ● ターゲットの配列作成
#--------------------------------------------------------------------------
alias make_targets_KGC_Counter make_targets
def make_targets
if @made_targets == nil
@made_targets = make_targets_KGC_Counter
end
return @made_targets
end
#--------------------------------------------------------------------------
# ○ アクション名
#--------------------------------------------------------------------------
def action_name
case kind
when 0 # 基本
case basic
when 0 # 攻撃
return Vocab.attack
when 1 # 防御
return Vocab.guard
when 2 # 逃走
return Vocab.escape
when 3 # 待機
return Vocab.wait
end
when 1 # スキル
return skill.name
when 2 # アイテム
return item.name
end
return ""
end
end
class Game_Battler
#--------------------------------------------------------------------------
# ○ カウンター行動リストの取得
#--------------------------------------------------------------------------
def counter_actions
result = []
states.each { |state| result += state.counter_actions }
return result
end
end
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# ○ カウンター行動リストの取得
#--------------------------------------------------------------------------
def counter_actions
result = super
equips.compact.each { |item| result += item.counter_actions }
return result
end
end
# 有効なカウンター行動をセット
target.counter_actions.each { |counter|
break if counter_added?
next if counter.condition.ignore_target
next if counter.condition.interrupt ^ interrupt # <-- if x != y
judge_counter_action(@active_battler, target, counter)
}
end
#--------------------------------------------------------------------------
# ○ カウンター可否
# target : 被攻撃者
#--------------------------------------------------------------------------
def can_counter?(target = nil)
return false if @counter_exec # カウンターに対するカウンターは行わない
return false if counter_added? # カウンター済み
if target != nil
return false unless target.movable? # 行動不能
end
if $imported["CooperationSkill"]
# 連係スキルにはカウンターを適用しない
return false if @active_battler.is_a?(Game_CooperationBattler)
end