Guest User

Untitled

a guest
May 25th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. #==============================================================================
  2. # ** Window_Base
  3. #------------------------------------------------------------------------------
  4. # This window class holds new methods for drawing orb HP bars.
  5. #==============================================================================
  6.  
  7. class Window_Base
  8. #----------------------------------------------------------------------------
  9. # * Constants
  10. #----------------------------------------------------------------------------
  11. HPbitmap = RPG::Cache.windowskin('HPbitmap')
  12. SPbitmap = RPG::Cache.windowskin('SPbitmap')
  13. Disable_Switch_ID = 1
  14. #----------------------------------------------------------------------------
  15. # * Alias Listing
  16. #----------------------------------------------------------------------------
  17. alias_method(:sarkilas_draw_actor_hp, :draw_actor_hp)
  18. alias_method(:sarkilas_draw_actor_sp, :draw_actor_sp)
  19. #----------------------------------------------------------------------------
  20. # * Draw Actor HP
  21. #----------------------------------------------------------------------------
  22. def draw_actor_hp(actor, x, y, width = 144)
  23. draw_actor_orb_bar(actor, x, y, width, 'hp')
  24. sarkilas_draw_actor_hp(actor, x, y, width) unless $game_switches[Disable_Switch_ID]
  25. end
  26. #----------------------------------------------------------------------------
  27. # * Draw Actor SP
  28. #----------------------------------------------------------------------------
  29. def draw_actor_sp(actor, x, y, width = 144)
  30. draw_actor_orb_bar(actor, x, y, width, 'sp')
  31. sarkilas_draw_actor_sp(actor, x, y, width) unless $game_switches[Disable_Switch_ID]
  32. end
  33. #----------------------------------------------------------------------------
  34. # * Draw Actor bitmap Bar
  35. #----------------------------------------------------------------------------
  36. def draw_actor_orb_bar(actor, x, y, width, type)
  37. # Define specific values
  38. case type
  39. when 'hp'
  40. bitmap = HPbitmap
  41. pool = actor.hp
  42. perc = (pool * 100) / actor.maxhp
  43. when 'sp'
  44. bitmap = SPbitmap
  45. pool = actor.sp
  46. perc = (pool * 100) / actor.maxsp
  47. end
  48. amount = (width / bitmap.width).floor - 1
  49. full = ((perc - (perc % 10)) / 10) - (10 - amount)
  50. half = (perc % 10) > 0 ? 1 : 0 ; opacity = (perc % 10) * 18 + 95
  51. empty = amount - full - half
  52. rect = Rect.new(0,0,bitmap.width,bitmap.height)
  53. # Draw all orbs on position
  54. for i in 0...full
  55. self.contents.blt(x, y, bitmap, rect)
  56. x += bitmap.width + 4
  57. end
  58. # Draw half orb if valid
  59. unless half == 0
  60. self.contents.blt(x, y, bitmap, rect, opacity)
  61. x += bitmap.width + 4
  62. end
  63. # Draw empty orbs if valid
  64. for i in 0...empty
  65. self.contents.blt(x, y, bitmap, rect, 95)
  66. x += bitmap.width + 4
  67. end
  68. end
  69. end
Add Comment
Please, Sign In to add comment