Advertisement
roninator2

Fomar0153 - Ticking HP Patched

Dec 6th, 2024
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 5.61 KB | None | 0 0
  1. #--------------------------------------------------------------------------
  2. # Ticking HP
  3. # by Fomar0153
  4. # Version 1.0
  5. # ----------------------
  6. # Notes
  7. # ----------------------
  8. # No requirements
  9. # Plug and play
  10. # not compatible with side view battle systems
  11. # ----------------------
  12. # Instructions
  13. # ----------------------
  14. # Just copy into your scripts in the Materials section.
  15. # ----------------------
  16. # Roninator2 fixes
  17. # Fixed healing not working outside battle
  18. # Fixed poison damage in battle
  19. #--------------------------------------------------------------------------
  20.  
  21. class Scene_Battle < Scene_Base
  22. #--------------------------------------------------------------------------
  23. # * Update Frame (Basic)
  24. #--------------------------------------------------------------------------
  25.     alias eb_update update
  26.     def update
  27.         eb_update
  28.         update_hp
  29.     end
  30. #--------------------------------------------------------------------------
  31. # * Update Frame (Basic)
  32. #--------------------------------------------------------------------------
  33.     alias eb_update_basic update_basic
  34.     def update_basic
  35.         eb_update_basic
  36.         update_hp
  37.     end
  38. #--------------------------------------------------------------------------
  39. # * Update HP
  40. #--------------------------------------------------------------------------
  41.     def update_hp
  42.         @last_check = 0 if @last_check == nil
  43.         return if @last_check == Graphics.frame_count
  44.         if Graphics.frame_count % 1 == 0 # change 60 to speed up or slow down
  45.             @last_check = Graphics.frame_count
  46.             for member in $game_party.members
  47.             member.roll_hp
  48.         end
  49.         @status_window.refresh
  50.         end
  51.     end
  52. end
  53.  
  54. class Game_Actor < Game_Battler
  55. #--------------------------------------------------------------------------
  56. # * Public Instance Variables
  57. #--------------------------------------------------------------------------
  58.     attr_accessor :hp_target
  59. #--------------------------------------------------------------------------
  60. # * Setup
  61. #--------------------------------------------------------------------------
  62.     alias eb_setup setup
  63.     def setup(actor_id)
  64.         eb_setup(actor_id)
  65.         @hp_target = 0
  66.     end
  67. #--------------------------------------------------------------------------
  68. # * Roll HP
  69. #--------------------------------------------------------------------------
  70.     def roll_hp
  71.         return if @hp_target == 0
  72.         @hp = [@hp + (@hp_target / @hp_target.abs), 0].max
  73.         @hp_target -= (@hp_target / @hp_target.abs)
  74.         @hp_target = 0 if @hp_target > 0 && @hp == mhp
  75.         refresh
  76.     end
  77. #--------------------------------------------------------------------------
  78. # * Dying?
  79. #--------------------------------------------------------------------------
  80.     def dying?
  81.         @hp + @hp_target <= 0
  82.     end
  83. #--------------------------------------------------------------------------
  84. # * Crisis?
  85. #--------------------------------------------------------------------------
  86.     def crisis?
  87.         @hp + @hp_target <= mhp / 4
  88.     end
  89. #--------------------------------------------------------------------------
  90. # * Damage Processing
  91. # @result.hp_damage @result.mp_damage @result.hp_drain
  92. # @result.mp_drain must be set before call.
  93. #--------------------------------------------------------------------------
  94.     def execute_damage(user)
  95.         on_damage(@result.hp_damage) if @result.hp_damage > 0
  96.     if SceneManager.scene_is?(Scene_Battle)
  97.       self.hp_target -= @result.hp_damage # ticking hp
  98.     else
  99.       self.hp -= @result.hp_damage
  100.     end
  101.     if self.hp < @result.hp_damage
  102.       self.hp = 0
  103.       @hp_target = 0
  104.     end
  105.         self.mp -= @result.mp_damage
  106.     user.hp += @result.hp_drain
  107.         user.mp += @result.mp_drain
  108.         refresh
  109.     end
  110. #--------------------------------------------------------------------------
  111. # * Regenerate Processing
  112. #--------------------------------------------------------------------------
  113.   def regenerate_hp
  114.     damage = -(mhp * hrg).to_i
  115.     perform_map_damage_effect if $game_party.in_battle && damage > 0
  116.     @result.hp_damage = [damage, max_slip_damage].min
  117.     if SceneManager.scene_is?(Scene_Battle)
  118.       self.hp_target -= @result.hp_damage # ticking hp
  119.     else
  120.       self.hp -= @result.hp_damage
  121.     end
  122.   end
  123. #--------------------------------------------------------------------------
  124. # * Processing at End of Battle
  125. #--------------------------------------------------------------------------
  126.     def on_battle_end
  127.         super
  128.         @hp_target = 0
  129.     end
  130. end
  131.  
  132. class Game_Enemy < Game_Battler
  133. #--------------------------------------------------------------------------
  134. # * Damage Processing
  135. # @result.hp_damage @result.mp_damage @result.hp_drain
  136. # @result.mp_drain must be set before call.
  137. #--------------------------------------------------------------------------
  138.     def execute_damage(user)
  139.         on_damage(@result.hp_damage) if @result.hp_damage > 0
  140.         self.hp -= @result.hp_damage
  141.         self.mp -= @result.mp_damage
  142.         user.hp_target += @result.hp_drain
  143.         user.mp += @result.mp_drain
  144.     end
  145. end
  146.  
  147. class Window_Base < Window
  148.   def critical_color;      text_color(18);  end;    # Critical
  149.   def wounded_color;      text_color(14);  end;    # Wounded
  150.   def crisis_color;      text_color(2);  end;    # Crisis 17
  151.   def knockout_color;      text_color(7);  end;    # Knockout 18
  152. #--------------------------------------------------------------------------
  153. # * Get HP Text Color
  154. #--------------------------------------------------------------------------
  155.     def hp_color(actor)
  156.         return knockout_color if actor.hp == 0
  157.         return critical_color if actor.hp < actor.mhp / 10 || actor.dying?
  158.         return crisis_color if actor.hp < actor.mhp / 4 || actor.crisis?
  159.         return wounded_color if actor.hp < actor.mhp / 2 || actor.crisis?
  160.         return normal_color
  161.     end
  162. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement