Health Bars: Changing Colour
by
Wayne Scales
With TRNG, we now can change the colours of default tomb4 bars like the air bar, hp bar, loading bar etc with a few simple script commands. Here is a health bar I have customized for my Secrets Of Nepal game. It's a nice icey blue bar to fit the snowy theme of the level.
Here is the syntax you have to follow in order to customise the bar you want:
Syntax: Customize=CUST_BAR, BarType (BAR_...),
FlagsBar (FBAR_...), XOrigin, YOrigin, XSize, YSize, IdColor1, IdColor2,
Extra
This can go in the title as well as the level section
of the script.
Field Descriptions
BarType (BAR_...) field=
In this field we type a bar_constant to specify which bar we want to modify. Here they are for reference:
BAR_AIR
BAR_DASH
BAR_HEALTH
BAR_LOAD_LEVEL
BAR_CUSTOM1
BAR_CUSTOM2
BAR_CUSTOM3
BAR_CUSTOM4
FlagsBar (FBAR_...) field
In this field we can create an animation for your selected bar
like flashing colours etc. You can use two or more FBAR_Flag commands to
specify an animation mode. If you don't wish to use this type IGNORE
Here is the description of the FBAR_SOUND_BAR_ANIM
taken from the reference section of the ng scripter.
Customize=CUST_BAR. This flag
creates in current bar floating colors like you see in audio bar in
Options screen.
When you use this flag you can also type in Extra
field an IdColor (pointing to some ColorRGB= command) to set the mask
color. The audio bar works in a particular way: there is a floating
effect using two colors, the MainColor (IdColor1) and the background
color (IdColor2), while the mask color will be used to paint the full
side of bar.
For example if you use this flag with BAR_HEALTH and
lara has 50% of HP, the left half of bar will be colored with MaskColor
to differentiate by right (empty) half. The mask color doesn't paint
fully the bar but it will be added to current floating effect. For
example if you set as MaskColor the rgb, with 0,0,0 values, you'll get
no difference between left side and right side of bar because adding the
0,0,0, nothing changes, while if you set like mask color the white, with
rgb values 255,255,255, the full side of bar will become fully white,
losing the floating effect.
For above reasons it is a bit
complicated set a good maskcolor. You should try a mask color where the
rgb value was not 0 but not 255 either. For example a color like:
128,128,128 (this is the default mask color if you type IGNORE in extra
field), or 63,63,63 (it used in tomb4 for audio bar in some
circumstances)
FBAR_SHOW_BAR_NAME
This flag is only used for custom bars, they have predefined
index to show the text.
BAR_CUSTOM1 : Extra NG String with index
= 301
BAR_CUSTOM2 : Extra NG String with index = 302
BAR_CUSTOM3 :
Extra NG String with index = 303
BAR_CUSTOM4 : Extra NG String with
index = 304
If you want to show the current value of the bar
under it you must type the variable placefolder for it:
301: Resistence #0050
OR
301: #0050
So
will be used the current value of Local Short Alfa1 under the
BAR_CUSTOM1.
XOrigin, YOrigin, XSize, YSize fields
These fields are quite cool as they allow you to change the size
and position of you bar ingame. I've had some great fun messing with
these. If you want to keep the original size of the bar just type ignore
in this field.
Remark: All
values you type in these fields are in pixels and they are computed to
work with a game screen resolution of 640x480.
This method is
necessary since you can't know what the effective game screen size will
be while a game is being played as the player could change the
resolution settings. Therefore you compute the position and size of bars
using a resolution of 640x480 pixels as a reference, then, if the game
is played at a different resolution, the trng engine will adapt
proportionally the coordinates you've set.
Here is the sizes of the default bars:
TypeBar OrgX OrgY SizeX SizeY
-------------------------------------
HealthBar 8 8 150 12
DashBar 481 8 150 12
AirBar 481 26 150 12
LoadBar 20 444 600 15
This is good as a basis to the size you wish to
achieve with your customised bars.
Remark: there
is some rounding changes between full screen and windowed mode, usually
with gaps of 1 or 2 pixels.
IdColor1 field
Here, we have to type an ID to identify a ColorRGB= script command with
rgb color set as the main colour for the bar. For example if you want
have a pure red bar you can type:
ColorRGB=3, 255,0,0
The ID is 3, so you'll type the value 3 in
IdColor1 field to set the red as main color (this is the main colour of
the full bar).
Warning: About
the ColorRGB command you reference with IdColor it's necessary it is
typed FIRST of Customize=CUST_BAR command otherwise when TRNG engine is
parsing the CUST_BAR command the ColorRGB (if you type it down) will
result as missing and it will appear black in color.
Here are the default colours used in the tomb4 bars:
BarType Red Green Blue
--------------------------
HealthBar 255 0 0
DashBar 0 255 0
AirBar 0 0 255
Again, this is a good basis for a certain colour you want to create. It requires trial and error but it's cool to see the mix you can create!
IdColor2 field
This works like IdColor1 except you can create a background colour for
the bar. The default tomb4 bar is set to black (0,0,0).
Remark: For some reason the values of IdColor1 and 2 works in the inverse way for custom bars, the IdColor1 should be the mask color [the usually 0, 0, 0 RGB] and the IdColor2 is the main color of the bar.
Extra field
This
field may accept different values in conjunction with further FBAR_
flags. Read the description of FBAR_ constants to discover the usage of
this Extra field.
The custom bar is different by other health, dash and
air bar, because in this case there is no predefined target for it. So
it is a free bar to use for your new skills and more. To use the new bar
you must assign a variable placefolder in the EXTRA field.
Customize= CUST_BAR, BAR_CUSTOM1, FlagsBar
(FBAR_...), XOrigin, YOrigin, XSize, YSize, IdColor1, IdColor2, #0042
#0042 means the Local Byte Alfa3 will be used to
store the value of the bar
You can use any variable placefolder for your custom bar, except, of course, from the TEXT entries
Now we're well on our way to customising all the
default tomb4 for bars to create some special effects and add that extra
detail to your mission.
Now we use the ColorRGB= command to
change the colour of the bar. Here's the syntax we will follow:
Syntax: ColorRGB= IdColor, Red, Green, Blue
It can go in both the level and title section of the script.
Remark: With ColorRGB you
can insert a RGB value to use in second moment with some flipeffect or
actions using the IdColor as reference to locate it.
Field Descriptions
IdColor field
This is the progressive number to identify this colour from other
colours you've set in same [Level] section. When you use some flipeffect
or action requiring a script colour you have to insert this IdColor
number in trigger to locate the wished colour.
Red field
This is the intensity of the red colour. You can type a value between 0
and 255.
Green field
This is the intensity of the green colour. You can type a value between
0 and 255.
Blue field
This is the intensity of the blue colour. You can type a value between 0
and 255.
That's it! Have fun experimenting with the fields and
see what effects you can come up with. Here is my customised script for
my bar.
ColorRGB=8, 0,190,255
Customize= CUST_BAR,
BAR_HEALTH, IGNORE, IGNORE, IGNORE, IGNORE, IGNORE, 8, IGNORE