#============================================================================== # ■ RGSS3 行動速度優先度&優先度変動特徴 Ver1.00 by 星潟 #------------------------------------------------------------------------------ # 行動速度について、アイテム・スキル毎に速度優先度を設定します。 # 行動予定のアイテム・スキルの行動速度優先度を以て # 再度行動順の並び変えが行われます。 # ポ○モンのでんこうせっか等のようなアイテムやスキルの作成に役立ちます。 # # 例.行動速度優先度1のバトラーは # 敏捷やアイテム・スキルの行動速度で負けていても # 行動速度優先度0以下のバトラーより早く行動する。 #============================================================================== # アイテム・スキルのメモ欄に設定。 # (設定を行わないアイテム・スキルや行動が存在しない場合の行動速度優先度は0) #------------------------------------------------------------------------------ # <行動速度優先度:1> # # このアイテム・スキルの行動速度優先度は1となる。 # 行動速度優先度0以下の相手より先制し、2以上の相手には先制される。 #------------------------------------------------------------------------------ # <行動速度優先度:-1> # # このアイテム・スキルの行動速度優先度は-1となる。 # 行動速度優先度-2以下の相手より先制し、0以上の相手には先制される。 #------------------------------------------------------------------------------ # <行動速度優先度タグ:あいうえお> # # このアイテム・スキルの行動速度優先度タグとして「あいうえお」を登録。 # この行動速度優先度タグはいくつでも設定可能。 #============================================================================== # アクター・エネミー・武器・防具・ステート等のメモ欄に設定。 #------------------------------------------------------------------------------ # <行動速度優先度変動:あいうえお,1> # # 行動速度優先タグとして「あいうえお」が登録されたアイテム・スキルの # 行動速度優先度を+1する。 # この行動速度優先度変動はいくつでも設定可能。 # (ただし、同一タグの物はより下に書き込まれた物に上書きされる) #============================================================================== module ActionSpeedPriority Word1 = "行動速度優先度" Word2 = "行動速度優先度タグ" Word3 = "行動速度優先度変動" end class Game_Battler < Game_BattlerBase #-------------------------------------------------------------------------- # 行動速度優先度 #-------------------------------------------------------------------------- def speed_priority fo = feature_objects @actions.collect {|action| i = action.item eval(action.speed_priority) + (i ? i.speed_priority_tag : []).inject(0) {|r1,t| r1 += fo.inject(0) {|r2,f| v = f.speed_priority_booster[t] r2 += v ? eval(v) : 0}}}.min || 0 end end class Game_Action #-------------------------------------------------------------------------- # 行動速度優先度文字列 #-------------------------------------------------------------------------- def speed_priority item ? item.speed_priority : "0" end end class RPG::UsableItem < RPG::BaseItem #-------------------------------------------------------------------------- # 行動速度優先度文字列 #-------------------------------------------------------------------------- def speed_priority @speed_priority ||= /<#{ActionSpeedPriority::Word1}[::](\S+)>/ =~ note ? $1.to_s : "0" end #-------------------------------------------------------------------------- # 行動速度優先度タグ #-------------------------------------------------------------------------- def speed_priority_tag @speed_priority_tag ||= create_speed_priority_tag end #-------------------------------------------------------------------------- # 行動速度優先度タグのデータ作成 #-------------------------------------------------------------------------- def create_speed_priority_tag a = [] note.each_line {|l| a.push($1.to_s) if /<#{ActionSpeedPriority::Word2}[::](\S+)>/ =~ l} a.uniq end end class RPG::BaseItem #-------------------------------------------------------------------------- # 行動速度優先度変動特徴 #-------------------------------------------------------------------------- def speed_priority_booster @speed_priority_booster ||= create_speed_priority_booster end #-------------------------------------------------------------------------- # 行動速度優先度変動特徴のデータ作成 #-------------------------------------------------------------------------- def create_speed_priority_booster h = {} note.each_line {|l| h[$1.to_s] = $2.to_s if /<#{ActionSpeedPriority::Word3}[::](\S+),(\S+)>/ =~ l} h end end class << BattleManager #-------------------------------------------------------------------------- # 行動順序の作成 #-------------------------------------------------------------------------- alias make_action_orders_speed_priority make_action_orders def make_action_orders make_action_orders_speed_priority hash = {} @action_battlers.each {|battler| sp = battler.speed_priority hash[sp] ||= [] hash[sp].push(battler)} new_order = [] (hash.keys.sort {|a,b| b <=> a}).each {|i| new_order += hash[i]} @action_battlers = new_order end end