If someone could point me in the right direction, I will be very greatful
How do I add a kit selector for each class?
-
The_Turkish_Moose
- Posts: 307
- Joined: 2013-03-16 14:40
How do I add a kit selector for each class?
I've looked around for tutorials which cover this feature but have found NOTHING. I would like to know how to add a kit selector button like the ones shown in the two videos bellow.
If someone could point me in the right direction, I will be very greatful
If someone could point me in the right direction, I will be very greatful
- Mats391
- PR:BF2 Lead Developer
- Posts: 7643
- Joined: 2010-08-06 18:06
Re: How do I add a kit selector for each class?
easiest way is to get those mods and look how they did it. Most likely something in the menu files. you can also check how pr does it, also in to menu files.
-
The_Turkish_Moose
- Posts: 307
- Joined: 2013-03-16 14:40
Re: How do I add a kit selector for each class?
Downloaded Armoured kill - the mod did not have the feature in the Armoured kill videoeasiest way is to get those mods and look how they did it. Most likely something in the menu files. you can also check how pr does it, also in to menu files.
Tried downloading Real War 3.0 but could not download the right mod anywhere
I guess I'll have to give the PR files a look. Hopefully, I can make sense of it! If anyone else has any knowledge on the matter, please post! Thanks Mats!
-
SANGUE-RUIM
- Posts: 1390
- Joined: 2009-04-26 12:37
Re: How do I add a kit selector for each class?
sorry not to help, but where do I download this Real War 3.0 mod? 
only found 2.0
only found 2.0
-
rPoXoTauJIo
- PR:BF2 Developer
- Posts: 1979
- Joined: 2011-07-20 10:02
Re: How do I add a kit selector for each class?
Both AK and RW using default "Unlock" system, while PR one is a bit more complicated.
That's how i understand it:
1. HUD being initialized by content\menu_server.zip\hud\hudsetup\hudsetupmain.con
2. Specifically we're interested in Customization/HudSetupCustomization.con
3. In that file we're creating our global kit node by:
4. Then we're initializing all the kits in python(that would be used later) by sending some rcon command.
Look for that file and what it does.
5. Then we're creating kit info nodeS(all of them) with alt\std button
6.That's our ru_2.con file, medic(kits numering from 0)
Node create:
Creating picture node with std weapon image(ParentNode, NodeName, position X, position Y, size X, size Y)
Creating picture node with alt weapon image(ParentNode, NodeName, position X, position Y, size X, size Y)
Notice it's not shown not because it's under std image, but because it's out of screen!
Creating STD button. Take note that it has default unclicked state, so it's out of screen by setting it's coords -1000 -1000.
1 texture is for default state.
2 for hovering with mouse.
3 assuming it's for clicked state.
Click sound.
Sending rcon command into bf2 if pressed. Bf2 catches it and looking if there's registered handlers for remote command. If any command found, it's being catch by PR modules, and(i assuming) being stored by some internal variable.
Assuming it's a command to remember choice done by player.
Setting kit for player by internal bf2 method.
Running script for HUD changes. Notice the argument std. Also 0 state - react only if pressed, 1 - if hover, idk if there's more states.
Text for pressed button(-1000, -1000), nothing here.
Button textures and text for non-pressed button.(it's present on screen and awaiting for click)
And here's alt button - it's on screen, awaiting for being pressed.
Non-pressed button - notice that it's out of screen.
7. In file above, when we're pressed alt\std button, we're not only sent event to python, but runned some script, placed in:
menu/HUD/HudSetup/Customization/scripts/ru/ru_2.con
The code below is needed for initialization, we're moving all th components outside the screen.
The code below is reading argument sent to our script, and moving nodes for kit init to required positions.
8. During map init we're calling PR inits by running faction_init.con file in content\factions_server.zip, and resetting all the hud nodes by running hudcustomizationreset.con by running all the scripts from it(remember, scripts moving nodes outside screen first, and checking for args later)
9. Then, as faction_init.con being called 2 times with 2 args(number of team, v_arg1 and name of team, v_arg2), we're running menu/HUD/HudSetup/Customization/HudCustomization.con v_arg1 v_arg2 2 times.
10. As .con grammar quite strict and not even have loops, PR'devs had to implement such check.
The code below checking if v_arg1 == number of our team, and if yes - checking for it's name in if-elseif loop
If team found, it's setting activating hud node, and setting visibility to team by setting it's node variable.
That's our painful HUD part, and it's done for now.
11. As bf2 has some major flaws in it's design, we're able to fix em with some python magic code
One of the problems is that there's can't be more than 7 kits initialized via map's init.con.
But with python, we're able to change kit's right-in-spawn in-game. How do we decide which kit to use?
In #6 point we're sent some command like that:
And as we saw, 0 or 1 were decided as argument because of alt\std button pressed state.
So basically, when we have kit selected\changed, python cathching this events, and storing those variables.
When player spawning, python checking which kit has been selected, which arg given(0, 1, assuming it's alt\std),
and changing player kit just-in-spawn moment.
Ofc, i could've mistaken in some parts, as PR sources are closed, but i assuming that's how it works in PR
That's how i understand it:
1. HUD being initialized by content\menu_server.zip\hud\hudsetup\hudsetupmain.con
2. Specifically we're interested in Customization/HudSetupCustomization.con
3. In that file we're creating our global kit node by:
Code: Select all
hudBuilder.createSplitNode Global KitCustomInitRootLook for that file and what it does.
Code: Select all
run kits/ru/ru_init.conCode: Select all
hudBuilder.createSplitNode Kit2CustomKit arf_Kit2Info
hudBuilder.setNodeShowVariable DemoRecInterfaceShow
run kits/ru/ru_2.conNode create:
Code: Select all
rem --- kits ru_2.con ---
rem --- Generated by PRBuild ---
hudBuilder.createSplitNode ru_Kit2Info ru_Kit2
hudBuilder.setNodeShowVariable Kit2Show
Code: Select all
rem --- Weapon Images ---
hudBuilder.createPictureNode ru_Kit2 ru_Kit2_StdImg 21 227 148 40
hudBuilder.setPictureNodeTexture Ingame/Weapons/Icons/Hud/rurif_ak74mscope.tga
Notice it's not shown not because it's under std image, but because it's out of screen!
Code: Select all
hudBuilder.createPictureNode ru_Kit2 ru_Kit2_AltImg -1000 -1000 148 40
hudBuilder.setPictureNodeTexture Ingame/Weapons/Icons/Hud/rurif_ak74m.tga1 texture is for default state.
2 for hovering with mouse.
3 assuming it's for clicked state.
Code: Select all
rem --- Buttons and Labels ---
rem --- Std Kits ---
hudBuilder.createButtonNode ru_Kit2 ru_Kit2_StdButton -1000 -1000 40 18
hudBuilder.setButtonNodeTexture 1 Ingame/Respawn/button_shortLight.tga
hudBuilder.setButtonNodeTexture 2 Ingame/Respawn/button_shortLight.tga
hudBuilder.setButtonNodeTexture 3 Ingame/Respawn/button_shortLight2.tga
Code: Select all
hudBuilder.setButtonNodeConCmd "sound.playSound rosePress" 0
Code: Select all
hudBuilder.setButtonNodeConCmd "rcon custom 2 0" 0
Code: Select all
hudBuilder.setButtonNodeConCmd "rcon select 2" 0
Code: Select all
hudBuilder.setButtonNodeConCmd "spawnManager.setPlayerKit 2" 0
Code: Select all
hudBuilder.setButtonNodeConCmd "run menu/HUD/HudSetup/Customization/scripts/ru/ru_2.con std" 0
Code: Select all
hudBuilder.createTextNode ru_Kit2 ru_Kit2_StdLabel -1000 -1000 40 18
hudBuilder.setTextNodeStyle Fonts/hudFontLocalBold_9.dif 0
hudBuilder.setNodeColor 0.729 0.729 0.729 1
hudBuilder.setTextNodeString "HUD_TEXT_MENU_SPAWN_KIT_STD"
Code: Select all
hudBuilder.createButtonNode ru_Kit2 ru_Kit2_StdButtonP 167 230 40 18
hudBuilder.setButtonNodeTexture 1 Ingame/Respawn/button_shortLight2.tga
hudBuilder.setButtonNodeTexture 2 Ingame/Respawn/button_shortLight2.tga
hudBuilder.setButtonNodeTexture 3 Ingame/Respawn/button_shortLight2.tga
hudBuilder.createTextNode ru_Kit2 ru_Kit2_StdLabelP 167 230 40 18
hudBuilder.setTextNodeStyle Fonts/hudFontLocalBold_9.dif 0
hudBuilder.setNodeColor 1 1 1 1
hudBuilder.setTextNodeString "HUD_TEXT_MENU_SPAWN_KIT_STD"
Code: Select all
rem --- Alt Kits ---
hudBuilder.createButtonNode ru_Kit2 ru_Kit2_AltButton 214 230 40 18
hudBuilder.setButtonNodeTexture 1 Ingame/Respawn/button_shortLight.tga
hudBuilder.setButtonNodeTexture 2 Ingame/Respawn/button_shortLight.tga
hudBuilder.setButtonNodeTexture 3 Ingame/Respawn/button_shortLight2.tga
hudBuilder.setButtonNodeConCmd "sound.playSound rosePress" 0
hudBuilder.setButtonNodeConCmd "rcon custom 2 1" 0
hudBuilder.setButtonNodeConCmd "rcon select 2" 0
hudBuilder.setButtonNodeConCmd "spawnManager.setPlayerKit 2" 0
hudBuilder.setButtonNodeConCmd "run menu/HUD/HudSetup/Customization/scripts/ru/ru_2.con alt" 0
hudBuilder.createTextNode ru_Kit2 ru_Kit2_AltLabel 214 230 40 18
hudBuilder.setTextNodeStyle Fonts/hudFontLocalBold_9.dif 0
hudBuilder.setNodeColor 0.729 0.729 0.729 1
hudBuilder.setTextNodeString "HUD_TEXT_MENU_SPAWN_KIT_ALT"
Code: Select all
hudBuilder.createButtonNode ru_Kit2 ru_Kit2_AltButtonP -1000 -1000 40 18
hudBuilder.setButtonNodeTexture 1 Ingame/Respawn/button_shortLight2.tga
hudBuilder.setButtonNodeTexture 2 Ingame/Respawn/button_shortLight2.tga
hudBuilder.setButtonNodeTexture 3 Ingame/Respawn/button_shortLight2.tga
hudBuilder.createTextNode ru_Kit2 ru_Kit2_AltLabelP -1000 -1000 40 18
hudBuilder.setTextNodeStyle Fonts/hudFontLocalBold_9.dif 0
hudBuilder.setNodeColor 1 1 1 1
hudBuilder.setTextNodeString "HUD_TEXT_MENU_SPAWN_KIT_ALT"
menu/HUD/HudSetup/Customization/scripts/ru/ru_2.con
The code below is needed for initialization, we're moving all th components outside the screen.
Code: Select all
rem --- scripts ru_2.con ---
rem --- Generated by PRBuild ---
hudBuilder.setActiveObject ru_Kit2 ru_Kit2_StdImg
hudBuilder.setNodePos -1000 -1000
hudBuilder.setActiveObject ru_Kit2 ru_Kit2_StdButton
hudBuilder.setNodePos -1000 -1000
hudBuilder.setActiveObject ru_Kit2 ru_Kit2_StdButtonP
hudBuilder.setNodePos -1000 -1000
hudBuilder.setActiveObject ru_Kit2 ru_Kit2_StdLabel
hudBuilder.setNodePos -1000 -1000
hudBuilder.setActiveObject ru_Kit2 ru_Kit2_StdLabelP
hudBuilder.setNodePos -1000 -1000
hudBuilder.setActiveObject ru_Kit2 ru_Kit2_AltImg
hudBuilder.setNodePos -1000 -1000
hudBuilder.setActiveObject ru_Kit2 ru_Kit2_AltButton
hudBuilder.setNodePos -1000 -1000
hudBuilder.setActiveObject ru_Kit2 ru_Kit2_AltButtonP
hudBuilder.setNodePos -1000 -1000
hudBuilder.setActiveObject ru_Kit2 ru_Kit2_AltLabel
hudBuilder.setNodePos -1000 -1000
hudBuilder.setActiveObject ru_Kit2 ru_Kit2_AltLabelP
hudBuilder.setNodePos -1000 -1000
Code: Select all
If v_arg1 == std
hudBuilder.setActiveObject ru_Kit2 ru_Kit2_StdImg
hudBuilder.setNodePos 21 227
hudBuilder.setActiveObject ru_Kit2 ru_Kit2_StdButtonP
hudBuilder.setNodePos 167 230
hudBuilder.setActiveObject ru_Kit2 ru_Kit2_StdLabelP
hudBuilder.setNodePos 167 230
hudBuilder.setActiveObject ru_Kit2 ru_Kit2_AltButton
hudBuilder.setNodePos 214 230
hudBuilder.setActiveObject ru_Kit2 ru_Kit2_AltLabel
hudBuilder.setNodePos 214 230
elseIf v_arg1 == alt
hudBuilder.setActiveObject ru_Kit2 ru_Kit2_AltImg
hudBuilder.setNodePos 21 227
hudBuilder.setActiveObject ru_Kit2 ru_Kit2_StdButton
hudBuilder.setNodePos 167 230
hudBuilder.setActiveObject ru_Kit2 ru_Kit2_StdLabel
hudBuilder.setNodePos 167 230
hudBuilder.setActiveObject ru_Kit2 ru_Kit2_AltButtonP
hudBuilder.setNodePos 214 230
hudBuilder.setActiveObject ru_Kit2 ru_Kit2_AltLabelP
hudBuilder.setNodePos 214 230
endIf9. Then, as faction_init.con being called 2 times with 2 args(number of team, v_arg1 and name of team, v_arg2), we're running menu/HUD/HudSetup/Customization/HudCustomization.con v_arg1 v_arg2 2 times.
10. As .con grammar quite strict and not even have loops, PR'devs had to implement such check.
The code below checking if v_arg1 == number of our team, and if yes - checking for it's name in if-elseif loop
If team found, it's setting activating hud node, and setting visibility to team by setting it's node variable.
Code: Select all
rem --- HudCustomization.con ---
rem --- Generated by PRBuild ---
If v_arg1 == 1
If v_arg2 == "ru"
hudBuilder.setActiveObject KitCustomInitRoot ru_KitInit1
hudBuilder.setNodeShowVariable Team1Selected
hudBuilder.setActiveObject Kit0CustomKit ru_Kit0Info
hudBuilder.setNodeShowVariable Team1Selected
hudBuilder.setActiveObject Kit1CustomKit ru_Kit1Info
hudBuilder.setNodeShowVariable Team1Selected
hudBuilder.setActiveObject Kit2CustomKit ru_Kit2Info
hudBuilder.setNodeShowVariable Team1Selected
hudBuilder.setActiveObject Kit3CustomKit ru_Kit3Info
hudBuilder.setNodeShowVariable Team1Selected
hudBuilder.setActiveObject Kit4CustomKit ru_Kit4Info
hudBuilder.setNodeShowVariable Team1Selected
hudBuilder.setActiveObject Kit5CustomKit ru_Kit5Info
hudBuilder.setNodeShowVariable Team1Selected
hudBuilder.setActiveObject Kit6CustomKit ru_Kit6Info
hudBuilder.setNodeShowVariable Team1Selected
endIf
If v_arg2 == "us"
hudBuilder.setActiveObject KitCustomInitRoot us_KitInit1
hudBuilder.setNodeShowVariable Team1Selected
hudBuilder.setActiveObject Kit0CustomKit us_Kit0Info
hudBuilder.setNodeShowVariable Team1Selected
hudBuilder.setActiveObject Kit1CustomKit us_Kit1Info
hudBuilder.setNodeShowVariable Team1Selected
hudBuilder.setActiveObject Kit2CustomKit us_Kit2Info
hudBuilder.setNodeShowVariable Team1Selected
hudBuilder.setActiveObject Kit3CustomKit us_Kit3Info
hudBuilder.setNodeShowVariable Team1Selected
hudBuilder.setActiveObject Kit4CustomKit us_Kit4Info
hudBuilder.setNodeShowVariable Team1Selected
hudBuilder.setActiveObject Kit5CustomKit us_Kit5Info
hudBuilder.setNodeShowVariable Team1Selected
hudBuilder.setActiveObject Kit6CustomKit us_Kit6Info
hudBuilder.setNodeShowVariable Team1Selected
endIf
elseIf v_arg1 == 2
If v_arg2 == "ru"
hudBuilder.setActiveObject KitCustomInitRoot ru_KitInit2
hudBuilder.setNodeShowVariable Team2Selected
hudBuilder.setActiveObject Kit0CustomKit ru_Kit0Info
hudBuilder.setNodeShowVariable Team2Selected
hudBuilder.setActiveObject Kit1CustomKit ru_Kit1Info
hudBuilder.setNodeShowVariable Team2Selected
hudBuilder.setActiveObject Kit2CustomKit ru_Kit2Info
hudBuilder.setNodeShowVariable Team2Selected
hudBuilder.setActiveObject Kit3CustomKit ru_Kit3Info
hudBuilder.setNodeShowVariable Team2Selected
hudBuilder.setActiveObject Kit4CustomKit ru_Kit4Info
hudBuilder.setNodeShowVariable Team2Selected
hudBuilder.setActiveObject Kit5CustomKit ru_Kit5Info
hudBuilder.setNodeShowVariable Team2Selected
hudBuilder.setActiveObject Kit6CustomKit ru_Kit6Info
hudBuilder.setNodeShowVariable Team2Selected
endIf
If v_arg2 == "us"
hudBuilder.setActiveObject KitCustomInitRoot us_KitInit2
hudBuilder.setNodeShowVariable Team2Selected
hudBuilder.setActiveObject Kit0CustomKit us_Kit0Info
hudBuilder.setNodeShowVariable Team2Selected
hudBuilder.setActiveObject Kit1CustomKit us_Kit1Info
hudBuilder.setNodeShowVariable Team2Selected
hudBuilder.setActiveObject Kit2CustomKit us_Kit2Info
hudBuilder.setNodeShowVariable Team2Selected
hudBuilder.setActiveObject Kit3CustomKit us_Kit3Info
hudBuilder.setNodeShowVariable Team2Selected
hudBuilder.setActiveObject Kit4CustomKit us_Kit4Info
hudBuilder.setNodeShowVariable Team2Selected
hudBuilder.setActiveObject Kit5CustomKit us_Kit5Info
hudBuilder.setNodeShowVariable Team2Selected
hudBuilder.setActiveObject Kit6CustomKit us_Kit6Info
hudBuilder.setNodeShowVariable Team2Selected
endIf
endIf
11. As bf2 has some major flaws in it's design, we're able to fix em with some python magic code
One of the problems is that there's can't be more than 7 kits initialized via map's init.con.
But with python, we're able to change kit's right-in-spawn in-game. How do we decide which kit to use?
In #6 point we're sent some command like that:
Code: Select all
rcon custom 2 0So basically, when we have kit selected\changed, python cathching this events, and storing those variables.
When player spawning, python checking which kit has been selected, which arg given(0, 1, assuming it's alt\std),
and changing player kit just-in-spawn moment.
Ofc, i could've mistaken in some parts, as PR sources are closed, but i assuming that's how it works in PR
Last edited by rPoXoTauJIo on 2014-09-30 22:42, edited 3 times in total.

assetruler69: I've seen things you smurfs wouldn't believe. Apaches on the Kashan. I watched burned down tank hulls after the launch of the single TOW. All those moments will be lost in time, like tears in rain.
Time to give up and respawn.
-
The_Turkish_Moose
- Posts: 307
- Joined: 2013-03-16 14:40
Re: How do I add a kit selector for each class?
I couldn't find the download for it either!sorry not to help, but where do I download this Real War 3.0 mod?
only found 2.0
rPoXoTauJIo, thanks for that awesome post. I'll look into it soon and let you know how it goes! THANKS AGAIN
-
rPoXoTauJIo
- PR:BF2 Developer
- Posts: 1979
- Joined: 2011-07-20 10:02
Re: How do I add a kit selector for each class?
Cause their official site&ftp are down.The_Turkish_Moose wrote:I couldn't find the download for it either!
All credits to BD i assume. I'm still not quite understand some parts of HUD managing, as after initializing mod&map there's quite a lot of cross-file runs and node changes.The_Turkish_Moose wrote:rPoXoTauJIo, thanks for that awesome post. I'll look into it soon and let you know how it goes! THANKS AGAIN![]()
Just keep in mind that part of this magic are closed behind PR sources, pretty much everything above is HUD madness, resulting in sent rcon command into py.
Here is good example how to modify player kit onspawn:
Kit Changer Script - Python - Official BF Editor Forums
Last edited by rPoXoTauJIo on 2014-10-01 11:38, edited 1 time in total.

assetruler69: I've seen things you smurfs wouldn't believe. Apaches on the Kashan. I watched burned down tank hulls after the launch of the single TOW. All those moments will be lost in time, like tears in rain.
Time to give up and respawn.
