Heartbreak61

「SIMPLE STUPID」 Common Event on Battle End v0.60

Feb 4th, 2013
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.24 KB | None | 0 0
  1. $imported = {} if $imported.nil?
  2. $imported["HBK_SSCEOBE"] = 0.60
  3. #==============================================================================
  4. # ■ 「SIMPLE STUPID」 Common Event on Battle End
  5. # by HBK61
  6. # Requires: N/A
  7. # Rewrites method:
  8. #   BattleManager#self.process_victory
  9. #   BattleManager#Self.process_escape
  10. #   BattleManager#self.process_defeat
  11. # Aliases method: N/A
  12. #      
  13. #==============================================================================
  14. # CHANGELOG
  15. # - ver0.60  2012.02.03   Initialization
  16. #==============================================================================
  17. # INTRODUCTION
  18. #   - This script allow you to run common event before leaving Battle Scene.
  19. #   You can set which common event to run on win, defeat, and lose.
  20. #==============================================================================
  21. # INSTRUCTION
  22. #   - Just edit on CONFIGURATION section below as you wish.
  23. #==============================================================================
  24. # TERM OF USE
  25. # - No need to gimme credit on your game, although its an honour to receive any.
  26. # - Feel free to use on commercial game.
  27. # - Feel free to use on adult-themed game.
  28. # - Feel free to use, edit, delete, wipe, burn, eat, or anything you want to do
  29. #   with this script as long as you don't claim this script as yours.
  30. #==============================================================================
  31. # SPECIAL THANKS
  32. # TheoAllen for the idea
  33.  
  34. module HBK
  35.   module BattleEnd
  36.   #--------------------------------------------------------------------------
  37.   # CONFIGURATION
  38.   # If you don't want to run common event, just set the value to 0  
  39.     Victory_Common_Event_ID = 1
  40.     Escape_Common_Event_ID = 2
  41.     Defeat_Common_Event_ID = 3
  42.   # WARNING!
  43.   # Do not edit below this point unless you know what to do!
  44.   #--------------------------------------------------------------------------
  45.   end
  46. end
  47.  
  48. module BattleManager
  49.   #--------------------------------------------------------------------------
  50.   # * Victory Processing
  51.   #--------------------------------------------------------------------------
  52.   def self.process_victory
  53.     play_battle_end_me
  54.     replay_bgm_and_bgs
  55.     SceneManager.scene.process_common_event(HBK::BattleEnd::Victory_Common_Event_ID)
  56.     $game_message.add(sprintf(Vocab::Victory, $game_party.name))
  57.     display_exp
  58.     gain_gold
  59.     gain_drop_items
  60.     gain_exp
  61.     SceneManager.return
  62.     battle_end(0)
  63.     return true
  64.   end
  65.   #--------------------------------------------------------------------------
  66.   # * Escape Processing
  67.   #--------------------------------------------------------------------------
  68.   def self.process_escape
  69.     $game_message.add(sprintf(Vocab::EscapeStart, $game_party.name))
  70.     success = @preemptive ? true : (rand < @escape_ratio)
  71.     Sound.play_escape
  72.     if success
  73.       SceneManager.scene.process_common_event(HBK::BattleEnd::Escape_Common_Event_ID)
  74.       process_abort
  75.     else
  76.       @escape_ratio += 0.1
  77.       $game_message.add('\.' + Vocab::EscapeFailure)
  78.       $game_party.clear_actions
  79.     end
  80.     wait_for_message
  81.     return success
  82.   end
  83.   #--------------------------------------------------------------------------
  84.   # * Defeat Processing
  85.   #--------------------------------------------------------------------------
  86.   def self.process_defeat
  87.     SceneManager.scene.process_common_event(HBK::BattleEnd::Defeat_Common_Event_ID)
  88.     $game_message.add(sprintf(Vocab::Defeat, $game_party.name))
  89.     wait_for_message
  90.     if @can_lose
  91.       revive_battle_members
  92.       replay_bgm_and_bgs
  93.       SceneManager.return
  94.     else
  95.       SceneManager.goto(Scene_Gameover)
  96.     end
  97.     battle_end(2)
  98.     return true
  99.   end
  100.  
  101. end #BattleManager
  102.  
  103. class Scene_Battle < Scene_Base
  104.   #--------------------------------------------------------------------------
  105.   # * new method: process_common_event
  106.   #--------------------------------------------------------------------------
  107.   def process_common_event(id)
  108.     return if id == 0
  109.     $game_temp.reserve_common_event(id)
  110.     while !scene_changing?
  111.       $game_troop.interpreter.update
  112.       $game_troop.setup_battle_event
  113.       wait_for_message
  114.       break unless $game_troop.interpreter.running?
  115.       update_for_wait
  116.     end
  117.   end
  118. end
Advertisement
Add Comment
Please, Sign In to add comment