Szyu

Battle Difficulties

Apr 22nd, 2014
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.45 KB | None | 0 0
  1. #==============================================================================
  2. # Battle Difficulties
  3. # Version 1.1
  4. # By Szyu
  5. #
  6. # About:
  7. # Enables stronger and weaker battle difficulies
  8. #
  9. # Instructions:
  10. # - Place below "▼ Materials" but above "▼ Main Process".
  11. #
  12. # How to Use:
  13. # Call script with "$game_party.set_difficulty(x)", where x represents one of
  14. #  the keys in the difficulty set GAME_DIFFICULTIES
  15. #  $game_party.set_difficulty(:normal)
  16. #
  17. # Updates (Pastebin):
  18. # http://adf.ly/4920670/battle-difficulties
  19. #
  20. #==============================================================
  21. #   * Configuration
  22. #==============================================================
  23.  
  24. # Set of difficulties
  25. GAME_DIFFICULTIES = {
  26.   :easy   => 0.75,
  27.   :normal => 1.0,
  28.   :hard   => 1.35,
  29.   :insane => 4.0
  30. }
  31. # Difficulty when started new game
  32. START_DIFFICULTY = :normal
  33.  
  34. #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  35. #==============================================================
  36. #   * Game_Party
  37. #==============================================================
  38. class Game_Party < Game_Unit
  39.   alias init_game_dif_sz initialize
  40.  
  41.   attr_reader :game_difficulty
  42.   attr_reader :difficulty_rate
  43.  
  44.   def initialize
  45.     init_game_dif_sz
  46.     @game_difficulty = START_DIFFICULTY
  47.     set_difficulty(@game_difficulty)
  48.   end
  49.  
  50.   def set_difficulty(dif)
  51.     @game_difficulty = dif
  52.     @difficulty_rate = GAME_DIFFICULTIES[@game_difficulty]
  53.     apply_new_difficulty
  54.   end
  55.  
  56.   def get_difficulty_text
  57.     return @game_difficulty.to_s
  58.   end
  59.  
  60.   def apply_new_difficulty
  61.     db_en = load_data("Data/Enemies.rvdata2")
  62.     $data_enemies.each do |en|
  63.       next if en.nil?
  64.       en.gold = (db_en[en.id].gold * @difficulty_rate).to_i
  65.       en.exp = (db_en[en.id].exp * @difficulty_rate).to_i
  66.       for i in 0..en.params.size-1
  67.         en.params[i] = (db_en[en.id].params[i] * @difficulty_rate).to_i
  68.       end
  69.       for i in 0..en.drop_items.size-1
  70.         en.drop_items[i].denominator = (db_en[en.id].drop_items[i].denominator * @difficulty_rate).to_i
  71.       end
  72.     end
  73.   end
  74. end
  75.  
  76. #==============================================================
  77. #   * DataManager
  78. #==============================================================
  79. class << DataManager
  80.   alias load_dif_sz extract_save_contents
  81.  
  82.   def extract_save_contents(contents)
  83.     load_dif_sz(contents)
  84.     $game_party.set_difficulty($game_party.game_difficulty)
  85.   end
  86. end
Add Comment
Please, Sign In to add comment