Advertisement
Dekita

hp gauges 1.1

Apr 2nd, 2013
274
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.15 KB | None | 0 0
  1. if true # << Make true to use this script, false to disable.
  2. #===============================================================================
  3. #
  4. # ☆ $D13x - Simple HP Gauge
  5. # -- Author : Dekita
  6. # -- Version : 1.1
  7. # -- Level : Very Easy
  8. # -- Requires : N/A
  9. # -- Engine : RPG Maker VX Ace.
  10. #
  11. #===============================================================================
  12. # ☆ Import
  13. #-------------------------------------------------------------------------------
  14. $D13x={}if$D13x==nil
  15. $D13x[:NME_Gauges]=true
  16. #===============================================================================
  17. # ☆ Updates
  18. #-------------------------------------------------------------------------------
  19. # D /M /Y
  20. # 3o/o3/2o13 - Update, (only visible when enemy hit)
  21. # 28/o3/2o13 - Started, Finished,
  22. #
  23. #===============================================================================
  24. # ☆ Introduction
  25. #-------------------------------------------------------------------------------
  26. # A Simple Script to show Enemy Hp Gauges in battle, some customizable options
  27. # such as color, height, width.
  28. #
  29. # May also show for actors depending on your battle system :)
  30. #
  31. #===============================================================================
  32. # ★☆★☆★☆★☆★☆★☆★☆★ TERMS AND CONDITIONS: ☆★☆★☆★☆★☆★☆★☆★☆★☆
  33. #===============================================================================
  34. # 1. You MUST give credit to "Dekita" !!
  35. # 2. You are NOT allowed to repost this script.(or modified versions)
  36. # 3. You are NOT allowed to convert this script.
  37. # 4. You are NOT allowed to use this script for Commercial games.
  38. # 5. ENJOY!
  39. #
  40. # "FINE PRINT"
  41. # By using this script you hereby agree to the above terms and conditions,
  42. # if any violation of the above terms occurs "legal action" may be taken.
  43. # Not understanding the above terms and conditions does NOT mean that
  44. # they do not apply to you.
  45. # If you wish to discuss the terms and conditions in further detail you can
  46. # contact me at http://dekitarpg.wordpress.com/
  47. #
  48. #===============================================================================
  49. # ☆ Instructions
  50. #-------------------------------------------------------------------------------
  51. # Place Below " ▼ Materials " and Above " ▼ Main " in your script editor.
  52. #
  53. #===============================================================================
  54. module NME_HP_Bars
  55. #===============================================================================
  56. #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  57. # ☆ Basic Settings
  58. #--------------------------------------------------------------------------
  59. # Importance Value (reccommended = 200)
  60. Gauge_z = 200
  61. # Gauge Colors
  62. Hp_Color_1 = Color.new(182,64,0)
  63. Hp_Color_2 = Color.new(212,212,64)
  64. Outline_Color = Color.new(0,0,0,182)
  65. Empty_Color = Color.new(0,0,0,98)
  66. # Gauge Size
  67. Height = 5
  68. Width = 52
  69. # Visibility of Gauge
  70. Opacity = 255
  71. # Make this true to always see the hp gauge(s)
  72. Always_See = false
  73. #####################
  74. # CUSTOMISATION END #
  75. end #####################
  76. #☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★#
  77. # #
  78. # http://dekitarpg.wordpress.com/ #
  79. # #
  80. #★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆#
  81. #===============================================================================#
  82. # ARE YOU MODIFYING BEYOND THIS POINT? \.\. #
  83. # YES?\.\. #
  84. # OMG, REALLY? \| #
  85. # WELL SLAP MY FACE AND CALL ME A DRAGONITE.\..\.. #
  86. # I REALLY DIDN'T THINK YOU HAD IT IN YOU.\..\.. #
  87. #===============================================================================#
  88. class NME_HUD < Sprite
  89. #===============================================================================
  90. #--------------------------------------------------------------------------
  91. # Initialize
  92. #--------------------------------------------------------------------------
  93. def initialize(viewport = nil, battler = nil)
  94. super(viewport)
  95. @battler = battler
  96. @width = NME_HP_Bars::Width
  97. @height = NME_HP_Bars::Height
  98. self.bitmap = Bitmap.new(@width,@height)
  99. bgrap = Cache.battler(@battler.battler_name, 0)
  100. @_X = (@battler.screen_x) - (self.bitmap.width/2)
  101. @_Y = (@battler.screen_y) - (bgrap.height)
  102. reset_the_gauge(true)
  103. self.opacity = 0 unless NME_HP_Bars::Always_See
  104. end
  105. #--------------------------------------------------------------------------
  106. # Reset Gauge
  107. #--------------------------------------------------------------------------
  108. def reset_the_gauge(init=false)
  109. self.bitmap = Bitmap.new(@width,@height)
  110. empty_color = Color.new(0,0,0,128)
  111. color_1 = NME_HP_Bars::Hp_Color_1
  112. color_2 = NME_HP_Bars::Hp_Color_2
  113. @hp = @battler.hp
  114. @old_hp = @hp
  115. @max_hp = @battler.mhp
  116. rate = @battler.hp_rate
  117. fill = [(@width * rate).to_i, @width].min
  118. self.bitmap.fill_rect(0, 0, @width, @height, NME_HP_Bars::Outline_Color)
  119. self.bitmap.fill_rect(1, 1, @width-2, @height-2, NME_HP_Bars::Empty_Color)
  120. self.bitmap.gradient_fill_rect(1, 1, fill-2, @height-2, color_1, color_2)
  121. self.z = NME_HP_Bars::Gauge_z
  122. self.x = @_X
  123. self.y = @_Y - self.bitmap.height
  124. self.opacity = NME_HP_Bars::Opacity if @hp > 0 unless init
  125. end
  126. #--------------------------------------------------------------------------
  127. # Dispose
  128. #--------------------------------------------------------------------------
  129. def dispose
  130. super
  131. end
  132. #--------------------------------------------------------------------------
  133. # Update
  134. #--------------------------------------------------------------------------
  135. def update
  136. super
  137. reset_the_gauge if @battler.hp != @old_hp
  138. self.opacity -= 1 if self.opacity > 0 unless NME_HP_Bars::Always_See
  139. self.opacity -= 2 if @battler.hp <= 0
  140. end
  141.  
  142. end
  143.  
  144. #===============================================================================
  145. class Sprite_Battler < Sprite_Base
  146. #===============================================================================
  147. #--------------------------------------------------------------------------
  148. # Alias List
  149. #--------------------------------------------------------------------------
  150. alias :init_simple_gauge :initialize
  151. alias :dispose_simple_gauge :dispose
  152. alias :update_simple_gauge :update
  153. #--------------------------------------------------------------------------
  154. # Object Initialization
  155. #--------------------------------------------------------------------------
  156. def initialize(viewport, battler = nil)
  157. init_simple_gauge(viewport, battler)
  158. @gauge = NME_HUD.new(viewport, battler) if @battler
  159. end
  160. #--------------------------------------------------------------------------
  161. # Free
  162. #--------------------------------------------------------------------------
  163. def dispose
  164. @gauge.dispose if @gauge
  165. dispose_simple_gauge
  166. end
  167. #--------------------------------------------------------------------------
  168. # Frame Update
  169. #--------------------------------------------------------------------------
  170. def update
  171. update_simple_gauge
  172. @gauge.update if @gauge && @battler
  173. end
  174.  
  175. end
  176.  
  177. #==============================================================================#
  178. # http://dekitarpg.wordpress.com/ #
  179. #==============================================================================#
  180. end # if true # << Make true to use this script, false to disable.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement