Advertisement
Dekita

hp gauge 1.2

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