HUD effects and messages - Doom Legacy Wiki

HUD effects and messages

From Doom Legacy Wiki

Jump to: navigation, search
Editing Tutorials

Legacy can be set so you can display information on the player's screen with text (in two formats) or images. The treatment for each one of them is completely different and both require the usage of FraggleScript.


Contents

Displaying text.

There are multiple ways to display text in the player's screen. You may choose to display it to all players or just to some of them or either to set the text in the center of the screen or in the top-left corner where all in-game messages appear. In any way, the font and colour used for these messages will be the standard Doom font. The standard Doom font does not make any difference between capital and non capital characters so "A" and "a" will be displayed both as "A".

From now on and to make things easier, we will refer as messages displayed in the top-left corner as "Messages" and to the ones displayed on the center as "Tips".


Displaying messages.

Messages displayed in the top-left corner are really displayed in Legacy's console. To display a message in the console you use the message fragglescript function. The message will be displayed to all players in game and will be warned with a "Beep" sound.

script 1
{
message("I am a message");
}
startscript(1);

The text between the " " marks will appear in the console.

Notice that you do not have to use the " " marks unless you want the exact text typed to appear. You can instead use variable names or game variables with this function. Also, you can put a comma between different elements you want displayed.

script 1
{
int a=15;
message(playername(), a);
}
startcript(1);

This script will result on the name of the player that triggered the script to appear in the console followed by the number "15" (the value of the variable "a"). This can also be combined with the quotation marks.


Displaying messages to only certain players.

You can display a message only in a certain player's consoles. To display a message in the console of a particular player you use the playermsg fragglescript function. The message will be displayed to the specified player in game and will be warned with a "Beep" sound. The syntax for this function is:

playermsg(playernumber, message)

Where playernumber is the player that will get the message in a range from 0 to 31 (notice that Legacy will indentify player 1 with the number 0 and so on) and message is the message itself as seen in the previous function. This way:

script 1
{
playermsg(1, "I am a message");
}
startscript(1);

The text between the " " marks will appear in the console of player 2 (Legacy will consider 0 to be player 1). Of course, you can change 1 for any number of player in the range 0-31.

Notice that you can use variables and commas to separate different parts of the message as with the message function.

Displaying tips.

Tips are displayed in the center of the screen and will be always centered, that is, you can't print tips in the sides of the screens or in the low or top parts of it. Also they will always be justified in a centered way so the length of the text will expand on both sides from the center of the screen (CHANGE THIS WITH SOME SCREENSHOT). Tips can be displayed to only a player or all of them. The time that the tip lasts on screen can freely be chosen.


Simple tips.

Simple tips are displayed with the tip fragglescript function. The tips displayed with this function will appear on the center of the screen for all players and will have a default duration of XXX tics (TODO: CHECK THIS!!). This function accepts up to 128 printable characters.

script(1)
{
tip("I am a tip");
}
startscript(1);

The text between the " " marks will appear in the center of the screen and dissapear shortly after. Notice that you do not have to use the " " marks unless you want the exact text typed to appear. As with the console messages seen above, you can use variable names or game variables with this function. Also, you can put a comma between different elements you want displayed.

script 1
{
int a=15;
tip(playername(), a);
}
startcript(1);

This script will result on the name of the player that triggered the script to appear in the center of the screen of all players followed by the number "15" (the value of the variable "a"). This can be combined with the quotation marks:

int numberoftimes=0;

script 1
{
tip(playername(), "triggered this script for the ", numberoftimes, "time!!");
numberoftimes  ;
}


Timed tips.

Timed tips work and appear exactly as the simple tips but the time the message lasts can be freely defined by the user. The messages will appear in all the players's screens and will accept up to 127 printable characters. The syntax for this function is:

timedtip(int clocks, tip)

Where "clocks" are the units of time in seconds/100 and "tip" is the tip or tips to be printed. The message will dissapear from the screen once the "clocks" have passed.

int numberoftimes=0;

script 1
{
timedtip(500, playername(), "triggered this script for the ", numberoftimes, "time!!");
numberoftimes  ;
}
startscript(1);

The script above will result on the message (comprised of a few variables and typed text) being printed for five seconds (500/100=5) in the screens of all players. You don't have to use tips comprised of several elements:

script 1
{
timedtip(500, "I AM A TIP THAT LASTS FOR 5 SECONDS!!");
}
startscript(1);


Displaying tips to only certain players.

As happened with the playermsg function, you can make the tips only be visible to certain players with the playertip function. The displayed text will last for a duration of XXX (TO-DO: CHECK THIS!!!). The sintax of this function is:

playertip(playernum, tip)

Where playernum is the number of the player (in a range from 0 to 31, as happened with the playermsg function) and tip is the text to be displayed that, as in previous examples, could be comprised of variables, typed texts between quotation marks or a combination of any of them separated by commas.

script 1
{
playertip(5, "PLAYER 1 IS A RETARD");
}
startscript(1);

The script above will tell the player number six that the player 1 seems to be a retard with a tip. Of course, tips spawned with this function can be more useful and complex:

script 1
{
int playerwhowillgettetip = rnd() % 31;
playertip(playerwhowillgettetip, "YOU KNOW, PLAYER NUMBER ", trigger, " IS IN THE HIDDEN AREA.");
}

The script above will tell a random player in the game that someone triggered (trigger variable means "number of the player that triggered the script") a script in some hidden area, thus, revealing his position.


Tip syntax.

Tips accept line break syntax for complex messages. For example:

script 1
{
tip("YOU ARE INTO THE HALLS OF THE DAMNED. YOU ARE GOING TO DIE NOW!".
}
startscript(1);

Will appear in one text line in the screen. This is not a problem for short tips but, what if you have longer tips?.

script 1
{
tip("YOU ARE INTO THE HALLS OF THE DAMNED. YOU ARE GOING TO DIE NOW!. PREPARE TO SUFFER THE 
CONSEQUENCES OF YOUR OWN STUPIDITY AND FACE YOUR MORTAL FATE IN THIS AWESOME WAD YOU ARE PLAYING 
NOW!!!");
}
startscript(1);

The text above clearly is beyond the limits of the screen and Fragglescript won't split it for you in various lines. Instead of that, the text will just be displayed from the center of the screen in one line with the consequence of you not seeing it completely. To solve this you can use line breaks. To add a line break just add "\n" (without the quotation marks) in the place where you want the line break to be:

script 1
{
tip("YOU ARE INTO THE HALLS OF THE DAMNED.\nYOU ARE GOING TO DIE NOW!.\nPREPARE TO
SUFFER THE CONSEQUENCES\nOF YOUR OWN STUPIDITY AND FACE YOUR MORTAL FATE\nIN THIS 
AWESOME WAD YOU ARE PLAYING NOW!!!");
}
startscript(1);

The script above will make the text appear in five different lines. Notice that spaces between characters when a line break occurs are avoided since it would mean a space before or after a line break (before wouldn't be noticeable but after would look like a text indent).

Displaying images.

You can also choose to display and modify images in the screen of the first player with fragglescript with the use of three different functions. The pictures displayed recieve the name of HUD pictures (from Heads Up Display Pictures). Examples of HUD pictures that are native to Legacy could be the status bar or the icons for ammo, health and armor in full-screen mode.

There are two important things you must note about HUD Pictures you create. First, no matter how you create them, the native Legacy HUD pictures will always be drawn above yours so if you plan to have an icon in the bottom of the screen and you have the status bar in the same place you won't see your own icon. Second, notice that, as in Legacy v1.42, there's no way in which you can spawn different pictures for different players, which is a shame.

That said, there are three commands you must know to manage the HUD pictures you create but there are also some previous requirements you must know about the image and about how to put it into your wad.


Things you must know: format, size, scale and transparency.

The pictures must be in a format that Legacy can recognise. That means that you can use bmp images with 256 colours using the Doom palette. If you don´t use the Doom palette your colours will look all warped and fun in game, so be warned.

The size of the image must be smaller than 320x200. If you ask yourself why, think about the old Doom resolution. That's it, 320x200. Legacy manages the images as if you were running the old resolution so it will always scale them. Say, you have an image that takes half of the screen at 320x200 resolution (a 160x100 image). Well, if you use a 640x400 resolution the image will be scaled so it looks like a 320x200 image. Same will hapen if you play at a resolution of 800x600 (with a result a 400x300 scaled image). Bear this always in mind when you design your HUD picture.

The HUD pictures you make may have transparency. That means that any pixel you put in the image that is of certain colour will appear as transparent in the image and, thus, the game screen will be seen through it. Transparent pixels must be of cyan (that is RGB 0,255, 255) as in the original Doom graphics.

Inserting your pictures in your wad.

Before you can use your picture you must "physically" insert it in your wad so Legacy can find it when you tell it to. I don't know in wich Legacy version you had to use a program called Lumpy.exe to insert your graphic lumps into your wad but well, forget about that now. To insert a HUD picture in your wad you'll need a wad program manager like XWE.

Open your program and create a new entry. Load your bmp file into this entry and set the offsets to xy(0,0). Then give it some name that doesn't beyond 8 characters and you're done. Remember the offsets thing if you don't want your HUD pictures to be displaced.


Creating your HUD picture in Legacy.

Once you have your image into your wad you can create a HUD picture in Legacy. Think as HUD pictures not as the bmp but as some abstract data collection. This data collection must have a name so first you have to do is to declare a variable that will store this data:

script 1
{
int myhudpicture;
}

O.k, now comes a harder part. You just declared the variable and now you're gonna fill it with information. You must use the createpic fragglescript function for that. This is the syntax for this function:

createpic(string lumpname, int x, int y, int draw, int trans, fixed priority)

Don't be afraid, we're gonna go step by step through each one of it's parts:

-string lumpname: this may sound complex but it´s nothing but the name you gave to the entry in your wad file (the one that couldn't be beyond 8 characters... Notice it hasn't to be the same as the bmp file you made). Think about it as if you were telling Legacy "Look into the wad and bring me here the entry with this name". Notice that, since it's a string of characters you must use quotation marks ("") so you literally refer to the picture.

-int x/int y: These are the coordinates at wich your picture will appear and they may range from x(0,319) and y(0,199). This is due to the 320x200 resolution we mentioned earlier, remember?. Also, Legacy will handle your pictures from the left-top part of them so if you put x,y at (0,0) your image will appear exactly at the upper left corner of the screen. When setting the coordinates for your HUD picture you may put them out of the boundaries of the screen so be careful with both the scaling and coordinates.

-int draw: This may be 0 or non 0. Zero just means that this picture won't be drawn to the screen right now (so you can create it now but make it appear later) and non-Zero means that it will be drawn to the screen.

-int trans: The Legacy team seems to intend to make the HUD pictures translucent... It¬¥s not clear if this works or not or if this is related to the draw value. According to the documents, a value of non-Zero to the trans setting will make the picture translucent. Anyway, we're not going to use it this tutorial :P.

-fixed priority: If you´re gonna have multiple HUD pictures that are meant to overlap in some moment you may want to manually set their priority so certain ones are drawn over others (as the Legacy native HUDS draw over your own HUD pictures). The higher this value, the "higher" it will be set. Think as it as "layers" in paint programs or, easier, a value of 100 is drawn over a value of 99.

So, now that we know what this means here's an example:

script 1
{
int myhudpicture;
myhudpicture=createpic("HUDPIC", 10, 10, 1, 0, 1);
}
startscript(1);

The script above declares a variable and fills it with a HUD picture in the wad called "HUDPIC". From this moment, when we want to modify this HUD picture we will refer to it in Fragglescript as "myhudpicture" and not as "HUDPIC" as you may thing: the content of the picture (the image) may change but the continent (myhudpicture variable) is still there. Think of the picture itself as liquid and in the variable as a bottle: you can fill a bottle with different liquids.

O.k, so the script above fed our variable with a picture called "HUDPIC", the coordinates are xy(10,10) so that´s the top-left corner with a margin of 10 pixels. Then it's directly drawn to the screen at that position, non translucent with a priority of 1. And there you have your picture.

Note: at this moment it ain't clear to me what happens if you skip one of the parameters but you can avoid the last three. That's what we'll do at this tutorial from now on.


Managing your HUD picture in Legacy.

Have you read the previous note?. Well, it makes our script go like this.

script 1
{ 
int myhudpicture;
myhudpicture=createpic("HUDPIC", 10, 10);
}
startscript(1);

This way our picture won't be directly drawn and won't have any priority number or anything. In a sense, our picture is there but it's just that is invisible to us. We could make it visible easy enough with the setpicvisible function. It's syntax goes like this:

setpicvisible(int handle, int visible)

Where handle is the name of the variable we set (the bottle, so to say it) and visible may be 0 (invisible) or non-Zero (visible).

Now we're gonna use it:

script 1
{
int myhudpicture;
myhudpicture=createpic("HUDPIC", 10, 10);
while(1)
{
 setpicvisible(myhudpicture, 0);
 wait(20);
 setpicvisible(myhudpicture, 1);
 wait(20);
}
}
startscript(1);

The script above declares the variable (the bottle), feeds it with a picture in the wad file called "HUDPIC" and then goes into a loop that makes it invisible and visible at 0.2 seconds intervals. The result of this is your picture using the famous "invulnerable" effect from old arcade games (flickering on and off).

This is only an example of the possibilities. You could turn the picture visible when something happens (a door is opened) and turn it off while it's closed so the player knows when the path is clear or not... But there are more things we can change like, for example, the position and even the image (remember, the liquid of the bottle, the bottle's name reference is the same). This can be done with the modifypic fragglescript function. It's syntax goes like this:

modifypic(int handle, string lumpname, {int x}, {int y})

Where handle keeps on being the name of the variable (or bottle), string lumpname is the name of the picture in the wad (the liquid) and intx/inty the coordinates. To use another image you must have previously inserted it into your wad but there's no need to declare two different variables if you're gonna have two different pictures: just empty your bottle and fill it with new liquid.

script 1
{
int myhudpicture;
myhudpicture=createpic("HUDPIC", 10, 10);
wait(100);
modifypic(myhudpicture, "HUDPIC2", 10, 20);
}
startscript(1);

That will make your hud picture appear at the given coordinates and, a second later, it will change coordinates to xy(10,20) and it's image to another called "HUDPIC2". Notice you can happily ignore the coordinates and change only the image that will appear at the same coordinates as it was before.

script 1
{
int myhudpicture;
myhudpicture=createpic("HUDPIC", 10, 10);
wait(100);
modifypic(myhudpicture, "HUDPIC2");
}
startscript(1);

That will only change the picture after a second but it will remain at the same place.


Final words.

And that was all. With this tutorial and a little practice you should be able to communicate all kinds of information to your player. You could even use combinations of them (for example, a HUD picture of a PDA console with "tips" over it... It would be 1000 more flexible if the "tip commands" allowed for coordinates and formatting anyway) so I recommend you to fire up your imagination when you do those single player maps and spice them up a bit with some interaction :).

Personal tools