How do you "connect" .fgd code to model skins? Created 3 years ago2020-06-06 21:07:47 UTC by hermanJnr. hermanJnr.

Created 3 years ago2020-06-06 21:07:47 UTC by hermanJnr. hermanJnr.

Posted 3 years ago2020-06-06 21:07:47 UTC Post #344372
Apologies if this has been answered before, I have been searching for tutorials for a few hours now and can't find what I'm looking for.

I've made a custom skin for Barney. However, I wanted to use this in my maps in addition to the original Barney skin, rather than just replacing the Barney model entirely with my new skin. Basically I want to emulate how you can have 4 different heads for the scientists even though it's one model.

To this end I edited the barney.qc of the decompiled model and added a new "body type" + additional lines referencing the new skins for this body type.

This seems to work fine, as Jed's HLMV is now showing me default Barney as body "subgroup 1", and "subgroup 2" is my custom skin. Two skins, one model...success!

I then created a custom .fgd for my mod, in which I added the option of choosing between "Default" Barney skin and my "Custom" one to the entity properties for Monster_Barney.

However, this last step doesn't work - the default skin is the only one shown, since the dialogue box has no way of knowing what it's actually referencing. I've tried looking up models with multiple skins like the Scientist but I've had no luck finding out how the .fgd actually knows what skin "Luther", "Slick" etc. refers to.

Basically...how do you connect your new Hammer dialogue boxes in the .fgd to your new model skins? I'm guessing I need to do a small amount of coding but I can't find which file to edit.

Any help appreciated with this - I will write a tutorial from step 1 if I can work it out with some help, I think it might help others.
Posted 3 years ago2020-06-06 22:49:17 UTC Post #344373
The fgd maps names like 'Luther' and 'Slick' to numerical values for the 'body' attribute. If I understand correctly then that attribute, along with 'skin' and a bunch of others, should be applicable to every entity with a model. However, the game code for barney takes direct control over this body attribute, with 0 being used when his gun is holstered, 1 when it's drawn and 2 when he doesn't have a gun, so setting that attribute is of no use - it'll get overridden immediately. The code doesn't mess with the skin attribute though, so a custom skin should be possible without having to modify game code.
Posted 3 years ago2020-06-07 10:03:58 UTC Post #344376
Awesome help Captain P, thank you! Saved me many hours of faffing with it. Super helpful :)

Also thank you for linking the barney.cpp. I was looking for this file too and had no luck.

The code in the end was as follows.

For adding the skins to Barney, you edit barney.qc with the following:
$texturegroup "skinfamilies"
{
{ "barney_body.bmp" "barney_legs.bmp" "barney_chrome.bmp" "w_beretta.bmp" }
{ "barney_body2.bmp" "barney_legs2.bmp" "barney_chrome2.bmp" "w_beretta2.bmp" }
}
This is added after the "body" entries for the gun and the "studio" body model. It is essential that there is a space between the {} brackets and the "model.bmp" entries on each side - otherwise compile fails.

The first line of the array specifies the default bitmaps used for the skin, the second line specifies the custom ones for the second skin and so on.

After adding the model to the mod subfolder, you edit your custom FGD for the mod as follows:
@PointClass base(Monster,TalkMonster, Sequence) size(-16 -16 0, 16 16 72) studio("models/barney.mdl") = monster_barney : "Barney"
[
skin(Choices) : "Skin" : 0 =
[
0 : "Barney"
1 : "Watson"
]
]
The labels can be whatever you want obviously, here they are used to specify either Default Barney or the custom character "Watson".

This same addition can be performed to "monster_barney_dead" in order to allow you to use the custom skin for Barney corpses in Hammer as well.

Result in game:
Barney SkinsBarney Skins
Dead Barney SkinsDead Barney Skins
The only thing I'm trying to work out now is how the "monster_barney_dead" entity specifies the model sequence for the corpse. Like...how "lying_on_back" sequence is tied to the "Lying on back" FGD parameter for "pose". Because it's not specified in the model .qc. Perhaps it's in the entity .CPP code.

Actually scratch that, turns out these values are specified in barney.cpp. So duplicating that .cpp for a custom NPC with the names of new animations would theoretically work. Sweet :)

Right now I use a non-solid monster_generic set to a scripted idle "dead" animation for custom dead animations, which is more clumsy.

Technically you could actually get around this in Hammer just by having a func_breakable over the corpse that triggers a gibshooter and killtarget on the monster_generic, but as far as I know func_breakables cannot be non-solid, so this might get in the way of gameplay.
Posted 3 years ago2020-06-07 14:58:45 UTC Post #344377
Took a few hours but I figured out how to add my custom "corpse" animations into the game :)
Custom Barney skins and monster_barney_dead animations
Quite happy with this. Hopefully future goldsrc mods I make will be considerably easier to customise regarding things like this now.
You must be logged in to post a response.