Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Char HP/SP/Statusbars when not moving (On Maps!) -> Like in Legaia 2 Duel Saga

Hi there!

Maybe ther ARE a bunch of this scripts, but i didn't find exactly that what i wanted... anbd had to request a new one^^

SO:
If you don't move, so you just stand, there should be appeard bars and the char's name in the bottom of the screen, but without any picture of 'em or sth like that.
Just the name 'n bars to go with the HP and MP.
There should be alle characters, like in my drawing.
And when you move on the boxes shall dissappear.
Hope you got it ;)

See this for it!:
http://i8.tinypic.com/853ginq.jpg[/img]

EDIT: This second and third 'Char 2' are char no. 3 and 4 though ^^ '
 

poccil

Sponsor

This code will do what you want.  Look at the code between the hash marks to learn how to customize it.

Code:
module Graphics
 if !defined?(height)
   class << self
     def height; 480; end
   end
 end
 if !defined?(width)
   class << self
     def width; 640; end
   end
 end
end

module BarWriter
  def self.drawBar(bitmap,x,y,width,height,value,maxvalue,color)
   bitmap.fill_rect(x,y+2,width,height,Color.new(0,0,0))
   bitmap.fill_rect(x,y,width*value/maxvalue,height,color)    
  end
end

module CharlieLeeBarWriter
  def self.drawBar(bitmap,x,y,width,height,value,maxvalue,color)
      buffer=Bitmap.new(width,height)
      bar=Bar.new(0,0,buffer.width,buffer.height,buffer)
      bar.refresh(value,maxvalue)
      bitmap.blt(x,y,buffer,buffer.rect)
      buffer.dispose
  end  
end


class ActorStatus < Window_Base
###################
  FONTNAME="Arial"
  FONTSIZE=16
  WAITCOUNT=15 # In frames (1/40 second)
  HPBARCOLOR=Color.new(0,0,200)
  SPBARCOLOR=Color.new(0,200,0)
  BARWRITERMODULE=::BarWriter
###################
  def initialize(id)
    @unitsize=FONTSIZE+8
    super(id*(Graphics.width/4),Graphics.height-((@unitsize*3)+32),
          Graphics.width/4,(@unitsize*3)+32)
    self.contents=Bitmap.new(self.width-32,self.height-32)
    @id=id
    @movecount=WAITCOUNT
    self.z=5000
    self.opacity=128
    self.contents.font.name=[FONTNAME,"Arial","Times New Roman"]
    self.contents.font.size=FONTSIZE
    refresh
  end
  def update
    super
    if $game_player.moving? || $game_temp.message_window_showing ||
        $game_player.move_route_forcing || $game_system.map_interpreter.running?
      self.visible=false
      @movecount=0
    elsif @movecount<WAITCOUNT
      self.visible=false
      @movecount+=1
    else
      if @movecount==WAITCOUNT || Graphics.frame_count%10==0
        refresh
      end
    end
  end
  def drawActorBar(x,y,word,width,color,value,maxvalue)
    bitmap=self.contents
    valuewidth=bitmap.text_size(value.to_s).width
    maxvaluewidth=bitmap.text_size("/"+maxvalue.to_s).width
    BARWRITERMODULE.drawBar(
      bitmap,x+32,y+(@unitsize/2),width-32,(@unitsize*2/5),
      value,maxvalue,color)
    bitmap.font.color = system_color
    bitmap.draw_text(x, y, bitmap.text_size(word).width, @unitsize, word)
    self.contents.font.color = value == 0 ? knockout_color :
        value <= maxvalue / 4 ? crisis_color : normal_color
    bitmap.draw_text(x+width-maxvaluewidth-valuewidth,
     y, valuewidth, @unitsize, value.to_s)
    self.contents.font.color = normal_color
    bitmap.draw_text(x+width-maxvaluewidth,
     y, maxvaluewidth, @unitsize, "/"+maxvalue.to_s)
  end
  def refresh
    self.contents.clear
    if !$game_party || @id>=$game_party.actors.size ||
       !$game_party.actors[@id]
       self.visible=false
       return
    end
    self.visible=true
    actor=$game_party.actors[@id]
    self.contents.font.color = normal_color
    self.contents.draw_text(0, 0, self.contents.width, @unitsize, actor.name)
    text = make_battler_state_text(actor, width, true)
    self.contents.font.color = actor.hp == 0 ? knockout_color : normal_color
    width=self.contents.text_size(text).width
    self.contents.draw_text(self.contents.width-width, 0, width, @unitsize, text)
    drawActorBar(0,@unitsize,$data_system.words.hp,self.contents.width,
       HPBARCOLOR,actor.hp,actor.maxhp)
    drawActorBar(0,@unitsize*2,$data_system.words.sp,self.contents.width,
       SPBARCOLOR,actor.sp,actor.maxsp)
  end
end



class Spriteset_Map
  if !defined?(petero_actordisplays_Spriteset_Map_initialize)
   alias petero_actordisplays_Spriteset_Map_initialize initialize
   alias petero_actordisplays_Spriteset_Map_update update
   alias petero_actordisplays_Spriteset_Map_dispose dispose
  end
  def initialize
    @actordisplays=[    
     ActorStatus.new(0),
     ActorStatus.new(1),
     ActorStatus.new(2),
     ActorStatus.new(3)
    ]
    petero_actordisplays_Spriteset_Map_initialize
  end
  def update
    for d in @actordisplays
     d.update
    end
    petero_actordisplays_Spriteset_Map_update
  end
  def dispose
    for d in @actordisplays
     d.dispose
    end
    petero_actordisplays_Spriteset_Map_dispose
  end
end
 
K, thx for it!
But, could ya do me a favor?
Could ya please change it that way, that there are my bars form Charlie Lee's Bar 1.3?

Code:
#==============================================================================
# ** Bar   ver. 1.3                      
# ** Author: Charlie Lee
#==============================================================================
#==============================================================================
# â–  BAR
#==============================================================================
class Bar
  attr_accessor :highlight_complete
  attr_accessor :back_opacity
  attr_accessor :opacity
  attr_accessor :bar
  attr_accessor :bar_background
  #--------------------------------------------------------------------------
  # â—
 

Jason

Awesome Bro

I would like this in my game if thats okay with you Final Griever, but I need to change some values and names on it anyway, poccil, any way you can make it so the windows kinda slide up to their position, that would be excellent.

Final, if your not okay with it, I'll not use it as you wanted it first.
 
Could you repost this the way it was before you edited to work with his bars.
So that I can check it out?
I have his battle system, and bars, but I use another bar that writes over it.
Can these be used as plug in, like menu? If not could you do that minor edit, if not that's okay.
 

poccil

Sponsor

I've modified the script above to make it extensible.  Now it relies on a specific bar writing module
that implements the function drawBar.  An example is shown here:

Code:
module BarWriter
  def self.drawBar(bitmap,x,y,width,height,value,maxvalue,color)
   bitmap.fill_rect(x,y,width,height,Color.new(0,0,0))
   bitmap.fill_rect(x,y+2,width*value/maxvalue,height,color)    
  end
end

The drawBar method has eight parameters, indicating the bitmap to draw the bar on, a value and maximum
value, its color, etc.

To set the module used, change the value of BARWRITERMODULE in the configuration section:

Code:
  BARWRITERMODULE=::BarWriter

(Note the two colons before the module's name.)
 
jbrist":2lc063vd said:
I would like this in my game if thats okay with you Final Griever, but I need to change some values and names on it anyway, poccil, any way you can make it so the windows kinda slide up to their position, that would be excellent.

Final, if your not okay with it, I'll not use it as you wanted it first.
Sure I am. :D

Fell free to use it in your game.
So thanks and your name in my credits goes to poccil!;)
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top