Advertisement
diamondandplatinum3

Control Escape Ratio ~ RGSS3

Dec 10th, 2012
646
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.71 KB | None | 0 0
  1. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  2. #             Control Escape Ratio
  3. #             Author: DiamondandPlatinum3
  4. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  5. #  Description:
  6. #
  7. #    This script will allow you to set a constant rate at which you can escape
  8. #    from battle, as well as setting an item that will guarantee you can
  9. #    escape.
  10. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  11. module DP3ESCAPERATIO
  12.   #=========================================================
  13.   #               EDITABLE REGION
  14.   #=========================================================
  15.  
  16.   ESCAPE_RATIO              = 25 # out of 100
  17.   GUARANTEE_ESCAPE_ITEM_ID  = 2  # Item ID of item that will guarantee you can escape
  18.  
  19.   #=========================================================
  20. end
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28. module BattleManager
  29.   #--------------------------------------------------------------------------
  30.   # * Create Escape Ratio
  31.   #--------------------------------------------------------------------------
  32.   def self.make_escape_ratio
  33.     @escape_ratio = DP3ESCAPERATIO::ESCAPE_RATIO
  34.   end
  35.   #--------------------------------------------------------------------------
  36.   # * Modify Escape Ratio ~ New Method
  37.   #--------------------------------------------------------------------------
  38.   def self.mod_escape_ratio( value )
  39.     @escape_ratio = value
  40.   end
  41.   #--------------------------------------------------------------------------
  42.   # * Escape Processing
  43.   #--------------------------------------------------------------------------
  44.   def self.process_escape
  45.     $game_message.add(sprintf(Vocab::EscapeStart, $game_party.name))
  46.    
  47.     # !-============ Replaced Line ============-! #
  48.    
  49.     success = @preemptive ? true : (rand(100) < @escape_ratio)
  50.    
  51.     # !-=======================================-! #
  52.    
  53.     Sound.play_escape
  54.     if success
  55.       process_abort
  56.     else
  57.       @escape_ratio += 0.1
  58.       $game_message.add('\.' + Vocab::EscapeFailure)
  59.       $game_party.clear_actions
  60.     end
  61.     wait_for_message
  62.     return success
  63.   end
  64. end
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74. class Scene_Battle
  75.   #--------------------------------------------------------------------------
  76.   # * Apply Skill/Item Effect
  77.   #--------------------------------------------------------------------------
  78.   alias dp3_mod_escrat_sb_app_itm_eff_845wc apply_item_effects
  79.   def apply_item_effects(target, item)
  80.     # Change Escape Ratio
  81.     BattleManager.mod_escape_ratio(100) if item.is_a?(RPG::Item) && item.id == DP3ESCAPERATIO::GUARANTEE_ESCAPE_ITEM_ID
  82.    
  83.     # Call Original Method
  84.     dp3_mod_escrat_sb_app_itm_eff_845wc(target, item)
  85.   end
  86. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement