バトルイベントの発生条件に変数を追加
Posted: 2019年11月25日(月) 20:51
前回の謎の存在同様作ったけど使わなかった掘り出し物
昔マップイベントには変数を条件に出来るのにバトルイベントには無いのが気に食わなくて
作ったスクリプト。(なお結局自分は今の所使ってないという無駄骨)
例えば特定の戦闘でアイテムやスキルを一定回数使ったら発生とかも工夫次第で可能なはず。
アクターID100をダミーアクターとして使い変数ID100を使える様にしてます。
弄れば使える変数を増やしたりも出来ますが自己責任で。
あんまテストはした記憶は無いのでミスがあるかも。
使用方法は下の画像とスクリプトの中見てね。
仕様:データベースで設定する都合上変数の中身は現状0~9999しか使用出来ません。
10000以上を条件にしたい場合は自分で改造してね。
素材単体での販売以外自由
昔マップイベントには変数を条件に出来るのにバトルイベントには無いのが気に食わなくて
作ったスクリプト。(なお結局自分は今の所使ってないという無駄骨)
例えば特定の戦闘でアイテムやスキルを一定回数使ったら発生とかも工夫次第で可能なはず。
アクターID100をダミーアクターとして使い変数ID100を使える様にしてます。
弄れば使える変数を増やしたりも出来ますが自己責任で。
あんまテストはした記憶は無いのでミスがあるかも。
使用方法は下の画像とスクリプトの中見てね。
仕様:データベースで設定する都合上変数の中身は現状0~9999しか使用出来ません。
10000以上を条件にしたい場合は自分で改造してね。
素材単体での販売以外自由
コード: 全て選択
#==============================================================================
# バトルイベントの発生条件に変数を追加
# byショウ
#利用規約
#素材単体での販売以外自由
#==============================================================================
class Game_Troop < Game_Unit
#--------------------------------------------------------------------------
# ● バトルイベント (ページ) の条件合致判定
# page : バトルイベントページ
#--------------------------------------------------------------------------
def conditions_met?(page)
c = page.condition
if not c.turn_ending and not c.turn_valid and not c.enemy_valid and
not c.actor_valid and not c.switch_valid
return false # 条件未設定…実行しない
end
if @event_flags[page]
return false # 実行済み
end
if c.turn_ending # ターン終了時
return false unless @turn_ending
end
dammy = 100#ダミーアクター設定用(便宜上100にしてるけど自由に)
if c.actor_valid and c.turn_valid and c.actor_id == dammy
#比較演算子設定(c.actor_hpの数値で設定)
if c.actor_hp == 0#等しい
return true if $game_variables[c.actor_id] == c.turn_a
elsif c.actor_hp == 1#等しくない
return true if $game_variables[c.actor_id] != c.turn_a
elsif c.actor_hp == 2#小さい
return true if $game_variables[c.actor_id] < c.turn_a
elsif c.actor_hp == 3#大きい
return true if $game_variables[c.actor_id] > c.turn_a
elsif c.actor_hp == 4#以下
return true if $game_variables[c.actor_id] <= c.turn_a
elsif c.actor_hp == 5#以上
return true if $game_variables[c.actor_id] >= c.turn_a
end
#比較演算子設定(c.actor_hpの数値で設定)
end
if c.turn_valid# ターン数
n = @turn_count
a = c.turn_a
b = c.turn_b
return false if (b == 0 and n != a)
return false if (b > 0 and (n < 1 or n < a or n % b != a % b))
end
if c.enemy_valid # 敵キャラ
enemy = $game_troop.members[c.enemy_index]
return false if enemy == nil
return false if enemy.hp * 100.0 / enemy.maxhp > c.enemy_hp
end
if c.actor_valid# アクター
actor = $game_actors[c.actor_id]
return false if actor == nil
return false if actor.hp * 100.0 / actor.maxhp > c.actor_hp
end
if c.switch_valid # スイッチ
return false if $game_switches[c.switch_id] == false
end
return true # 条件合致
end
end