pevhs.ch ~/tf2/nhbgum/

Modifying the default bodygroups

This only applies if you are using Linux AND are ready to compile programs from source.
Throuhought the years, I've made multiple programs and shell scripts in the aim to automate to a maximum the maintenance of nhbgum. This had the nice side effect of rendering substantial modifications possible, e.g. swapping the bodygroups with custom ones and even defining which bodygroups are used in case one wants to make the mod compatible with custom models which use more/less bodygroups than their default counterpart. This is also the setup I use to update the mod.

This is a rough explanation of how everything is glued together. I DID NOT CHECK TO SEE IF I FORGOT STEPS OR MADE MISTAKES, for I am lazy.

1: Get/Compile/Install the tools

2: Set $WINTF2DIR

This environment variable is used by some scripts to know where to look for folders and Window binaries. export WINTF2DIR="$HOME/games/win/tf2" is my definition present in $HOME/.profile, which points to my Windows install of TF2. Change it as you see fit. (Don't forget to log out for the changes to take effect.)

3: Setup directories and bodygroups

Copy TF2's item schema located in "tf/scripts/items/items_game.txt" in the directory of nhm_factory, alongside the scripts.

Copy the directory "no_hats_bgum" and rename it to your liking. This is because the directory tree is important.

If your models don't use the same number of bodygroups (e.g. your custom pyro model doesn't have a belt bodygroup, your custom medic model has a hat bodygroup), you can define it in <yourfolder>/masks.cnf, with this syntax:

# Refer to nhschema/src/format.c (classinfo[] definition) to know the
# bodygroup names and the default values.
# This is the config used for no_hats_thf.

mask_soldier ""
mask_demo "B_SHOES"
mask_heavy "B_HAT"
mask_engineer "B_HAT"
mask_sniper ""
mask_spy "B_HAT"
mask_scout "B_SHOES | B_HAT"
mask_medic "B_MEDIC_BACKPACK | B_HAT"
mask_pyro ""

Now the hard part: change the bodygroup files (located in <yourfolder>/out_nh2/uncompiled/*/*.smd) with the files that are used by your mod.

Once it's done, refer to your masks.cnf file or the default bodygroups at nhschema/src/format.c bodyinfo[] to know which files you must create next to the classes' SMD files from these names: hat, headphones, dogtags, backpack, grenades, head, shoes, hands. (Refer once again to nhschema/src/format.c bodyinfo[] to know which file name corresponds to which bodygroup) The content of these files may be written in the generated QC files depending on the bodygroups the hats replace (e.g. if a hat for the pyro replaces his backpack and head, the content of the files backpack and head will be written to the QC file). This means that you must write a $bodygroup rule that calls in the SMD corresponding to the needed bodygroup (by default, I use $include rules in those to call QCI files, but I guess you could skip the QCI part and write $bodygroup rules in the file directly). Look at already present directories to see how I did it.

Once this is done, you finally can...

4: Execute the scripts

And pray that I got everything right. Otherwise, take it as a challenge.
If you're lucky, genall.sh can take care of it in one go. Feel free to read them to see how they work. (Don't pay attention to warnings about entries trying to mount on themselves.)

Last notes

Did you want to do this, but only for one class and not all of them? Well too bad, this setup isn't able to filter out classes. You may get away with it by using nhcustom2 with a config file looking somewhat like this:

#example with the soldier

remove
class:"^Soldier$"
class:Soldier+class:All classes}path:soldier



I'm not good at explaining things.















Below is the old content of this document. It probably doesn't interest you.


Info: Some of the information here is no longer up to date.
Read the edits at the end.

This is a response I gave to an e-mail I received that shows how no_hats_bgum can be
modified to use different bodygroups instead of the default ones.

-----------

https://gamebanana.com/mods/198508
Is there a way to use No Hats Mod with this other mod without having
cosmetic-wearing Scouts wear lower poly versions of their default
cap/cosmetic-wearing Pyros wearing lower poly gas masks and oxygen tanks?

-----------

Hello,

[...]

Yes, there is a way, although it's probably not what you expect or want.
Since the mod works by recompiling a lot of hats with the default bodygroup,
it means that the bodygroups which you want to replace with a higher poly
version are embedded in around 1800 models. This means that you have to
recompile those models with the high poly version of the bodygroups.

[...]

Here's how you would do it:

1. Download the mod's repository at <https://git.pevhs.ch/no-hats-bgum.git>.
   [outdated: see edit 1]

2. in "/nhm_source/mechbgum_no_hats_mod/uncompiled", replace the bodygroups
   in each class's folder with the bodygroups coming from your mod (which you
   need to decompile). Example: "soldier_hat_bodygroup.smd" is the soldier's
   helmet and needs to be replaced with the helmet from your mod.

3. If your mod uses custom textures that are in a different location than the
   default ones (yours does), add the "$cdmaterials" directives that are in
   your mod's QC files to the files "animation.qci" which are present in each
   class's folder. For example, "$cdmaterials "models\player\pyro\nonhwm\""
   must be added to uncompiled/pyro/animation.qci, as the textures present in
   that folder are used by the pyro head of your mod.

4. Finally, compile each model. This can be done painlessly with tools like
   Crowbar. Merge the result with the files located in  0kb_files and only
   then can you pack the mod into a VPK file, using Valve's tool.

That is a lot. And the compilation step would need to be redone whenever this
mod receives an update, so unless you know how to write scripts to simplify
the process, it's a looot of work. It will probably never be simple enough
to be considered useful.

[...]

I hope this helped, or at least, was interesting.

Fedora31

--------------------------------
Edits:

1. This is no longer true. If you have Windows, you download the ZIP
   file located at <https://pevhs.ch/tmp/nhbgum_uncompiled.zip>, or, if you
   run Linux AND want to do things cleanly, see edit 2.

2. The mod is now generated automatically with the help of shell scripts and custom
   programs. If you want to create a mod which can easily be updated, you should
   read what is written here <https://pevhs.ch/tf2/nhbgum/> under "More customization".
   It probably isn't easy to setup for the first time and requires some knowledge in
   scripting, but it can come in handy if you wish to keep your mod updated alongside TF2.