Advertisement
Dekita

Simple NME HP v1.0

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