Floating Weapon Icon Fix Tutorial (FAQ)
Posted: Tue Apr 11, 2006 7:17 pm
Well, first, I'd like you all to know that I thought PAN-Fnord sent OOM-9 this tutorial. It turns out that Mike Z did actually. I got the tutorial from OOM-9, and we both attempted to make it work. I also gave this tutorial to Rends, but he has barely glanced at it so far.
Well, OOM-9 had 0% success. I had 50% success. I had also been trying to make this work for many days. Annoyed, I sent a PM to PAN-Fnord (but my PM is still in my Outbox instead of my Sentbox, which means he hasn't read it yet), for help. I'd try sending the same PM to Mike Z, but...I don't know if he has a Game Toast Forums account. If so, I still don't know his username.
Impatient, I post this tutorial here, in the form that OOM-9 got it from Mike Z (a series of PMs).
Now, what I have done is get the weapon icon to be in the correct location. Sounds like I fixed it doesn't it? Nope. I still have the floating icon somewhere. Well, for this fix, we need a .msh file called invisible_mesh.msh, which is an invisible mesh. Bandu kindly created one for me and I used it (first time I attempted the tutorial's fix). Well, after many unsuccessful attempts at making the icons be fixed, I thought that maybe Bandu's .msh file was oncorrectly made (no offense!). So, I asked Qdin to make me this file. No luck. Nothing changed at all.
So, this is as far as I have gotten. I was hoping that by posting this tutorial and my entire PM to PAN-Fnord, people may be able to solve the floating weapon icon problem and help others.
So, here is the HUD Tutorial:
Here are the entire contents of my PM to PAN-Fnord:
Thank you, you all, for your patience and time. Please help.
Oh, BTW, the floating icon error happens to any new models (and renamed models).
- Majin Revan
Well, OOM-9 had 0% success. I had 50% success. I had also been trying to make this work for many days. Annoyed, I sent a PM to PAN-Fnord (but my PM is still in my Outbox instead of my Sentbox, which means he hasn't read it yet), for help. I'd try sending the same PM to Mike Z, but...I don't know if he has a Game Toast Forums account. If so, I still don't know his username.
Impatient, I post this tutorial here, in the form that OOM-9 got it from Mike Z (a series of PMs).
Now, what I have done is get the weapon icon to be in the correct location. Sounds like I fixed it doesn't it? Nope. I still have the floating icon somewhere. Well, for this fix, we need a .msh file called invisible_mesh.msh, which is an invisible mesh. Bandu kindly created one for me and I used it (first time I attempted the tutorial's fix). Well, after many unsuccessful attempts at making the icons be fixed, I thought that maybe Bandu's .msh file was oncorrectly made (no offense!). So, I asked Qdin to make me this file. No luck. Nothing changed at all.
So, this is as far as I have gotten. I was hoping that by posting this tutorial and my entire PM to PAN-Fnord, people may be able to solve the floating weapon icon problem and help others.
So, here is the HUD Tutorial:
Okay. BTW, once you understand this and can implement the fix, please POST it as a thread so other people get the help. Thank you.
This may end up a multi-message-long description, cuz the HUD is hard.
So...the HUD layout is defined in Common/hud/PC/1playerhud.hud. If you open that file and look around, eventually you will find the place where P1's weapon is displayed:
Group("player1weapon1group")
In that section there is Model3D("player1weapon1mesh"), which is the actual icon's information. The mesh that the icon uses changes depending on which weapon you've selected, and the MeshInfo{} blocks
===========
MeshInfo("rep_weap_inf_rifle")
{
Position(-0.219723, 0.364485, 0.003263, "Viewport")
Rotation(1.538445, 95.690582, 4.455857)
Scale(0.800000, 0.800000, 0.800000)
}
===========
tell the icon where to be onscreen if the mesh it's using is named that. Not the weapon ODF, the msh.
The actual problem you're having is that the default position for that icon is in the middle of the screen, and your new weapons don't have a MeshInfo() block that repositions it back in the right spot.
Therefore, the easy fix that you can't ship with your mod is to add a MeshInfo() block for your new weapon, save that file, and re-munge Common. The HUD files end up in ingame.lvl, and you do NOT want to ship this with your mod.
Initially, I thought this was all you could do, but after about 3 hours of poking around I've come up with a hack/workaround that you CAN ship with your mod.
On to Part 2....
My next thought was well, create a new HUD file and redefine that icon, then ship only that new HUD file with your mod. Turns out, you can create all the new icons you want, but you can't redefine old ones...so you can get *another* icon that's in the right spot, but you'll still have your the default midscreen one from 1playerhud as well.
Then I poked around in Common/hud/hudtransforms.hud. This file is basically a list of "if I change my weapon to X, actually display mesh Y in the hud." So with a bit of suaveness, and the creation of a mesh that exists but doesn't have visible geometry, you can solve the problem.
You create a new file, say extraweapons.hud, that looks like this:
Code:
ViewPort("Transforms")
{
EventNameFilter("player%")
TransformNameMesh("player1weapon1")
{
// Take a weapon-change, give back a different mesh name to be displayed.
EventInput("player1.weapon1.change")
EventOutput("player1.weapon1.mesh")
// Make these meshes appear as another mesh in the BF2 HUD spot
// from the file 1playerhud.hud.
// The point is to replace "hud_droideka_shield" with a mesh that you create
// which exists but is invisible. The mesh MUST exist!
// If you do that, then that gets rid of the midscreen floating weapon display
// for our new weapons.
NameMesh("arcrifle", "hud_droideka_shield")
NameMesh("dc15", "hud_droideka_shield")
}
}
Group("extraWeaponDisplay")
{
PropagateAlpha(1)
Viewport(1)
Position(0.000000, 1.00000, 0.000000, "Viewport")
ZOrder(255)
EventEnable("player1.weaponsEnable")
EventDisable("player1.weaponsDisable")
Group("extraWeaponIcon")
{
Viewport(1)
Position(0.346161, -0.450412, 0.000000, "Viewport")
EventEnable("initialize")
Model3D("player1weapon1mesh")
{
// Instead of using player1.weapon1.mesh, which was replaced in the
// NameMesh() with hud_droideka_shield, we're using the actual
// mesh of the weapon that the player switched to, which is
// still rep_weap_inf_rifle or arcrifle or whatnot.
EventMesh("player1.weapon1.change")
Viewport(1)
ZOrder(5)
EventEnable("player1.weapon1.mesh")
EventDisable("player1.weapon1.disable")
// This model should be offscreen and invisible if the weapon
// is not defined below - this is to avoid showing duplicates of
// weapons that already are defined in the BF2 1playerhud.hud file.
// To accomplish that, scale to 0 and place offscreen.
Scale(0, 0, 0)
Position(500, 500, 500, "viewport")
// Now, for our new weapons only, reposition this icon and display it.
MeshInfo("dc15")
{
Viewport(1)
Position(-0.219723, 0.364485, 0.003263, "Viewport")
Rotation(1.538445, 95.690582, 4.455857)
Scale(0.800000, 0.800000, 0.800000)
}
MeshInfo("arcrifle")
{
Viewport(1)
Position(-0.219723, 0.364485, 0.003263, "Viewport")
Rotation(1.538445, 95.690582, 4.455857)
Scale(0.800000, 0.800000, 0.800000)
}
}
}
}
What this file does is:
For your new weapons, it makes the old 1playerhud icon display hud_droideka_shield midscreen. (You'll see why that's important.)
It then creates a new HUD icon, which displays your new weapons in the correct spot. For all other weapons not explicitly defined, this new icon displays itself invisible and offscreen, so you see the old 1playerhud icon instead.
If you want to add more new weapons, they need a NameMesh() line and a MeshInfo() block in this file.
How is this a solution?
On to part 3....
To solve the entire problem, you also need to create an invisible mesh - let's say you make it invisible_mesh.msh. Place that in your side's MSH folder, and add it to the *whole side's* REQ file: if your side is rep, then in rep.req you would add:
Code:
REQN
{
"model"
"invisible_mesh"
}
Additionally, you save that extra HUD file in your side's ODF folder, say as extraweapons.hud. You need to add that to your side's REQ as well:
Code:
REQN
{
"config"
"extraweapons"
}
***Note: Saving it as a .hud file may not make it munge - it SHOULD though. If it doesn't, then we'll have to figure out how to do that as well.
(I tried all this except I munged it as part of the main game instead of my mod - I'll do it as a mod after this.)****
Why include it in the entire side's REQ? Because now any time you load a unit from that side, those files will automatically be included as well.
You also need to replace the references to hud_droideka_shield in the new .hud file with references to your new invisible_mesh. This is so the 1playerhud icon ends up displaying the invisible mesh.
Once that's all done, munge your side and try it out....
Well, turns out it won't munge the extraweapons file into the right thing if it's not named .hud. So....save it as extraweapons.hud anywhere in your entire side (I just put it in the base folder).
Then you have to edit your side munge bat, as follows:
The file is data_modID/_BUILD/Sides/munge_side.bat
Open it up in a text editor, and search for "combo". You should find:
Code:
configmunge -inputfile $*.combo %MUNGE_ARGS% -sourcedir %SOURCE_DIR% -outputdir %MUNGE_DIR% 2>>%MUNGE_LOG%
move /y configmunge.log configmunge_combo.log
Copy those two lines, and paste them again, then change "$*.combo" to "$*.hud", like so:
Code:
configmunge -inputfile $*.combo %MUNGE_ARGS% -sourcedir %SOURCE_DIR% -outputdir %MUNGE_DIR% 2>>%MUNGE_LOG%
move /y configmunge.log configmunge_combo.log
configmunge -inputfile $*.hud %MUNGE_ARGS% -sourcedir %SOURCE_DIR% -outputdir %MUNGE_DIR% 2>>%MUNGE_LOG%
move /y configmunge.log configmunge_combo.log
...then save. :^)
That'll munge all .hud files in the side, also.
You still need to include it in the REQ and all that.
You can even make this change to the template munge_side.bat in modtools_dir/data/_BUILD, and that way it'll copy that new batch file into any new sides you create so you only have to do it once. In fact, I'm going to change it here as well, so any new release of the modtools will have that change in it.
I just tested this, and it works. :^) Admittedly I don't have the invisible mesh, but I know that part will work.
Mike Z
Here are the entire contents of my PM to PAN-Fnord:
Hello, PAN-Fnord, how are you? I am a mapper for SWBF II. I was a major mapper for SWBF (in the modding community of course).
OOM-9 sent me your tutorial and perhaps told you of me. We have both worked on making our HUD work, but he has been 0% successful, and I have been 50% successful.
I have gotten the icon to move to the right location. However, I still have the floating icon just sitting there. I followed your tutorial exactly. I even got an invisible_mesh.msh from a fellow modder (I got another one from someone else thinking that his had errors, but it made no difference).
I have the extraweapons.hud file in my data_RE1\Sides\rep folder. My invisible_mesh.msh file is in the data_RE1\Sides\rep\msh folder. I have also edited my rep.req file exactly as needed.
I have edited the munge_side.bat file correctly as well.
These are the only things I did (and I changed my extraweapons.hud file). I had edited my 1playerhud.hud file at first, but it made no difference, so I reverted back to the default one.
Maybe you could show me your extraweapons.hud file, fully changed for four weapons. I have tried for many days now to get it working, but nothing comes out of it and I'm getting frustrated.
I tried placing the hud_droideka_shield.msh file in the extraweapons.hud file, but it never made a difference in-game.
Here is my extraweapons.hud file:
Code: Select all
ViewPort("Transforms") { EventNameFilter("player%") TransformNameMesh("player1weapon1") { // Take a weapon-change, give back a different mesh name to be displayed. EventInput("player1.weapon1.change") EventOutput("player1.weapon1.mesh") // Make these meshes appear as another mesh in the BF2 HUD spot // from the file 1playerhud.hud. // The point is to replace "hud_droideka_shield" with a mesh that you create // which exists but is invisible. The mesh MUST exist! // If you do that, then that gets rid of the midscreen floating weapon display // for our new weapons. NameMesh("rep_weap_dc17blast", "invisible_mesh") NameMesh("rep_weap_dc17sniper", "invisible_mesh") NameMesh("rep_weap_dc17antia", "invisible_mesh") NameMesh("rep_weap_inf_dc15carbine", "invisible_mesh") } } Group("extraWeaponDisplay") { PropagateAlpha(1) Viewport(1) Position(0.000000, 1.00000, 0.000000, "Viewport") ZOrder(255) EventEnable("player1.weaponsEnable") EventDisable("player1.weaponsDisable") Group("extraWeaponIcon") { Viewport(1) Position(0.346161, -0.450412, 0.000000, "Viewport") EventEnable("initialize") Model3D("player1weapon1mesh") { // Instead of using player1.weapon1.mesh, which was replaced in the // NameMesh() with hud_droideka_shield, we're using the actual // mesh of the weapon that the player switched to, which is // still rep_weap_inf_rifle or arcrifle or whatnot. EventMesh("player1.weapon1.change") Viewport(1) ZOrder(5) EventEnable("player1.weapon1.mesh") EventDisable("player1.weapon1.disable") // This model should be offscreen and invisible if the weapon // is not defined below - this is to avoid showing duplicates of // weapons that already are defined in the BF2 1playerhud.hud file. // To accomplish that, scale to 0 and place offscreen. Scale(0, 0, 0) Position(500, 500, 500, "viewport") // Now, for our new weapons only, reposition this icon and display it. MeshInfo("rep_weap_dc17blast") { Viewport(1) Position(-0.219723, 0.364485, 0.003263, "Viewport") Rotation(1.538445, 95.690582, 4.455857) Scale(0.800000, 0.800000, 0.800000) } MeshInfo("rep_weap_dc17sniper") { Viewport(1) Position(-0.219723, 0.364485, 0.003263, "Viewport") Rotation(1.538445, 95.690582, 4.455857) Scale(0.800000, 0.800000, 0.800000) } MeshInfo("rep_weap_dc17antia") { Viewport(1) Position(-0.219723, 0.364485, 0.003263, "Viewport") Rotation(1.538445, 95.690582, 4.455857) Scale(0.800000, 0.800000, 0.800000) } MeshInfo("rep_weap_inf_dc15carbine") { Viewport(1) Position(-0.249442, 0.359076, 0.007261, "Viewport") Rotation(0.804269, 90.747269, 359.999695) Scale(1.140000, 1.140000, 1.140000) } } } }
Hopefully you will be able to help. I thank you for your time.
- Majin Revan
Thank you, you all, for your patience and time. Please help.
Oh, BTW, the floating icon error happens to any new models (and renamed models).
- Majin Revan