ezmash

Battle Result Switches (VX Ace)

Nov 12th, 2016
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.46 KB | None | 0 0
  1. #=============================================================================
  2. # Battle Result Switches
  3. # by Shaz
  4. # Last updated: 2016.11.13
  5. #=============================================================================
  6. #
  7. # This script allows you to turn on switches when a battle ends, which you can
  8. # then use to trigger common events or map events.
  9. #
  10. #-----------------------------------------------------------------------------
  11. # Terms of use:
  12. # Can be used in commercial games
  13. # Please do not repost this script - link back to the original source
  14. #=============================================================================
  15.  
  16. # CUSTOMIZATION
  17. # Replace 0 with the id of the switch you want turned on when the battle ends
  18. # with the specified result.  0 means no switch will be turned on.  You can
  19. # use the same switch number for all results if appropriate.  No leading zeros.
  20.  
  21. module SHAZ
  22.   module BRS
  23.     WIN = 0
  24.     LOSE = 0
  25.     ESCAPE = 0
  26.     ABORT = 0
  27.   end
  28. end
  29.  
  30.  
  31. module BattleManager
  32.  
  33.   class << self
  34.     alias shaz_battle_result_setup setup
  35.     alias shaz_battle_result_process_victory process_victory
  36.     alias shaz_battle_result_process_escape process_escape
  37.     alias shaz_battle_result_process_abort process_abort
  38.     alias shaz_battle_result_process_defeat process_defeat
  39.   end
  40.  
  41.  
  42.   def self.setup(troop_id, can_escape = true, can_lose = false)
  43.     shaz_battle_result_setup(troop_id, can_escape, can_lose)
  44.     $game_switches[SHAZ::BRS::WIN] = false if SHAZ::BRS::WIN != 0
  45.     $game_switches[SHAZ::BRS::LOSE] = false if SHAZ::BRS::LOSE != 0
  46.     $game_switches[SHAZ::BRS::ESCAPE] = false if SHAZ::BRS::ESCAPE != 0
  47.     $game_switches[SHAZ::BRS::ABORT] = false if SHAZ::BRS::ABORT != 0
  48.     @escaping = false
  49.   end
  50.  
  51.   def self.process_victory
  52.     res = shaz_battle_result_process_victory
  53.     $game_switches[SHAZ::BRS::WIN] = true if SHAZ::BRS::WIN != 0
  54.     return res
  55.   end
  56.  
  57.   def self.process_escape
  58.     @escaping = true
  59.     res = shaz_battle_result_process_escape
  60.     @escaping = false
  61.     $game_switches[SHAZ::BRS::ESCAPE] = true if res && SHAZ::BRS::ESCAPE != 0
  62.     return res
  63.   end
  64.  
  65.   def self.process_abort
  66.     res = shaz_battle_result_process_abort
  67.     $game_switches[SHAZ::BRS::ABORT] = true if !@escaping && SHAZ::BRS::ABORT != 0  
  68.     return res
  69.   end
  70.  
  71.   def self.process_defeat
  72.     res = shaz_battle_result_process_defeat
  73.     $game_switches[SHAZ::BRS::LOSE] = true if SHAZ::BRS::LOSE != 0
  74.     return res
  75.   end
  76. end
Advertisement
Add Comment
Please, Sign In to add comment