if battler.current_action != nil
item = battler.current_action.item
update_forecast_item(item)
else
update_forecast_item($data_skills[159])
end
saba_kiski_battle_turn_start
if item != nil && item.operate_time(battler) > 0 &&
OrderManager.top_unit.operate != true
play_operate_se
refresh_status
@log_window.display_prepare_item(battler, item)
end
end
#--------------------------------------------------------------------------
# ○ 駆動SE再生
#--------------------------------------------------------------------------
def play_operate_se
Audio.se_play(OPERATE_SE_FILE, OPERATE_SE_VOLUME, OPERATE_SE_PITCH)
end
#--------------------------------------------------------------------------
# ● ターン終了
#--------------------------------------------------------------------------
def turn_end
all_battle_members.each do |battler|
battler.on_turn_end
if battler.result.status_affected?
refresh_status
@log_window.display_auto_affected_status(battler)
@log_window.wait_and_clear
end
end
BattleManager.turn_end
process_event
start_party_command_selection
calculate_battlers_speed
end
#--------------------------------------------------------------------------
# ● スキル/アイテムの使用
#--------------------------------------------------------------------------
alias saba_kiski_battle_use_item use_item
def use_item
saba_kiski_battle_use_item
return if @subject.current_action == nil
targets = @subject.current_action.make_targets.compact
targets.each do |target|
delay = target.result.delay_count
if delay != 0
OrderManager.delay_order(target, delay)
#@log_window.display_delay(target, delay)
end
unit = OrderManager.find_unit(target)
if unit && unit.cancel?
unit.battler.turn_count += 1
OrderManager.cancel(unit)
end
end
end
#--------------------------------------------------------------------------
# ● 戦闘行動終了時の処理
#--------------------------------------------------------------------------
alias saba_kiski_battle_process_action_end process_action_end
def process_action_end
OrderManager.update_delay_time
if BattleManager.battle_end?
OrderManager.remove_forecast_unit
end
saba_kiski_battle_process_action_end
end
end
class Window_ActorCommand
def cancel_enabled?
return false
end
end
class Spriteset_Battle
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
alias saba_kiseki_battle_initialize initialize
def initialize
@battle_units = {}
saba_kiseki_battle_initialize
@viewport3.rect.height = Saba::Kiseki::ORDER_BAR_HEIGHT
@kiseki_sprite = Spriteset_Kiseki.new(@viewport3)
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
alias saba_kiseki_battle_update update
def update
saba_kiseki_battle_update
update_battle_unit
@kiseki_sprite.update if @kiseki_sprite
end
#--------------------------------------------------------------------------
# ○ ユニット更新
#--------------------------------------------------------------------------
def update_battle_unit
remove_list = @battle_units.keys
OrderManager.units.each do |unit|
if @battle_units[unit] == nil
@battle_units[unit] = Spriteset_BattleUnit.new(@viewport3, unit)
else
remove_list.delete(unit)
end
@battle_units[unit].update
end
remove_list.each { |unit|
sprite = @battle_units[unit]
sprite.dispose
@battle_units.delete(unit)
}
end
#--------------------------------------------------------------------------
# ● 解放
#--------------------------------------------------------------------------
alias saba_kiseki_battle_dispose dispose
def dispose
@battle_units.values.each { |sprite| sprite.dispose }
@kiseki_sprite.dispose
saba_kiseki_battle_dispose
end
end
class Window_Selectable
#--------------------------------------------------------------------------
# ● 項目の選択
#--------------------------------------------------------------------------
alias saba_kiseki_battle_select select
def select(index)
saba_kiseki_battle_select(index)
call_handler(:change)
end
#--------------------------------------------------------------------------
# ● ウィンドウのアクティブ化
#--------------------------------------------------------------------------
def activate
super
call_handler(:change)
self
end
end
@result.success = true if @result.delay_count != 0 || @result.cancel
end
end
#--------------------------------------------------------------------------
# ○ ターン開始処理
#--------------------------------------------------------------------------
def on_turn_start
regenerate_all
update_state_turns
update_buff_turns
remove_states_auto(2)
remove_buffs_auto
make_actions
end
#--------------------------------------------------------------------------
# ● ターン終了処理
#--------------------------------------------------------------------------
def on_turn_end
@result.clear
end
#--------------------------------------------------------------------------
# ● 戦闘行動終了時の処理
#--------------------------------------------------------------------------
def on_action_end
@result.clear
remove_states_auto(1)
@turn_count += 1
end
#--------------------------------------------------------------------------
# ○ ステートによる駆動時間を取得
#--------------------------------------------------------------------------
def state_operate_time
n = nil
states.reverse.each do |state|
if state.operate_formula
n = state.operate_time(self)
end
end
return n
end
#--------------------------------------------------------------------------
# ○ ステートによる硬直時間を取得
#--------------------------------------------------------------------------
def state_stiff_time
n = nil
states.reverse.each do |state|
if state.stiff_formula
n = state.stiff_time(self)
end
end
return n
end
end
class << BattleManager
#--------------------------------------------------------------------------
# ● 次のコマンド入力へ
#--------------------------------------------------------------------------
def next_command
begin
if !actor || !actor.next_command
battler = OrderManager.top_unit.battler
unless battler.actor?
unless battler.current_action
OrderManager.top_unit.usable_item = $data_skills[1]
return false
end
OrderManager.top_unit.usable_item = battler.current_action.item
return false
end
return false if @actor_index == battler.index
@actor_index = battler.index
if OrderManager.top_unit.operate # 発動
OrderManager.top_unit.remove_operate_state
battler.current_action.set_usable_item(OrderManager.top_unit.usable_item)
return false
end
return false if @actor_index >= $game_party.members.size
end
end until actor.inputable?
return true
end
#--------------------------------------------------------------------------
# ● 行動順序の作成
#--------------------------------------------------------------------------
def make_action_orders
battler = OrderManager.top_unit.battler
if battler.current_action == nil || battler.current_action.item == nil
@action_battlers = [battler]
elsif battler.current_action.item.operate_time(battler) > 0 &&
OrderManager.top_unit.operate != true
# 発動待ち
OrderManager.top_unit.usable_item = battler.current_action.item
OrderManager.top_unit.add_operate_state
@action_battlers = []
else
@action_battlers = [battler]
end
end
#--------------------------------------------------------------------------
# ● ターン終了
#--------------------------------------------------------------------------
alias saba_kiseki_battle_turn_end turn_end
def turn_end
saba_kiseki_battle_turn_end
unit = OrderManager.top_unit
OrderManager.clear_forecast
OrderManager.update_top
end
end
class Game_Enemy
#--------------------------------------------------------------------------
# ● 戦闘行動の作成
#--------------------------------------------------------------------------
alias saba_kiseki_battke_make_actions make_actions
def make_actions
# 発動待ちを上書きしないように
unit = OrderManager.find_unit(self)
if unit && unit.operate
return
end
saba_kiseki_battke_make_actions
end
#--------------------------------------------------------------------------
# ● 行動条件合致判定[ターン数]
#--------------------------------------------------------------------------
def conditions_met_turns?(param1, param2)
n = @turn_count
#p name + " " + @turn_count.to_s
if param2 == 0
n == param1
else
n > 0 && n >= param1 && n % param2 == param1 % param2
end
end
end
class Game_Actor
#--------------------------------------------------------------------------
# ● 戦闘行動の作成
#--------------------------------------------------------------------------
alias saba_kiseki_battke_make_actions make_actions
def make_actions
# 発動待ちを上書きしないように
unit = OrderManager.find_unit(self)
if unit && unit.operate
return
end
saba_kiseki_battke_make_actions
end
end
class Window_BattleActor
#--------------------------------------------------------------------------
# ○ 味方キャラオブジェクト取得
#--------------------------------------------------------------------------
def actor
$game_party.battle_members[@index]
end
end
class << BattleManager
attr_reader :preemptive
attr_reader :surprise
attr_reader :phase
def battle_end?
return true if $game_party.members.empty?
return true if $game_party.all_dead?
return true if $game_troop.all_dead?
return true if aborting?
return false
end
end
class Game_Action
#--------------------------------------------------------------------------
# ● 公開インスタンス変数
#--------------------------------------------------------------------------
attr_accessor :targets
attr_accessor :save_targets
#--------------------------------------------------------------------------
# ● クリア
#--------------------------------------------------------------------------
alias saba_kiseki_battle_clear clear
def clear
saba_kiseki_battle_clear
@targets = nil
save_targets = false
end
#--------------------------------------------------------------------------
# ● ターゲットの配列作成
#--------------------------------------------------------------------------
alias saba_kiseki_battle_make_targets make_targets
def make_targets
return @targets if @targets && @save_targets
@targets = saba_kiseki_battle_make_targets
return @targets
end
#--------------------------------------------------------------------------
# ● アイテムを設定
#--------------------------------------------------------------------------
def set_usable_item(item)
@item.object = item
self
end
end
# クリティカルボーナス時に表示されるメッセージ
CriticalBonusText = "クリティカルボーナス!!"
end
end
#===================================
# ここまで
#===================================
$rsi ||= {}
$rsi["空の軌跡_ATボーナス"] = true
class RPG::UsableItem
#--------------------------------------------------------------------------
# ● 駆動時間の取得
#--------------------------------------------------------------------------
alias _kiseki_bonus_operate_time operate_time
def operate_time(battler)
if BonusManager.rash?
0
else
_kiseki_bonus_operate_time(battler)
end
end
#--------------------------------------------------------------------------
# ● 硬直時間の取得
#--------------------------------------------------------------------------
alias _kiseki_bonus_stiff_time stiff_time
def stiff_time(battler)
if BonusManager.rash?
0
else
_kiseki_bonus_stiff_time(battler)
end
end
end
class << BattleManager
#--------------------------------------------------------------------------
# ● セットアップ
#--------------------------------------------------------------------------
alias _kiseki_bonus_setup setup
def setup(troop_id, can_escape = true, can_lose = false)
_kiseki_bonus_setup(troop_id, can_escape, can_lose)
setup_bonus
end
#--------------------------------------------------------------------------
# ● ボーナスのセットアップ
#--------------------------------------------------------------------------
def setup_bonus
BonusManager.clear
BonusManager.init_bonus
end
end
class << OrderManager
#--------------------------------------------------------------------------
# ● 先頭ユニットを削除し、次のユニットに入れ替えます。
#--------------------------------------------------------------------------
alias _kiseki_bonus_update_top update_top
def update_top
BonusManager.next_bonus
_kiseki_bonus_update_top
end
#--------------------------------------------------------------------------
# ● 指定のバトラーの順番を遅らせる。
#--------------------------------------------------------------------------
alias _kiseki_bonus_delay_order delay_order
def delay_order(battler, value)
_kiseki_bonus_delay_order(battler, value) unless BonusManager.full_guard?
end
end
module BonusManager
module_function
include Rokan::Kiseki_Plugin
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def init_manager
@rate_list = []
@bonus_list = []
clear
end
#--------------------------------------------------------------------------
# ● クリア
#--------------------------------------------------------------------------
def clear
@rate_list.clear
@bonus_list.clear
@sprites_listener = nil
end
#--------------------------------------------------------------------------
# ● クリティカル判定
#--------------------------------------------------------------------------
def critical?
get_bonus == 6 && $game_party.in_battle
end
#--------------------------------------------------------------------------
# ● 完全防御判定
#--------------------------------------------------------------------------
def full_guard?
get_bonus == 7 && $game_party.in_battle
end
#--------------------------------------------------------------------------
# ● ラッシュ判定
#--------------------------------------------------------------------------
def rash?
get_bonus == 8
end
#--------------------------------------------------------------------------
# ● アクティブなボーナスの取得
#--------------------------------------------------------------------------
def get_bonus
@bonus_list[1]
end
#--------------------------------------------------------------------------
# ● インデックスを指定したボーナスの取得
#--------------------------------------------------------------------------
def get_bonus_with_index(index)
@bonus_list[index]
end
#--------------------------------------------------------------------------
# ● 新たに追加するボーナスの取得
#--------------------------------------------------------------------------
def get_pop_bonus
case rand(@rate_list[9].last)
when @rate_list[0]; -1
when @rate_list[1]; 0
when @rate_list[2]; 1
when @rate_list[3]; 2
when @rate_list[4]; 3
when @rate_list[5]; 4
when @rate_list[6]; 5
when @rate_list[7]; 6
when @rate_list[8]; 7
when @rate_list[9]; 8
else; -1
end
end
#--------------------------------------------------------------------------
# ● ボーナスの初期化
#--------------------------------------------------------------------------
def init_bonus
init_bonus_rate
@bonus_list.clear
10.times{@bonus_list << get_pop_bonus}
end
#--------------------------------------------------------------------------
# ● ボーナス発生確率の初期化
#--------------------------------------------------------------------------
def init_bonus_rate
@rate_list.clear
first = last = 0
BOP[$game_variables[BCV]].each_with_index{|value, index|
last += value unless value.zero?
@rate_list << Range.new(first, last)
first = last
}
end
#--------------------------------------------------------------------------
# ● ボーナスを進める
#--------------------------------------------------------------------------
def next_bonus
@bonus_list.shift
@bonus_list << get_pop_bonus
@sprites_listener.next_bonus if @sprites_listener
end
#--------------------------------------------------------------------------
# ● ボーナススプライトを可視化する
#--------------------------------------------------------------------------
def sprites_listener=(obj)
@sprites_listener = obj
end
end
BonusManager.init_manager
class Game_Battler
#--------------------------------------------------------------------------
# ● ダメージの処理
#--------------------------------------------------------------------------
alias _kiseki_bonus_execute_damage execute_damage
def execute_damage(user)
if BonusManager.critical?
@result.critical_damage_values
elsif BonusManager.full_guard?
@result.clear_damage_values
@result.cancel = false
end
_kiseki_bonus_execute_damage(user)
end
#--------------------------------------------------------------------------
# ● 使用効果[HP 回復] ※再定義
#--------------------------------------------------------------------------
def item_effect_recover_hp(user, item, effect)
value = (mhp * effect.value1 + effect.value2) * rec
value *= user.pha if item.is_a?(RPG::Item)
value *= 1.5 if BonusManager.critical? # 追加
value = value.to_i
@result.hp_damage -= value
@result.success = true
self.hp += value
end
#--------------------------------------------------------------------------
# ● 使用効果[MP 回復] ※再定義
#--------------------------------------------------------------------------
def item_effect_recover_mp(user, item, effect)
value = (mmp * effect.value1 + effect.value2) * rec
value *= user.pha if item.is_a?(RPG::Item)
value *= 1.5 if BonusManager.critical? # 追加
value = value.to_i
@result.mp_damage -= value
@result.success = true if value != 0
self.mp += value
end
#--------------------------------------------------------------------------
# ● 使用効果[TP 増加] ※再定義
#--------------------------------------------------------------------------
def item_effect_gain_tp(user, item, effect)
value = effect.value1.to_i
value *= 1.5 if BonusManager.critical? # 追加
@result.tp_damage -= value
@result.success = true if value != 0
self.tp += value
end
#--------------------------------------------------------------------------
# ● ステートの付加可能判定
#--------------------------------------------------------------------------
alias _kiseki_bonus_state_addable? state_addable?
def state_addable?(state_id)
_kiseki_bonus_state_addable?(state_id) && !BonusManager.full_guard?
end
#--------------------------------------------------------------------------
# ● 使用効果[ステート解除]
#--------------------------------------------------------------------------
alias _kiseki_bonus_item_effect_remove_state item_effect_remove_state
def item_effect_remove_state(user, item, effect)
_kiseki_bonus_item_effect_remove_state(user, item, effect) unless BonusManager.full_guard?
end
#--------------------------------------------------------------------------
# ● ボーナスによる回復適用
#--------------------------------------------------------------------------
def bonus_recover_effect
@result.clear
@result.used = (0..5).include?(BonusManager.get_bonus)
case BonusManager.get_bonus
when 0
self.hp -= @result.hp_damage = -(mhp * 0.1).to_i
when 1
self.hp -= @result.hp_damage = -(mhp * 0.5).to_i
when 2
self.mp -= @result.mp_damage = -(mmp * 0.1).to_i
when 3
self.mp -= @result.mp_damage = -(mmp * 0.5).to_i
when 4
self.tp -= @result.tp_damage = -10
when 5
self.tp -= @result.tp_damage = -50
end
end
end
class Bonus < Sprite
include Saba::Kiseki
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(viewport, index)
super(viewport)
@index = index
set_bitmap unless @index.zero?
if self.bitmap
self.x = MARGIN_LEFT + 40
self.y = set_new_y
self.z = 4
self.ox = self.bitmap.width / 2
self.oy = self.bitmap.height
end
self.opacity = 0
end
#--------------------------------------------------------------------------
# ● ボーナスIDの取得
#--------------------------------------------------------------------------
def get_bonus
BonusManager.get_bonus_with_index(@index)
end
#--------------------------------------------------------------------------
# ● ビットマップのセット
#--------------------------------------------------------------------------
def set_bitmap
case get_bonus
when 0
self.bitmap = Cache.system("AT_BONUS_HP10")
when 1
self.bitmap = Cache.system("AT_BONUS_HP50")
when 2
self.bitmap = Cache.system("AT_BONUS_MP10")
when 3
self.bitmap = Cache.system("AT_BONUS_MP50")
when 4
self.bitmap = Cache.system("AT_BONUS_TP10")
when 5
self.bitmap = Cache.system("AT_BONUS_TP50")
when 6
self.bitmap = Cache.system("AT_BONUS_CRI")
when 7
self.bitmap = Cache.system("AT_BONUS_DUARD")
when 8
self.bitmap = Cache.system("AT_BONUS_RASH")
end
end
#--------------------------------------------------------------------------
# ● 移動先の y 座標を設定
#--------------------------------------------------------------------------
def set_new_y
@new_y = 32
@new_y += MARGIN_CURRENT_BOTTOM if @index > 1
@new_y += MARGIN_TOP + UNIT_INTERVAL * (@index-1)
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
if self.bitmap
super
update_x
update_y
update_z
update_zoom
update_opacity
end
end
#--------------------------------------------------------------------------
# ● x 座標の更新
#--------------------------------------------------------------------------
def update_x
end
#--------------------------------------------------------------------------
# ● y 座標の更新
#--------------------------------------------------------------------------
def update_y
if self.y != @new_y
self.y = [self.y - ((@new_y - self.y).abs < 3 ? 1 : 3), @new_y].max
flash_top_bonus if @index == 1 && self.y == @new_y
end
end
#--------------------------------------------------------------------------
# ● z 座標の更新
#--------------------------------------------------------------------------
def update_z
self.z = @index > 1 ? 4 : 7
end
#--------------------------------------------------------------------------
# ● 拡大率の更新
#--------------------------------------------------------------------------
def update_zoom
if (get_bonus == -1 || @index.zero?) && !self.zoom_x.zero?
self.zoom_x = self.zoom_y -= 0.05
end
end
#--------------------------------------------------------------------------
# ● 透明度の更新
#--------------------------------------------------------------------------
def update_opacity
self.opacity += 12 if self.opacity != 255
end
#--------------------------------------------------------------------------
# ● ボーナスを進める
#--------------------------------------------------------------------------
def next_bonus
@index -= 1
set_new_y unless @index.zero?
end
#--------------------------------------------------------------------------
# ● 先頭に到達したボーナスをフラッシュさせてみる
#--------------------------------------------------------------------------
def flash_top_bonus
flash(Color.new(255, 255, 255, 196), 40)
end
end
class Bonus_Spriteset
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(viewport)
@viewport = viewport
create_bonus
end
#--------------------------------------------------------------------------
# ● ボーナススプライトの生成
#--------------------------------------------------------------------------
def create_bonus
@bonus_sprites = []
10.times{|i| @bonus_sprites << Bonus.new(@viewport, i)}
end
#--------------------------------------------------------------------------
# ● ボーナスを1つ進める
#--------------------------------------------------------------------------
def next_bonus
@bonus_sprites.shift.dispose
@bonus_sprites.each{|bonus| bonus.next_bonus}
@bonus_sprites << Bonus.new(@viewport, 8)
end
#--------------------------------------------------------------------------
# ● 解放
#--------------------------------------------------------------------------
def dispose
@bonus_sprites.each{|bonus| bonus.dispose}
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
def update
@bonus_sprites.each{|bonus| bonus.update}
end
end
class Spriteset_Battle
#--------------------------------------------------------------------------
# ● オブジェクト初期化
#--------------------------------------------------------------------------
alias _kiseki_bonus_initialize initialize
def initialize
_kiseki_bonus_initialize
@bonus_spriteset = Bonus_Spriteset.new(@viewport3)
BonusManager.sprites_listener = @bonus_spriteset
end
#--------------------------------------------------------------------------
# ● フレーム更新
#--------------------------------------------------------------------------
alias _kiseki_bonus_update update
def update
_kiseki_bonus_update
@bonus_spriteset.update if @bonus_spriteset
end
#--------------------------------------------------------------------------
# ● 解放
#--------------------------------------------------------------------------
alias _kiseki_bonus_dispose dispose
def dispose
_kiseki_bonus_dispose
@bonus_spriteset.dispose
end
end
class Window_BattleLog < Window_Selectable
include Rokan::Kiseki_Plugin
#--------------------------------------------------------------------------
# ● クリティカルヒットの表示
#--------------------------------------------------------------------------
alias _kiseki_bonus_display_critical display_critical
def display_critical(target, item)
display_critical_bonus
_kiseki_bonus_display_critical(target, item)
end
#--------------------------------------------------------------------------
# ● クリティカルボーナスの表示
#--------------------------------------------------------------------------
def display_critical_bonus
if BonusManager.critical?
add_text(CriticalBonusText)
wait
end
end
#--------------------------------------------------------------------------
# ● ボーナスによる回復結果の表示
#--------------------------------------------------------------------------
def display_bonus_recover(target)
if target.result.used
Sound.play_recovery
last_line_number = line_number
case BonusManager.get_bonus
when 0..1
add_text(target.result.hp_damage_text)
when 2..3
add_text(target.result.mp_damage_text)
when 4..5
add_text(target.result.tp_damage_text)
end
SceneManager.scene.refresh_status
wait
wait if line_number > last_line_number
back_to(last_line_number)
end
end
end
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# ● パーティコマンド選択の開始
#--------------------------------------------------------------------------
alias _kiseki_bonus_start_party_command_selection start_party_command_selection
def start_party_command_selection
battler = OrderManager.top_unit.battler
battler.bonus_recover_effect
@log_window.display_bonus_recover(battler)
_kiseki_bonus_start_party_command_selection
end
end
逃跑
class Scene_Battle
#--------------------------------------------------------------------------
# ● アクターコマンドウィンドウの作成
#--------------------------------------------------------------------------
alias saba_kiseki_escape_create_actor_command_window create_actor_command_window
def create_actor_command_window
saba_kiseki_escape_create_actor_command_window
@actor_command_window.set_handler(:escape, method(:command_escape))
end
end
class Window_ActorCommand
#--------------------------------------------------------------------------
# ● コマンドリストの作成
#--------------------------------------------------------------------------
alias saba_kiseki_escape_make_command_list make_command_list
def make_command_list
saba_kiseki_escape_make_command_list
add_command(Vocab::escape, :escape, BattleManager.can_escape?)
end
end
class RPG::Skill < RPG::UsableItem
#--------------------------------------------------------------------------
# ○ 連係スキルであるか
#--------------------------------------------------------------------------
def is_cooperation?
self.note.each_line { |line|
# 開始タグを探す
if line =~ KGC::CooperationSkill::Regexp::Skill::BEGIN_COOPERATE
return true
end
}
return false
end
end
class Game_CooperationSkill
#--------------------------------------------------------------------------
# ○ 公開インスタンス変数
#--------------------------------------------------------------------------
attr_reader :id # 発動スキル ID
attr_reader :need_skills # 必要スキル ID リスト
attr_reader :params # 条件パラメータ
attr_reader :params_over # 条件パラメータ: ~以上
attr_reader :need_arrays # 必要属性・ステートリスト
attr_reader :disuse_arrays # 不要属性・ステートリスト
#--------------------------------------------------------------------------
# ○ オブジェクト初期化
# skill_id : スキル ID
# note : メモ
#--------------------------------------------------------------------------
def initialize(skill_id, note)
@id = skill_id
@need_skills = []
@params = {}
@params_over = {}
@need_arrays = {}
@disuse_arrays = {}
parse_note(note)
end
#--------------------------------------------------------------------------
# ○ スキルを取得
#--------------------------------------------------------------------------
def skill
return $data_skills[@id]
end
#--------------------------------------------------------------------------
# ○ メモ欄を解析
# note : メモ
#--------------------------------------------------------------------------
def parse_note(note)
coop_flag = false
note.each_line { |line|
case line
when KGC::CooperationSkill::Regexp::Skill::BEGIN_COOPERATE
# 連係スキル定義開始
coop_flag = true
when KGC::CooperationSkill::Regexp::Skill::END_COOPERATE
# 連係スキル定義終了
coop_flag = false
end
next unless coop_flag
case line
when KGC::CooperationSkill::Regexp::Skill::NEED_SKILLS
# 必要スキル
parse_need_skills($1.scan(/\-?\d+/))
when KGC::CooperationSkill::Regexp::Skill::COOPERATE_PARAMS
# パラメータ
parse_params($1, $2.to_i, $3)
when KGC::CooperationSkill::Regexp::Skill::COOPERATE_ARRAYS
# 属性・ステート
parse_arrays($1, $2.scan(/\-?\d+/))
end
}
end
#--------------------------------------------------------------------------
# ○ 必要スキルを解析
# list : スキル ID 一覧
#--------------------------------------------------------------------------
def parse_need_skills(list)
skills = []
list.each { |num|
skills << num.to_i
}
@need_skills << skills
end
#--------------------------------------------------------------------------
# ○ 連係スキルの能力値修正を適用
# param : 対象パラメータ
# value : 修正値
# cond : 以上 or 以下
#--------------------------------------------------------------------------
def parse_params(param, value, cond)
KGC::CooperationSkill::PARAMS.each { |k, v|
next if param !~ /(?:#{v})/i
@params[k] = value
@params_over[k] = (cond !~ /UNDER|以下/i)
break
}
end
#--------------------------------------------------------------------------
# ○ 連係スキルの追加属性・ステートを適用
# param : 対象パラメータ
# list : 属性・ステート一覧
#--------------------------------------------------------------------------
def parse_arrays(param, list)
KGC::CooperationSkill::ARRAYS.each { |k, v|
next if param !~ /(?:#{v})/i
if @need_arrays[k] == nil
@need_arrays[k] = []
@disuse_arrays[k] = []
end
list.each { |num|
n = num.to_i
if n > 0
@need_arrays[k] |= [n]
else
@disuse_arrays[k] |= [n.abs]
end
}
break
}
end
end
#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★
$data_skills = load_data("Data/Skills.rvdata") if $data_skill == nil
module KGC::CooperationSkill
# 連係スキルリストを変換
list = []
$data_skills.each { |skill|
next if skill == nil
next unless skill.is_cooperation?
list << Game_CooperationSkill.new(skill.id, skill.note)
}
SKILLS = list
end
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
# ● スキルの使用可能判定
# skill : スキル
#--------------------------------------------------------------------------
def skill_can_use?(skill)
return super
end
end
class Game_CooperationSkillUser
#--------------------------------------------------------------------------
# ○ 公開インスタンス変数
#--------------------------------------------------------------------------
attr_reader :index # 発動者のインデックス
attr_reader :skill_id # 発動者が使用したスキル ID
attr_reader :target_battlers # 攻撃対象
#--------------------------------------------------------------------------
# ○ オブジェクト初期化
#--------------------------------------------------------------------------
def initialize(battler)
if $imported["Counter"]
battler.action.made_targets = nil
end
@index = battler.index
@skill_id = battler.action.skill_id
@target_battlers = []
battler.action.make_targets.each { |t|
@target_battlers << t.index
}
end
#--------------------------------------------------------------------------
# ○ 同値判定
#--------------------------------------------------------------------------
def equal?(obj)
return false unless obj.is_a?(Game_CooperationSkillUser)
return false if @index != obj.index
return false if @skill_id != obj.skill_id
return false if @target_battlers != obj.target_battlers
return true
end
#--------------------------------------------------------------------------
# ○ 等値演算子
#--------------------------------------------------------------------------
def ==(obj)
return self.equal?(obj)
end
end
class Scene_Battle < Scene_Base
#--------------------------------------------------------------------------
# ● 開始処理
#--------------------------------------------------------------------------
alias start_KGC_CooperationSkill start
def start
start_KGC_CooperationSkill
init_cooperation_skill
end
#--------------------------------------------------------------------------
# ○ 連係スキル用変数初期化
#--------------------------------------------------------------------------
def init_cooperation_skill
@cooperation_skill_judged = false
@cooperation_skill_exec = false
@cooperation_skill_data = nil
@cooperate_actors = []
@cooperate_enemies = []
end
#--------------------------------------------------------------------------
# ● パーティコマンド選択の開始
#--------------------------------------------------------------------------
alias start_party_command_selection_KGC_CooperationSkill
start_party_command_selection
def start_party_command_selection
if $game_temp.in_battle
init_cooperation_skill
end
start_party_command_selection_KGC_CooperationSkill
end
#--------------------------------------------------------------------------
# ● 戦闘処理の実行開始
#--------------------------------------------------------------------------
alias start_main_KGC_CooperationSkill start_main
def start_main
start_main_KGC_CooperationSkill
init_cooperate_battler_list
end
#--------------------------------------------------------------------------
# ○ 判定用データ初期化
#--------------------------------------------------------------------------
def init_cooperate_battler_list
[:actor, :enemy].each { |i|
case i
when :actor
cooperate_battlers = @cooperate_actors
members = $game_party.members
when :enemy
cooperate_battlers = @cooperate_enemies
members = $game_troop.members
end
# 対象側バトラーを設定
cooperate_battlers.clear
unless KGC::CooperationSkill::EXECUTE_ORIGIN_SKILL
members.each { |battler|
next unless battler.action.skill?
cooperate_battlers << Game_CooperationSkillUser.new(battler)
}
end
}
end
#--------------------------------------------------------------------------
# ● 戦闘行動の実行
#--------------------------------------------------------------------------
alias execute_action_KGC_CooperationSkill execute_action
def execute_action
@cooperation_skill_judged = false
if KGC::CooperationSkill::EXECUTE_ORIGIN_SKILL
execute_action_KGC_CooperationSkill
judge_cooperation_skill(@active_battler)
else
judge_cooperation_skill(@active_battler)
unless @cooperation_skill_judged && @cooperation_skill_exec
execute_action_KGC_CooperationSkill
end
end
if @cooperation_skill_exec
if @cooperation_skill_judged
execute_cooperation_skill
else
finish_cooperation_skill
end
end
end
#--------------------------------------------------------------------------
# ○ 連係スキル第一発動判定
# battler : 行動者
#--------------------------------------------------------------------------
def judge_cooperation_skill(battler)
return false if @cooperation_skill_judged
return false if @cooperation_skill_exec
@cooperation_skill_judged = true
target_unit = (battler.is_a?(Game_Actor) ? $game_troop : $game_party)
if battler.action.kind == 1
# 対象が残っていれば第二発動判定
unless target_unit.all_dead?
return judge_cooperation_skill_second(battler)
end
else
# 行動がスキル以外なら判定用配列から削除
if target_unit.is_a?(Game_Party)
remove_cooperate_battler(:enemy, battler)
elsif target_unit.is_a?(Game_Troop)
remove_cooperate_battler(:actor, battler)
end
end
return false
end
#--------------------------------------------------------------------------
# ○ 連係加担者削除
# type : :actor or :enemy
# battler : 削除対象
#--------------------------------------------------------------------------
def remove_cooperate_battler(type, battler)
battlers = (type == :actor ? @cooperate_actors : @cooperate_enemies)
battlers.each_index { |i|
if battlers.index == battler.index
battlers = nil
end
}
battlers.compact!
end
#--------------------------------------------------------------------------
# ○ 連係スキル第二発動判定
# battler : 行動者
#--------------------------------------------------------------------------
def judge_cooperation_skill_second(battler)
# 判定用データ作成
@current_cooperate_user = Game_CooperationSkillUser.new(battler)
if battler.is_a?(Game_Actor)
remove_cooperate_battler(:actor, battler)
@cooperate_actors |= [@current_cooperate_user]
elsif battler.is_a?(Game_Enemy)
remove_cooperate_battler(:enemy, battler)
@cooperate_enemies |= [@current_cooperate_user]
end
# 連係スキル発動判定
KGC::CooperationSkill::SKILLS.each { |cs|
# アクター判定
if battler.is_a?(Game_Actor)
judge_cooperation_skill_third(:actor, cs)
# エネミー判定
elsif battler.is_a?(Game_Enemy)
judge_cooperation_skill_third(:enemy, cs)
end
break if @cooperation_skill_exec
}
return @cooperation_skill_exec
end
#--------------------------------------------------------------------------
# ○ 連係スキル第三発動判定
# type : :actor or :enemy
# cs_data : Cooperation skill data
#--------------------------------------------------------------------------
def judge_cooperation_skill_third(type, cs_data)
if type == :enemy
# エネミーに発動させない場合は戻る
return unless KGC::CooperationSkill::PERMIT_ENEMY
end
@cooperation_skill_exec = false
case type
when :actor
cooperate_battlers = @cooperate_actors
members = $game_party.members
when :enemy
cooperate_battlers = @cooperate_enemies
members = $game_troop.members
end
if battler.is_a?(Game_Actor) || KGC::CooperationSkill::PERMIT_ENEMY
# 発動者に含まれているか判定
@exec_battlers.each_index { |i|
return true if @exec_battlers.index == battler.index
}
end
return false
end
end