Advertisement
TroyZ

TroyZ - Guard Rate Mods

Jun 10th, 2013
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.75 KB | None | 0 0
  1. # ==============================================================================
  2. # ▼▼▼▼▼▼                   TroyZ - Guard Rate Mods                        ▼▼▼▼▼▼
  3. # ==============================================================================
  4. # Script by : Agung Prasetyo(TroyZ)
  5. # Contact me by : - Email agung.endisnear.xyz@gmail.com
  6. #                 - Forum RPGMakerID, username TroyZ
  7. #                 - Handphone 085756289121
  8. # Engine : VXAce
  9. # Level : Easy
  10. # Version : 1.0
  11. # ------------------------------------------------------------------------------
  12. # Change Logs :
  13. # 10 June 2013 : Version 1.0 released
  14. # ------------------------------------------------------------------------------
  15. # How this work :
  16. # As default, the damage will be reduced by half when guarding. This script
  17. # allows you to change the default damage reduced when guarding.
  18. # ------------------------------------------------------------------------------
  19. # How to use :
  20. # Place it between material and main. Use this notetag :
  21. # <guard rate: x>
  22. # To apply custom damage reducer when guarding. Only applies to actors and enemies.
  23. # For example, this notetag goes into the first actor in the database :
  24. # <guard rate: 3>
  25. # Means that, income damage when guarding will be divided by 3
  26. # ------------------------------------------------------------------------------
  27. # Who to credit :
  28. # - Allah swt. : For the chance of living that he has given to me.
  29. # - Nabi Muhammad saw. : As a leader and messenger and prophet of Islam.
  30. #                        I'm proud to be your follower. :)
  31. # - Agung Prasetyo(TroyZ) : Thats me, of course, the ones that made this script. :P
  32. # ------------------------------------------------------------------------------
  33. # License :
  34. # - Free Game : Just credit those names above.
  35. # - Commercial Game : Same as free game's license + the full version of your
  36. #                     commercially game given to me free of charge. :P
  37. # ------------------------------------------------------------------------------
  38. $imported = {} if $imported.nil?
  39. $imported[:TroyZ_GuardRateMods] = true
  40.  
  41. # ------------------------------------------------------------------------------
  42. # Configuration of script starts here
  43. # ------------------------------------------------------------------------------
  44. module AGUNG
  45.   module GUARD_RATE
  46.     GUARD_RATE_DEFAULT = 2 # when guarding, damage will be divided by this
  47.                            # default number
  48.   end
  49.  
  50.   module NOTETAGS_GUARD_RATE
  51.     GUARD_RATE = /<(?:GUARD RATE|guard rate):[ ]*(\d+)>/i
  52.   end
  53. end
  54. # ------------------------------------------------------------------------------
  55. # End of configuration
  56. # ------------------------------------------------------------------------------
  57. module DataManager
  58.   # ----------------------------------------------------------------------------
  59.   # Alias method, for notetags using
  60.   # ----------------------------------------------------------------------------
  61.   class << self
  62.     alias agung_load_guard_rate_dbase_x    load_database
  63.   end
  64.  
  65.   def self.load_database
  66.     agung_load_guard_rate_dbase_x
  67.     agung_load_guard_rate_notetags_x
  68.   end
  69.  
  70.   # ----------------------------------------------------------------------------
  71.   # New method, to use notetags
  72.   # ----------------------------------------------------------------------------
  73.   def self.agung_load_guard_rate_notetags_x
  74.     [$data_actors,$data_enemies].each do |dbase|
  75.         dbase.compact.each do |groups|
  76.           groups.agung_load_guard_rate_x
  77.         end
  78.     end
  79.   end
  80. end
  81.  
  82. class RPG::Actor < RPG::BaseItem
  83.   # ----------------------------------------------------------------------------
  84.   # New accessor, to store guard rate
  85.   # ----------------------------------------------------------------------------
  86.   attr_accessor :guard_rate
  87.  
  88.   # ----------------------------------------------------------------------------
  89.   # New method, to load guard rate notetags
  90.   # ----------------------------------------------------------------------------
  91.   def agung_load_guard_rate_x
  92.     @guard_rate = AGUNG::GUARD_RATE::GUARD_RATE_DEFAULT
  93.     self.note.split(/[\r\n]+/).each { |baris|
  94.       case baris
  95.       when AGUNG::NOTETAGS_GUARD_RATE::GUARD_RATE
  96.         @guard_rate = $1.to_i
  97.       end
  98.     }
  99.   end
  100. end
  101.  
  102. class RPG::Enemy < RPG::BaseItem
  103.   # ----------------------------------------------------------------------------
  104.   # New accessor, to store guard rate
  105.   # ----------------------------------------------------------------------------
  106.   attr_accessor :guard_rate
  107.  
  108.   # ----------------------------------------------------------------------------
  109.   # New method, to load guard rate notetags
  110.   # ----------------------------------------------------------------------------
  111.   def agung_load_guard_rate_x
  112.     @guard_rate = AGUNG::GUARD_RATE::GUARD_RATE_DEFAULT
  113.     self.note.split(/[\r\n]+/).each { |baris|
  114.       case baris
  115.       when AGUNG::NOTETAGS_GUARD_RATE::GUARD_RATE
  116.         @guard_rate = $1.to_i
  117.       end
  118.     }
  119.   end
  120. end
  121.  
  122. class Game_Battler < Game_BattlerBase
  123.   # ----------------------------------------------------------------------------
  124.   # Overwrite method, to check who is guarding, and calculate the rate damage
  125.   # ----------------------------------------------------------------------------  
  126.   def apply_guard(damage)
  127.     return damage / (damage > 0 && guard? ? $data_actors[id].guard_rate * grd : 1) if actor?
  128.     return damage / (damage > 0 && guard? ? $data_enemies[@enemy_id].guard_rate * grd : 1) if enemy?
  129.     damage / (damage > 0 && guard? ? 2 * grd : 1)
  130.   end
  131. end
  132. # ------------------------------------------------------------------------------
  133. # END OF SCRIPT
  134. # ------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement