Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #==============================================================================
- # ** Window_Base
- #------------------------------------------------------------------------------
- # This window class holds new methods for drawing orb HP bars.
- #==============================================================================
- class Window_Base
- #----------------------------------------------------------------------------
- # * Constants
- #----------------------------------------------------------------------------
- HPbitmap = RPG::Cache.windowskin('HPbitmap')
- SPbitmap = RPG::Cache.windowskin('SPbitmap')
- Disable_Switch_ID = 1
- #----------------------------------------------------------------------------
- # * Alias Listing
- #----------------------------------------------------------------------------
- alias_method(:sarkilas_draw_actor_hp, :draw_actor_hp)
- alias_method(:sarkilas_draw_actor_sp, :draw_actor_sp)
- #----------------------------------------------------------------------------
- # * Draw Actor HP
- #----------------------------------------------------------------------------
- def draw_actor_hp(actor, x, y, width = 144)
- draw_actor_orb_bar(actor, x, y, width, 'hp')
- sarkilas_draw_actor_hp(actor, x, y, width) unless $game_switches[Disable_Switch_ID]
- end
- #----------------------------------------------------------------------------
- # * Draw Actor SP
- #----------------------------------------------------------------------------
- def draw_actor_sp(actor, x, y, width = 144)
- draw_actor_orb_bar(actor, x, y, width, 'sp')
- sarkilas_draw_actor_sp(actor, x, y, width) unless $game_switches[Disable_Switch_ID]
- end
- #----------------------------------------------------------------------------
- # * Draw Actor bitmap Bar
- #----------------------------------------------------------------------------
- def draw_actor_orb_bar(actor, x, y, width, type)
- # Define specific values
- case type
- when 'hp'
- bitmap = HPbitmap
- pool = actor.hp
- perc = (pool * 100) / actor.maxhp
- when 'sp'
- bitmap = SPbitmap
- pool = actor.sp
- perc = (pool * 100) / actor.maxsp
- end
- amount = (width / bitmap.width).floor - 1
- full = ((perc - (perc % 10)) / 10) - (10 - amount)
- half = (perc % 10) > 0 ? 1 : 0 ; opacity = (perc % 10) * 18 + 95
- empty = amount - full - half
- rect = Rect.new(0,0,bitmap.width,bitmap.height)
- # Draw all orbs on position
- for i in 0...full
- self.contents.blt(x, y, bitmap, rect)
- x += bitmap.width + 4
- end
- # Draw half orb if valid
- unless half == 0
- self.contents.blt(x, y, bitmap, rect, opacity)
- x += bitmap.width + 4
- end
- # Draw empty orbs if valid
- for i in 0...empty
- self.contents.blt(x, y, bitmap, rect, 95)
- x += bitmap.width + 4
- end
- end
- end
Add Comment
Please, Sign In to add comment