The RPG Maker Resource Kit

RMRK RPG Maker Creation => RPG Maker General => General Scripting => Topic started by: Xplosive_Shadow on May 22, 2007, 05:08:08 PM

Title: A really advanced HUD i made!!! Please rate it too.
Post by: Xplosive_Shadow on May 22, 2007, 05:08:08 PM
I've made an awesome hud script that fully works with all rpg made games check the screens to see.
The HUD shows your lvl, your name, how much xp you have and need, how much life you have, how much xp you have and the picture of your battler ( when you use an visual equip script the visual equip will actually work in the HUD too and the money amout you have on hand.  ;D

SCREEN:
(https://rmrk.net/proxy.php?request=http%3A%2F%2Fimg367.imageshack.us%2Fimg367%2F4222%2Fhudfl6.th.png&hash=2ece7d56a0c06929bcc4e31e4f7b190161dc4ee3)

[spoiler]class Window_2 < Window_Base
  $defaultfontsize = 20 #Change to the font size you want
  @GOLD_ICON = RPG::Cache.icon("acce_005")
 
def draw_normal_barz(x, y, type, length, thick, e1, e2, c1 = Color.new(153,238,153,255), c2 = Color.new(0,0,0,255))
   if type == "horizontal"
     width = length
     height = thick
     self.contents.fill_rect(x-1, y - 1, width+2, height + 3, Color.new(255, 255, 255, 255))
     self.contents.fill_rect(x, y, width, height + 1, Color.new(0, 0, 0, 255))
     w = width * e1 / e2
     for i in 0..height
     r = c1.red + (c2.red - c1.red)   * (height -i)/height  + 0   * i/height
     g = c1.green + (c2.green - c1.green) * (height -i)/height  + 0 * i/height
     b = c1.blue + (c2.blue - c1.blue)  * (height -i)/height  + 0 * i/height
     a = c1.alpha + (c2.alpha - c1.alpha)* (height -i)/height  + 255 * i/height
     self.contents.fill_rect(x, y+i, w, 1, Color.new(r, g, b, a))
   end
elsif type == "vertical"
   width = thick
   height = length
     self.contents.fill_rect(x-1, y - 1, width+3, height + 2, Color.new(255, 255, 255, 255))
     self.contents.fill_rect(x, y, width+1, height , Color.new(0, 0, 0, 255))
   h = height * e1 / e2
   for i in 0..width
     r = c1.red + (c2.red - c1.red)   * (width -i)/width  + 0   * i/width
     g = c1.green + (c2.green - c1.green) * (width -i)/width  + 0 * i/width
     b = c1.blue + (c2.blue - c1.blue)  * (width -i)/width  + 0 * i/width
     a = c1.alpha + (c2.alpha - c1.alpha)* (width -i)/width  + 255 * i/width
     self.contents.fill_rect(x+i, y, 1, h, Color.new(r, g, b, a))
   end
end
end

def draw_actor_barz(actor,x, y, type, length, thick, e1, e2, c1 = Color.new(255,0,0,255), c2 = Color.new(0,0,0,255))
   if type == "horizontal"
     width = length
     height = thick
     self.contents.fill_rect(x-1, y - 1, width+2, height + 3, Color.new(255, 255, 255, 255))
     self.contents.fill_rect(x, y, width, height + 1, Color.new(0, 0, 0, 255))
     w = width * e1 / e2
     for i in 0..height
     r = c1.red + (c2.red - c1.red)   * (height -i)/height  + 0   * i/height
     g = c1.green + (c2.green - c1.green) * (height -i)/height  + 0 * i/height
     b = c1.blue + (c2.blue - c1.blue)  * (height -i)/height  + 0 * i/height
     a = c1.alpha + (c2.alpha - c1.alpha)* (height -i)/height  + 255 * i/height
     self.contents.fill_rect(x, y+i, w, 1, Color.new(r, g, b, a))
   end
elsif type == "vertical"
   width = thick
   height = length
     self.contents.fill_rect(x-1, y - 1, width+3, height + 2, Color.new(255, 255, 255, 255))
     self.contents.fill_rect(x, y, width+1, height , Color.new(0, 0, 0, 255))
   h = height * e1 / e2
   for i in 0..width
     r = c1.red + (c2.red - c1.red)   * (width -i)/width  + 0   * i/width
     g = c1.green + (c2.green - c1.green) * (width -i)/width  + 0 * i/width
     b = c1.blue + (c2.blue - c1.blue)  * (width -i)/width  + 0 * i/width
     a = c1.alpha + (c2.alpha - c1.alpha)* (width -i)/width  + 255 * i/width
     self.contents.fill_rect(x+i, y, 1, h, Color.new(r, g, b, a))
   end
end
end
 
  def initialize
    super(0, 0, 225, 120)
    self.contents = Bitmap.new(width-32, height-32)
    self.contents.font.size = 12 #Change to the font size you want
    self.opacity = 127
    self.contents.font.name = "Tahoma" #Change to your font stile
    refresh
  end
  def refresh
    self.contents.clear
      draw_normal_barz(36, 27, "horizontal", 150, 8, $game_actors[1].hp.to_i, $game_actors[1].maxhp.to_i, Color.new (225, 0, 0, 150)) # HP BAR
  draw_normal_barz(36, 40, "horizontal", 150, 8, $game_actors[1].sp.to_i, $game_actors[1].maxsp.to_i, Color.new (0,0,255,150)) # SP BAR
  draw_normal_barz(36, 53, "horizontal", 150, 8, $game_actors[1].exp_s.to_i, $game_actors[1].next_exp_s.to_i, Color.new (0, 255, 0, 225)) #XP BAR
      draw_actor_graphic($game_actors[1], 15, 63) #Actor 1 graphics
      self.contents.font.size = 22 #Change to the font size you want
      self.contents.font.bold = true #Change to bold yes or no
  draw_actor_level($game_actors[1], 128, -5) #Actor 1 level
      self.contents.font.size = 28 #Change to the font size you want
      self.contents.font.name = "Monotype Corsiva" #Change to your font stile
  draw_actor_name($game_actors[1],30 ,-5)
    self.contents.font.bold = false #Change to bold yes or no
      self.contents.font.size = 20 #Change to the font size you want
    self.contents.blt(30, 63, RPG::Cache.icon("acce_005"), Rect.new(0, 0, 24, 24))#GOLD ICON
    self.contents.draw_text(50, 60, 200, 32, "Gold: " + $game_party.gold.to_s)#GOLD AMOUNT
      self.contents.font.size = 12 #Change to the font size you want
      self.contents.font.name = "Tahoma" #Change to your font stile 
    self.contents.draw_text(65, 15, 200, 32, "HP: " + $game_party.actors[0].hp.to_s + "/" + $game_party.actors[0].maxhp.to_s)# HP BAR
    self.contents.draw_text(65, 28, 200, 32, "SP: " + $game_party.actors[0].sp.to_s + "/" + $game_party.actors[0].maxsp.to_s)# SP BAR
    self.contents.draw_text(65, 41, 200, 32, "Exp needed: " + $game_party.actors[0].next_rest_exp_s)#XP BAR
   
  def update
    refresh
  end
  def mouse_over?(window)
    if $mouse.x > window.x and $mouse.x < window.x + window.width and
      $mouse.y > window.y and $mouse.y < window.y + window.height
      return true
    end
    return false
  end
end
end

class Scene_Map
alias old_main main
  alias old_update update
  def init_hud
    @Window2 = Window_2.new
    @Exp = $game_party.actors[0].next_rest_exp_s
    @Hp = $game_party.actors[0].hp
    @Sp = $game_party.actors[0].sp
    @gold = $game_party.gold
    @str = $game_party.actors[0].str
    @dex = $game_party.actors[0].dex
    @agi = $game_party.actors[0].agi
    @int = $game_party.actors[0].int
    @level = $game_party.actors[0].level
    @Name = $game_party.actors[0].name
  end
  def main
    init_hud
    old_main
  end
  def dispose
    old_dispose
    @Window2.dispose
  end
  def update
    @Window2.update
    old_update
    end
  end
[/spoiler]

Just make a script and call it HUD also at this icon to icons file in materialbase and name it acce_005.png:

(https://rmrk.net/proxy.php?request=http%3A%2F%2Fimg510.imageshack.us%2Fimg510%2F1664%2Facce005cf7.png&hash=0c97b2ccabd98787694543a5250a05a0e96d0bf0)

HOPE YOU ALL LIKE IT AND PLEASE RATE ME!!!
Title: Re: A really advanced HUD i made!!! Please rate it too.
Post by: Zeriab on May 22, 2007, 06:42:55 PM
2 quick things.

1st: I added [code][/code] tags to your code. Remember that next time you post a script ^_^

2nd: You have uploaded the coin picture with imageshack. Remember to tell people they have to rename the file to acce_005.png or something similar.


I'll edit this if no new post have been made by the time when I have more to say ^_^
Title: Re: A really advanced HUD i made!!! Please rate it too.
Post by: Xplosive_Shadow on May 22, 2007, 07:43:39 PM
THX for the tips dude im new in scripting but i think this script works quite good il post more in time i hope but thx for the tip!  ^-^
Title: Re: A really advanced HUD i made!!! Please rate it too.
Post by: Halestorm5 on May 22, 2007, 07:53:07 PM
If you open the menu with this hud, the hud is still showing on the menu.
Title: Re: A really advanced HUD i made!!! Please rate it too.
Post by: Xplosive_Shadow on May 22, 2007, 08:39:48 PM
HMMM i see your point thx for mentioning il try to get it fixed  :police:
Title: Re: A really advanced HUD i made!!! Please rate it too.
Post by: Neverplayd on June 26, 2007, 04:20:59 AM
This is a really good HUD :). But is there any way you can remove the HUD and put it back on later, like for cutscenes and stuff?
ty