#============================================================================== # ■ RGSS3 一時セルフスイッチ Ver1.00 by 星潟 #------------------------------------------------------------------------------ # 別マップからの場所移動や別バージョンのデータをロードされるまでの間だけ # マップイベント内で維持される特殊なセルフスイッチを実装します。 #============================================================================== module TempSelfSwitch #空のハッシュを用意。 S = {} #一時セルフスイッチに対応するイベントのページ条件でのスイッチIDを指定。 S[11] = 1 S[12] = 2 S[13] = 3 S[14] = 4 #-------------------------------------------------------------------------- # キー配列をキャッシュ化 #-------------------------------------------------------------------------- def self.keys @keys ||= S.keys end end class Game_Event < Game_Character #-------------------------------------------------------------------------- # 初期化 #-------------------------------------------------------------------------- alias initialize_temp_self_switch initialize def initialize(map_id, event) event.pages.each {|page| page.condition.condition_change_for_temp_self_switch} initialize_temp_self_switch(map_id, event) end #-------------------------------------------------------------------------- # 一時セルフスイッチ #-------------------------------------------------------------------------- def temp_self_switch @temp_self_switch ||= {} end #-------------------------------------------------------------------------- # 一時セルフスイッチの変更 #-------------------------------------------------------------------------- def temp_self_switch_change(key,flag) temp_self_switch[key] = flag $game_map.need_refresh = true end #-------------------------------------------------------------------------- # 一時セルフスイッチの確認 #-------------------------------------------------------------------------- def temp_self_switch_check(key) return true unless key temp_self_switch[key] end #-------------------------------------------------------------------------- # イベントページの条件合致判定 #-------------------------------------------------------------------------- alias conditions_met_temp_self_switch1? conditions_met? def conditions_met?(page) conditions_met_temp_self_switch1?(page) && conditions_met_temp_self_switch2?(page) end #-------------------------------------------------------------------------- # 一時セルフスイッチによるイベントページの条件合致判定 #-------------------------------------------------------------------------- def conditions_met_temp_self_switch2?(page) return true unless page c = page.condition temp_self_switch_check(c.temp_self_switch1) && temp_self_switch_check(c.temp_self_switch2) end end class Game_Interpreter #-------------------------------------------------------------------------- # 一時セルフスイッチの変更 #-------------------------------------------------------------------------- def temp_self_switch_change(event_id,key,flag) c = get_character(event_id) c.temp_self_switch_change(key,flag) if c && c.is_a?(Game_Event) end end class RPG::Event::Page::Condition attr_accessor :temp_self_switch1 attr_accessor :temp_self_switch2 #-------------------------------------------------------------------------- # スイッチを一時スイッチに読み替え #-------------------------------------------------------------------------- def condition_change_for_temp_self_switch if switch1_valid if TempSelfSwitch.keys.include?(switch1_id) @temp_self_switch1 = TempSelfSwitch::S[switch1_id] @switch1_valid = false @switch1_id = 1 end end if switch2_valid if TempSelfSwitch.keys.include?(switch2_id) @temp_self_switch2 = TempSelfSwitch::S[switch2_id] @switch2_valid = false @switch2_id = 1 end end end end