Save-Point

Full Version: Save-Point
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Board Message
Sorry, you do not have permission to access this resource.
Save-Point - Show HP Bars under the enemy sprite?

Save-Point

Full Version: Show HP Bars under the enemy sprite?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Is it possible by a script to show an Enemy HP Bar under a specific sprite?
Which engine are you using? I think it was VX but I can't remember.
Also in which context do you need to see these bars? On the map?
(08-27-2012, 01:45 PM)MetalRenard Wrote: [ -> ]Which engine are you using? I think it was VX but I can't remember.
Also in which context do you need to see these bars? On the map?

Yes, I want the actor sprite on the map to have under him his HP Bar
and I want the Enemy sprite on the map to have under him directly his HP Bar

Is that possible in VXA?
Its all I ask no more and no less.

Could you help me with this because I searched for this a lot Sarcasm
I would surely give you a credit.

Here is the script from VX

Code:
#==============================================================================
# Vampyr HP Bars
#==============================================================================
if Vampyr_Kernel.enabled?("Vampyr SBABS")
#------------------------------------------------------------------------------
Vampyr_Kernel.register("Vampyr HP Bars", 1.1, "11/30/2009")
#------------------------------------------------------------------------------
class Vampyr_HPBars < Sprite

def initialize(viewport, parent)
super(viewport)
@parent = parent
@base = Cache.system("HP Base")
self.bitmap = Bitmap.new(@base.width, @base.height)
refresh
end

def update
super
refresh if something_changed?
end

def refresh
@old_x = self.x = @parent.screen_x-(self.bitmap.width/2)
@old_y = self.y = @parent.screen_y
@old_hp = @parent.actor.hp
@old_stolen = @parent.stolen
self.bitmap.clear
if (@parent.is_a?(Game_Event) or @parent.is_a?(Game_Monster)) and @parent.actor.overkill
bar = Cache.system("Overkill Bar")
elsif (@parent.is_a?(Game_Event) or @parent.is_a?(Game_Monster)) and @parent.actor.hp <= (@parent.actor.maxhp*15/100) and !@parent.stolen
bar = Cache.system("Enemy Steal Bar")
else
bar = (@parent.is_a?(Game_Ally) ? Cache.system("Ally HP Bar") : Cache.system("Enemy HP Bar"))
end
self.bitmap.blt(0, 0, @base, @base.rect)
rect = Rect.new(0, 0, bar.width*@parent.actor.hp/@parent.actor.maxhp, bar.height)
self.bitmap.blt(0, 0, bar, rect)
end

def something_changed?
return false if self.bitmap.disposed?
return true if @old_x != @parent.screen_x-(self.bitmap.width/2)
return true if @old_y != @parent.screen_y
return true if @old_hp != @parent.actor.hp
return true if @old_stolen != @parent.stolen
return false
end

def dispose
self.bitmap.dispose
super
end

end

#------------------------------------------------------------------------------
class Vampyr_BossHPBar < Sprite

def initialize(viewport, parent)
super(viewport)
@parent = parent
@base = Cache.system("Boss Base")
@bars = []
@values = []
@rects = []
for i in 0...@parent.boss
@bars[i] = Cache.system("Boss HP Bar ##{i+1}")
@values << (@parent.actor.maxhp.divmod @parent.boss)[0]*i
@rects[i] = @bars[i].rect
end
@values << @parent.actor.maxhp
self.bitmap = Bitmap.new(@base.width, @base.height)
self.x = (Graphics.width-self.bitmap.width)/2
self.y = Graphics.height-self.bitmap.height-48
refresh
end

def update
super
refresh if @old_hp != @parent.actor.hp
end

def refresh
@old_hp = @parent.actor.hp
self.bitmap.clear
self.bitmap.blt(0, 0, @base, @base.rect)
hp = @parent.actor.hp.divmod @parent.boss
max = @parent.actor.maxhp.divmod @parent.boss
for i in 0...@bars.size
next if @parent.actor.hp.between?(@values[i], @values[i+1])
next if @parent.actor.hp < @values[i]
self.bitmap.blt(0, 0, @bars[i], @bars[i].rect)
end
for i in 0...@bars.size
next unless @parent.actor.hp.between?(@values[i], @values[i+1])
x = @parent.actor.maxhp - @parent.actor.hp
y = @parent.actor.maxhp - @parent.actor.hp
z = max[0] - y % (max[0]+max[1])
@rects[i] = Rect.new(0, 0, @bars[i].width*z/(max[0]+max[1]), @bars[i].height)
self.bitmap.blt(0, 0, @bars[i], @rects[i])
end
end

def dispose
self.bitmap.dispose
super
end

end

#------------------------------------------------------------------------------
class Spriteset_Map

alias vampyr_sbabs_enemyhp_smap_initialize initialize
alias vampyr_sbabs_enemyhp_smap_update update
alias vampyr_sbabs_enemyhp_smap_dispose dispose
alias vampyr_sbabs_enemyhp_smap_refresh_characters refresh_characters

def initialize
@monsters_hp_bars = {}
@enemies_hp_bars = {}
@allies_hp_bars = {}
@boss_hud = nil
vampyr_sbabs_enemyhp_smap_initialize
end

def update
vampyr_sbabs_enemyhp_smap_update
update_monsters_hp_bars
update_enemies_hp_bars
update_boss_hp_bar
update_allies_hp_bars
end

def dispose
vampyr_sbabs_enemyhp_smap_dispose
dispose_bars
end

def update_enemies_hp_bars
for event in $game_map.events.values
next unless event.in_battle
next if event.boss > 0
if @enemies_hp_bars[event.id] == nil and $game_player.in_range?($game_player, event, 3) and !event.actor.dead?
next if event.object or event.puzzle
@enemies_hp_bars[event.id] = Vampyr_HPBars.new(@viewport1, event)
elsif @enemies_hp_bars[event.id] != nil and $game_player.in_range?($game_player, event, 3) and !event.actor.dead?
@enemies_hp_bars[event.id].update
elsif @enemies_hp_bars[event.id] != nil
@enemies_hp_bars[event.id].dispose
@enemies_hp_bars.delete(event.id)
end
end
end

def update_monsters_hp_bars
for monster in $game_monsters.compact
if @monsters_hp_bars[monster.id] == nil and $game_player.in_range?($game_player, monster, 3) and !monster.actor.dead?
@monsters_hp_bars[monster.id] = Vampyr_HPBars.new(@viewport1, monster)
elsif @monsters_hp_bars[monster.id] != nil and $game_player.in_range?($game_player, monster, 3) and !monster.actor.dead?
@monsters_hp_bars[monster.id].update
elsif @monsters_hp_bars[monster.id] != nil
@monsters_hp_bars[monster.id].dispose
@monsters_hp_bars.delete(monster.id)
end
end
end

def update_boss_hp_bar
for event in $game_map.events.values
next unless event.in_battle
next unless event.boss > 0
if @boss_hud == nil and !event.actor.dead?
@boss_hud = Vampyr_BossHPBar.new(@viewport3, event)
elsif @boss_hud != nil and !event.actor.dead?
@boss_hud.update
elsif @boss_hud != nil and event.actor.dead?
@boss_hud.dispose
@boss_hud = nil
end
end
end

def update_allies_hp_bars
for ally in $game_allies.compact
next if ally.map_id != $game_map.map_id
if @allies_hp_bars[ally.id] == nil and $game_player.in_range?($game_player, ally, 3) and !ally.actor.dead? and !$game_player.in_vehicle?
@allies_hp_bars[ally.id] = Vampyr_HPBars.new(@viewport1, ally)
elsif @allies_hp_bars[ally.id] != nil and $game_player.in_range?($game_player, ally, 3) and !ally.actor.dead? and !$game_player.in_vehicle?
@allies_hp_bars[ally.id].update
elsif @allies_hp_bars[ally.id] != nil
@allies_hp_bars[ally.id].dispose
@allies_hp_bars.delete(ally.id)
end
end
end

def refresh_characters
vampyr_sbabs_enemyhp_smap_refresh_characters
for i in @allies_hp_bars.values
i.dispose
end
@allies_hp_bars.clear
end

def dispose_bars
@monsters_hp_bars.values.compact.each { |i| i.dispose }
@enemies_hp_bars.values.compact.each { |i| i.dispose }
@allies_hp_bars.values.compact.each { |i| i.dispose }
@boss_hud.dispose if @boss_hud != nil
end

end
#------------------------------------------------------------------------------
end
Is it possible to convert this to ACE?
I myself cannot help you but someone who could help you needed the information I asked you for. Now they have a clear idea of what the problem is and what context the problem occurs in. It should make helping you out much easier. :)
Yea I can help you with this also. Like I said in your other topic it might take me a few days because I am busy with other stuff, but I will get it done for you.

and for future reference when your showing code can you put it in a spoiler, it makes it easier to scroll through the topic when we don't have to scroll through a bunch of code. Very cheery
(08-27-2012, 07:24 PM)Bravo2Kilo Wrote: [ -> ]Yea I can help you with this also. Like I said in your other topic it might take me a few days because I am busy with other stuff, but I will get it done for you.

and for future reference when your showing code can you put it in a spoiler, it makes it easier to scroll through the topic when we don't have to scroll through a bunch of code. Very cheery
Better late than never Blushing + Cheery
I just want the HP Bars Script not all of the other ABS script.

Just HP Bar under the enemy,
Thanks! Laughing

I will make sure I will give you a credit.