Jump to content
Nicke

XS - Alignment Hud

Recommended Posts

xs.png

Alignment Hud

Version 1.0b

Introduction
This scripts is a plain and pretty alignment hud. It can display how many alignments you want, i.e evil, neutral and good etc.The alignment bar is controlled by a variable and for example a negative value would mean you are getting more evil and a positive value being the opposite.


Features

  • The option to change the hud settings. Positions, fonts etc.
  • A switch to enable/disable it.
  • Alignments is controlled by a variable ingame.
  • The current alignment is displayed below the bar.
  • When the alignment variable has changed the bar will animate to its value. (It will slide).
  • The ability to check an alignment, can be useful in a quest made only for the alignment "Good" etc. This can be checked via the conditional branch.
  • Play a sound when alignment changes.
  • And more!

Screenshots


xs-alignment.png

xs-alignment2.png



How to Use
Instructions how to use it can be find inside the script.
To install this script, open up your script editor and copy/paste this script to an open slot below Materials but above Main. Remember to save.

Script
Get the script here.

Updates
Version 1.0b up. Fixed a issue with sound being played even if the hud was disabled. Cleaned up some misspellings too.

Credit
Do credit me, Nicke, if you are planing on using this script. Thanks.
Can be use in a commercial project.

Edited by Nicke

Share this post


Link to post
Share on other sites

Oi Nicke, how about packing yourself a script demo, you have so many them scattered around now!

Great work though :3 You've grown quite a bit.

 

~Cookies

Share this post


Link to post
Share on other sites

@AlexxanderX: Thats your decision where it should start. Just set the variable to 100 from the beginning and the alignment will be neutral.

Share this post


Link to post
Share on other sites

Stupid question...I should have figured this out by now. But if i want the gauge to be at the bottom right what do i change what to? I know 0, 0 is top left. But i dont know the calculation to do bottom right

Edited by HalestormXV

Share this post


Link to post
Share on other sites

Just change the x and y position for the hud. The bar is hard coded so you need to modify its x and y values if you want to change them too.

Share this post


Link to post
Share on other sites

I think he meant what the coordinates would be to make it appear at the bottom right corner.

Share this post


Link to post
Share on other sites

Oh, to modify here, in script:

#    HUD = [width, height, x,   y,   z,  opacity,  skin]
  HUD =   [200,	 70,  -8,  24,  200,    0,	  nil]

 

And I think here, I don't now how more lines are where need to edit:

 def draw_alignment_bar
   # // Method to draw the alignment bar.
   color1 = XAIL::ALIGNMENT_HUD::BAR_COLOR1
   color2 = XAIL::ALIGNMENT_HUD::BAR_COLOR2
   w = window_width
   x = 0
   y = 22
   contents.fill_rect(x, y + 1, w, 8, XAIL::ALIGNMENT_HUD::BAR_COLOR_BACK)
   contents.fill_rect(x, y, w, 8, XAIL::ALIGNMENT_HUD::BAR_COLOR_OUTLINE)
   contents.gradient_fill_rect(x, y, @var, 8, color1, color2)
 end

Share this post


Link to post
Share on other sites

It may be a stupid question, but I cannot find the line with the starting value and I am too stupid to change the bar in game.^^

Share this post


Link to post
Share on other sites

It may be a stupid question, but I cannot find the line with the starting value and I am too stupid to change the bar in game.^^

 

To set a starting value just run an event that will do a control variable and set the variable of ur alignment gauge to what you want it to be. If you want to change it in game just adjust that variable.

 

And thanks Alexx. Yeah i figured that part. I Was just wondering if there was a specific calculation to perform so you can get the exact numbers for the bottom right of the screen by using the game window's resolution.

Share this post


Link to post
Share on other sites

Cool, but is it possible to for the bar to go to the left and right of the neutral not from right to where you are, so if your good it should just go from neutral to good and not through evil and if your evil the bar shouldn't be in the VERY evil area as-well it should go from neutral. Basically is it possible to make the bars come from the center otherwise it seems like you had to be very evil to become good...

 

EDIT:

Also and when I tried using the script I crashed and it said

 

"Script 'Alignment Bar' line 32: SyntaxError occurred.

class/module name must be CONSTANT"

Edited by Darren Destiny

Share this post


Link to post
Share on other sites

@Darren: Can you show me the script you are using because I don't ge that type of bug. As for the alignment values you have to change them for yourself in the settings.

Share this post


Link to post
Share on other sites

@Darren: Can you show me the script you are using because I don't ge that type of bug. As for the alignment values you have to change them for yourself in the settings.

 

The script I am using is just the unedited script on the page

 

 

#==============================================================================
#   XS - Alignment Hud
#   Author: Nicke
#   Created: 14/04/2012
#   Edited: 16/04/2012
#   Version: 1.0b
#==============================================================================
# Instructions
# -----------------------------------------------------------------------------
# To install this script, open up your script editor and copy/paste this script
# to an open slot below â–¼ Materials but above â–¼ Main. Remember to save.
#
# A small hud to display the current alignemnt. (Good, neutral or evil etc)
# Setup the alignments in the settings below. Make sure to change in
# alignment_values if you increase BAR_MAX value.
#
# You can use a call script to check an alignemnt also:
# check_alignment?("Evil")
# !check_alignment?("Very Good")
#
# You can also call set_Alignment f you wish to reset the default value of the
# alignment.
#
# Make sure you change COUNT_WAIT and CHANGING if you feel like the bar is
# updating slowly.
#
# *** Only for RPG Maker VX Ace. ***
#==============================================================================
($imported ||= {})["XAIL-ALIGNMENT-HUD"] = true
module XAIL
 module alignment_HUD
 #--------------------------------------------------------------------------#
 # * Settings
 #--------------------------------------------------------------------------#
  # FONT = [name, size, color, bold, shadow]
  FONT = [["Ankladaâ„¢","Verdana"], 16, Color.new(255,255,255), true, true]
  # HUD = [width, height, x,   y,   z,  opacity,  skin]
  HUD =   [200,	 70,  -8,  24,  200,	0,	  nil]
  # The title for the alignment.
  # Can be disabled if set to nil.
  # Note: If title is disabled the Alignment won't be displayed.
  # TITLE = string
  TITLE = "Alignment »  "
  # Visbility switch.
  # HUD_SWITCH = switch_id
  HUD_SWITCH = 1
  # Alignment variable. This controls the Alignment value.
  # VAR = variable_id
  VAR = 1
  # Alignment default value (100 = neutral).
  # DEFAULT_VAL = number
  DEFAULT_VAL = 100
  # Add here which types of alignments you want.
  # Icons are optional.
  # alignments = {}
  # :symbol => string, icon_index (optional)
  alignments = {
  :very_evil  => ["Very Evil",  187],
  :evil	   => ["Evil"		   ],
  :neutral	=> ["Neutral",	190],
  :good	   => ["Good"		   ],
  :very_good  => ["Very Good",  189]
  } # Don't remove this line!
  # Option to enable/disable the icons.
  # SHOW_ICONS = true/false.
  SHOW_ICONS = true
  # Offset the icons in x position.
  # Change this if you want it to look consistent with the bar.
  # ICONS_X_OFFSET = number.
  ICONS_X_OFFSET = (HUD[0] / 2) - 12
  # Change the Alignment values in here.
  # Note: The current values are based on the default ones.
  # so if you change the maximum value (200 is default) you might want to
  # change the values in here as well.
  # Alignment values:
   def self.alignment_values
	case $game_variables[VAR]
	when 0		  ; return alignments[:very_evil][0]
	when 51..74	 ; return alignments[:evil][0]
	when 75..125	; return alignments[:neutral][0]
	when 126..150   ; return alignments[:good][0]
	else			; return alignments[:very_good][0]
	end
  end  
  # Option to enable/disable the bar.
  # SHOW_BAR = true/false.
  SHOW_BAR = true
  # Set this to the max value for the Alignment bar.
  # BAR_MAX = number
  BAR_MAX = 200
  # Set the colors of the Alignment bar.
  # BAR_COLOR = Color.new(rgba)
  BAR_COLOR1 =		Color.new(255,10,10,150)	# // Red.
  BAR_COLOR2 =		Color.new(10,255,10,150)	# // Green.
  BAR_COLOR_BACK =	Color.new(255,255,255,150)  # // White.
  BAR_COLOR_OUTLINE = Color.new(0,0,0,225)		# // Black.
  # Set how long time it should take before the bar should animate in to the
  # right value.
  COUNT_WAIT = 10
  CHANGING = 1 # // The time lapse between count changing.
  # Play a sound if Alignment changes.
  # SOUND = [sound, vol, pitch, play]
  # Can be disabled if set to nil.
  SOUND = ["Applause1", 60, 100]
 end
end
# *** Don't edit below unless you know what you are doing. ***
#==============================================================================#
# ** Game_Interpreter
#==============================================================================#
class Game_Interpreter
 def check_alignment?(alignment)
# // Method to check an alignment.
current_Alignment = XAIL::ALIGNMENT_HUD::ALIGNMENT_values
return true if current_Alignment == Alignment
return false
 end
 def set_alignment
# // Quick method to set Alignment to default value.
$game_variables[XAIL::ALIGNMENT_HUD::VAR] = XAIL::ALIGNMENT_HUD::DEFAULT_VAL
 end
end
#==============================================================================#
# ** Window_Alignment_Hud
#------------------------------------------------------------------------------
#  Class for drawing the Alignment hud.
#==============================================================================#
class Window_Alignment_Hud < Window_Base
 def initialize
# // Method to initialize the window.
super(0, 0, window_width, window_height)
@var = $game_variables[XAIL::ALIGNMENT_HUD::VAR]
@Alignment = XAIL::ALIGNMENT_HUD::ALIGNMENT_values
@wait_period = XAIL::ALIGNMENT_HUD::COUNT_WAIT
refresh
 end
 def window_width
# // Method to return the width with offset.
return XAIL::ALIGNMENT_HUD::HUD[0] + 24
 end
 def window_height
# // Method to return the height.
return XAIL::ALIGNMENT_HUD::HUD[1]
 end
 def refresh
# // Method to refresh the hud.
contents.clear
draw_Alignment_bar  if	 XAIL::ALIGNMENT_HUD::SHOW_BAR
draw_icons		  if	 XAIL::ALIGNMENT_HUD::SHOW_ICONS
draw_Alignment	  unless XAIL::ALIGNMENT_HUD::TITLE.nil?
 end
 def draw_Alignment_bar
# // Method to draw the Alignment bar.
color1 = XAIL::ALIGNMENT_HUD::BAR_COLOR1
color2 = XAIL::ALIGNMENT_HUD::BAR_COLOR2
w = window_width
x = 0
y = 22
contents.fill_rect(x, y + 1, w, 8, XAIL::ALIGNMENT_HUD::BAR_COLOR_BACK)
contents.fill_rect(x, y, w, 8, XAIL::ALIGNMENT_HUD::BAR_COLOR_OUTLINE)
contents.gradient_fill_rect(x, y, @var, 8, color1, color2)
 end
 def draw_icons
# // Method to draw Alignment icons.
x = 0
for i in XAIL::ALIGNMENT_HUD::ALIGNMENTS.values
  next if i[1].nil?
  draw_icon(i[1], x, 0)
  x += XAIL::ALIGNMENT_HUD::ICONS_X_OFFSET
end
 end
 def draw_alignment
# // Method to draw the hud.
contents.font = Font.new(XAIL::ALIGNMENT_HUD::FONT[0], XAIL::ALIGNMENT_HUD::FONT[1])
contents.font.color = XAIL::ALIGNMENT_HUD::FONT[2]
contents.font.bold = XAIL::ALIGNMENT_HUD::FONT[3]
contents.font.shadow = XAIL::ALIGNMENT_HUD::FONT[4]
title = XAIL::ALIGNMENT_HUD::TITLE
Alignment = XAIL::ALIGNMENT_HUD.alignment_values
text = title + Alignment unless alignment.nil?
draw_text(0, 26, window_width, line_height, text, 0)
reset_font_settings
 end
 def update
# // Method to update the hud.
super  
@wait_period -= 1 if @wait_period != 0
if @var != $game_variables[XAIL::ALIGNMENT_HUD::VAR] and @wait_period == 0
  if @var < $game_variables[XAIL::ALIGNMENT_HUD::VAR]
	@var += 1
  else
	@var -= 1
  end
  if self.visible
	if @Alignment != XAIL::ALIGNMENT_HUD::ALIGNMENT_values and !XAIL::ALIGNMENT_HUD::SOUND.nil?
	  @Alignment = XAIL::ALIGNMENT_HUD::ALIGNMENT_values
	  RPG::SE.new(XAIL::ALIGNMENT_HUD::SOUND[0], XAIL::ALIGNMENT_HUD::SOUND[1], XAIL::ALIGNMENT_HUD::SOUND[2]).play
	end
  end
  refresh
  @wait_period = XAIL::ALIGNMENT_HUD::CHANGING
end
 end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  Show Alignment on map.
#==============================================================================
class Scene_Map < Scene_Base
 alias xail_align_hud_start start
 def start(*args, &block)
# // Method to start the Alignment hud on the map.
xail_align_hud_start(*args, &block)
@var = $game_variables[XAIL::ALIGNMENT_HUD::VAR]
create_Alignment_hud
@align_hud_window.visible = $game_switches[XAIL::ALIGNMENT_HUD::HUD_SWITCH]
 end
 def create_Alignment_hud
# // Method to create the Alignment hud.
@align_hud_window = Window_Alignment_Hud.new
@align_hud_window.x = XAIL::ALIGNMENT_HUD::HUD[2]
@align_hud_window.y = XAIL::ALIGNMENT_HUD::HUD[3]
@align_hud_window.z = XAIL::ALIGNMENT_HUD::HUD[4]
@align_hud_window.opacity = XAIL::ALIGNMENT_HUD::HUD[5]
@align_hud_window.windowskin = Cache.system(XAIL::ALIGNMENT_HUD::HUD[6]) unless XAIL::ALIGNMENT_HUD::HUD[6].nil?
 end
 alias xail_align_hud_update update
 def update(*args, &block)
# // Method to update the Alignment hud on the map.
xail_align_hud_update(*args, &block)
check_Alignment_var
@align_hud_window.visible = $game_switches[XAIL::ALIGNMENT_HUD::HUD_SWITCH]
 end
 def check_Alignment_var
# // Method to check that the variable doesn't exceeds its min and max value.
if @var != $game_variables[XAIL::ALIGNMENT_HUD::VAR]
  if $game_variables[XAIL::ALIGNMENT_HUD::VAR] == [$game_variables[XAIL::ALIGNMENT_HUD::VAR], 0].min
	$game_variables[XAIL::ALIGNMENT_HUD::VAR] = 0
  end
  if $game_variables[XAIL::ALIGNMENT_HUD::VAR] == [$game_variables[XAIL::ALIGNMENT_HUD::VAR], XAIL::ALIGNMENT_HUD::BAR_MAX].max
	$game_variables[XAIL::ALIGNMENT_HUD::VAR] = XAIL::ALIGNMENT_HUD::BAR_MAX
  end
  @var = $game_variables[XAIL::ALIGNMENT_HUD::VAR]
end
 end
end # END OF FILE
#=*==========================================================================*=#
# ** END OF FILE
#=*==========================================================================*=#

 

 

And I cant see what settings I need to edit to make the bar come from the center to the outside

Share this post


Link to post
Share on other sites

@Darren: It is not necessary to come from the middle. See, if the bar would go from poor to rich, it is not sure, that you must be poor to get rich. Do you see, what I mean?

Share this post


Link to post
Share on other sites

@Darren: No you have changed something on line 32. It should be like this:

module ALIGNMENT_HUD

But you had it like this:

module alignment_HUD

Share this post


Link to post
Share on other sites

Thx, found out what happened :), when I copied it into my game I had the word alignment highlighted with Ctrl+f, and for some reason this caused it to change it to lowercase...

Share this post


Link to post
Share on other sites

@Niclas: Is it possible to multiply your HUD to make it twice?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
Top ArrowTop Arrow Highlighted