Iron Sight Tutorial (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

kinetosimpetus
Imperial Systems Expert
Imperial Systems Expert
Posts: 2381
Joined: Wed Mar 25, 2009 4:15 pm
Projects :: A secret project
Games I'm Playing :: Warframe STO

Iron Sight Tutorial (FAQ)

Post by kinetosimpetus »

http://www.youtube.com/watch?v=-xN3brwjfe8

It's pretty simple, as long as you know how to create a custom ingame.lvl which is outlined HERE.

The added entry in data_MODID\Common\ingame.req is like this:

Code: Select all

    REQN
    {
        "config"
        "1playerhud"
    }
If ironsights are the only thing you want to do with your ingame.lvl, the whole .req can look like this:

Code: Select all

ucft
{
    REQN
    {
        "config"
        "1playerhud"
    }
}
Make a 512 x 512 .tga that is completely transparent. Set this as the ScopeTexture in every weapon you want to use ironsights with. I tried a smaller one, 8 x 8, but it didn't work. Simply loading a null ScopeTexture will result in a default one being used.

I made the ironsights by adding a second weapon icon, like the ones in the lower left corner, or "floating" if they are new weapons, but the positioning has to be in the right spot for ironsights, and it has to display them at pretty much the opposite times that the actual weapon icons are shown.

The file 1playerhud.hud is located in data_MODID\Common\hud\PC. This is the file usually edited for making custom huds. I think you could rename it to something else if you want to keep separate hud files, just list the names of the hud files you need in the ingame.req under config.

Here is my 1playerhud.hud:
Hidden/Spoiler:
[code]FileInfo("1playerhud")
{
Viewports(1)

}

Group("player1weaponinformationforironsights")
{
PropagateAlpha(1)

Viewport(1)

ZOrder(255)

EventEnable("player1.spawn")
EventDisable("player1.die")

Group("player1weapon1groupforironsights")
{
Viewport(1)
EventEnable("initialize")

Model3D("player1weapon1mesh")
{
EventMesh("player1.weapon1.mesh")

Viewport(1)

ZOrder(5)

EventEnable("player1.weapon1.disable")
EventDisable("player1.weapon1.mesh")

MeshInfo("rep_weap_inf_dc15carbine")
{
Position(0.500000, 0.950000, 0.000000, "Viewport")
Rotation(0.000000, 180.000000, 0.000000)
Scale(20.000000, 20.00000, 20.000000)
}
MeshInfo("rep_weap_inf_pistol_dc18")
{
Position(0.500000, 0.950000, 0.000000, "Viewport")
Rotation(0.000000, 180.000000, 0.000000)
Scale(20.000000, 20.00000, 20.000000)
}
MeshInfo("kin_weap_inf_rifle_dc15ax")
{
Position(0.500000, 1.200000, 0.000000, "Viewport")
Rotation(-5.000000, 180.000000, 0.000000)
Scale(20.000000, 20.00000, 20.000000)
}
MeshInfo("rep_weap_inf_rifle")
{
Position(0.500000, 1.200000, 0.000000, "Viewport")
Rotation(-5.000000, 180.000000, 0.000000)
Scale(20.000000, 20.00000, 20.000000)
}
}
}
}[/code]
Updated sample code including floating icon fix here.

The first part, "FileInfo", I don't really know what it does, but I don't think it hurts...

The rest is a modification of part of the original hud which I deleted.

The first and outermost "Group" has EventEnable and EventDisable codes that turn this HUD element off when you die or enter a CP. Otherwise ironsights will appear when either of those happen.

I dont know if the inner group is needed, it was like this in the original, so I left it.

The "Model3D" section has 2 more events, these are simply reversed from the original, which hides the weapon icons when zooming in with a scope, so now the new set of icons will appear when zooming as long as the weapon uses a scope.

To add a weapon to the Model3d, copy one of the "MeshInfo" Blocks and change the name to the name of the weapon's .msh. Then test it ingame, if it needs to be moved down, try adding 0.05 to the middle Position number, or subtracting if it is too low. If a weapon is exceptionally long or tall, the first rotation parameter can be changed to rotate the weapon. Use a negative angle to aim down.

If you don't add a meshinfo block for a weapon, an icon will 'float' in the upper left corner of the screen, so add a meshinfo to move it offscreen. Moving the weapon to the left should work:

Code: Select all

Position(-0.500000, 0.000000, 0.000000, "Viewport")
in your mission lua, find the ReadDataFile line for the global ingame.lvl that should already be there, copy and paste a line above or below it adding "dc:" without the quotes before the word "ingame".

Munge with only Common checked.

After munging, the ingame.lvl will have to be copied from data_MODID\_LVL_PC to your mod's addon folder: gamedata\addon\MODID\data\_LVL_PC\
Last edited by kinetosimpetus on Tue Feb 07, 2012 8:23 pm, edited 3 times in total.
User avatar
yuke5
Field Commander
Field Commander
Posts: 945
Joined: Wed Jun 29, 2011 10:42 pm
Games I'm Playing :: SWBF2 TF2 RC KOTOR
xbox live or psn: My steam is yuke5.
Location: Vermont

Re: Tutorial: Ironsights

Post by yuke5 »

This is fantastic! :D Belongs in the FAQ for sure. I'm going to add this to all my future/current maps/mods right away. Thank you very much for doing this, you're too kind.
Noobasaurus
Droid Pilot Assassin
Droid Pilot Assassin
Posts: 2006
Joined: Tue Aug 17, 2010 5:56 pm

Re: Tutorial: Ironsights

Post by Noobasaurus »

What exactly is an "ironsight"? I have an assumption it's the first-person gun in the middle but I'm not exactly sure...
User avatar
yuke5
Field Commander
Field Commander
Posts: 945
Joined: Wed Jun 29, 2011 10:42 pm
Games I'm Playing :: SWBF2 TF2 RC KOTOR
xbox live or psn: My steam is yuke5.
Location: Vermont

Re: Tutorial: Ironsights

Post by yuke5 »

Watch the video posted at the top of the thread.
User avatar
Cerfon Rournes
Master Bounty Hunter
Master Bounty Hunter
Posts: 1558
Joined: Thu Jul 08, 2010 5:53 pm
Projects :: WIP. I will reveal what it is later on..
Games I'm Playing :: SWBF2-SWRC
xbox live or psn: No gamertag set
Location: New York, USA
Contact:

Re: Tutorial: Ironsights

Post by Cerfon Rournes »

Awesome! Thanks :)
AQT
Gametoast Staff
Gametoast Staff
Posts: 4910
Joined: Sat Nov 03, 2007 4:55 pm
Location: SoCal, USA

Re: Tutorial: Ironsights

Post by AQT »

@Noobasaurus: In addition to what yuke wrote: Iron Sight. :google:

Thanks for the tutorial, kinetos! :thumbs:
User avatar
Unlucky13
Sergeant Major
Sergeant Major
Posts: 239
Joined: Mon Jan 24, 2011 11:11 am
Projects :: Models models models
Games I'm Playing :: Random stuff

Re: Tutorial: Ironsights

Post by Unlucky13 »

Nice job! One more thing to make BF2 so much better.
User avatar
naru1305
Major General
Major General
Posts: 657
Joined: Fri Jan 07, 2011 4:57 pm
Games I'm Playing :: SWBF2
Location: Germany
Contact:

Re: Iron Sight Tutorial (FAQ)

Post by naru1305 »

thanks for this tutorial :bowdown:
i think we will see many ironsights next time :D
kinetosimpetus
Imperial Systems Expert
Imperial Systems Expert
Posts: 2381
Joined: Wed Mar 25, 2009 4:15 pm
Projects :: A secret project
Games I'm Playing :: Warframe STO

Re: Iron Sight Tutorial (FAQ)

Post by kinetosimpetus »

Oh, I forgot something. For weapons you DON'T want to us iron sights, you need to add a msh info block that moves the icon off screen.
AQT
Gametoast Staff
Gametoast Staff
Posts: 4910
Joined: Sat Nov 03, 2007 4:55 pm
Location: SoCal, USA

Re: Iron Sight Tutorial (FAQ)

Post by AQT »

It seems that iron sights are incompatible with weapons whose HUD icons were fixed using FragMe!'s tutorial. This was puzzling me for the last few hours. Just putting it out there for anyone who may be having problems getting the weapons to show up.
User avatar
Fiodis
Master of the Force
Master of the Force
Posts: 4145
Joined: Wed Nov 12, 2008 9:27 pm
Projects :: Rannoch + Tientia + Tools Programming

Re: Iron Sight Tutorial (FAQ)

Post by Fiodis »

Pity. Then if we have custom weapon models we need to use stock icons for them if we want ironsights?
kinetosimpetus
Imperial Systems Expert
Imperial Systems Expert
Posts: 2381
Joined: Wed Mar 25, 2009 4:15 pm
Projects :: A secret project
Games I'm Playing :: Warframe STO

Re: Iron Sight Tutorial (FAQ)

Post by kinetosimpetus »

I am not sure what the problem is. In the video the DC-15s has a fixed icon as well as ironsights.
Ninja
Master Sergeant
Master Sergeant
Posts: 172
Joined: Thu Jan 07, 2010 9:49 pm
Projects :: Ghostmark
Location: Inside your sandwich

Re: Iron Sight Tutorial (FAQ)

Post by Ninja »

kinetosimpetus wrote:I am not sure what the problem is. In the video the DC-15s has a fixed icon as well as ironsights.
Is the DC-15 icon placed by the v1.3 patch or is the it placed using FragMe!'s icon fix?

I had to "unfix" icons to get iron sights to work on weapons with fixed icons, but it worked fine with a pistol model which the v1.3 patch fixed the icon for.
kinetosimpetus
Imperial Systems Expert
Imperial Systems Expert
Posts: 2381
Joined: Wed Mar 25, 2009 4:15 pm
Projects :: A secret project
Games I'm Playing :: Warframe STO

Re: Iron Sight Tutorial (FAQ)

Post by kinetosimpetus »

It is possible that weapon was fixed by the patch I guess.
User avatar
Cerfon Rournes
Master Bounty Hunter
Master Bounty Hunter
Posts: 1558
Joined: Thu Jul 08, 2010 5:53 pm
Projects :: WIP. I will reveal what it is later on..
Games I'm Playing :: SWBF2-SWRC
xbox live or psn: No gamertag set
Location: New York, USA
Contact:

Re: Iron Sight Tutorial (FAQ)

Post by Cerfon Rournes »

I have gotten the Ironsight working with fixed icons (for custom/stock models)
This does not require a extra weapons file.
In 1playerhud find this line.
Hidden/Spoiler:
[code]Group("player1weapon1group")
{
Viewport(1)
Position(1.046161, -1.150412, 0.000000, "Viewport")
EventEnable("initialize")
Model3D("player1weapon1mesh")
{
EventMesh("player1.weapon1.mesh")
Viewport(1)
ZOrder(5)
EventEnable("player1.weapon1.mesh")
EventDisable("player1.weapon1.disable")
MeshInfo("hud_vehicle_lasers")
{
Position(-0.185992, 0.354928, -0.000509, "Viewport")
Rotation(0.804269, 359.994110, 359.999695)
Scale(1.200000, 1.200000, 1.200000)
}[/code]
Under that will be listed stock weapons with their fixed icon positions.
So, you can load your weapon there as well. (Since you are loading a custom ingame.lvl) Simply copy one that is relevant to the size, positioning of your custom model,( Example, if your model is a rifle, use imp_weap_inf_e11's position as a ref) and paste it right under/over the original Meshinfo line. Then replace the msh name with your custom one.
Example. Some lines before I add the custom Meshinfo line.
Hidden/Spoiler:
[code]MeshInfo("hud_imp_flamethrower")
{
Position(-0.173776, 0.358333, 0.205979, "Viewport")
Rotation(0.013809, 0.000000, 359.991669)
Scale(0.250001, 0.250001, 0.250001)
}

MeshInfo("imp_weap_inf_e11")
{
Position(-0.242922, 0.360546, 0.003365, "Viewport")
Rotation(0.804269, 90.747269, 359.999695)
}

MeshInfo("imp_weap_inf_pistol")
{
Position(-0.264184, 0.356163, -0.003873, "Viewport")
Rotation(0.804269, 90.747269, 359.999695)
Scale(1.240000, 1.240000, 1.240000)
}[/code]
I copy the imp_weap_inf_e11, put it under, and change the name to a custom msh.
Hidden/Spoiler:
[code] MeshInfo("hud_imp_flamethrower")
{
Position(-0.173776, 0.358333, 0.205979, "Viewport")
Rotation(0.013809, 0.000000, 359.991669)
Scale(0.250001, 0.250001, 0.250001)
}

MeshInfo("imp_weap_inf_e11")
{
Position(-0.242922, 0.360546, 0.003365, "Viewport")
Rotation(0.804269, 90.747269, 359.999695)
}

MeshInfo("esm_r37_rifle")
{
Position(-0.242922, 0.360546, 0.003365, "Viewport")
Rotation(0.804269, 90.747269, 359.999695)
}

MeshInfo("imp_weap_inf_pistol")
{
Position(-0.264184, 0.356163, -0.003873, "Viewport")
Rotation(0.804269, 90.747269, 359.999695)
Scale(1.240000, 1.240000, 1.240000)[/code]
Then just save, munge, and copy the ingame to your respective addon folder.
So far, this has worked for me every time. I hope this helps anyone having problems. :)
Remember, you can do this for any weapon1 floating icon.
User avatar
SAMofBIA
Major General
Major General
Posts: 649
Joined: Tue Jun 15, 2010 3:38 pm
Projects :: Nothing....nothing at all.
Games I'm Playing :: League of Legends
xbox live or psn: No gamertag set
Location: MIA and not stopping in often anymore.

Re: Iron Sight Tutorial (FAQ)

Post by SAMofBIA »

in addition to the amazingly awesome ironsight, the clone skin is pretty great too!
Ninja
Master Sergeant
Master Sergeant
Posts: 172
Joined: Thu Jan 07, 2010 9:49 pm
Projects :: Ghostmark
Location: Inside your sandwich

Re: Iron Sight Tutorial (FAQ)

Post by Ninja »

Cerfon Rournes wrote:I have gotten the Ironsight working with fixed icons (for custom/stock models)
This does not require a extra weapons file...

Then just save, munge, and copy the ingame to your respective addon folder.
So far, this has worked for me every time. I hope this helps anyone having problems. :)
Remember, you can do this for any weapon1 floating icon.
When I tried this, it just added another icon, there was still one floating in the middle of the screen. I think this would only work if you replace the default ingame.lvl.
User avatar
Cerfon Rournes
Master Bounty Hunter
Master Bounty Hunter
Posts: 1558
Joined: Thu Jul 08, 2010 5:53 pm
Projects :: WIP. I will reveal what it is later on..
Games I'm Playing :: SWBF2-SWRC
xbox live or psn: No gamertag set
Location: New York, USA
Contact:

Re: Iron Sight Tutorial (FAQ)

Post by Cerfon Rournes »

Are you using a custom weapon? It it's stock, it should be already fixed.. :?
EDIT
You were correct, you need to replace the global ingame for my method to work, sorry for not mentioning that..
Because of that, my tuto is kinda useless..
kinetosimpetus
Imperial Systems Expert
Imperial Systems Expert
Posts: 2381
Joined: Wed Mar 25, 2009 4:15 pm
Projects :: A secret project
Games I'm Playing :: Warframe STO

Re: Iron Sight Tutorial (FAQ)

Post by kinetosimpetus »

I've been trying to get floating icons fixed at the same time as using ironsights, and haven't gotten it to work without replacing the global ingame.lvl. I think if floating icons were fixed in the global ingame, the local ingame can make ironsights without conflict, but I haven't tried it that way yet. *

The extraweapons fix makes the original floating icon invisible, then adds a new visible one that it can manipulate to the right position. the problem is, when you zoom in, the thing that makes the floating icon invisible now seems to make the ironsights invisible, but leaves part of an apparently new floating icon in the corner.

I have also tried making a complete ingame.lvl to use as a local ingame, and remove the original ingame from the lua, but that results in a ctd.

*I don't want to edit the global ingame as long as there is a chance that the local one can be made to work, i don't like editing the global ingame.lvl because if I do it to fix my mod, and someone else edits it to fix their mod, and 5 other people edit it to fix their mod and make custom HUD's, players will have to choose whose ingame to use, and they might not all work with every mod. and installation would be harder.

My current 1playerhud.hud
Hidden/Spoiler:
[code]FileInfo("1playerhud")
{
Viewports(1)

}

Group("player1weaponinformationforironsights")
{
PropagateAlpha(1)

Viewport(1)

ZOrder(255)

EventEnable("player1.spawn")
EventDisable("player1.die")

Group("player1weapon1groupforironsights")
{
Viewport(1)
EventEnable("initialize")

Model3D("player1weapon1mesh")
{
EventMesh("player1.weapon1.mesh")

Viewport(1)

ZOrder(5)

EventEnable("player1.weapon1.disable")
EventDisable("player1.weapon1.mesh")

MeshInfo("kin_weap_inf_rifle_dc15ax")
{
Position(0.500000, 1.200000, 0.000000, "Viewport")
Rotation(-5.000000, 180.000000, 0.000000)
Scale(20.000000, 20.00000, 20.000000)
}
MeshInfo("rep_weap_inf_rifle")
{
Position(0.500000, 1.200000, 0.000000, "Viewport")
Rotation(-5.000000, 180.000000, 0.000000)
Scale(20.000000, 20.00000, 20.000000)
}
MeshInfo("rep_weap_inf_pistol_dc18")
{
Position(0.500000, 0.950000, 0.000000, "Viewport")
Rotation(0.000000, 180.000000, 0.000000)
Scale(20.000000, 20.00000, 20.000000)
}
MeshInfo("rep_weap_inf_dc15carbine")
{
Position(0.500000, 0.950000, 0.000000, "Viewport")
Rotation(0.000000, 180.000000, 0.000000)
Scale(20.000000, 20.00000, 20.000000)
}
MeshInfo("rep_weap_inf_pistol_mini_r")
{
Position(0.500000, 1.050000, 0.000000, "Viewport")
Rotation(0.000000, 180.000000, 0.000000)
Scale(20.000000, 20.00000, 20.000000)
}
}
}
}[/code]
extraweapons.hud
Hidden/Spoiler:
[code]Code:

ViewPort("Transforms")
{


//EventNameFilter("player%")


// First Weapons Section

TransformNameMesh("player1weapon1")
// add msh names of first weapons here and remove unused lines
{
NameMesh("rep_weap_inf_pistol_mini_r", "com_inv_mesh")
//NameMesh("rep_weap_inf_carbine", "com_inv_mesh")
//NameMesh("rep_weap_inf_dc15m", "com_inv_mesh")
//NameMesh("disrupter_rifle", "com_inv_mesh")
//NameMesh("weap_inf_dc17pistol_r_small", "com_inv_mesh")
NameMesh("delta_weap_helm_pistol", "com_inv_mesh")
//NameMesh("rep_weap_inf_rifle_dc15ax", "com_inv_mesh")
//NameMesh("rep_weap_dc17sniper", "com_inv_mesh")
//NameMesh("rep_weap_dc17rifle", "com_inv_mesh")
//NameMesh("rep_weap_dc17antiarmor", "com_inv_mesh")

NameMesh("cis_weap_inf_assault_cannon", "com_inv_mesh")

EventInput("player1.weapon1.change")
EventOutput("player1.weapon1.mesh")
}

}

Group("extraWeaponDisplay")
{
PropagateAlpha(1)
Viewport(1)
//Position(0.0000000, 1.000000, 0.000000, "Viewport")
ZOrder(255)

//EventEnable("player1.weaponsEnable")
//EventDisable("player1.weaponsDisable")


EventEnable("player1.weapon1.mesh")
EventDisable("player1.weapon1.disable")


Group("extraWeaponIcon")
{
Viewport(1)
//Position(0.346161, -0.450412, 0.000000, "Viewport")
EventEnable("initialize")

Model3D("player1.weapon1mesh")
{
EventMesh("player1.weapon1.change")
Viewport(1)
ZOrder(5)

EventEnable("player1.weapon1.mesh")
EventDisable("player1.weapon1.disable")

//Position(500.000000, 500.000000, 500.000000, "Viewport")
//Rotation(0.804269, 359.994110, 359.999695)
Scale(0.000000, 0.000000, 0.000000)

//change position, rotation and scale of first weapon here, remove unused lines


//MeshInfo("rep_weap_inf_carbine")
//{
// Position(-0.231578, 0.259076, 0.007261, "Viewport")
// Rotation(0.804269, 90.747269, 359.999695)
// Scale(1.140000, 1.140000, 1.140000)
//}
MeshInfo("rep_weap_inf_pistol_mini_r")
{
Position(0.100000, 0.900000, 0.000000, "Viewport")
Rotation(0.000000, 90.000000, 0.000000)
Scale(1.000000, 1.000000, 1.000000)
}
//MeshInfo("rep_weap_inf_dc15m")
//{
// Position(-0.215316, 0.367230, -0.007488, "Viewport")
// Rotation(0.804269, 90.747269, 359.999695)
// Scale(0.820000, 0.820000, 0.820000)
//}
//MeshInfo("disrupter_rifle")
//{
// Position(-0.222832, 0.361293, 0.014590, "Viewport")
// Rotation(0.804269, 90.747269, 359.999695)
//}
//MeshInfo("weap_inf_dc17pistol_r_small")
//{
// Position(-0.260316, 0.356366, -0.002834, "Viewport")
// Rotation(0.804269, 90.747269, 359.999695)
// Scale(0.800000, 0.800000, 0.800000)
//}
MeshInfo("delta_weap_helm_pistol")
{
Position(-0.260316, 0.356366, -0.002834, "Viewport")
Rotation(0.804269, 90.747269, 359.999695)
Scale(0.800000, 0.800000, 0.800000)
}
//MeshInfo("rep_weap_inf_rifle_dc15ax")
//{
// Position(-0.215316, 0.367230, -0.007488, "Viewport")
// Rotation(0.804269, 90.747269, 359.999695)
// //Scale(0.820000, 0.820000, 0.820000)
//}
//MeshInfo("rep_weap_inf_dc17blaster")
//{
// Position(-0.249442, 0.359076, 0.007261, "Viewport")
// Rotation(0.804269, 90.747269, 359.999695)
// Scale(1.000000, 1.000000, 1.000000)
//}
//MeshInfo("rep_weap_inf_dc17sniper")
//{
// Position(-0.249442, 0.359076, 0.007261, "Viewport")
// Rotation(0.804269, 90.747269, 359.999695)
// Scale(1.000000, 1.000000, 1.000000)
//}
//MeshInfo("rep_weap_inf_dc17antiarmor")
//{
// Position(-0.249442, 0.359076, 0.007261, "Viewport")
// Rotation(0.804269, 90.747269, 359.999695)
// Scale(1.000000, 1.000000, 1.000000)
//}
MeshInfo("cis_weap_inf_assault_cannon")
{
Position(-0.222832, 0.361293, 0.014590, "Viewport")
Rotation(0.804269, 90.747269, 359.999695)
}
}
}

// Second Weapons Section

TransformNameMesh("player1weapon2")
// add names of second weapons here
{
NameMesh("com_weap_inf_grenadethermal", "com_inv_mesh")

EventInput("player1.weapon2.change")
EventOutput("player1.weapon2.mesh")
}

Group("extraWeaponDisplay")
{
PropagateAlpha(1)
Viewport(1)
Position(0.0000000, 1.000000, 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("player1.weapon2mesh")
{
EventMesh("player1.weapon2.change")
Viewport(1)
ZOrder(5)
EventEnable("player1.weapon2.mesh")
EventDisable("player1.weapon2.disable")
Position(500.000000, 500.000000, 500.000000, "Viewport")
Rotation(0.804269, 359.994110, 359.999695)
Scale(0.000000, 0.000000, 0.000000)

// adjust position, rotation and scale of second weapon here


MeshInfo("com_weap_inf_grenadethermal")
{
Rotation(0.804269, 90.747269, 359.999695)
}
}
}
}
}[/code]
User avatar
Fiodis
Master of the Force
Master of the Force
Posts: 4145
Joined: Wed Nov 12, 2008 9:27 pm
Projects :: Rannoch + Tientia + Tools Programming

Re: Iron Sight Tutorial (FAQ)

Post by Fiodis »

I thought we couldn't replace the global ingame.lvl, since not all the files included in it are also present in the data_***/Common folder?
Post Reply