[Tutorial] 100% custom HUD [Last Update 25.01.16] (FAQ)

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
User avatar
Anakin
Master of the Force
Master of the Force
Posts: 4817
Joined: Sat Sep 19, 2009 11:37 am
Projects :: RC Side Mod - Remastered - SWBF3 Legacy
Location: Mos Espa (germany)

[Tutorial] 100% custom HUD [Last Update 25.01.16] (FAQ)

Post by Anakin »

The big HUD Tutorial


==============================ATTENTION=============================
Remaster 1.3 is released.
To disable all HUD elements use rema_noHUD = true in your mission and load a custom lvl file with
the default stock HUD but with your changes. For further Information about this, read the Remaster
developer documentation.
==================================================================


I haven't found a way to make a 100% custom HUD without an global ingame here on GT and everyone told me it's not possible. So i played around with the HUD and found a way to do it.

What can you learn with this tutorial:
  • Step 0: Major trick for resolution problems
  • Step 1: Remove any msh things from the HUD
  • Step 2: Remove any bitmaps from the HUD
  • Step 3: Remove any textes from the HUD (updated)
  • Step 4: The HUD file itselfe
    • Part 1: New msh, Basics (Groups, Move,...)
    • Part 2: Colored msh, EventColor
    • Part 3: Bitmaps, rect()
    • Part 4: Msh transforms
  • Step 5: custom minimap

==============================NOTICE==============================
After this is my first tutorial it would be nice if you can tell
me if something is not understandable.
==================================================================



First of all a big thanks to


Step 0: Major trick for resolution problems
So after there are lots of Problems with people playing on different resolution, here is a tipp, how to fix this.
In the following tutorial you'll learn, how to modify the HUD and how to load the lvl files. This is about how to load different lvls for different resolutions.

Code: Select all

local screenWidth, screenHeight = ScriptCB_GetScreenInfo()
if screenHeight > 1000 and screenWidth > 1900 then
	ReadDataFile("dc:ingame.lvl")
	ReadDataFile("ingame.lvl")
	ReadDataFile("dc:bmpKill.lvl")
else
	ReadDataFile("ingame.lvl")
end
If you add this if-else condition to your lua you can specify what file should be loaded. You'll learn about the lvl files later. All you need to know is that the custom ingame.lvl and bmpKill.lvl are loaded if the screen is higher than 1000 and bigger than 1900 pxl.
You can also use elseif if you want to distinguish more than two cases.

To make your changes be available on more than just one resolution you can work with the aspect ratio. You need to make HUD changes such as weapon icons only once per aspect ratio. Here an exaple code

Code: Select all

       local screenWidth, screenHeight = ScriptCB_GetScreenInfo()
        local aspectRatio = screenWidth / screenHeight
                print("ME5_MiscFunctions:    Width: "..screenWidth.."    Height: "..screenHeight.."    Aspect Ratio: "..aspectRatio)
        if aspectRatio <= 1.4 then
                        print("ME5_MiscFunctions: Aspect Ratio is 4:3; loading scopes as such")
                ReadDataFile("..\\..\\addon\\ME5\\data\\_LVL_PC\\ar\\ar43\\ar.lvl")
        elseif aspectRatio <= 1.63 and aspectRatio >= 1.5 then
                        print("ME5_MiscFunctions: Aspect Ratio is 16:10; loading scopes as such")
                ReadDataFile("..\\..\\addon\\ME5\\data\\_LVL_PC\\ar\\ar1610\\ar.lvl")
        elseif aspectRatio <= 1.9 and aspectRatio >= 1.63 then
                        print("ME5_MiscFunctions: Aspect Ratio is 16:9; loading scopes as such")
                ReadDataFile("..\\..\\addon\\ME5\\data\\_LVL_PC\\ar\\ar169\\ar.lvl")
        else
                        print("ME5_MiscFunctions: Error! Invalid aspect ratio ("..aspectRatio..")! Defaulting to workaround")
                ReadDataFile("..\\..\\addon\\ME5\\data\\_LVL_PC\\ar\\ar.lvl")
        end
Special thanks to marth for the script.


Step 1: Remove any msh things from the HUD

Ok this is about msh files and how to remove them from the HUD.
Examples for msh's on the HUD are the icons or the reticule. All HUD msh's are in the C:\BF2_ModTools\data_XXX\Common\mshs folder
If you want to remove an msh you need to scale it down to 0.0. For this you browse the directory i pointed out above and make a new option file.
Let's say we want to remove the reticule's bullseye. So first check if there still is an option file. In this case you just edit it and add

Code: Select all

-scale 0.0
to it. You also can remove everything that was in there before it doesn't matter after we want to remove it. Make sure the option files is called hud_main_reticule_bullseye.msh.option. and not something like hud_main_reticule_bullseye.msh.option.txt!

Ok now the munge.bat will scale the reticule's bullseye to 0.0 when munging it. But first we need to tell the munge.bat that we want this msh be munged.
You need to edit the ingame.lvl in the C:\BF2_ModTools\data_XXX\Common folder.

There is a lot of stock stuff we don't need. So remove everything beside the bullseye.

Code: Select all

ucft
{
    REQN
    {
        "model"
		"hud_main_reticule_bullseye"
    }
}
Go and munge the ingame.lvl. You all read the tutorial from [RDH]Zerted?? If not now is the time for it ;) After you understood this part, you can use my Custom LVL maker to build your lvl files. But it is good to understand the basics from Zerted's tutorial. And don't forget to copy the ingame.lvl manuel if you don't use the option file from the lvlmaker!

Now we need to setup the lua.
The interesting thing is the function ScriptInit(). Find the line

Code: Select all

ReadDataFile("ingame.lvl")
And add your custom ingame.lvl BEFORE the stock one.

Code: Select all

ReadDataFile("dc:ingame.lvl")
ReadDataFile("ingame.lvl")
What bf2 is now going to do: It load's your custom bullseye scaled to 0.0. And after this it loads all the stock things. But not the bullseye after it already knows one (your one). That's why you need the custom line before the stock one.

Go and run BF2 and enjoy the difficult with an removed bullseye.
This works for all hud msh.


Step 2: Remove any bitmaps from the HUD

After you tested the msh remove possibilities you should have noticed there are things that cannot be removed this way (ammo clips, healthbar, heatbar,..). These are bitmaps. So you don't have an msh, only tga files.
The idea is the same as for the msh. Do something to make it invisible. So let's say we want to remove the ammo clips. The hud_clipbar_segment.tga can be found in the C:\BF2_ModTools\data_XXX\Common\interface folder. Edit it with an picture editor of your choice. But make sure it saves the tga with transparent. PSE for examples does not. I use Paint.Net for this.
You may already know we now need to edit the ingame.lvl again.
That's right, but we need a new ingame.lvl and not the one where we have the msh things in.
So there are two ways:
1st: use the How to munge a custom lvl tutorila somewhere here on gt
2nd: duplicate the ingame.req file, rename it and edit the duplication.

I toke the 2nd option.
So now i have an ingameMsh.req and an ingame.req in the C:\BF2_ModTools\data_XXX\Common folder.
edit the ingame.req and add your tga you want to remove.

Code: Select all

ucft
{
	REQN
	{
		"texture"
		"hud_clipbar_segment"
	}
}
Munge your map/mod and go to C:\BF2_ModTools\data_XXX\_LVL_PC rename the ingame.lvl to bmpKill.lvl and copy it to your addon\XXX\data\_lvl_pc\ folder.
Just keep in mind what req file in your C:\BF2_ModTools\data_XXX\Common folder is called ingame.req - the msh one or the bmpKill one - if you munge your ingame the next time.

Now we are ready to set up the lua.
So find this part again

Code: Select all

ReadDataFile("dc:ingame.lvl")
ReadDataFile("ingame.lvl")
and change it to

Code: Select all

ReadDataFile("dc:ingame.lvl")
ReadDataFile("ingame.lvl")
ReadDataFile("dc:bmpKill.lvl")
So why all this trouble and why don't we add the bitmap to the custom ingame.lvl?
It's because bitmaps will be overwritten. BF will load your custom bitmap in the first step, together with your custom msh files. Than from the stock ingame.lvl BF loads everything it doesn't already know AND all bitmaps. And now comes our bmpKill.lvl with the transparent tgas and BF loads them again.
You can also add the bmp's tgas to your custom ingame.lvl and load it before and after the stock one, but i thought this way is more cool 8). Also if you have bigger ingame.lvl bf take longer to load your map/mod if you load it twice.

So munge the edited lua file and enjoy a gamplay without ammo sticks.
This works for all bmps.


Step 3: Remove any textes from the HUD

= UPDATE =============================================
I released a mod that removes the text for you. It is more powerful since it uses a
few new tricks and functions to rescue every menu and submenu text.
But if you prefer to do everything on your own and stay with ugly unreadable text
and a huge sized mod feel free to continue reading this section
====================================================


Now we know how to disable all objects. But there are still the text things we don't like.
To remove them we need an font that takes spaces for all letters. I made one, but it's not perfect, after there are still things left (äöü and other things).
Follow the tutorial for custom fonts
Name the font the same the one is called you want to remove. And add it to an new req file the way they are loaded in the core file. Do not add them to the core.req. We have to do it the same way we did for the ingame.req

Code: Select all

ucft
{
	REQN
	{
		"font"
		"gamefont_large"
		"gamefont_medium"
		"gamefont_small"
		"gamefont_super_tinny"
		"gamefont_tinny"
	}
}
if you take these all everything is removed. But don't forget some text we need (the esc menu for example).
munge the new core file and name it txtKill.lvl when it is munged. Than munge the stock core file again (!important because Modtools copies the core.lvl to the Addon folder!).
Now go and edit your lua again and find this part:

Code: Select all

ReadDataFile("dc:ingame.lvl")
ReadDataFile("ingame.lvl")
ReadDataFile("dc:bmpKill.lvl")
and change it to

Code: Select all

ReadDataFile("dc:ingame.lvl")
ReadDataFile("ingame.lvl")
ReadDataFile("dc:bmpKill.lvl")
ReadDataFile("dc:txtKill.lvl")
And again the question why don't we add the "zero fonts" to the core file. The problem is that bf loads it when it opens the addme file. And than every menu textes and also the ones from other maps/mods are removed. That's way we load it in the lua file. Than this is only for your map/mod.
I think the most interesting things are the ammo numbers and the weapon names. So here are the fonts you need to remove:
gamefont_large: reinforcements, ammo numbers
gamefont_small: weapon names
The problem we now have is that some menu textes are removed (spawn menu, esc menu, stats,...)
To fix that you need to edit the scripts and add them to the ingame.req. Replace all gamefont_large with an copy of the font with an different name. This font you need to load in the core.req (NOT txtKill.req).

Code: Select all

ucft
{
	REQN
    {
        "script"
        "ifs_sideselect"
		"ifs_charselect"
		"ifs_mapselect"
		"ifs_readyselect"
    }
	
	REQN
    {
        "script"
        "platform=pc"
        "ifs_pc_spawnselect"
	}

    REQN
    {
        "model"
		"hud_main_reticule_bullseye"
    }
}
So the fonts change with different display high in some scripts. I have the problem with an Full HD Display that the Unit's names are displayed, but not the information of them in the spawn screen (Ingame i have no problems).
Also some scripts are loaded in the common.req file. You need to look for all loaded scripts if there is the font called you use. But till now i haven't got this working. So if you have an idea please tell us.

Ok i no find a way to make it work 100%.
This is what you need to do:
change font = gMenuButtonFont, in the ifs_sideselect.lua to font = "gamefont_large_rc", and load the script in the ingame.req. But remember that the font name need to be loaded in the core file. If you called it something else you need to take this name.
To make the text availabel at the loadscreen i haven't found a way. But if you load the txtKill.lvl at the end of the function you have the most time the textes displayed.
Also BF seams to have problems with mungeing the same fonts with different names. So as far as i noticed medium and small are the same. That's why we have problems with the medium fonts.
To fix it you need to change all calls for gamefont_medium to gamefont_small_rc or what ever you called the font.
Than you need to edit the common.req and only load this script:

Code: Select all

ucft
{
    REQN
    {
        "script"
        "ifs_pausemenu"
	}
}
In this script you need to make the same changes with the fonts you did before in the othere scripts, too.
So now we have the problem, that the stats have no textes. But we also can not load the stat script in the common, because for some reason it doesn't work.
So go to C:\BF2_ModTools\data_XXX\Common\scripts and edit Objective_Conquest.lua or what ever objective you use and find the function ObjectiveConquest:Complete(winningTeam) (it's the last one in conquest). At the end you write ReadDataFile("core.lvl") this makes BF load the stock core file when you won or loos. So than it has the stock fonts again and can display the stats correctly.

Code: Select all

function ObjectiveConquest:Complete(winningTeam)
	if not self.multiplayerRules then
		--remove all the cp markers
		for i, cp in pairs(self.commandPosts) do
			MapRemoveEntityMarker(cp.name)
		end
	end
	
	--then call the default objective complete method
	Objective.Complete(self, winningTeam)
	ReadDataFile("core.lvl")
end
Of cause we needn't forget to load our edited scripts (ifs_pausemenu,..). Do this in each mission script at the beginning after the ScriptCB_DoFile() lines:

Code: Select all

ReadDataFile("dc:common.lvl")
ReadDataFile("common.lvl")

Step 4: The HUD file itselfe

Ok this is very complex, so i start with

Part 1: New msh, Basics (Groups, Move,...)
This Part is very simple. It's about a new msh that you add to the HUD. All msh files for the HUD go to C:\BF2_ModTools\data_XXX\Common\mshs.
The tga's for them can also go there or you put them to C:\BF2_ModTools\data_RCM\Common\interface.

Than we need to add them to our ingame.req. You remember the one where we removed msh things.

Code: Select all

ucft
{
	REQN
	{
		"texture"
		"hud_rc_main"
	}
	
    REQN
    {
        "model"
		"hud_main_reticule_bullseye"
		"hud_rc"
    }
}

As you see the new msh (hud_rc) goes to model and the texture of the msh (hud_rc_main) goes to the texture. You know this section from the removing bitmap step, but this tga goes to the ingame.req not the bmpKill.req.
Ok now BFII knows our files. But we need an other file where define the position and the event it should apear. Therefore we need to edit the 1playerhud.hud file. Just to clear: 1player means one player is playing. 2playerhud.hud overwrite the things in 1playerhud.hud if two players are playing with a split screen. We will not need that while moding for PC. The hudtransforms.hud file is for different transformations, more about this later.
But before we start to edit the hud file itselfs we add it to our ingame.req

Code: Select all

ucft
{
	REQN
	{
		"texture"
		"hud_rc_main"
	}
	
    REQN
    {
        "model"
		"hud_main_reticule_bullseye"
		"hud_rc"
    }

    REQN
    {
        "config"
        "1playerhud"
    }
}
You see the ingame.req become bigger and bigger and that's way i made the thing with the bmpKill.lvl instead of loading the ingame.lvl twice.

Ok now we are ready to edit the HUD file. So browse C:\BF2_ModTools\data_RCM\Common\hud there you find the 1playerhud.hud file. But wait there is an PC folder with an other 1playerhud.hud file. After i wasn't sure what file BF2 munged and it seamed to me it takes everytime an other, i renamed the on in the PC folder to org_1playerhud.hud, so now bf2 need to take the on in the directory i pointed out above.

Now when you edit the 1playerhud.hud file there are a lot of things you will not need. You can delete everything. Because you also load the stock ingame.lvl and so the stock and with this the stock 1playerhud.hud file.
So here is your clean hud file. I don't know what this first lines are good for, but it was there before, so i added the header again:

Code: Select all

FileInfo("republicHUD")
{
    Viewports(1)
}
As far as i noticed you can take any name for the FileInfo("").
To add our new msh file we now add the following code.

Code: Select all

Group("player1huddisplay")
{
	PropagateAlpha(1)
    Viewport(1)
    Position(0.000000, 1.00000, 0.000000, "Viewport")
    ZOrder(1)
    EventEnable("player1.spawn")
    EventDisable("player1.die")
	
	Model3D("player1hud")
	{
		Mesh("hud_rc")
		Viewport(1)
		Position(0.480000, 9.900000, 0.000000, "Viewport")
		Rotation(0.000000, 0.000000, 0.000000)
		Scale(21.800000, 24.000000, 10.000000)
		ZOrder(0)
		EventEnable("player1.spawn")
	    EventDisable("player1.die")
	}
	
}
So what is this all good for. The first line is just an group. You can name it what ever you like. At the next lines come some basic properties for that group. I don't know what they all mean, but here are some i know:

PropagateAlpha(1) - As far as i know it enables transparency to the objects.
Viewport(1) - you've seen it in the header. everything has this inside, so i added it, too.
Position(0.000000, 1.00000, 0.000000, "Viewport") - ok that's simple x, y, z but be carefull with changes just change a little bit. I have no idea about the scale, but somethimes +1 moves the things just an cm and sometimes a +0.1 makes your msh jump out of the screen.
Scale(0.000000, 0.000000, 0.000000) - isn't in this example, but this is for Scaleing the group/elements. No scale has the parameters (1.000000, 1.000000, 1.000000), or you delete this line.
Rotation(0.000000, 0.000000, 0.000000) - This rotates things. I have no idea in which direction. it was different for each thing i rotated and it also depens on the group's basis roation values.
ZOrder(1) - this means what element is before the others. 0 is the neares one to the camera, everything higher is more away. This can but needn't affect to bitmaps the same it does for mshs.
EventEnable("player1.spawn") - so this is about when your group is displayed in this case when the player spawn. There is no list about all events.
EventDisable("player1.die") - nothing to say.

After the properties you see an element. But there can also come a new child group.
All the Proporties above can be added to every element or child groupe. But remember that position or scale, or rotation changes are additive. So if you move the basis group to 0.1 and the child group/Element to 0.1 it's at position 0.2 on the screen.

About the zOrder:
If you have more child groups you can range their elements or their new child groups with the ZOrder again. This is not additive! Lets say we have two groups:

Code: Select all

Group("One")
{
	PropagateAlpha(1)
    Viewport(1)
    Position(0.000000, 1.00000, 0.000000, "Viewport")
    ZOrder(0)
    EventEnable("player1.spawn")
    EventDisable("player1.die")
	
	Model3D("One")
	{
		Mesh("One")
		Viewport(1)
		ZOrder(255)
		EventEnable("player1.spawn")
	    EventDisable("player1.die")
	}
}

Group("Two")
{
	PropagateAlpha(1)
    Viewport(1)
    Position(0.000000, 1.00000, 0.000000, "Viewport")
    ZOrder(1)
    EventEnable("player1.spawn")
    EventDisable("player1.die")
	
	Model3D("Two")
	{
		Mesh("two")
		Viewport(1)
		ZOrder(0)
		EventEnable("player1.spawn")
	    EventDisable("player1.die")
	}
}
In this case the msh one is displayed before the msh two because the whole group one is before the group two. It doesn't matter what the child groups/elements say. If you have more than one child you can range them with the ZOrder again.
There are lots of more options but they are mostly selfexplained.

An other tip if you make custom hud icons you can add their msh to the ingame.lvl and than make all the extraweapon's change from the floating icon tutorial in the 1playerud.hud file, or you make them in the extraweapon's file. I just thought it was an good i dea to have hud icons in the ingame.lvl file.


Part2: Colored msh, EventColor
OK now we know how to add msh to our hud. But sometimes we want to have a different color for different events (reticule team color, health color,..)

For this i have two examples. First is the reticule.

Code: Select all

Group("player1reticule")
{
	EventPosition("player1.weapon1.reticule.position")
	Position(0.500000, 0.5000, 0.000000, "Viewport")
	Scale(0.8000, 0.8000, 0.8000)
	PropagateAlpha(1)
	Alpha(1.0000)
	EventEnable("player1.weapon1.reticule.position")
	EventDisable("player1.weapon1.reticule.disable")
	EventAlpha("player1.reticule.alpha")
	
	Model3D("player1reticule_inside")
	{
		Mesh("hud_rc_reticule_inside")
		Lighting(5)
		Scale(0.100000, 0.100000, 0.100000)
		ZOrder(1)
		Lighting(5)
		Alpha(0.750000)
		ColorChangeRate(0.001000)
		EventEnable("initialize")
		EventColor("player1.weapon1.target.teamColor")
	}
	
	Model3D("player1reticule_outside")
	{
		Mesh("hud_rc_reticule_outside")
		Scale(0.100000, 0.100000, 0.100000)
		Alpha(0.400000)
		ColorChangeRate(0.001000)
		EventEnable("initialize")
		EventColor("player1.weapon1.target.teamColor")
	}
}
This is the important part. You can copy it from the org_1playerhud.hud.
In this case the above is not from the stock hud files, it's my Republic Commando's reticule. But this will do for pointing out how it works.
On of the basics of the reticule is the msh file. You need to add an texture to the msh even we will not use it. A white tga will do. There is still one in the interface folder, so you can make an reticule msh without texture and hex edit the MATL from the stock reticule.
OK to make it very simple this only enables a new msh on the screen (the reticule) and than there is the EventColor("player1.weapon1.target.teamColor") line at the msh's properties.
How the msh is added i explained in Part 1. The EventColor("") paint the reticule in the color of the team. How to change the Team's color i have no idea. If you want to have an statical color you can use instead of the EventColor line Color( R, Y, B) use values between 0 and 255 for Red, Yellow, Blue.

This was a very short example, but here is an other one:
The healthbar changes the color, if the healthvalue goes down.

Code: Select all

Group("player1healthbar")
{
    PropagateAlpha(1)
    Viewport(1)
    Position(0.010803, 0.952479, 0.000000, "Viewport")
	ZOrder(0)
    Alpha(0.600000)
    Color(255, 231, 255)
    FadeInTime(1.000000)
    FadeOutTime(0.200000)
    EventEnable("player1.health")
    EventDisable("player1.healthDisable")
	
	BarBitmap("player1health_fill_l")
    {
        FlashyIncFadeOutTime(1.000000)
        FlashyDecFadeOutTime(1.000000)
        Bitmap("hud_rc_health_bitmap")
        BitmapRect(0.225000, 0.060000, "Left", "Top", "Viewport")
        TexCoords(0.000000, 0.500000, 1.000000, 1.000000)
        Viewport(1)
        Position(-0.010157, -0.165000, 0.000000, "Viewport")
        ZOrder(2)
		EventValue("player1.healthFraction")
		EventColor("player1.healthColorNew")
        EventPulseRate("player1.healthRegenPulseRate")
        ColorChange(0, 0, 0)
        ColorChangeRate(0.200000)
		EventEnable("player1.healthFraction")
        EventDisable("player1.healthDisable")
    }
}
Here come lots of new things. The bitmap, the eventvalue, rect,...
But we will only look at the color.
Important is this line:
EventColor("player1.healthColorNew")
you can also name it "player1.blablub" Important is that it is the same name as here at the transformation.
This need to be before the healthbar group.

Code: Select all

ViewPort("Transforms")
{
    TransformNumberColor("player1healthcolor")
    {
        NumberColor(0.000000, 200, 0, 0)
        NumberColor(0.290000, 200, 0, 0)
        NumberColor(0.300000, 150, 240, 26)
        NumberColor(0.590000, 150, 240, 26)
        NumberColor(0.600000, 0, 213, 6)
        NumberColor(1.000000, 0, 213, 6)
		
		EventInput("player1.healthFraction")
        EventOutput("player1.healthColorNew")
    }
}
I don't understand exactly, how it works, but it does :D so the healtFraction is the input value.
The NumberColor returns a color to player.healthColorNew. It depens on how big the inputvalue is in relation to it's start value.
Please do not hit me for my bad english. I try to explain with an example:
Your health is 100. Than you set this for the Value of the healthbar. When you are looking for the EventColor player1.healthColorNew the transformation returns it's value. And this depens on the EventInput player1.healthFraction. The Healthfraction is a value between 1.0 and 0.0, depending on how much of your life is left. You specify the return color with the NumberColor(upper/lower range, R, Y, B).
These Transformation can be found in the hudtransforms.hud file i told you above. I tryed to make these transforms in this file, but it doesn't worked. So i added the transform to the 1playerhud.hud file and than it worked.

After we saw the Rect() function and the bitmaps it's now interesting, how these things works and so we now come to


Part 3: Bitmaps and rect()
The bitmaps are simple tga files mostly with white and transparent parts. You find them in the inteface folder.
The Bitmap alone would simply shown on the screen with the color you define with EventColor() or Color(). But the BitmapRect() function defines an rectangle, what part of the Bitmap is shown.
So it's like you have an Bitmap as an pattern and the BitmapRect() draws just the part that is defined as an rectangle. But it only draws the white parts and not the transparents of the bitmap.
An example for this special Bitmaps are the Healthbar or the Jetpackbar.
I take again my Republic Commando HUD, so don't wonder that the values are not from the stock HUD.

Code: Select all

Group("player1healthbar")
{
    PropagateAlpha(1)
    Viewport(1)
    Position(0.010803, 0.952479, 0.000000, "Viewport")
	ZOrder(0)
    Alpha(0.600000)
    Color(255, 231, 255)
    FadeInTime(1.000000)
    FadeOutTime(0.200000)
    EventEnable("player1.health")
    EventDisable("player1.healthDisable")
	
	BarBitmap("player1health_fill_l")
    {
        FlashyIncFadeOutTime(1.000000)
        FlashyDecFadeOutTime(1.000000)
        Bitmap("hud_rc_health_bitmap")
        BitmapRect(0.225000, 0.060000, "Left", "Top", "Viewport")
        TexCoords(0.000000, 0.500000, 1.000000, 1.000000)
        Viewport(1)
        Position(-0.010157, -0.165000, 0.000000, "Viewport")
        ZOrder(2)
		EventValue("player1.healthFraction")
		EventColor("player1.healthColorNew")
        EventPulseRate("player1.healthRegenPulseRate")
        ColorChange(0, 0, 0)
        ColorChangeRate(0.200000)
		EventEnable("player1.healthFraction")
        EventDisable("player1.healthDisable")
    }
}
You see the first part just ranges the Healthbar group on the screen and an element of the group is the BarBitmap with the following functions:
FlashyIncFadeOutTime(1.000000) - the time to fade in the new bar part when you get health.
FlashyDecFadeOutTime(1.000000) - the time to fade out the lost bar part when you loose health.
Bitmap("hud_rc_health_bitmap") - this opens the bitmap that should be drawn on the screen.
BitmapRect(0.225000, 0.060000, "Left", "Top", "Viewport") - this defines the rectangle that is drawn from the Bitmap ( X, Y). Left and Top says where to begin with drawing. In this case you will move the rectangle and bitmap with position begining at the upper left corner.
TexCoords(0.000000, 0.500000, 1.000000, 1.000000) . I have no Idea again.
EventValue("player1.healthFraction") - for some reason this affect the first value of the rectangle.

So now let's say we want to have an square with rounded edges. So you make an tga file with rounded edges, load it as Bitmap() and all is done.
The problem is mostly that the Bitmap is much bigger than the drawn rectangle. So when i made the HUD changes i started to move the bitmap at it's position and made the big and hight with the rect' X,Y values. Adn than i edited the tga to make the squar become round.

Sometimes it would be nice to change the direction the bar goes down. For this you can take the Rotation() function. Just change the last value. So for example Rotation(0.000000, 0.000000, 90.000000).

An other Tip: If you want the bar to go down from left to right you can also take negative values for the rectangel function. That's the way i made it at my RC HUD.

Code: Select all

Group("player1healthbar")
{
    PropagateAlpha(1)
    Viewport(1)
    Position(0.010803, 0.952479, 0.000000, "Viewport")
	ZOrder(0)
    Alpha(0.600000)
    Color(255, 231, 255)
    FadeInTime(1.000000)
    FadeOutTime(0.200000)
    EventEnable("player1.health")
    EventDisable("player1.healthDisable")
	
	BarBitmap("player1health_fill_l")
    {
        FlashyIncFadeOutTime(1.000000)
        FlashyDecFadeOutTime(1.000000)
        Bitmap("hud_rc_health_bitmap")
        BitmapRect(0.225000, 0.060000, "Left", "Top", "Viewport")
        TexCoords(0.000000, 0.500000, 1.000000, 1.000000)
        Viewport(1)
        Position(-0.010157, -0.165000, 0.000000, "Viewport")
        ZOrder(2)
		EventValue("player1.healthFraction")
		EventColor("player1.healthColorNew")
        EventPulseRate("player1.healthRegenPulseRate")
        ColorChange(0, 0, 0)
        ColorChangeRate(0.200000)
		EventEnable("player1.healthFraction")
        EventDisable("player1.healthDisable")
    }
	
	BarBitmap("player1health_fill_r")
    {
        FlashyIncFadeOutTime(1.000000)
        FlashyDecFadeOutTime(1.000000)
        Bitmap("hud_rc_health_bitmap")
        BitmapRect(-0.225000, 0.060000, "Left", "Top", "Viewport")
        TexCoords(0.000000, 0.500000, 1.000000, 1.000000)
        Viewport(1)
        Position(0.988282, -0.165000, 0.000000, "Viewport")
        ZOrder(2)
		EventValue("player1.healthFraction")
		EventColor("player1.healthColorNew")
        EventPulseRate("player1.healthRegenPulseRate")
        ColorChange(0, 0, 0)
        ColorChangeRate(0.200000)
		EventEnable("player1.healthFraction")
        EventDisable("player1.healthDisable")
    }
}

This way you can mirrow the bar insteaf of rotate it and make a new bitmap.


Part 4: Msh transforms
You may have the problem that you want to change some stock weapons msh but cannot find where the HUDIcon = "" line is in the odf file. For example the detpack plunger.
There is still a way to change the Icon with Msh transforms. It's the same that the floating icon fix (fif) uses.
At the fif you want to remove the floating icon and make a new one at the right position. Therefore you transform the icon to an invisible one and make a new one with the right position.
But this doesn't only work for removing things you can also change the stock icon to an new one instead of scaleing the stock one down and make a new one.

Code: Select all

ViewPort("Transforms")
{
	EventNameFilter("player%")

	TransformNameMesh("player1weapon1")   // add msh names of first weapons here and remove unused lines
	{
		/////////////////////////////////REPUBLIK/////////////////////////////////
		NameMesh("first_msh", "second_msh")

		EventInput("player1.weapon1.change")
		EventOutput("player1.weapon1.mesh")
	}
}
I have no idea what EventNameFilter("player%") is good for. Maybe FragMe! can tell us somethings about this. The EventInput and Output works simular to the color transformation, but in this case the Output returns an msh file, the second_msh. So in one word it return everytime someone calls first_msh the second_msh.


Step 5: Custom minimap

There are many who tried to move the minimap somewhere else and most failed. But thelegend finaly found a way to disable the stock minimap. It's very easy. You just need this line:

Code: Select all

DisableSmallMapMiniMap()
below the function ScriptPostLoad() in your lua. That will remove the stock minimap and does not affect a custom created. So everything that you put in your custom hud file won't be removed. That way you can make a custom minimap or remove it completely. If you wish to make a custom minimap for all mods/maps you'd need to add this line within a script at the beginning of function ScriptPostLoad().


So that's all i know about HUD things. Enjoy and i hope for many new and interesting HUDs :D
Last edited by Anakin on Sat Sep 21, 2019 8:37 am, edited 25 times in total.
JimmyAngler
High General
High General
Posts: 837
Joined: Mon Nov 04, 2013 10:37 am
Projects :: Battlefront Halation
Games I'm Playing :: SWBF 1-2-2015
xbox live or psn: none
Location: Area 51

Re: [Tutorial]How to make a 100% custom HUD without global f

Post by JimmyAngler »

woohoo it's out! I can't wait to see what else you are going to add to it. :thumbs:
Marth8880
Resistance Leader
Posts: 5042
Joined: Tue Feb 09, 2010 8:43 pm
Projects :: DI2 + Psychosis
Games I'm Playing :: Silent Hill 2
xbox live or psn: Marth8880
Location: Edinburgh, UK
Contact:

Re: [Tutorial]How to make a 100% custom HUD without global f

Post by Marth8880 »

Yes! Finally, a workaround! Great! :thumbs: Very excited to learn about the custom HUD itself. :)
User avatar
Anakin
Master of the Force
Master of the Force
Posts: 4817
Joined: Sat Sep 19, 2009 11:37 am
Projects :: RC Side Mod - Remastered - SWBF3 Legacy
Location: Mos Espa (germany)

Re: [Tutorial]How to make a 100% custom HUD without global f

Post by Anakin »

Thank you both :D


Just added the first two parts of the HUD file itselfe
JimmyAngler
High General
High General
Posts: 837
Joined: Mon Nov 04, 2013 10:37 am
Projects :: Battlefront Halation
Games I'm Playing :: SWBF 1-2-2015
xbox live or psn: none
Location: Area 51

Re: [Tutorial]How to make a 100% custom HUD without global f

Post by JimmyAngler »

Is the Faq still taking tutorials? This is a must have.
User avatar
Locutus
1st Lieutenant
1st Lieutenant
Posts: 420
Joined: Fri Jun 04, 2010 10:08 am
Projects :: Stargate Battlefront Pegasus
Location: Germany
Contact:

Re: [Tutorial]How to make a 100% custom HUD without global f

Post by Locutus »

Never bothered making my own HUD but thanks to your tutorial this might change.
Awesome, Anakin, thanks for sharing!
Tutorial is very detailed and well explained, great work, man :thumbs:
User avatar
Anakin
Master of the Force
Master of the Force
Posts: 4817
Joined: Sat Sep 19, 2009 11:37 am
Projects :: RC Side Mod - Remastered - SWBF3 Legacy
Location: Mos Espa (germany)

Re: [Tutorial] 100% custom HUD [FINISHED][Last Update 07.02.

Post by Anakin »

Thank you all for your feedback.

I just finished the tutorial.


==EDIT==

Ok i just updated this on how you can remove the textes from HUD, but still have the menu textes. This will cause a little ligthing problem on the wining/loosing screen, but i think i can live with that bug.


@Staff: would be nice if you could add this tutorial to the FAQs


==EDIT2==

for some reason the text on the stats are not displayed at every map. I have no idea why. First it worked everywhere, than only on coruscant.

So you need to figure out wheather it works for you or not.
JimmyAngler
High General
High General
Posts: 837
Joined: Mon Nov 04, 2013 10:37 am
Projects :: Battlefront Halation
Games I'm Playing :: SWBF 1-2-2015
xbox live or psn: none
Location: Area 51

Re: [Tutorial] 100% custom HUD [Last Update 07.02.14] (FAQ)

Post by JimmyAngler »

I just wanted to say that this is one of the best and easiest tutorials to read on this entire gametoast site. I laughed at the comedic parts and put on quizzical faces when it got difficult. Thank you Anakin for your wonderful work.
User avatar
Anakin
Master of the Force
Master of the Force
Posts: 4817
Joined: Sat Sep 19, 2009 11:37 am
Projects :: RC Side Mod - Remastered - SWBF3 Legacy
Location: Mos Espa (germany)

Re: [Tutorial] 100% custom HUD [Last Update 20.02.14] (FAQ)

Post by Anakin »

All links fixed after the hack.

==EDIT==
links are reseted to the old. But you can see here how to fix them by yourselfe, untill guru fixed the problem for all links in common.


Also i made a Update. Now there is an other Step (0). It's about the Problem that the HUD changes all work just for your resolution. With this trick you can make different HUD files for different resolutions.
User avatar
Nedarb7
Lieutenant General
Lieutenant General
Posts: 676
Joined: Sat Sep 22, 2012 3:41 pm

Re: [Tutorial] 100% custom HUD [Last Update 20.02.14] (FAQ)

Post by Nedarb7 »

Could you explain how the values work in BitmapRect()? You say they control the x and y values and the numbers appear to be really small. Say I wanted a spear shape with a texture size of 128x32, what would I do to find the correct x and y values? And what would happen if I changed the origin to Center Center, could I still use the same x and y numbers? After multiple attempts I haven't figured it out :runaway:
User avatar
Anakin
Master of the Force
Master of the Force
Posts: 4817
Joined: Sat Sep 19, 2009 11:37 am
Projects :: RC Side Mod - Remastered - SWBF3 Legacy
Location: Mos Espa (germany)

Re: [Tutorial] 100% custom HUD [Last Update 20.02.14] (FAQ)

Post by Anakin »

the origin Center Center will just define where you start with the rectangle.
The values are simply trying out what works for you. When i made my HUD i first made a complete white tga file, than i moved the rectangle to its position.
After it was at the right position i changed the x,y values to fit to the screen. Finaly i changed the tga file to go with the rectangle.
About the x,y values i found out it's a kind of relation. So lets say you have a tga file 32x32 and you found a rec that works for you. But the borders are too fuzzy. So you cange the tga file to 64x64. It will be drawn exactly the same way as the 32x32 bitmap but with higher resolution. I don't realy understand how it works 100%.

Here is a picture what the differences between top left and center center are:
Hidden/Spoiler:
Image
User avatar
Ginev
Command Sergeant Major
Command Sergeant Major
Posts: 260
Joined: Thu Apr 02, 2009 7:02 am
Projects :: Remaking FR Battlefront 3 Tatooine map.
Games I'm Playing :: nothing for now
xbox live or psn: No gamertag set
Location: Bulgaria

Re: [Tutorial] 100% custom HUD [Last Update 25.01.16] (FAQ)

Post by Ginev »

So does this mean that we can make a hud with working healtbars similar to the Free Radical battlefront 3?
User avatar
Anakin
Master of the Force
Master of the Force
Posts: 4817
Joined: Sat Sep 19, 2009 11:37 am
Projects :: RC Side Mod - Remastered - SWBF3 Legacy
Location: Mos Espa (germany)

Re: [Tutorial] 100% custom HUD [Last Update 25.01.16] (FAQ)

Post by Anakin »

yes of course.
Last edited by Anakin on Wed Jul 06, 2016 10:09 am, edited 1 time in total.
Marth8880
Resistance Leader
Posts: 5042
Joined: Tue Feb 09, 2010 8:43 pm
Projects :: DI2 + Psychosis
Games I'm Playing :: Silent Hill 2
xbox live or psn: Marth8880
Location: Edinburgh, UK
Contact:

Re: [Tutorial] 100% custom HUD [Last Update 25.01.16] (FAQ)

Post by Marth8880 »

Anakin wrote:yes of cause.
;)
User avatar
Anakin
Master of the Force
Master of the Force
Posts: 4817
Joined: Sat Sep 19, 2009 11:37 am
Projects :: RC Side Mod - Remastered - SWBF3 Legacy
Location: Mos Espa (germany)

Re: [Tutorial] 100% custom HUD [Last Update 25.01.16] (FAQ)

Post by Anakin »

woops. So now they have a cause for a new case of mistake. And of course i learned once in an english course that it is not of cause :P
Post Reply