RPGVX.net

  RPG-Maker VX => VX Technik [Frageforum] => Thema gestartet von: Michel am Juni 28, 2011, 22:32:12

Titel: Enemy HP Leiste für mein ABS
Beitrag von: Michel am Juni 28, 2011, 22:32:12
Hallo VX-Profis!

Ich benutze seit neustem das PR Active Battle System (http://www.rpgmakervx.net/index.php?showtopic=21110 (http://www.rpgmakervx.net/index.php?showtopic=21110)), das beinahe perfekt meinen Vorstellungen entspricht!

Jedoch gibt ein GROSSES Manko, das ich bei aller Mühe nicht allein beheben kann: Im aktiven Kampf wird beim Gegner keine HP-Leiste angezeigt, sondern lediglich Schadenspunkte!

So weiß ich nie, wie lange ich noch draufhauen muss, bis der Gegner stirbt =(

Nun, es andere ABS wie z.B. das Amethyst SBABS (http://www.rpgmakervx.net/index.php?showtopic=27983 (http://www.rpgmakervx.net/index.php?showtopic=27983)), die dieses Problem nicht haben, aber diese Systeme gefallen mir insgesamt nicht so gut wie das PRABS!

Hat jemand von euch Zeit, mir eine „Enemy HP Leiste“ für mein ABS zu basteln?

Ein Spezialist wird das recht schnell scripten können.
Ich glaube MelekTaus kennt sich bei solchen HUD-Fragen sehr gut aus!

Möglicherweise kann der HP-Bar-Code vom Amethyst SBABS weiterhelfen:
#==============================================================================
# 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

Ich wäre jedenfalls unendlich dankbar für diese Leistung!

Liebe Grüße

Michel
SimplePortal 2.3.3 © 2008-2010, SimplePortal