Advertisement
lavendersiren

HP/SP/EXP Meter edit (broken)

Nov 26th, 2017
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.89 KB | None | 0 0
  1. #==============================================================================
  2. # Add-On: HP/SP/EXP Meter
  3. # by Atoa
  4. # edited by shinyjiggly/lavendersiren
  5. #==============================================================================
  6. # Adds HP/SP/EXP Meters
  7. # Remove this Add-On if you wish to use custom HP/SP/EXP bars
  8. # This Add-On must be always bellow 'ACBS | Battle Windows'
  9. # if you are using it
  10. #note: the edits are unfinished and currently only affect the hp bar.
  11. #they will be applied to the sp bar eventually.
  12. #==============================================================================
  13.  
  14. module Atoa
  15. HP_Meter = 'HPMeter' # Name of the HP meter graphic file
  16. HP_Meter2 = 'HPMeter2' # Name of the vertical HP meter graphic file
  17. SP_Meter = 'SPMeter' # Name of the SP meter graphic file
  18. EXP_Meter = 'EXPMeter' # Name of the EXP meter graphic file
  19.  
  20.  
  21. # Bars position adjust
  22. # [x, y]
  23. HP_Pos_Adjust = [20, 0]
  24. SP_Pos_Adjust = [20, 0]
  25. EXP_Pos_Adjust = [20, 0]
  26. end
  27.  
  28. #==============================================================================
  29. # ■ Game_Actor
  30. #==============================================================================
  31. class Game_Actor < Game_Battler
  32. #--------------------------------------------------------------------------
  33. def now_exp
  34. return @exp - @exp_list[@level]
  35. end
  36. #--------------------------------------------------------------------------
  37. def next_exp
  38. return @exp_list[@level+1] > 0 ? @exp_list[@level+1] - @exp_list[@level] : 0
  39. end
  40. end
  41.  
  42. #==============================================================================
  43. # ■ Window_Base
  44. #==============================================================================
  45. class Window_Base < Window
  46. #--------------------------------------------------------------------------
  47. include Atoa
  48. #--------------------------------------------------------------------------
  49. horizontal_bars = false
  50. #this is over here because putting it up higher in the script just gave errors.
  51. #kinda nooby with ruby here so bear with me.
  52. #ideally this should be able to be changed elsewhere or something
  53.  
  54. alias draw_actor_hp_bar draw_actor_hp
  55. if horizontal_bars == true
  56. def draw_actor_hp(actor, x, y, width = 144)
  57. #is defining the same thing differently even a good idea? it doesn't particularly strike me as being so. idk.
  58. bar_x = HP_Pos_Adjust[0] + x
  59. bar_y = HP_Pos_Adjust[1] + y + (Font.default_size * 2 /3)
  60. @skin = RPG::Cache.windowskin(HP_Meter)
  61. @width = @skin.width
  62. @height = @skin.height / 3
  63. src_rect = Rect.new(0, 0, @width, @height) #edit
  64. self.contents.blt(bar_x, bar_y, @skin, src_rect)
  65. @line = (actor.hp == actor.maxhp ? 2 : 1)
  66. @amount = 100 * actor.hp / actor.maxhp
  67. src_rect2 = Rect.new(0, @line * @height, @width * @amount / 100, @height)
  68. self.contents.blt(bar_x, bar_y, @skin, src_rect2)
  69. draw_actor_hp_bar(actor, x, y, width)
  70. end
  71. else #vertical version
  72. def draw_actor_hp(actor, x, y, width = 144) #draws the numbers
  73. #global positions of the bars
  74. bar_x = HP_Pos_Adjust[0] + x + (Font.default_size * 2 /3)
  75. #parens thing makes sure it's in the right spot on the menu
  76. bar_y = HP_Pos_Adjust[1] + y
  77. @skin = RPG::Cache.windowskin(HP_Meter2)#the windowskin used
  78. @width = @skin.width / 3 #splits it into 3 parts
  79. @height = @skin.height #basic height
  80. #these are presumibly used to get a measure for how large to make the bars
  81.  
  82. src_rect = Rect.new(0, 0, @width, @height) #bar background setup
  83. #x coords, y coords, image used, rectangle to draw
  84. self.contents.blt(bar_x, bar_y, @skin, src_rect) #base rectangle for back
  85.  
  86. @line = (actor.hp == actor.maxhp ? 2 : 1) #which line is it using
  87. @amount = 100 * actor.hp / actor.maxhp #percent of hp remaining
  88.  
  89. #selects the proper bar, selects the y
  90. src_rect2 = Rect.new(@line * @width , 0 , @width , @height * @amount / 100) #the action rectangle
  91. self.contents.blt(bar_x, bar_y , @skin, src_rect2) #bacon lettuce tomato
  92. #x coord, y coord, bitmap, rectangle
  93. #important note: this thing drains the bar the wrong way, even when I've attempted to flip the bar.
  94. #that winds up only flipping the graphics
  95. draw_actor_hp_bar(actor, x, y, width)
  96. end
  97. end
  98. #--------------------------------------------------------------------------
  99. alias draw_actor_sp_bar draw_actor_sp
  100. def draw_actor_sp(actor, x, y, width = 144)
  101. bar_x = SP_Pos_Adjust[0] + x
  102. bar_y = SP_Pos_Adjust[1] + y + (Font.default_size * 2 /3)
  103. @skin = RPG::Cache.windowskin(SP_Meter)
  104. @width = @skin.width
  105. @height = @skin.height / 3
  106. src_rect = Rect.new(0, 0, @width, @height)
  107. self.contents.blt(bar_x, bar_y, @skin, src_rect)
  108. @line = (actor.sp == actor.maxsp ? 2 : 1)
  109. @amount = (actor.maxsp == 0 ? 0 : 100 * actor.sp / actor.maxsp)
  110. src_rect2 = Rect.new(0, @line * @height, @width * @amount / 100, @height)
  111. self.contents.blt(bar_x, bar_y, @skin, src_rect2)
  112. draw_actor_sp_bar(actor, x, y, width)
  113. end
  114. #--------------------------------------------------------------------------
  115. alias draw_actor_exp_bar draw_actor_exp
  116. def draw_actor_exp(actor, x, y)
  117. bar_x = EXP_Pos_Adjust[0] + x
  118. bar_y = EXP_Pos_Adjust[1] + y + (Font.default_size * 2 /3)
  119. @skin = RPG::Cache.windowskin(EXP_Meter)
  120. @width = @skin.width
  121. @height = @skin.height / 3
  122. src_rect = Rect.new(0, 0, @width, @height)
  123. self.contents.blt(bar_x, bar_y, @skin, src_rect)
  124. @line = (actor.now_exp == actor.next_exp ? 2 : 1)
  125. @amount = (actor.next_exp == 0 ? 0 : 100 * actor.now_exp / actor.next_exp)
  126. src_rect2 = Rect.new(0, @line * @height, @width * @amount / 100, @height)
  127. self.contents.blt(bar_x, bar_y, @skin, src_rect2)
  128. draw_actor_exp_bar(actor, x, y)
  129. end
  130. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement