Show Enemy HP Gauge + (de)buffs

Hi!


I'm looking for a script that shows enemy hp gauges and buffs/debuffs which are applied to them.


It needs to be compatible with YEA Battle System (and Luna Engine). I looked into HP gauges from Moghunter and YEA, but sadly they don't seem to show (de)buffs. Luna's own hp gauge system seems a tad bugged.


Anyone knows a script that does?
Try this:


http://forums.rpgmakerweb.com/index.php?/topic/697-enemy-hp-bars/


I know it can be modified for status as well. I've done it.
Thank you.


How did you do that, if I may ask? I am not a scripter so I honesly wouldn't know how to do that, heh.
Hello.

I did something similar a long time ago.

I modified the script a bit to make it customizable.

Spoiler
#==============================================================================# Display State icons# By Lecode#==============================================================================module Lecode_StatesIcons #- :top or :bottom Position = :top Offset_X = 0 Offset_Y = 0 #- Space between icons Space = 2 #- false = show only when the battler is selected Always_Visible = true #- Icons z Z = 5 Opacity = 205 endclass LeState_Icons def initialize(battler,sprite) @battler = battler @sprite = sprite @last_record = [] @icons = [] end def update return if @battler.nil? update_icons refresh_icons update_positions update_visibility end def update_icons @icons.each { |i| i.update } end def refresh_icons dispose_icons if @battler.dead? return if @battler.dead? return if @battler.states == @last_record @last_record = @battler.states dispose_icons x = 0 @battler.states.each { |state| icon = Sprite.new icon.bitmap = Bitmap.new(24,24) icon_index = state.icon_index bitmap = Cache.system("Iconset") rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24) icon.bitmap.blt(0, 0, bitmap, rect) icon.x = x icon.z = Lecode_StatesIcons::Z icon.opacity = Lecode_StatesIcons:😮pacity x += 24 @icons.push(icon) } end def update_positions total_width = @icons.size*(24+space) x = @battler.screen_x - total_width/2 if position == :top y = @battler.screen_y - @sprite.height - 24 else y = @battler.screen_y - 24 end x += Lecode_StatesIcons:😮ffset_X y += Lecode_StatesIcons:😮ffset_Y @icons.each_with_index { |ic,i| ic.x = x+i*(24+space) ic.y = y } end def update_visibility @icons.each { |i| i.visible = visible? } end def visible? return true if Lecode_StatesIcons::Always_Visible return false unless SceneManager.scene_is?(Scene_Battle) return false unless SceneManager.scene.enemy_window.visible return true if SceneManager.scene.enemy_window.enemy == @battler return true if SceneManager.scene.enemy_window.select_all? return false end def space Lecode_StatesIcons::Space end def position Lecode_StatesIcons:😛osition end def dispose_icons @icons.each { |i| i.bitmap.dispose i.dispose } @icons.clear end endclass Sprite_Battler < Sprite_Base alias lecode_siinitialize initialize def initialize(viewport, battler = nil) lecode_siinitialize(viewport, battler) @state_icons = LeState_Icons.new(@battler,self) end alias lecode_sidispose dispose def dispose lecode_sidispose @state_icons.dispose_icons end alias lecode_siupdate update def update lecode_siupdate @state_icons.update end endclass Scene_Battle attr_reader :enemy_windowend 
It simply displays the states icons, so you need another script for the bars.

I tested with yea HP bar and it works well.
Awesome, that works. Would your code be allowed for commercial, eventually?


And is it possible to have a turn counter too? 😛
Awesome, that works. Would your code be allowed for commercial, eventually?
Yeah, absolutely.

And is it possible to have a turn counter too?  😛  
Good idea. I'll do that.
Awesome 😀 looking forward to it!
Voila.

Spoiler
#==============================================================================# Display State icons# By Lecode# Requested from BCj#----------------------=beginFree to use in commercial games as long as you credit me=end#==============================================================================module Lecode_StatesIcons #- :top or :bottom Position = :bottom Offset_X = 0 Offset_Y = 0 #- Space between icons Space = 2 #- false = show only when the battler is selected Always_Visible = true #- Icons z Z = 5 Opacity = 205 #- Show turn count ? Turn_Count= true TC_Size = 16 TC_Color = Color.new(255,255,255) #- Change text color when current turn count = TC_Warning_Turn TC_Warning_Turn = 1 TC_Warning_Color = Color.new(245,100,100) TC_Warning_Blink = true TC_Blink_Color = Color.new(255,255,255) TC_Blink_Duration = 30 #- Wait x frames before looping TC_Blink_Wait = 5 end#==============================================================================# END OF CONFIGURATION#==============================================================================class LeState_Icons def initialize(battler,sprite) @battler = battler @sprite = sprite @last_record = [] @icons = [] @turns = [] @blinking_ics = [] @blink_frame = 0 end def update return if @battler.nil? update_icons refresh_icons update_positions update_visibility update_blinks end def update_icons @icons.each { |i| i.update } @turns.each { |i| i.update } end def refresh_icons dispose_icons if @battler.dead? return if @battler.dead? return if current_record == @last_record @last_record = @battler.states dispose_icons @battler.states.each { |state| #- Icon icon = Sprite.new icon.bitmap = Bitmap.new(24,24) icon_index = state.icon_index bitmap = Cache.system("Iconset") rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24) icon.bitmap.blt(0, 0, bitmap, rect) icon.z = Lecode_StatesIcons::Z icon.opacity = Lecode_StatesIcons:😮pacity @icons.push(icon) #- Turn count turn_count = @battler.state_turns[state.id] tc_sprite = Sprite.new dum_bitmap = Bitmap.new(1,1) dum_bitmap.font.size = Lecode_StatesIcons::TC_Size rect = dum_bitmap.text_size(turn_count) tc_sprite.bitmap = Bitmap.new(rect.width+4,rect.height+4) tc_sprite.bitmap.font.size = Lecode_StatesIcons::TC_Size if turn_count == Lecode_StatesIcons::TC_Warning_Turn tc_sprite.bitmap.font.color = Lecode_StatesIcons::TC_Warning_Color else tc_sprite.bitmap.font.color = Lecode_StatesIcons::TC_Color end if state.auto_removal_timing == 2 tc_sprite.bitmap.draw_text(0,0,rect.width+2,rect.height+2,turn_count.to_s) end tc_sprite.z = icon.z+1 @turns.push(tc_sprite) if Lecode_StatesIcons::TC_Warning_Blink && state.auto_removal_timing == 2 start_blink(icon) if turn_count == Lecode_StatesIcons::TC_Warning_Turn end #- @last_record.push(turn_count) } @blink_frame = Lecode_StatesIcons::TC_Blink_Duration end def current_record arr = @battler.states @battler.states.each { |s| arr.push(@battler.state_turns[s.id]) } return arr end def start_blink(sprite) @blinking_ics.push(sprite) end def update_positions #- Icons total_width = @icons.size*(24+space) x = @battler.screen_x - total_width/2 if position == :top y = @battler.screen_y - @sprite.height - 24 else y = @battler.screen_y - 24 end x += Lecode_StatesIcons:😮ffset_X y += Lecode_StatesIcons:😮ffset_Y @icons.each_with_index { |ic,i| ic.x = x+i*(24+space) ic.y = y } #- Turn counts @turns.each_with_index { |ic,i| ic.x = x+i*(24+space) ic.y = y } end def update_visibility @icons.each { |i| i.visible = visible? } @turns.each { |i| i.visible = visible? } end def visible? return true if Lecode_StatesIcons::Always_Visible return false unless SceneManager.scene_is?(Scene_Battle) return false unless SceneManager.scene.enemy_window.visible return true if SceneManager.scene.enemy_window.enemy == @battler return true if SceneManager.scene.enemy_window.select_all? return false end def update_blinks color = Lecode_StatesIcons::TC_Blink_Color duration = Lecode_StatesIcons::TC_Blink_Duration wait = Lecode_StatesIcons::TC_Blink_Wait @blink_frame = [@blink_frame+1,duration+wait].min if @blink_frame == duration+wait @blink_frame = 0 @blinking_ics.each { |ic| ic.flash(color,duration) } end end def space Lecode_StatesIcons::Space end def position Lecode_StatesIcons:😛osition end def dispose_icons @icons.each { |i| i.bitmap.dispose i.dispose } @icons.clear @turns.each { |i| i.bitmap.dispose i.dispose } @turns.clear @blinking_ics.clear end endclass Sprite_Battler < Sprite_Base alias lecode_siinitialize initialize def initialize(viewport, battler = nil) lecode_siinitialize(viewport, battler) @state_icons = LeState_Icons.new(@battler,self) end alias lecode_sidispose dispose def dispose lecode_sidispose @state_icons.dispose_icons end alias lecode_siupdate update def update lecode_siupdate @state_icons.update end endclass Scene_Battle attr_reader :enemy_windowendclass Game_Battler attr_reader :state_turnsend 
I also added a blink effect :B

http://i.imgur.com/Np00c5g.gifv
Amazing, wish I could give you more than one like 😀


Edit: Ahh there's a conflict with Yea Buff&State manager.


Guess these two don't work together 🙁
Why don't you use YEA Enemy Bars then? It's set up to work with YEA Buff and States manager. Or does that not work with your battle engine?

Edit: Saw OP. It *should* still work though, as I have debuffs showing on mine. Maybe a conflict with Luna?
Why don't you use YEA Enemy Bars then? It's set up to work with YEA Buff and States manager. Or does that not work with your battle engine?


Edit: Saw OP. It *should* still work though, as I have debuffs showing on mine. Maybe a conflict with Luna?
I use YEA Enemy HP Bars, but they don't show enemy (de)buffs for me.


And neither does Luna's own hp bars 🙁 (not to mention, Luna's own hp bars are glitchy and they are influenced by tint screens..)
Hmmm...mine might work because I don't use the add/remove buff commands, but instead treat them as states. I suppose that would be a stop gap solution, but I think it would not work well with your battle system (as I think you need them as buffs from what I saw playing the game).

Guess my idea won't work then, sorry.
Edit: Ahh there's a conflict with Yea Buff&State manager.

Guess these two don't work together 🙁
It should be ok now:

Spoiler
Code:
#==============================================================================# Display State icons# By Lecode# Requested from BCj#----------------------# Free to use in commercial games as long as you credit me#==============================================================================module Lecode_StatesIcons    #- :top or :bottom  Position = :bottom  Offset_X = 0  Offset_Y = 0    #- Space between icons  Space = 2    #- false = show only when the battler is selected  Always_Visible = true    #- Icons z  Z = 5  Opacity = 205    #- Show turn count ?  Turn_Count= true  TC_Size = 16  TC_Color = Color.new(255,255,255)    #- Change text color when current turn count = TC_Warning_Turn  TC_Warning_Turn = 1  TC_Warning_Color = Color.new(245,100,100)    TC_Warning_Blink = true  TC_Blink_Color = Color.new(255,255,255)  TC_Blink_Duration = 30  #- Wait x frames before looping  TC_Blink_Wait = 5  end#==============================================================================# END OF CONFIGURATION#==============================================================================class LeState_Icons    def initialize(battler,sprite)    @battler = battler    @sprite = sprite    @last_record = []    @icons = []    @turns = []    @blinking_ics = []    @blink_frame = 0  end    def update    return if @battler.nil?    update_icons    refresh_icons    update_positions    update_visibility    update_blinks  end    def update_icons    @icons.each { |i| i.update }    @turns.each { |i| i.update }  end    def refresh_icons    dispose_icons if @battler.dead?    return if @battler.dead?    return if current_record == @last_record    @last_record = @battler.states    dispose_icons    @battler.states.each { |state|      #- Icon      icon = Sprite.new      icon.bitmap = Bitmap.new(24,24)      icon_index = state.icon_index      bitmap = Cache.system("Iconset")      rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)      icon.bitmap.blt(0, 0, bitmap, rect)      icon.z = Lecode_StatesIcons::Z      icon.opacity = Lecode_StatesIcons::Opacity      @icons.push(icon)      #- Turn count      turn_count = state_turns(state)      tc_sprite = Sprite.new      dum_bitmap = Bitmap.new(1,1)      dum_bitmap.font.size = Lecode_StatesIcons::TC_Size      rect = dum_bitmap.text_size(turn_count)      tc_sprite.bitmap = Bitmap.new(rect.width+4,rect.height+4)      tc_sprite.bitmap.font.size = Lecode_StatesIcons::TC_Size      if turn_count == Lecode_StatesIcons::TC_Warning_Turn        tc_sprite.bitmap.font.color = Lecode_StatesIcons::TC_Warning_Color      else        tc_sprite.bitmap.font.color = Lecode_StatesIcons::TC_Color      end      if state.auto_removal_timing == 2        tc_sprite.bitmap.draw_text(0,0,rect.width+2,rect.height+2,turn_count.to_s)      end      tc_sprite.z = icon.z+1      @turns.push(tc_sprite)      if Lecode_StatesIcons::TC_Warning_Blink && state.auto_removal_timing == 2        start_blink(icon) if turn_count == Lecode_StatesIcons::TC_Warning_Turn      end      #-      @last_record.push(turn_count)    }    @blink_frame = Lecode_StatesIcons::TC_Blink_Duration  end    def current_record    arr = @battler.states    @battler.states.each { |s|      arr.push(state_turns(s))    }    return arr  end    def start_blink(sprite)    @blinking_ics.push(sprite)  end    def update_positions    #- Icons    total_width = @icons.size*(24+space)    x = @battler.screen_x - total_width/2    if position == :top      y = @battler.screen_y - @sprite.height - 24    else      y = @battler.screen_y - 24    end    x += Lecode_StatesIcons::Offset_X    y += Lecode_StatesIcons::Offset_Y    @icons.each_with_index { |ic,i|       ic.x = x+i*(24+space)      ic.y = y    }    #- Turn counts    @turns.each_with_index { |ic,i|      ic.x = x+i*(24+space)      ic.y = y    }  end    def update_visibility    @icons.each { |i| i.visible = visible? }    @turns.each { |i| i.visible = visible? }  end    def visible?    return true if Lecode_StatesIcons::Always_Visible    return false unless SceneManager.scene_is?(Scene_Battle)    return false unless SceneManager.scene.enemy_window.visible    return true if SceneManager.scene.enemy_window.enemy == @battler    return true if SceneManager.scene.enemy_window.select_all?    return false  end    def update_blinks    color = Lecode_StatesIcons::TC_Blink_Color    duration = Lecode_StatesIcons::TC_Blink_Duration    wait = Lecode_StatesIcons::TC_Blink_Wait    @blink_frame = [@blink_frame+1,duration+wait].min    if @blink_frame == duration+wait      @blink_frame = 0      @blinking_ics.each { |ic|        ic.flash(color,duration)      }    end  end    def space    Lecode_StatesIcons::Space  end    def position    Lecode_StatesIcons::Position  end    def state_turns(state)    if $imported["YEA-Buff&StateManager"]      return @battler.state_turns(state)    end    return @battler.state_turns[state.id]  end    def dispose_icons    @icons.each { |i| i.bitmap.dispose      i.dispose }    @icons.clear    @turns.each { |i| i.bitmap.dispose      i.dispose }    @turns.clear    @blinking_ics.clear  end  endclass Sprite_Battler < Sprite_Base    alias lecode_siinitialize initialize  def initialize(viewport, battler = nil)    lecode_siinitialize(viewport, battler)    @state_icons = LeState_Icons.new(@battler,self)  end    alias lecode_sidispose dispose  def dispose    lecode_sidispose    @state_icons.dispose_icons  end    alias lecode_siupdate update  def update    lecode_siupdate    @state_icons.update  end  endclass Scene_Battle  attr_reader :enemy_windowendunless $imported["YEA-Buff&StateManager"]class Game_Battler  attr_reader :state_turnsendend 
Yes! It works 😀
Code fixed.
Spoiler: Lecode Show State Icons
Ruby:
#==============================================================================
# Display State icons
# By Lecode
# Requested from BCj
#----------------------
# Free to use in commercial games as long as you credit me
#==============================================================================
module Lecode_StatesIcons
    #- :top or :bottom
    Position = :bottom
    Offset_X = 0
    Offset_Y = 0
    #- Space between icons
    Space = 2
    #- false = show only when the battler is selected
    Always_Visible = true
    #- Icons z
    Z = 5
    Opacity = 205
    #- Show turn count ?
    Turn_Count = true
    TC_Size = 16
    TC_Color = Color.new(255,255,255)
    #- Change text color when current turn count = TC_Warning_Turn
    TC_Warning_Turn = 1
    TC_Warning_Color = Color.new(245,100,100)
    TC_Warning_Blink = true
    TC_Blink_Color = Color.new(255,255,255)
    TC_Blink_Duration = 30
    #- Wait x frames before looping
    TC_Blink_Wait = 5
end
#==============================================================================
# END OF CONFIGURATION
#==============================================================================

class LeState_Icons
    def initialize(battler,sprite)
        @battler = battler
        @sprite = sprite
        @last_record = []
        @icons = []
        @turns = []
        @blinking_ics = []
        @blink_frame = 0
    end
    def update
        return if @battler.nil?
        update_icons
        refresh_icons
        update_positions
        update_visibility
        update_blinks
    end
    def update_icons
        @icons.each { |i| i.update }
        @turns.each { |i| i.update }
    end
    def refresh_icons
        dispose_icons if @battler.dead?
        return if @battler.dead?
        return if current_record == @last_record
        @last_record = @battler.states
        dispose_icons
        @battler.states.each { |state|
            #- Icon
            icon = Sprite.new
            icon.bitmap = Bitmap.new(24,24)
            icon_index = state.icon_index
            bitmap = Cache.system("Iconset")
            rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
            icon.bitmap.blt(0, 0, bitmap, rect)
            icon.z = Lecode_StatesIcons::Z
            icon.opacity = Lecode_StatesIcons::opacity
            @icons.push(icon)
            #- Turn count
            turn_count = state_turns(state)
            tc_sprite = Sprite.new
            dum_bitmap = Bitmap.new(1,1)
            dum_bitmap.font.size = Lecode_StatesIcons::TC_Size
            rect = dum_bitmap.text_size(turn_count)
            tc_sprite.bitmap = Bitmap.new(rect.width+4,rect.height+4)
            tc_sprite.bitmap.font.size = Lecode_StatesIcons::TC_Size
            if turn_count == Lecode_StatesIcons::TC_Warning_Turn
                tc_sprite.bitmap.font.color = Lecode_StatesIcons::TC_Warning_Color
            else
                tc_sprite.bitmap.font.color = Lecode_StatesIcons::TC_Color
            end
            if state.auto_removal_timing == 2
                tc_sprite.bitmap.draw_text(0,0,rect.width+2,rect.height+2,turn_count.to_s)
            end
            tc_sprite.z = icon.z+1
            @turns.push(tc_sprite)
            if Lecode_StatesIcons::TC_Warning_Blink && state.auto_removal_timing == 2
                start_blink(icon) if turn_count == Lecode_StatesIcons::TC_Warning_Turn
            end
            #- @last_record.push(turn_count)
            }
        @blink_frame = Lecode_StatesIcons::TC_Blink_Duration
    end
    def current_record
        arr = @battler.states
        @battler.states.each { |s| arr.push(state_turns(s)) }
        return arr
    end
    def start_blink(sprite)
        @blinking_ics.push(sprite)
    end
    def update_positions
        #- Icons
        total_width = @icons.size*(24+space)
        x = @battler.screen_x - total_width/2
        if position == :top
            y = @battler.screen_y - @sprite.height - 24
        else
            y = @battler.screen_y - 24
        end
        x += Lecode_StatesIcons::Offset_X
        y += Lecode_StatesIcons::Offset_Y
        @icons.each_with_index { |ic,i|
            ic.x = x+i*(24+space)
            ic.y = y
        }
        #- Turn counts
        @turns.each_with_index { |ic,i|
            ic.x = x+i*(24+space)
            ic.y = y
        }
    end
    def update_visibility
        @icons.each { |i| i.visible = visible? }
        @turns.each { |i| i.visible = visible? }
    end
    def visible?
        return true if Lecode_StatesIcons::Always_Visible
        return false unless SceneManager.scene_is?(Scene_Battle)
        return false unless SceneManager.scene.enemy_window.visible
        return true if SceneManager.scene.enemy_window.enemy == @battler
        return true if SceneManager.scene.enemy_window.select_all?
        return false
    end
    def update_blinks
        color = Lecode_StatesIcons::TC_Blink_Color
        duration = Lecode_StatesIcons::TC_Blink_Duration
        wait = Lecode_StatesIcons::TC_Blink_Wait
        @blink_frame = [@blink_frame+1,duration+wait].min
        if @blink_frame == duration+wait
            @blink_frame = 0
            @blinking_ics.each { |ic| ic.flash(color,duration) }
        end
    end
    def space
        Lecode_StatesIcons::Space
    end
    def position
        Lecode_StatesIcons::Position
    end
    def state_turns(state)
        if $imported["YEA-Buff&StateManager"]
            return @battler.state_turns(state)
        end
        return @battler.state_turns[state.id]
    end
    def dispose_icons
    @icons.each { |i|
        i.bitmap.dispose
        i.dispose
        }
        @icons.clear
        @turns.each { |i|
        i.bitmap.dispose
        i.dispose
        }
        @turns.clear
        @blinking_ics.clear
    end
end

class Sprite_Battler < Sprite_Base
    alias lecode_siinitialize initialize
    def initialize(viewport, battler = nil)
        lecode_siinitialize(viewport, battler)
        @state_icons = LeState_Icons.new(@battler,self)
    end
    alias lecode_sidispose dispose
    def dispose
        lecode_sidispose
        @state_icons.dispose_icons
    end
    alias lecode_siupdate update
    def update
        lecode_siupdate
        @state_icons.update
    end
end

class Scene_Battle
    attr_reader :enemy_window
end

unless $imported["YEA-Buff&StateManager"]
    class Game_Battler
    attr_reader :state_turns
    end
end
I don't know why you revived this very old thread but let me tell you that its update_visibility method is a real heavyweight. I mean, it wastes lots of milliseconds recalculating the result of visible? every single time it iterates through all of the @icons and @turns variables. It would have been better to just make that series of checks once before the code even iterates through all of the available @icons.
I don't know why you even bother replying to this, but

but let me tell you that its update_visibility method is a real heavyweight.
No, it's a weight, but not heavy.
Yes, you can make it more optimized. But If you have lag, it is most likely caused by something else and not this in particular.

Original thread: https://forums.rpgmakerweb.com/threads/show-enemy-hp-gauge-de-buffs.43717/