#============================================================================== # ■ RGSS3 ターン終了時ステート付与/解除特徴 Ver1.01 by 星潟 #------------------------------------------------------------------------------ # ターン終了時に指定したステートを一定確率で付与/解除する特徴を実装します。 #============================================================================== # 特徴を有する項目(アクター・エネミー・職業・装備品・ステート等)のメモ欄に指定。 # ステートID、確率の両方にスクリプト文が使用可能です。 #------------------------------------------------------------------------------ # <ターン終了時ステート付与:10,50> # # ターン終了時、50%の確率でステートID10が付与される特徴を得ます。 #------------------------------------------------------------------------------ # <ターン終了時ステート解除:11,25> # # ターン終了時、25%の確率でステートID11が付与される特徴を得ます。 # ただ、同時にターン終了時ステート付与の効果で # 同一ステートが付与されていた場合はこの解除効果は発生しません。 #============================================================================== module AddRemoveStatesInTurnEnd #ターン終了時ステート付与の設定用キーワードを指定。 Word1 = "ターン終了時ステート付与" #ターン終了時ステート解除の設定用キーワードを指定。 Word2 = "ターン終了時ステート解除" end class Game_Battler < Game_BattlerBase #-------------------------------------------------------------------------- # ステート自動解除 #-------------------------------------------------------------------------- alias remove_states_auto_turn_end_remove_state remove_states_auto def remove_states_auto(timing) remove_states_auto_turn_end_remove_state(timing) state_change_auto_in_turn_end if timing == 2 end #-------------------------------------------------------------------------- # ターン終了時ステート解除 #-------------------------------------------------------------------------- def state_change_auto_in_turn_end return unless $game_party.in_battle af = [] rf = [] feature_objects.each {|f| f.add_states_in_turn_end.each {|k,v| af.push(eval(k)) if eval(v) > rand(100)} af.uniq! f.remove_states_in_turn_end.each {|k,v| i = eval(k) rf.push(i) if !af.include?(i) && eval(v) > rand(100)}} rf.uniq! rrs = @result.removed_states.clone af.each {|i| add_state(i)} @result.removed_states = rrs rf.each {|i| remove_state(i)} end end class RPG::BaseItem #-------------------------------------------------------------------------- # ターン終了時ステート付与 #-------------------------------------------------------------------------- def add_states_in_turn_end @add_states_in_turn_end ||= create_add_states_in_turn_end end #-------------------------------------------------------------------------- # ターン終了時ステート付与データ作成 #-------------------------------------------------------------------------- def create_add_states_in_turn_end h = {} w = AddRemoveStatesInTurnEnd::Word1 self.note.each_line {|l| h[$1.to_s] = $2.to_s if /<#{w}[::](\S+),(\S+)>/ =~ l} h end #-------------------------------------------------------------------------- # ターン終了時ステート解除 #-------------------------------------------------------------------------- def remove_states_in_turn_end @remove_states_in_turn_end ||= create_remove_states_in_turn_end end #-------------------------------------------------------------------------- # ターン終了時ステート解除データ作成 #-------------------------------------------------------------------------- def create_remove_states_in_turn_end h = {} w = AddRemoveStatesInTurnEnd::Word2 self.note.each_line {|l| h[$1.to_s] = $2.to_s if /<#{w}[::](\S+),(\S+)>/ =~ l} h end end