Advertisement
mjshi

After Battle Events Edit (Standalone Ver)

Sep 13th, 2015
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.87 KB | None | 0 0
  1. #-------------------------------------------------------------------------------
  2. # After Battle Events (Vlue) Addon by mjshi
  3. # Version 1.0
  4. # Automatically turns off switches after battle event processing
  5. #-------------------------------------------------------------------------------
  6. # Usage: Put in scripts, above Main.
  7. #-- Victory is called after all enemies are dead and before exp/gold/etc
  8. #-- Escape is called when the escape command is chosen and before the result
  9. #-- Abort is called when successfully escaping or manual battle abort
  10. #-- Defeat is called when all allies are dead
  11. # Requires: None
  12. #-------------------------------------------------------------------------------
  13.  
  14. module AfterBattleEvents
  15.   #-----------------------------------------------------------------------------
  16.   # Configuration:
  17.   # These switches will be turned on when each respective  event occurs.
  18.   #-----------------------------------------------------------------------------
  19.   VICTORY_EVENT_SWITCH = 90
  20.   ESCAPE_EVENT_SWITCH = 91
  21.   ABORT_EVENT_SWITCH = 92
  22.   DEFEAT_EVENT_SWITCH = 93
  23. end
  24.  
  25. module BattleManager
  26.   class << self
  27.     alias event_process_victory process_victory
  28.     alias event_process_escape process_escape
  29.     alias event_process_abort process_abort
  30.     alias event_process_defeat process_defeat
  31.   end
  32.   def self.process_victory
  33.     SceneManager.scene.play_victory_event
  34.     return event_process_victory
  35.   end
  36.   def self.process_escape
  37.     SceneManager.scene.play_escape_event
  38.     return event_process_escape
  39.   end
  40.   def self.process_abort
  41.     SceneManager.scene.play_abort_event
  42.     return event_process_abort
  43.   end
  44.   def self.process_defeat
  45.     SceneManager.scene.play_defeat_event
  46.     return event_process_defeat
  47.   end
  48. end
  49.  
  50. class Scene_Battle
  51.   include AfterBattleEvents
  52.  
  53.   def play_victory_event
  54.     $game_switches[VICTORY_EVENT_SWITCH] = true
  55.     process_end_event
  56.   end
  57.   def play_escape_event
  58.     $game_switches[ESCAPE_EVENT_SWITCH] = true
  59.     process_end_event
  60.   end
  61.   def play_abort_event
  62.     $game_switches[ABORT_EVENT_SWITCH] = true
  63.     process_end_event
  64.   end
  65.   def play_defeat_event
  66.     $game_switches[DEFEAT_EVENT_SWITCH] = true
  67.     process_end_event
  68.   end
  69.   def process_end_event
  70.     while !scene_changing?
  71.       $game_troop.interpreter.update
  72.       $game_troop.setup_battle_event
  73.       wait_for_message
  74.       wait_for_effect if $game_troop.all_dead?
  75.       process_forced_action
  76.      
  77.       $game_switches[VICTORY_EVENT_SWITCH] ? $game_switches[VICTORY_EVENT_SWITCH] = false : nil
  78.       $game_switches[ESCAPE_EVENT_SWITCH] ? $game_switches[ESCAPE_EVENT_SWITCH] = false : nil
  79.       $game_switches[ABORT_EVENT_SWITCH] ? $game_switches[ABORT_EVENT_SWITCH] = false : nil
  80.       $game_switches[DEFEAT_EVENT_SWITCH] ? $game_switches[DEFEAT_EVENT_SWITCH] = false : nil
  81.      
  82.       break unless $game_troop.interpreter.running?
  83.     end
  84.   end
  85. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement