#============================================================================== # ■ RGSS3 ターン開始時コモンイベント Ver1.02 by 星潟 #------------------------------------------------------------------------------ # 通常、アイテム・スキルのコモンイベントは使用後に起動しますが # このスクリプトを用いた設定では、ターン開始時に発動します。 # # 通常のコモンイベントと異なり # 戦闘時でなければ効果がないので注意が必要です。 #------------------------------------------------------------------------------ # ★使用例(アイテム・スキルのメモ欄に記入) #------------------------------------------------------------------------------ # <ターン開始時コモン:5> # # このターンの開始時、コモンイベント5を発生させる。 #============================================================================== # Ver1.01 行動が空の場合にエラーとなる不具合を修正しました。 #============================================================================== module TS_COMMON #ターン開始時コモンイベント配列設定用ワードを指定。 WORD = "ターン開始時コモン" end module BattleManager #-------------------------------------------------------------------------- # データ取得用バトラー取得 #-------------------------------------------------------------------------- def self.action_battlers_for_ts_common @action_battlers end end class Game_Troop < Game_Unit attr_accessor :turn_start_common_events #-------------------------------------------------------------------------- # セットアップ #-------------------------------------------------------------------------- alias setup_turnstart_common setup def setup(troop_id) #元の処理を実行する setup_turnstart_common(troop_id) #ターン開始時コモンイベント配列を生成 @turn_start_common_events = [] end #-------------------------------------------------------------------------- # バトルイベントのセットアップ #-------------------------------------------------------------------------- alias setup_battle_event_turnstart_common setup_battle_event def setup_battle_event #本来の処理を実行 setup_battle_event_turnstart_common #イベント実行中なら中断する。 return if @interpreter.running? #ターン開始時コモンイベント配列が空なら中断する return if @turn_start_common_events.empty? #ターン開始時コモンイベント配列の先頭からデータを取り出し、イベントをセットアップ @interpreter.setup($data_common_events[@turn_start_common_events.shift].list) end end class Scene_Battle < Scene_Base #-------------------------------------------------------------------------- # ターンスタート #-------------------------------------------------------------------------- alias turn_start_turnstart_common turn_start def turn_start #本来の処理を行う turn_start_turnstart_common #全てのメンバーの行動からターン開始時コモンイベントを取得する BattleManager.action_battlers_for_ts_common.each {|m| m.actions.each {|a| next unless a next unless a.item next if a.item.turn_start_common_events.empty? $game_troop.turn_start_common_events += a.item.turn_start_common_events } } end end class RPG::BaseItem #-------------------------------------------------------------------------- # ターン開始時コモンイベント #-------------------------------------------------------------------------- def turn_start_common_events #既にデータがある場合、そのデータを返す @ts_common ||= create_turn_start_common_events end #-------------------------------------------------------------------------- # ターン開始時コモンイベントデータ作成 #-------------------------------------------------------------------------- def create_turn_start_common_events #空の配列を作成 r = [] #メモ欄からキーワードを元にデータを生成 if /<#{TS_COMMON::WORD}[::](\S+)>/ =~ note $1.to_s.split(/\s*,\s*/).each {|i| r.push(i.to_i)} end #配列を返す r end end