Advertisement
Falmc

Pearl Party Hp Mp bars

Dec 6th, 2012
9,297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 2.84 KB | None | 0 0
  1. #===============================================================================
  2. # * Falcao Pearl ABS Party HUD Add-On
  3. #
  4. # This add-on display followers HP and MP bars on the current screen
  5. # For logic reasons the bars are displayed only while in battle
  6. # This script take the same colors of the Game Player HUD
  7. #
  8. # Website: http://falcaorgss.wordpress.com/
  9. # Foro: www.makerpalace.com
  10. #
  11. # * Intallation
  12. # Copy and paste the script below Pearl ABS Liquid system, edit module below
  13. # for convenience
  14. #-------------------------------------------------------------------------------
  15.  
  16. module PartyHud
  17.  
  18.   Pos_X = 0     # Position x on the screen
  19.   Pos_Y = 120   # Position Y on the screen
  20.  
  21. end
  22.  
  23. class PearlPartyHud < Sprite
  24.   include PearlBars
  25.   def initialize(viewport)
  26.     super(viewport)
  27.     self.bitmap = Bitmap.new(160, 180)
  28.     self.x = PartyHud::Pos_X
  29.     self.y = PartyHud::Pos_Y
  30.     @party = []
  31.     @old_data = {}
  32.     $game_player.followers.each {|f| @party << f.battler if f.visible?}
  33.     refresh_party_hud
  34.     update
  35.   end
  36.  
  37.   def refresh_party_hud
  38.     self.bitmap.clear
  39.     self.bitmap.font.size = 16
  40.     y = 0
  41.     hc = HP_Color ; mc = MP_Color
  42.     @party.each do |battler|                             # w    h
  43.       PearlKernel.draw_hp(self.bitmap, battler, 8, y + 30, 80,  8,  hc, true)
  44.       PearlKernel.draw_mp(self.bitmap, battler, 8, y + 43, 80,  8,  mc)
  45.       @old_data[battler.id] = [battler.hp, battler.mp]
  46.       y += 48
  47.     end
  48.   end
  49.  
  50.   def update
  51.     @party.each {|battler|
  52.     if @old_data[battler.id][0] != battler.hp
  53.       refresh_party_hud
  54.     elsif @old_data[battler.id][1] != battler.mp
  55.       refresh_party_hud
  56.     end}
  57.   end
  58.  
  59.   def dispose
  60.     self.bitmap.dispose
  61.     super
  62.   end
  63. end
  64.  
  65. class Spriteset_Map
  66.   alias falcaopearl_party_create create_pearl_abs_sprites
  67.   def create_pearl_abs_sprites
  68.     @framerr = 0
  69.     falcaopearl_party_create
  70.   end
  71.  
  72.   alias falcaopearl_party_update update_pearl_abs_main_sprites
  73.   def update_pearl_abs_main_sprites
  74.     update_party_hud_sprites
  75.     falcaopearl_party_update
  76.   end
  77.  
  78.   def update_party_hud_sprites
  79.     if $game_player.pearl_menu_call[1] == 1
  80.       dispose_party_hud
  81.       return
  82.     end
  83.     if @framerr == 0
  84.       if $game_player.follower_fighting?
  85.         create_party_hud
  86.       else ; dispose_party_hud
  87.       end
  88.     else
  89.       @framerr += 1
  90.       @framerr = 0 if @framerr == 10
  91.     end
  92.     @party_hud.update unless @party_hud.nil?
  93.   end
  94.  
  95.   def create_party_hud
  96.     return if !@party_hud.nil?
  97.     @party_hud = PearlPartyHud.new(@viewport2)
  98.   end
  99.  
  100.   def dispose_party_hud
  101.     return if @party_hud.nil?
  102.     @party_hud.dispose
  103.     @party_hud = nil
  104.   end
  105.  
  106.   alias falcaopearl_party_dispose dispose_pearl_main_sprites
  107.   def dispose_pearl_main_sprites
  108.     falcaopearl_party_dispose
  109.     dispose_party_hud
  110.   end
  111. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement