Advertisement
TheSixth

Movement Speed Altering Features by Sixth

Oct 4th, 2015
662
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 9.05 KB | None | 0 0
  1. #===============================================================================
  2. # * [ACE] Movement Speed Altering Features
  3. #===============================================================================
  4. # * Made by: Sixth (www.rpgmakervxace.net, www.forums.rpgmakerweb.com)
  5. # * Version: 1.1
  6. # * Updated: 17/02/2018
  7. # * Requires: -------
  8. #-------------------------------------------------------------------------------
  9. # * < Change Log >
  10. #-------------------------------------------------------------------------------
  11. # * Version 1.0 (04/10/2015)
  12. #   - Initial release.
  13. # * Version 1.1 (17/02/2018)
  14. #   - Fixed the movement speed change for followers.
  15. #-------------------------------------------------------------------------------
  16. # * < Description >
  17. #-------------------------------------------------------------------------------
  18. # * This script will let you make features which can manipulate the player's
  19. #   movement speed on the map.
  20. # * These features can be assigned to:
  21. #   - Actors
  22. #   - Classes
  23. #   - Enemies (requires Falcao's ABS)
  24. #   - Equipment
  25. #   - States
  26. # * Settings for maximum/minimum bonuses gained from equipment.
  27. # * Settings for absolute minimum and maximum movement speed.
  28. # * The effect can be set to be dash-only.
  29. # * The bonus can be gotten from the party leader's equipment only, or from
  30. #   all active member's equipment (battle members).
  31. # * If you use Falcao's ABS, you can manipulate the enemy event's movement
  32. #   speed on the map too.
  33. # * Disable switch for eventing purposes.
  34. #-------------------------------------------------------------------------------
  35. # * < Note-Tags >
  36. #-------------------------------------------------------------------------------
  37. # Just note-tag your actors/classes/enemies/equipment/states with this note:
  38. #
  39. #   <speed bonus: +val>
  40. #   <speed bonus: -val>
  41. #
  42. # Replace 'val' with the bonus percentage added/removed to/from the speed.
  43. # Always use + for positive bonuses and - for negative ones!
  44. #
  45. # Examples:
  46. #
  47. #   <speed bonus: +50>
  48. # This makes the equip gain a "Movement Speed +50%" effect. If the player equips
  49. # it, the movement speed will be raised significantly (by 50%).
  50. #
  51. #   <speed bonus: -20>
  52. # This makes the equip gain a "Movement Speed -20%" effect. If the player equips
  53. # it, the movement speed will be decreased by 20%.
  54. #
  55. # NOTE:
  56. # These bonuses are stackable! Meaning all of your equipment's bonus will be
  57. # added together and the final value is used to determine the real bonus.
  58. # For example, if the player got an equipment with +20% speed, another with +10%,
  59. # and yet another with -15% speed effect, the final bonus will be:
  60. # 20 + 10 - 15 = 15%
  61. #
  62. # You can choose which party members will affect the movement speed, the party
  63. # leader only, or the whole active party (battle members).
  64. #-------------------------------------------------------------------------------
  65. # * < Installation >
  66. #-------------------------------------------------------------------------------
  67. # * Place this script below Materials but above Main!
  68. #-------------------------------------------------------------------------------
  69. # * < Compatibility Info >
  70. #-------------------------------------------------------------------------------
  71. # * No known incompatibilities.
  72. #-------------------------------------------------------------------------------
  73. # * < Known Issues >
  74. #-------------------------------------------------------------------------------
  75. # * No known issues.
  76. #-------------------------------------------------------------------------------
  77. # * < Terms of Use >
  78. #-------------------------------------------------------------------------------
  79. # * Free to use for whatever purposes you want.
  80. # * Credit me (Sixth) in your game, pretty please! :P
  81. # * Posting modified versions of this script is allowed as long as you notice me
  82. #   about it with a link to it!
  83. #===============================================================================
  84. $imported = {} if $imported.nil?
  85. $imported["SixthSpeedBonus"] = true
  86. #===============================================================================
  87. # Settings:
  88. #===============================================================================
  89. module SpeedBonus
  90.   #-----------------------------------------------------------------------------
  91.   # Player Bonus Source Settings:
  92.   #-----------------------------------------------------------------------------
  93.   # true = Only the leader's equips will be checked for speed bonuses.
  94.   # false = All battle members' equips will be checked for speed bonuses.
  95.   #-----------------------------------------------------------------------------
  96.   LeaderOnly = true
  97.  
  98.   #-----------------------------------------------------------------------------
  99.   # Player Bonus Type Settings:
  100.   #-----------------------------------------------------------------------------
  101.   # true = The bonus will only be applied when the player is running.
  102.   # false = The bonus will be applied on walking and running alike.
  103.   #-----------------------------------------------------------------------------
  104.   DashOnly = false
  105.  
  106.   #-----------------------------------------------------------------------------
  107.   # Disable Switch Settings:
  108.   #-----------------------------------------------------------------------------
  109.   # Set this setting to a switch ID.
  110.   # Whenever this switch is ON, the bonus speed effects will be ignored.
  111.   # Useful for evented scenes, I guess.
  112.   #-----------------------------------------------------------------------------
  113.   DisableSwitch = 50
  114.  
  115.   #-----------------------------------------------------------------------------
  116.   # Bonus Limit Settings:
  117.   #-----------------------------------------------------------------------------
  118.   # With these settings, you can limit the maximum and minimum amount of speed
  119.   # bonus a character can get. These limits will be applied BEFORE the real
  120.   # speed calculation, meaning they will limit the total bonus itself only.
  121.   # The settings are in float values (0.2 means 20%, -0.42 means -42%, etc).
  122.   # So, if the player got a total of +53% speed bonus, but the maximum cap is
  123.   # set to be 0.4, the final bonus value will be +40% instead of +53%.
  124.   #-----------------------------------------------------------------------------
  125.   MaxBonus = 0.4
  126.   MinBonus = -0.4
  127.  
  128.   #-----------------------------------------------------------------------------
  129.   # Absolute Speed Limit Settings:
  130.   #-----------------------------------------------------------------------------
  131.   # In case you need to limit the movement speed AFTER the bonus addition, you
  132.   # can set a limit here for both maximum and minimum cap.
  133.   # This means that if the character's final speed value reached 10, but the
  134.   # maximum cap here is set to 8, it will be reduced to the value of the cap,
  135.   # so, instead of being 10, it will be 8 at the end.
  136.   # The minimum cap can NOT be lower than 1!
  137.   #-----------------------------------------------------------------------------
  138.   AbsMaxCap = 8
  139.   AbsMinCap = 1
  140.  
  141. end
  142. #===============================================================================
  143. # End of Settings! Do not edit below this line unless pink pigs are flying!
  144. #===============================================================================
  145.  
  146. class Game_CharacterBase
  147.  
  148.   alias add_equip_effs7643 real_move_speed
  149.   def real_move_speed
  150.     if self.is_a?(Game_Player) &&
  151.        ((SpeedBonus::DashOnly == true && dash?) || SpeedBonus::DashOnly == false)
  152.       base = add_equip_effs7643
  153.       return base if $game_switches[SpeedBonus::DisableSwitch]
  154.       base += base * $game_party.speed_bonus
  155.       return [[base,SpeedBonus::AbsMinCap].max,SpeedBonus::AbsMaxCap].min
  156.     elsif self.is_a?(Game_Event) && @enemy
  157.       base = add_equip_effs7643
  158.       return base if $game_switches[SpeedBonus::DisableSwitch]
  159.       base += base * @enemy.speed_bonus
  160.       return [[base,SpeedBonus::AbsMinCap].max,SpeedBonus::AbsMaxCap].min
  161.     else
  162.       return add_equip_effs7643
  163.     end
  164.   end
  165.  
  166. end
  167.  
  168. class Game_Party < Game_Unit
  169.  
  170.   def speed_bonus
  171.     bonus = 0
  172.     if SpeedBonus::LeaderOnly == true
  173.       leader.feature_objects.each {|eq| bonus += eq.speed_bonus if !eq.nil? }
  174.     else
  175.       battle_members.each do |mem|
  176.         mem.feature_objects.each {|eq| bonus += eq.speed_bonus if !eq.nil? }
  177.       end
  178.     end
  179.     return [[bonus,SpeedBonus::MinBonus].max,SpeedBonus::MaxBonus].min
  180.   end
  181.  
  182. end
  183.  
  184. class Game_Enemy < Game_Battler
  185.  
  186.   def speed_bonus
  187.     bonus = 0
  188.     feature_objects.each {|eq| bonus += eq.speed_bonus if !eq.nil? }
  189.     return [[bonus,SpeedBonus::MinBonus].max,SpeedBonus::MaxBonus].min
  190.   end
  191.    
  192. end
  193.  
  194. class RPG::BaseItem
  195.  
  196.   attr_accessor :speed_bonus
  197.  
  198.   def speed_bonus
  199.     get_speed_bonus if @speed_bonus.nil?
  200.     return @speed_bonus  
  201.   end
  202.  
  203.   def get_speed_bonus
  204.     @speed_bonus = @note =~ /<speed bonus: ([+\-]\d+)>/i ? $1.to_i * 0.01 : 0
  205.     return @speed_bonus
  206.   end
  207.  
  208. end
  209. #==============================================================================
  210. # !!END OF SCRIPT - OHH, NOES!!
  211. #==============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement