Advertisement
Double_X

YEA-InstantCast YSA-PCTB Compatibility

Jun 16th, 2015
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.18 KB | None | 0 0
  1. if $imported["YSA-PCTB"] && $imported["YEA-InstantCast"]
  2.  
  3. #------------------------------------------------------------------------------|
  4.  
  5. #------------------------------------------------------------------------------|
  6. #  * Edit module: BattleManager                                                |
  7. #------------------------------------------------------------------------------|
  8.  
  9. class << BattleManager
  10.  
  11.   #----------------------------------------------------------------------------|
  12.   #  Rewrite method: sort_battlers                                             |
  13.   #----------------------------------------------------------------------------|
  14.   def sort_battlers(cache = false)
  15.     return if !btype?(:pctb)
  16.     battlers = []
  17.     for battler in ($game_party.members + $game_troop.members)
  18.       # Rewritten to exclude the actor with an instant action
  19.       next if battler.dead? || battler == $game_temp.instant_actor
  20.       #
  21.       battlers.push(battler)
  22.     end
  23.     battlers.sort! { |a,b|
  24.       if a.pctb_ctr(cache) != b.pctb_ctr(cache)
  25.         a.pctb_ctr(cache) <=> b.pctb_ctr(cache)
  26.       elsif a.pctb_prediction != b.pctb_prediction
  27.         b.pctb_prediction <=> a.pctb_prediction
  28.       elsif a.agi != b.agi
  29.         b.agi <=> a.agi
  30.       elsif a.screen_x != b.screen_x
  31.         a.screen_x <=> b.screen_x
  32.       else
  33.         a.name <=> b.name
  34.       end
  35.     }
  36.     # Added to add the actor with an instant action as the 1st battler
  37.     if $game_temp.instant_actor
  38.       battlers = [$game_temp.instant_actor] + battlers
  39.       $game_temp.instant_actor = nil
  40.     end
  41.     #
  42.     return battlers
  43.   end # sort_battlers
  44.  
  45. end # BattleManager
  46.  
  47. #------------------------------------------------------------------------------|
  48. #  * Edit class: Game_Temp                                                     |
  49. #------------------------------------------------------------------------------|
  50.  
  51. class Game_Temp
  52.  
  53.   #----------------------------------------------------------------------------|
  54.   #  New public instance variable                                              |
  55.   #----------------------------------------------------------------------------|
  56.   # Stores the actor with an instant action
  57.   attr_accessor :instant_actor
  58.   #
  59.  
  60. end # Game_Temp
  61.  
  62. #------------------------------------------------------------------------------|
  63. #  * Edit class: Scene_Battle                                                  |
  64. #------------------------------------------------------------------------------|
  65.  
  66. class Scene_Battle
  67.  
  68.   #----------------------------------------------------------------------------|
  69.   #  Alias method: perform_instant_action                                      |
  70.   #----------------------------------------------------------------------------|
  71.   alias perform_instant_action_pctb perform_instant_action
  72.   def perform_instant_action
  73.     # Added to store the actor with an instant action
  74.     $game_temp.instant_actor = BattleManager.actor
  75.     #
  76.     perform_instant_action_pctb
  77.   end # perform_instant_action
  78.  
  79. end # Scene_Battle
  80.  
  81. #------------------------------------------------------------------------------|
  82.  
  83. end # if $imported["YSA-PCTB"] && $imported["YEA-InstantCast"]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement