Advertisement
gerkrt

Modifiy combat step rate command

Sep 14th, 2011
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.44 KB | None | 0 0
  1. #==============================================================================
  2. # Modifiy combat step rate command
  3. # By gerkrt/gerrtunk
  4. # Version: 1
  5. # License: GPL, credits
  6. # Date: 4/1/2011
  7. # For the latests updates or bugs fixes of this script check here:
  8. # http://usuarios.multimania.es/kisap/english_list.html
  9. #==============================================================================
  10.  
  11. =begin
  12.  
  13. ---------INTRODUCTION----------
  14.  
  15. This script adds a lost feature from old rpgmakers: the changue combate rate
  16. command. It also lets you restart it.
  17.  
  18. --------INSTRUCTIONS------------
  19.  
  20. modify_step_count(new_step_count, map_id): This lets you changue the basic value
  21. of step counts calculation. You have to pass first the new steps value.
  22. If you dont pass a map id value it will use the map where you are.
  23.  
  24. restart_step_count(map id): This restarts the actual step count, putting it
  25. in a similar initital value. If you dont pass a map id value it will use the
  26. map where you are.
  27.  
  28. -Note that the script tries to save the actual steps of the player and add
  29. that in the new step count. You can anulate that calling the restart method
  30. before modifing it.
  31.  
  32. -The information is saved when you save the game and its permanent.
  33.  
  34. ----------EXAMPLES--------------
  35.  
  36. modify_step_count (56)   --> This changues the steps count of the actual map
  37. to 56.
  38.  
  39. modify_step_count (5, 34)  --> This changues the map 5 to 34 steps count.
  40.  
  41. =end
  42.  
  43.  
  44. class Interpreter
  45.   #--------------------------------------------------------------------------
  46.   # * Restart Encounter Count
  47.   # alias gameplayer method and check map id
  48.   #--------------------------------------------------------------------------
  49.   # If you want to not save the actual steps, use it
  50.   def restart_step_count(map_id=-1)
  51.     # If the map id is -1, mark of actual default map, use actual map_id
  52.     if map_id == -1
  53.       map = $game_map.map_id
  54.     # If not, changue the id specified
  55.     else
  56.       map = map_id
  57.     end
  58.    
  59.     # Call the real method
  60.     $game_player.restart_step_count(map)
  61.   end
  62.  
  63.   #--------------------------------------------------------------------------
  64.   # * Modify Step Count
  65.   #  add or update a new step count in list and call apply in gameplayer
  66.   #--------------------------------------------------------------------------
  67.   def modify_step_count(value, map_id=-1)
  68.    
  69.     # If the map id is -1, mark of actual default map, use actual map_id
  70.     if map_id == -1
  71.       map = $game_map.map_id
  72.     # If not, changue the id specified
  73.     else
  74.       map = map_id
  75.     end
  76.    
  77.     # Add or update value.
  78.     $game_system.moded_steps_counts[map] = value
  79.    
  80.     # Apply it
  81.     $game_player.apply_step_count(value, map)
  82.  
  83.   end
  84.  
  85. end
  86.  
  87.  
  88.  
  89. class Game_System
  90.  
  91.   attr_accessor :moded_steps_counts      # List of new steps counts pushed
  92.   alias gs_init_wep_msc initialize
  93.  
  94.   def initialize
  95.     @moded_steps_counts = []
  96.     gs_init_wep_msc
  97.   end
  98.  
  99. end
  100.  
  101.  
  102.  
  103. class Game_Player
  104.  
  105.   #--------------------------------------------------------------------------
  106.   # * Get Encounter Count
  107.   #--------------------------------------------------------------------------
  108.   def encounter_count
  109.     return @encounter_count
  110.   end
  111.  
  112.   #--------------------------------------------------------------------------
  113.   # * Restart Encounter Count
  114.   #
  115.   #--------------------------------------------------------------------------
  116.   def restart_step_count(map)
  117.    
  118.     # If exist a modified rate use it
  119.     if $game_system.moded_steps_counts[map] != nil
  120.       n = $game_system.moded_steps_counts[map]
  121.      
  122.     # If not use bd one. It needs to load it.
  123.     else
  124.       bdmap = load_data(sprintf("Data/Map%03d.rxdata", map))
  125.       n = bdmap.encounter_step
  126.     end
  127.     @encounter_count = rand(n) + rand(n) + 1
  128.    
  129.   end
  130.  
  131.   #--------------------------------------------------------------------------
  132.   # * Apply Step Count
  133.   #--------------------------------------------------------------------------
  134.   def apply_step_count(value, map)
  135.      
  136.       # First calculate the number of steps using base map/moded array - actual
  137.       # If exist a modified rate use it
  138.       if $game_system.moded_steps_counts[map] != nil
  139.         n = $game_system.moded_steps_counts[map]
  140.        
  141.       # If not use bd one
  142.       else
  143.         bdmap = load_data(sprintf("Data/Map%03d.rxdata", map))
  144.         n = bdmap.encounter_step
  145.       end
  146.      
  147.       # Rest it, and make that cant be negative.
  148.       c = (@encounter_count - n).abs
  149.      
  150.       # Create the new count adding the actual steps
  151.       @encounter_count = rand(n) + rand(n) + 1 + c
  152.       # Make sure that its at less 0
  153.       @encounter_count.abs
  154.      
  155.   end
  156.  
  157.   #--------------------------------------------------------------------------
  158.   # * Make Encounter Count
  159.   # moded to check for moded steps rates
  160.   # no es reseteja cuan surts del mapa x ho pot ser x una altre cosa
  161.   #--------------------------------------------------------------------------
  162.   def make_encounter_count
  163.    
  164.     # Image of two dice rolling
  165.     if $game_map.map_id != 0
  166.      
  167.       # If exist a modified rate use it
  168.       if $game_system.moded_steps_counts[$game_map.map_id] != nil
  169.         n = $game_system.moded_steps_counts[$game_map.map_id]
  170.       # If not use bd one
  171.       else
  172.         n = $game_map.encounter_step
  173.       end
  174.       #p 'encounter fet, n', n
  175.       @encounter_count = rand(n) + rand(n) + 1
  176.     end
  177.   end  
  178.  
  179. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement