Main Menu
  • Welcome to The RPG Maker Resource Kit.

Supersimple Head-Up Display

Started by Sthrattoff, December 30, 2006, 02:31:40 AM

0 Members and 1 Guest are viewing this topic.

Sthrattoff

This is my first script posted here, so give me comment or something, ok?


#====================================================================
# Supersimple Head-Up Display
#-----------------------------------------------------------------
# ** Version 1.0
# ** Original by Sthrattoff
#====================================================================

# Description :
# This script will allow you to show a HUD window on your map.

# Instruction :
# Put this script above main

# How to Use?
# To call, use Call Script :
# Call Script : $window = Window_HUD.new(game_party_id(0-3))
# To remove, use this
# Call Script : $window.dispose
# For RMXP - PK : "Add self.contents.font.name and font.size by yourself"

#==============================================
# Modification to Window_Base
#==============================================

class Window_Base < Window
 
  def draw_actor_face(actor, x, y)
    bitmap = RPG::Cache.picture(actor.name)
    self.contents.blt(0, 0, bitmap, Rect.new(0, 0, 96, 96))
  end

  def draw_actor_hpbar(actor, x, y, w = 120)
    # Defines actor hp and maxhp
    vitality = actor.hp
    maxvitality = actor.maxhp
    # Defines color used on bar
    bordercolor = system_color
    outercolor = Color.new(220, 10, 0, 255)
    midcolor = Color.new(220, 35, 0, 255)
    innercolor = Color.new(220, 60, 0, 255)
    emptycolor = Color.new(0, 0, 0, 255)
    # Defines length of bar
    linewidth = (((vitality * 1.0) / maxvitality) * (w - 2))
    emptywidth = ((w - 1) - linewidth)
    emptyx = ((x + 1) + linewidth)
    # Drawing line and border
    borderup = Rect.new(x, y, w, 1)
    borderleft = Rect.new(x, y + 1, 1, 6)
    borderdown = Rect.new(x, y + 7, w, 1)
    borderright = Rect.new(x + w - 1, y + 1, 1, 6)
    emptyline = Rect.new(x + 1, y + 1, w - 2, 6)
    outerline = Rect.new(x + 1, y + 1, linewidth, 6)
    midline = Rect.new(x + 2, y + 2, linewidth - 2, 4)
    innerline = Rect.new(x + 3, y + 3, linewidth - 4, 2)
    # Coloring the bar
    self.contents.fill_rect(borderup, bordercolor)
    self.contents.fill_rect(borderleft, bordercolor)
    self.contents.fill_rect(borderdown, bordercolor)
    self.contents.fill_rect(borderright, bordercolor)
    self.contents.fill_rect(emptyline, emptycolor)
    self.contents.fill_rect(outerline, outercolor)
    self.contents.fill_rect(midline, midcolor)
    self.contents.fill_rect(innerline, innercolor)
  end

  def draw_actor_spbar(actor, x, y, w = 200)
    # Defines actor sp and maxsp
    force = actor.sp
    maxforce = actor.maxsp
    # Defines color used on bar
    bordercolor = system_color
    outercolor = Color.new(0, 110, 180, 255)
    midcolor = Color.new(0, 135, 180, 255)
    innercolor = Color.new(0, 160, 180, 255)
    emptycolor = Color.new(0, 0, 0, 255)
    # Defines length of bar
    linewidth = (((force * 1.0) / maxforce) * (w - 2))
    emptywidth = ((w - 1) - linewidth)
    emptyx = ((x + 1) + linewidth)
    # Drawing line and border
    borderup = Rect.new(x, y, w, 1)
    borderleft = Rect.new(x, y + 1, 1, 6)
    borderdown = Rect.new(x, y + 7, w, 1)
    borderright = Rect.new(x + w - 1, y + 1, 1, 6)
    emptyline = Rect.new(x + 1, y + 1, w - 2, 6)
    outerline = Rect.new(x + 1, y + 1, linewidth, 6)
    midline = Rect.new(x + 2, y + 2, linewidth - 2, 4)
    innerline = Rect.new(x + 3, y + 3, linewidth - 4, 2)
    # Coloring the bar
    self.contents.fill_rect(borderup, bordercolor)
    self.contents.fill_rect(borderleft, bordercolor)
    self.contents.fill_rect(borderdown, bordercolor)
    self.contents.fill_rect(borderright, bordercolor)
    self.contents.fill_rect(emptyline, emptycolor)
    self.contents.fill_rect(outerline, outercolor)
    self.contents.fill_rect(midline, midcolor)
    self.contents.fill_rect(innerline, innercolor)
  end

end

#==============================================
# Window_HUD
#==============================================

class Window_HUD < Window_Base

  def initialize(actor)
    super(0, 0, 160, 128)
    self.contents = Bitmap.new(width - 32, height - 32)
    @index = actor
    refresh
  end

  def refresh
    self.contents.clear
    @actor = $game_party.actors[@index]
    draw_actor_face(@actor, 0, 0)
    draw_actor_name(@actor, 108, 0)
    draw_actor_hpbar(@actor, 108, 32 + 16, 52)
    draw_actor_hp(@actor, 108, 32)
    draw_actor_spbar(@actor, 108, 64 + 16, 52)
    draw_actor_sp(@actor, 108, 64)
    draw_actor_level(@actor, 0, 128)
    draw_actor_class(@actor, 64, 128)
  end

  def change
    refresh
  end

end


Don't forget to post any bugs...
Symphony of Alderra : Memoirs of Life

Storyline : 200% (Overimaginatives)
Scripting : 100% (At last...)
Eventing  : 100%
Mapping   : 0.125%

feildmaster

#1
im gona try it out now.. give me a  few to put it in...

ok... i got a syntax error... dunno why...
----Current Games working on----
--Rage O' Delusion - Overall Percentage Finished : 4% -- Expected release... Unknown
--The Other Dimension - Overall Percentage done : 1 - Expected Release : No time soon...
v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^v^
Feildmaster Productions
Made By One Man Run by the Same...
Making Games for Everyone...
Oh yeah, and everything else web based
For a charge... Of course...

Me™

ALL HAIL ME™

Snailer

#3
:p would be nice lol.
What does it do exactly >.< lol


Sthrattoff

Can you tell me which line or the error message?
Oh, I've updated my script. Just copy paste on first post...
Symphony of Alderra : Memoirs of Life

Storyline : 200% (Overimaginatives)
Scripting : 100% (At last...)
Eventing  : 100%
Mapping   : 0.125%

Winged

Quote from: Snailer on December 30, 2006, 12:22:40 PM
:p would be nice lol.
What does it do exactly >.< lol

How I explain HUD's are they show a characters characteristics on the screen. Examples: Kingdom Hearts 1 and 2, Devil May Cry, Ragnarok Online, Maple Story, ROSE Online, WoW, Trickster and basically most MMORPGs.

~Winged



Snailer


Sthrattoff

Hello anybody...
Does that script work?

I need some evaluation on my skill :
-> Create a script without testing at RMXP...
Symphony of Alderra : Memoirs of Life

Storyline : 200% (Overimaginatives)
Scripting : 100% (At last...)
Eventing  : 100%
Mapping   : 0.125%

Arrow

#8
I'LL GIVE IT A SHOT!

Edit when done.

EDIT: Same problem, a syntax error. Thing is, it woun't say where, throws me up at the beggining of Game_Temp. Good luck with this man.