Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

2 Pages V  < 1 2  
Closed TopicStart new topic
> Submission: Enemy HP Window, by Noobitron
Night_Runner
post Jan 12 2010, 10:09 PM
Post #21


Level 50
Group Icon

Group: +Gold Member
Posts: 1,529
Type: Scripter
RM Skill: Undisclosed




Jens answered the question of more enemies in the #15 post, but this is a edited version that hides the enemy windows once the enemy is dead:

Code
CODE
# Breath of Fire Enemy window
# By Noobitron
# Slanted Bars by Sephiroth Spawn.
# Edited by NR (13/Jan/10)

class Window_Base
  # define enemy name
  def draw_enemy_name(enemy, x, y)
    self.contents.font.color = normal_color
    self.contents.draw_text(x, y, 120, 32, enemy.name)
  end
  
  #--------------------------------------------------------------------------
  # * Draw Slant Bar(by SephirothSpawn)
  #--------------------------------------------------------------------------
  def draw_slant_bar(x, y, min, max, width = 152, height = 6,
      bar_color = Color.new(150, 0, 0, 255), end_color = Color.new(255, 255, 60, 255))
    # Draw Border
    for i in 0..height
      self.contents.fill_rect(x + i, y + height - i, width + 1, 1, Color.new(50, 50, 50, 255))
    end
    # Draw Background
    for i in 1..(height - 1)
      r = 100 * (height - i) / height + 0 * i / height
      g = 100 * (height - i) / height + 0 * i / height
      b = 100 * (height - i) / height + 0 * i / height
      a = 255 * (height - i) / height + 255 * i / height
      self.contents.fill_rect(x + i, y + height - i, width, 1, Color.new(r, b, g, a))
    end
    # Draws Bar
    for i in 1..( (min / max.to_f) * width - 1)
      for j in 1..(height - 1)
        r = bar_color.red * (width - i) / width + end_color.red * i / width
        g = bar_color.green * (width - i) / width + end_color.green * i / width
        b = bar_color.blue * (width - i) / width + end_color.blue * i / width
        a = bar_color.alpha * (width - i) / width + end_color.alpha * i / width
        self.contents.fill_rect(x + i + j, y + height - j, 1, 1, Color.new(r, g, b, a))
      end
    end
  end
end



#ENEMY HP WINDOW
class Window_EnemyHP < Window_Base
  def initialize
    super(0, 0, 160, 480)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 0
    refresh
  end

  #REFRESH
  def refresh
  self.contents.clear
  i = 0
    for enemy in $game_troop.enemies
      i += 1
      next if enemy.hp <= 0
      x = 0
      y = i * 30
      draw_slant_bar(x, y + 25, enemy.hp, enemy.maxhp, width = 100, height = 6, bar_color = Color.new(150, 0, 0, 255), end_color = Color.new(255, 255, 60, 255))
      draw_slant_bar(x, y + 30, enemy.sp, enemy.maxsp, width = 100, height = 6, bar_color = Color.new(150, 0, 150, 255), end_color = Color.new(0, 0, 255, 255))
      draw_enemy_name(enemy, x, y)
     end
   end
end



class Scene_Battle
  
  alias nr_queed_main               main
  alias queed_update                update
  alias queed_update_phase5         update_phase5
  alias queed_update_phase4_step1   update_phase4_step1
  alias queed_update_phase4_step5   update_phase4_step5
  alias queed_start_skill_select    start_skill_select
  alias queed_end_skill_select      end_skill_select
  alias queed_start_item_select     start_item_select
  alias queed_end_item_select       end_item_select
  
  def main
    # Prepare troop
    @troop_id = $game_temp.battle_troop_id
    $game_troop.setup(@troop_id)
    # Make enemy window:
    @enemy_window = Window_EnemyHP.new
    @enemy_window.z = 250
    # Call original main
    nr_queed_main
    # Dispose of windows
    @enemy_window.dispose
  end
  
  def update
    @enemy_window.update
    queed_update
  end

  def start_skill_select
    queed_start_skill_select
    @enemy_window.visible = false
  end

  def end_skill_select
    queed_end_skill_select
    @enemy_window.visible = true
  end

  def start_item_select
    queed_start_item_select
    @enemy_window.visible = false
  end
    
  def end_item_select
    queed_end_item_select
    @enemy_window.visible = true
  end
    
  def update_phase5
    # If wait count is larger than 0
    if @phase5_wait_count > 0
      # Decrease wait count
      @phase5_wait_count -= 1
      # If wait count reaches 0
      if @phase5_wait_count == 0
        @enemy_window.visible = false
        # Show result window
        @result_window.visible = true
        # Clear main phase flag
        $game_temp.battle_main_phase = false
        # Refresh status window
        @status_window.refresh
        @enemy_window.refresh
      end
      return
    end
    queed_update_phase5
  end

  def update_phase4_step1
    queed_update_phase4_step1
    @enemy_window.refresh
  end

  def update_phase4_step5
    # Hide help window
    @help_window.visible = false
    # Refresh status window
    @status_window.refresh
    @enemy_window.refresh
    queed_update_phase4_step5
  end
end

#==============================================================================
# ** Window_BattleStatus
#------------------------------------------------------------------------------
#  Edited to display SephirothSpawn's slanted bars for the players
#==============================================================================


class Window_BattleStatus < Window_Base
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  alias nr_queed_refresh refresh
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  # alias nr_queed_refresh refresh
  def refresh(*args)
    # Call original refresh
    i = nr_queed_refresh(*args)
    $game_party.actors.each_with_index {
      |actor, i| draw_actor_hp(actor, i * 160 + 4, 32, 120) }
    return i
  end
  #--------------------------------------------------------------------------
  # * Draw_Actor_HP
  #--------------------------------------------------------------------------
  def draw_actor_hp(actor, x, y, width)
    draw_slant_bar(x, 55, actor.hp, actor.maxhp, width)
    super(actor, x, y, width)
  end
  #--------------------------------------------------------------------------
  # * Draw_Actor_SP
  #--------------------------------------------------------------------------
  def draw_actor_sp(actor, x, y, width)
    draw_slant_bar(x, 88, actor.sp, actor.maxsp, width, 6, bar_color = Color.new(150, 0, 150, 255), end_color = Color.new(0, 0, 255, 255))
    super(actor, x, y, width)
  end
end


If you want it to hide the spot where the window was as well, go to line 59:
CODE
i += 1

and put it down 1 line, so it reads;
CODE
next if enemy.hp <= 0
i += 1


To only show bars for the enemy (and not for the players), scroll down to the end of the code, and delete everything after (and including)
CODE
class Window_BattleStatus < Window_Base

on line 165.


__________________________
K.I.S.S.
Want help with your scripting problems? Upload a demo! Or at the very least; provide links to the scripts in question.

Most important guide ever: Newbie's Guide to Switches
Go to the top of the page
 
+Quote Post
   
MistTribe
post Apr 20 2010, 12:06 PM
Post #22


Level 1
Group Icon

Group: Member
Posts: 11
Type: Mapper
RM Skill: Advanced




Can someone edit this so it only shows the enemy hp bars not the heros?


__________________________

Go to the top of the page
 
+Quote Post
   
Yusshin
post Apr 21 2010, 04:01 AM
Post #23


In'shallah !
Group Icon

Group: Revolutionary
Posts: 282
Type: Writer
RM Skill: Beginner




Works perfectly; thanks!


__________________________
Go to the top of the page
 
+Quote Post
   
MEands
post Jul 12 2010, 06:49 PM
Post #24


We're out of nachos?!!
Group Icon

Group: Revolutionary
Posts: 535
Type: None
RM Skill: Skilled
Rev Points: 15




Oh wow, nice script.

So I have some questions.

Is there a way to move the enemy health bars, because the "fight/escape" bar at the beginning always covers that and it looks ugly.

Also, is there a way to make the bars only visable when the selected monster is displayed, and to put the bar over them.

Also, I think somebody already asked this: Is there a way for only the enemies to have the health bars, not the actors.

I know it's a lot to ask, but help would be appreciated.


__________________________
I'm a Christian, just in case you were wondering.



Go to the top of the page
 
+Quote Post
   
Kinerex Shiomi
post Aug 27 2010, 02:59 PM
Post #25


Level 3
Group Icon

Group: Member
Posts: 39
Type: Event Designer
RM Skill: Advanced




When I have more then 2 enemies in battle it cuts off the third enemy hp bar. But thats fine bc i just want to get rid of the enemies HP bars all together, so how do I do that?


__________________________
[Show/Hide] Read at your own despair

Life=Honor
Honor=God
God=Life

Soldier of John 3:16 XD






~spoiler'd by Hyla

GSORBY FOR LIFE!!!
Go to the top of the page
 
+Quote Post
   
Night_Runner
post Aug 27 2010, 06:47 PM
Post #26


Level 50
Group Icon

Group: +Gold Member
Posts: 1,529
Type: Scripter
RM Skill: Undisclosed




I'm a little bit confused, why would you be searching for a enemy HP bar script if you didn't want your enemies to have a HP bar?

[Show/Hide] Just Bars for Player
CODE
# Breath of Fire Enemy window
# By Noobitron
# Slanted Bars by Sephiroth Spawn.

class Window_Base
  #--------------------------------------------------------------------------
  # * Draw Slant Bar(by SephirothSpawn)
  #--------------------------------------------------------------------------
  def draw_slant_bar(x, y, min, max, width = 152, height = 6,
      bar_color = Color.new(150, 0, 0, 255), end_color = Color.new(255, 255, 60, 255))
    return if [max, width, height].include?(0)
    # Draw Border
    for i in 0..height
      self.contents.fill_rect(x + i, y + height - i, width + 1, 1, Color.new(50, 50, 50, 255))
    end
    # Draw Background
    for i in 1..(height - 1)
      r = 100 * (height - i) / height + 0 * i / height
      g = 100 * (height - i) / height + 0 * i / height
      b = 100 * (height - i) / height + 0 * i / height
      a = 255 * (height - i) / height + 255 * i / height
      self.contents.fill_rect(x + i, y + height - i, width, 1, Color.new(r, b, g, a))
    end
    # Draws Bar
    for i in 1..( (min / max.to_f) * width - 1)
      for j in 1..(height - 1)
        r = bar_color.red * (width - i) / width + end_color.red * i / width
        g = bar_color.green * (width - i) / width + end_color.green * i / width
        b = bar_color.blue * (width - i) / width + end_color.blue * i / width
        a = bar_color.alpha * (width - i) / width + end_color.alpha * i / width
        self.contents.fill_rect(x + i + j, y + height - j, 1, 1, Color.new(r, g, b, a))
      end
    end
  end
end


class Window_BattleStatus < Window_Base
  #--------------------------------------------------------------------------
  # * Alias Methods
  #--------------------------------------------------------------------------
  alias_method :nr_playerbar_refresh,  :refresh  unless $@
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  # alias_method :nr_playerbar_refresh,  :refresh  unless $@
  def refresh
    # Run the original refresh
    nr_playerbar_refresh
    # Draw in the HP & SP Bars.
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      actor_x = i * 160 + 4
      draw_slant_bar(actor_x, 55, actor.hp, actor.maxhp, 120)
      draw_slant_bar(actor_x, 88, actor.sp, actor.maxsp, 120, 6, Color.new(150, 0, 150, 255), Color.new(0, 0, 255, 255))
    end
  end
end


__________________________
K.I.S.S.
Want help with your scripting problems? Upload a demo! Or at the very least; provide links to the scripts in question.

Most important guide ever: Newbie's Guide to Switches
Go to the top of the page
 
+Quote Post
   
Jojozityjo
post Sep 25 2011, 04:29 AM
Post #27


Level 1
Group Icon

Group: Member
Posts: 7
Type: None
RM Skill: Intermediate




hope it isnt too late but i have an error with this one and i cannot figure out why it is there. I tried it an older project i made just to test scripts and it worked perfectly in there, even with other adds ons like battle scripts. But this new project, even with no other scripts, i keep getting an error message saying ....

Script 'Enemy HP Window' Line 30: ArgumentError Occurred.
bad value for range

can any one help with this?
Go to the top of the page
 
+Quote Post
   

2 Pages V  < 1 2
Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 19th June 2013 - 03:08 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker