Advertisement
Scinaya

Encounter Management by Craze

Apr 28th, 2011
958
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 4.60 KB | None | 0 0
  1. #===============================================================================
  2. #
  3. # Craze's Script Asylum - Encounter Management
  4. # Last Date Updated: 2010.06.10
  5. # Level: Easy
  6. #
  7. # Now you can affect the rate of random encounters, or let the player do so.
  8. #
  9. # If you use Battle Engine Melody's <variable x: +y>  or  <variable x: -y> tags
  10. # or call common events, you can let the player use items that repel or even
  11. # encourage enemy encounters.
  12. #===============================================================================
  13. # Instructions
  14. # -----------------------------------------------------------------------------
  15. # To install this script, open up your script editor and copy/paste this script
  16. # to an open slot below ▼ Materials but above ▼ Main. Remember to save.
  17. #===============================================================================
  18. # Compatibility
  19. # -----------------------------------------------------------------------------
  20. # Note: This script overwrites make_encounter_count. Obviously, do not use this
  21. # with any other encounter rate-adjusting scripts.
  22. #===============================================================================
  23.  
  24. $imported = {} if $imported == nil
  25. $imported["EncManagement"] = true
  26.  
  27. module CRAZE
  28.   module ENC_MANAGE
  29.  
  30.     # This is the id of the variable you can manipulate to adjust the game's
  31.     # encounter rate. Positive numbers add more steps between encounters;
  32.     # negative numbers reduce the steps between encounters.
  33.     ENC_RATE_MOD_VAR = 41
  34.  
  35.     # If this is set to true, the variable above will reset to 0 whenever the
  36.     # player moves to a new map. If this is false, make sure that you event
  37.     # a system that keeps the variable in check.
  38.     RESET_ENC_RATE_ON_TRANSFER = true
  39.  
  40.     # If this is set to true, the encounter rate will be calculated a little
  41.     # differently than the default. This will tighten the possible range of
  42.     # steps between encounters - encounters will occur after a more predictable
  43.     # distance. If false, the default VX method is used.
  44.     ALTERED_ENC_RATE_METHOD = true
  45.  
  46.     # These allow you to make sure that the player can never go absolutely
  47.     # crazy with your encounter rate options! These are the minimum and maximum
  48.     # amount of steps that have to occur between random encounters.
  49.     MIN_ENC_RATE = 5
  50.     MAX_ENC_RATE = 300
  51.  
  52.   end
  53. end
  54.  
  55. #===============================================================================
  56. # Editing anything past this point may potentially result in causing computer
  57. # damage, incontinence, or horrible Mousie-based death. Edit at your own risk.
  58. #===============================================================================
  59.  
  60. #==============================================================================
  61. # Game_Player
  62. #==============================================================================
  63.  
  64. class Game_Player < Game_Character
  65.  
  66.   #--------------------------------------------------------------------------
  67.   # overwrite method: make_encounter_count
  68.   #--------------------------------------------------------------------------
  69.  
  70.   def make_encounter_count
  71.     if $game_map.map_id != 0
  72.       if CRAZE::ENC_MANAGE::ALTERED_ENC_RATE_METHOD
  73.         n = $game_map.encounter_step
  74.         n = n + rand(n) + 1  # As if rolling a die and adding max
  75.       else
  76.         n = $game_map.encounter_step
  77.         n = rand(n) + rand(n) + 1  # As if rolling 2 dice
  78.       end
  79.     end
  80.     unless n == nil
  81.       n += $game_variables[CRAZE::ENC_MANAGE::ENC_RATE_MOD_VAR]
  82.       n = [n, CRAZE::ENC_MANAGE::MIN_ENC_RATE].max
  83.       n = [n, CRAZE::ENC_MANAGE::MAX_ENC_RATE].min
  84.       @encounter_count = n
  85.     end
  86.   end
  87.  
  88. end # Game_Player
  89.  
  90. #==============================================================================
  91. # Scene_Map
  92. #==============================================================================
  93.  
  94. class Scene_Map
  95.  
  96.   #--------------------------------------------------------------------------
  97.   # alias method: update_transfer_player
  98.   #--------------------------------------------------------------------------
  99.  
  100.   alias csa_enc_mng_update_transfer_player update_transfer_player unless $@
  101.   def update_transfer_player
  102.     return unless $game_player.transfer?
  103.     reset = CRAZE::ENC_MANAGE::RESET_ENC_RATE_ON_TRANSFER
  104.     $game_variables[CRAZE::ENC_MANAGE::ENC_RATE_MOD_VAR] = 0 if reset
  105.     csa_enc_mng_update_transfer_player
  106.   end
  107.  
  108. end # Scene_Map
  109.  
  110. #===============================================================================
  111. #
  112. # END OF FILE
  113. #
  114. #===============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement