Advertisement
TheoAllen

Theo - Wounded state

Feb 21st, 2013
532
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 8.69 KB | None | 0 0
  1. # =============================================================================
  2. # ♫ ~ Wounded state by TheoAllen ~ ♫
  3. # Version  : 1.1
  4. # Requires : N/A
  5. # Contact  : www.rpgmakerid.com
  6. # =============================================================================
  7. # ♫ UPDATES :
  8. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  9. # 2013.03.04 - Add notetags for actor and enemy
  10. # 2013.02.22 - Started and finished script
  11. #
  12. # =============================================================================
  13. # ♫ DESCRIPTION :
  14. # This script allow you to automatically add state if the characters or enemy
  15. # in wounded condition. To disable this automatic add state for some enemies or
  16. # characters, just simply put resist state in feature system
  17. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  18. # ♫ INSTRUCTION :
  19. # Put this script below material but above main in script editor. Don't forget
  20. # to save.
  21. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  22. # ♫ HOW TO USE :
  23. # -------------------------------
  24. # ACTOR AND ENEMY NOTETAGS
  25. # -------------------------------
  26. # <wounded cond: x%>
  27. # To specify wounded condition. Default value can be configured below.
  28. #
  29. # <wounded state: x>
  30. # To specify which state will be add if the battler met the wounded condition.
  31. # Default value can be configured below.
  32. # =============================================================================
  33. # ♫ TERMS OF USE :
  34. # - Credit me, TheoAllen. If you think it's necessary.
  35. # - You may use and edit this script both commercial and non-commercial or even
  36. #   adult game as long as u don't claim it's yours.
  37. # - I'll be glad if you give me a free copy of your game if you use this script
  38. #   in your commercial project.
  39. # =============================================================================
  40. $imported = {} if $imported.nil?
  41. $imported["Theo-WoundedState"] = true
  42. # =============================================================================
  43. # ♫ CONFIGURATIONS ~ ♫
  44. # =============================================================================
  45. module THEOLIZED
  46.   module WS
  47.    
  48.     WOUNDED_CONDITION = 0.25 # default percentage of wounded condition.
  49.     WOUNDED_STATE_ID = 0     # default wounded state ID
  50.  
  51.   end
  52. end
  53. # =============================================================================
  54. # ♫ Do not edit unless you know what to do ~ ♫
  55. # =============================================================================
  56. # SCRIPT INFOS :
  57. # -------------------------------------
  58. # Rewriten method :
  59. # N/A
  60. # -------------------------------------
  61. # Aliased method :
  62. # - DataManager
  63. #     def self.load_database
  64. # - Game_BattlerBase
  65. #     def refresh
  66. # =============================================================================
  67. # ♫ NOTETAGS ~ ♫
  68. # =============================================================================
  69. module THEOLIZED
  70.   module NOTETAGS_WS
  71.    
  72.     WOUNDED_COND  = /<(?:WOUNDED COND|wounded cond):[ ]*(\d+)([%])>/i
  73.     WOUNDED_STATE = /<(?:WOUNDED STATE|wounded state):[ ]*(\d+)>/i
  74.    
  75.   end
  76. end
  77. # =============================================================================
  78. # ♫ Module DataManager ~ ♫
  79. # =============================================================================
  80. module DataManager
  81.   #--------------------------------------------------------------------------
  82.   # ♫ Aliased load database
  83.   #--------------------------------------------------------------------------
  84.   class <<self; alias theolized_load_ws_db load_database; end
  85.   def self.load_database
  86.     theolized_load_ws_db
  87.     theolized_load_ws_notetags
  88.   end
  89.   #--------------------------------------------------------------------------
  90.   # ♫ Load wounded state notetags
  91.   #--------------------------------------------------------------------------
  92.   def self.theolized_load_ws_notetags
  93.     groups = [$data_enemies, $data_actors]
  94.     for group in groups
  95.       for obj in group
  96.         next if obj.nil?
  97.         obj.theolized_load_ws_notetags
  98.       end
  99.     end
  100.   end
  101. end
  102. # =============================================================================
  103. # ♫ RPG::Actor ~ ♫
  104. # =============================================================================
  105. class RPG::Actor
  106.   attr_accessor :wound_state
  107.   attr_accessor :wound_cond
  108.   #--------------------------------------------------------------------------
  109.   # ♫ Load wounded state notetags
  110.   #--------------------------------------------------------------------------
  111.   def theolized_load_ws_notetags
  112.     @wound_state = THEOLIZED::WS::WOUNDED_STATE_ID
  113.     @wound_cond  = THEOLIZED::WS::WOUNDED_CONDITION
  114.     self.note.split(/[\r\n]+/).each { |line|
  115.       case line
  116.       when THEOLIZED::NOTETAGS_WS::WOUNDED_COND
  117.         @wound_cond = $1.to_f * 0.01
  118.       when THEOLIZED::NOTETAGS_WS::WOUNDED_STATE
  119.         @wound_state = $1.to_i
  120.       end
  121.     }
  122.   end
  123.    
  124. end
  125. # =============================================================================
  126. # ♫ RPG::Enemy~ ♫
  127. # =============================================================================
  128. class RPG::Enemy
  129.   attr_accessor :wound_state
  130.   attr_accessor :wound_cond
  131.   #--------------------------------------------------------------------------
  132.   # ♫ Load wounded state notetags
  133.   #--------------------------------------------------------------------------
  134.   def theolized_load_ws_notetags
  135.     @wound_state = THEOLIZED::WS::WOUNDED_STATE_ID
  136.     @wound_cond  = THEOLIZED::WS::WOUNDED_CONDITION
  137.     self.note.split(/[\r\n]+/).each { |line|
  138.       case line
  139.       when THEOLIZED::NOTETAGS_WS::WOUNDED_COND
  140.         @wound_cond = $1.to_f * 0.01
  141.       when THEOLIZED::NOTETAGS_WS::WOUNDED_STATE
  142.         @wound_state = $1.to_i
  143.       end
  144.     }
  145.   end
  146.    
  147. end
  148. # =============================================================================
  149. # ♫ Game_BattlerBase ♫
  150. # =============================================================================
  151. class Game_BattlerBase
  152.   #--------------------------------------------------------------------------
  153.   # ♫ Aliased refresh
  154.   #--------------------------------------------------------------------------
  155.   alias theo_wound_refresh refresh
  156.   def refresh
  157.     theo_wound_refresh
  158.     apply_wounded_state
  159.   end
  160.   #--------------------------------------------------------------------------
  161.   # ♫ Check wounded
  162.   #--------------------------------------------------------------------------
  163.   def wounded?
  164.     return false
  165.   end
  166.   #--------------------------------------------------------------------------
  167.   # ♫ Get wounded state id
  168.   #--------------------------------------------------------------------------  
  169.   def wounded_state_id
  170.     return 0
  171.   end
  172.   #--------------------------------------------------------------------------
  173.   # ♫ Apply wounded state
  174.   #--------------------------------------------------------------------------
  175.   def apply_wounded_state
  176.     return if wounded_state_id <= 0
  177.     wounded? ? add_state(wounded_state_id) : remove_state(wounded_state_id)
  178.   end
  179. end
  180. # =============================================================================
  181. # ♫ Game_Actor ♫
  182. # =============================================================================
  183. class Game_Actor < Game_Battler
  184.   #--------------------------------------------------------------------------
  185.   # ♫ Check wounded
  186.   #--------------------------------------------------------------------------
  187.   def wounded?
  188.     return hp_rate <= $data_actors[id].wound_cond
  189.   end
  190.   #--------------------------------------------------------------------------
  191.   # ♫ Get wounded state id
  192.   #--------------------------------------------------------------------------
  193.   def wounded_state_id
  194.     return $data_actors[id].wound_state
  195.   end
  196.  
  197. end
  198. # =============================================================================
  199. # ♫ Game_Enemy ♫
  200. # =============================================================================
  201. class Game_Enemy < Game_Battler
  202.   #--------------------------------------------------------------------------
  203.   # ♫ Check wounded
  204.   #--------------------------------------------------------------------------
  205.   def wounded?
  206.     return hp_rate <= $data_enemies[@enemy_id].wound_cond
  207.   end
  208.   #--------------------------------------------------------------------------
  209.   # ♫ Get wounded state id
  210.   #--------------------------------------------------------------------------
  211.   def wounded_state_id
  212.     return $data_enemies[@enemy_id].wound_state
  213.   end
  214.  
  215. end
  216. # =============================================================================
  217. # ♫ End of Script ♫
  218. # =============================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement