Advertisement
Dekita

simplehpgauge1.4

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