Saints Row 2 How are NPCs clothed/made?

Hello, V ;)

Something me- and probably everyone else who's looked at SR2 NPCs- have always wondered is how NPCs are clothed. It's confusing because the XTBL file for NPCs accurately shows the clothes or proportions of the NPCs, but upon modification, no changes are seen. Then there's another file (.cvtf extension) that also has what NPCs wear, but (I cannot remember exactly) upon modification via hex editing, it either changes nothing or crashes the game.
So basically, how are NPCs made?

Thanks :)
 
I believe that the NPCs for SR2 used a crunched table file similar to vehicles. We found we spent a lot of time parsing xml and to speed things up we just crunched it to binary data. I'll see if I can dig something up on this format for you.
 
I believe that the NPCs for SR2 used a crunched table file similar to vehicles. We found we spent a lot of time parsing xml and to speed things up we just crunched it to binary data. I'll see if I can dig something up on this format for you.

That would be awesomely awesome, thank you!
 
We made a tool that crunched the xtbl into the cvtf file. Here's what I can see about the format:

header:
for each variant:
uint32 offset to variant name​
uint32 offset to character type​
uint32 offset to mesh variant persona chance​
for each vid group:​
offset to vid group name​
for each vid option:​
uint32 offset to option index name​
uint32 offset to vids​
uint32 offset to obscured vids​
uint32 offset to vid option​
uint32 offset to vid groups​
for each material group:​
for each material option:​
uint32 offset to material list​
uint32 offset to material option​
for each color scheme:​
uint32 offset to color entry​
uint32 offset to color scheme option​
for each texture group:​
for each texture entry:​
uint32 offset to bitmap name​
uint32 offset to texture entry​
uint32 offset to texture group options​
uint32 offset to material groups​
for each morph set:​
uint32 offset to morph set name​
uint32 offset to morph sets​

uint32 offset to variants

following this header was the data itself that seems to just be allocated in chunks based on what it represents.

This one might just need the cruncher to be released.
 
I am probably most excited about a cvtf tool for npcs and vehicles. That has been a huge roadblock for us for so many projects. :D
 
Hey, guys. I was the main programmer for the NPC construction system back on SR2 (I'll have to talk to Jeff next week about getting verified for a [V] name). It's been a few years, but here's what I remember about how this system worked:

The NPCs were all built out of the same basic body mesh, customization morphs, and clothing components that we used for the player customization. We had a special NPC construction tool for the character artists to use, which was basically an ugly Windows GUI wrapping all of the same options in the in-game customization interface, plus some extra data for setting up the randomization percentages. I assume that the xtbl files that you are seeing are the output of this tool.

The NPC setup file was then read in by another PC tool, which loaded all of the different customization meshes that were required to build the NPC, assembled them all together, and then ran a number of optimizations for performance and memory (things like deleting the faces/triangles for parts of the skin/clothing that are covered up by other clothing options, like a jacket covering a shirt, combining triangles from different source meshes if they use the same material, etc.) IIRC, the output of this tool was something like a cnpc/gnpc file? I'm guessing that the cvtf file (character variant table file, maybe?) was also an output of this tool, and basically encodes the various randomization options for enabling or disabling different groups of faces, selecting body and facial morphs, and swapping colors/textures.

Basically, without access to that NPC builder tool, modifying the xtbl for the NPC would not have any visible effect, as you've noticed. Messing with the cvtf file in a hex editor probably could allow you to tweak some parts of the NPC, like relative spawn percentages for different clothing/body options, or changing color values, but I'm not surprised that most changes to it just lead to the way of pain. Hopefully, if we end up releasing crunchers/tools for SR2, the NPC builder will be included in that package, along with the creation GUI app. I don't know anything about the release plans there though, although I can ask around the office next week. Otherwise, if we can document the binary format for the NPC files, it may be possible to reverse-engineer a copy of the tool, but that's not a trivial project.

DISCLAIMER!!! All of this is from memory from code I haven't looked at in five years, so I'm sure there's at least some errors in there. When I'm back in the office next week, I'll see if I can pull down the old SR2 codebase and refresh my memory.

-Mike Flavin, Graphics Programmer, Volition
 
That's amazing detail, thanks. There were mesh files for the NPCs, which I assume you meant when you said "cnpc/gnpc".

Although one thing still bothers me. There are 3 different types of NPC. There's SNPC for cutscenes, NPC for main world/everything else, but there is a CNPC type which I haven't the foggiest what it does.
 
Yeah, I was talking about the mesh files.

IIRC, CNPCs were cutscene-only NPCs which had higher-res textures and such, and wouldn't fit in a normal character slot. They could only be loaded during cutscenes, where we repurposed some other memory. As far as SNPC vs. NPC, I'd have to look that up. I know there was a difference, but I can't for the life of me remember what it was.
 
Basically, without access to that NPC builder tool, modifying the xtbl for the NPC would not have any visible effect, as you've noticed. Messing with the cvtf file in a hex editor probably could allow you to tweak some parts of the NPC, like relative spawn percentages for different clothing/body options, or changing color values, but I'm not surprised that most changes to it just lead to the way of pain.

I've been able to do this in my NPC mod by editing character_definitions.xtbl, but there's only so much you can do with that one file. Getting NPC tools or the info to create our own would be kickass.
 
Getting NPC tools or the info to create our own would be kickass.

The ability to create/customize our own NPC population would be kickass I agree.:D

If an NPC creator/editor mode was integrated within the game that would enable us to access the NPC builder tool via GUI simply by starting the game and at the start screen click on "NPC Builder".
npcguiv1.png


Then in a similar way that we create our player character, we can now create a new NPC and give it AI behaviours via choosing attributes like cowardly, average, offensive or pissed off.:p
The clothes we select for it would remain static ( maintaining the same geometric size/skeleton/mesh ) but the clothes colors can be dynamic as it already is.
After all the NPC properties are done, we just save it as NPC_fh_cstm_01, then all the relative data is compiled by the NPC Builder and all the files are saved in their proper places or there could be a special folder made that contains all the new NPC info.
If it may be too much for the engine to handle, perhaps the new NPC can be selected to replace an existing NPC.

If this could be done, sales revenue will certainly skyrocket.;)

Even if the NPC Builder was made available as a DLC that installs and integrates all the required files into the proper game directory locations making it easier for use, just think of the fun possibilites for us and tons of revenue for Volition.
Many more people would be purchasing it, I will and so would additional millions.
The demand for more game customization increases every day and you people at Volition from what I have seen here on this site are stepping in the right direction.:cool:
 
Back
Top