RimWorld

RimWorld

26 ratings
Creating Custom Races with Big & Small Framework (with or without Biotech)
By RedMattis
This is a guide for how to go beyond creating xenotypes and create a proper custom race using the Big & Small Framework. This means the likes of robots, snake people with actual tails instead of legs, and so on.

It also goes through a few tricks related to Biotech which can be useful for those happy to rely entierly on xenotypes but looking for ways to create more neat graphics or gameplay behaviour.

To show how to set up a race this guide will go through how to create the joke race "Neko-Harpy", which you can download below.
4
2
2
   
Award
Favorite
Favorited
Unfavorite
Before you start
If this is your first mod, check out the guides over at "Modding_Tutorials" in the Rimworld Wiki.

The most important things to learn from there is:

1. The folder structure
2. XML (it is pretty easy)

You won't need C#, so you can ignore those guides.
Associated Mods
When following the guide, it is advised to download the sample mod and read through the comments in the files.
https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=3360783902



This mod was in part built to serve as an example for how to set up more advanced races.

https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=3360323573

Reading this Guide
This guide will show you a rather complex kind of race, but as you can see in the examples many races can be very simple to make.

If you're fine with having a Biotech DLC dependency you don't need to set up a RaceTracker, and can safely ignore that section. The most important parts for you is setting up a BodyDef (if you want custom anatomy) and the PawnExtension parts, since those can also freely be used by any gene.
Short Guide
Originally posted by AStarTrekStawman:
Okay, that's a lot of text, what's the minimum I need for a race? I just want to give my pawns 6 fingers on each hand and I don't want to understand what I'm doing.

  • ThingDef (Aka. "RaceDef")
  • BodyDef

That's it.


Minimal Human


Here is all the code of the ThingDef

<ThingDef ParentName="Human" BS_Alt="ThingDef_AlienRace"> <defName>SRM_SixFingerHuman</defName> <label>six-finger-human</label> <description>Humans famed for their... six fingers.</description> <statBases/> <race> <body>SRM_SixFingerHumanBody</body> </race> </ThingDef>

For the fingers simply copy the human bodydef and copy-paste add one extra finger on each hand.

You're done!




Originally posted by NotAFurry:
I want to make tail-less catgirls! How do I give them cat ears?

You don't need a special framework for that, just add a RenderNode to a HediffDef and you're golden!

Originally posted by NotAFurry:
And the catgirls have four legs! Always tough, males look like females, 20 melee, always naked, and absolutely no genes ever because i irrationally hate Biotech for some reason!

Also, make them the size of a Husky. And super beautiful!

And no matter the source they should be totally immune to Asthma!

Fiiiiiiine.


Inhuman with Cat Ears and four legs and... etc.


<ThingDef ParentName="Human" BS_Alt="ThingDef_AlienRace"> <defName>SRM_FourLegCatgirl</defName> <label>catgirl with four legs</label> <description>A race most known for sleeping on your keyboard. Yes. YOUR keyboard specifically dear reader.</description> <statBases> <SM_BodySizeMultiplier>0.85</SM_BodySizeMultiplier> <PawnBeauty>2</PawnBeauty> </statBases> <race><body>SRM_FourLegCatgirlBody</body></race> <modExtensions> <!-- Required to get the Hediff/tracker added. --> <li Class="BigAndSmall.RaceExtension"> <raceHediff>SRM_FourLegCatgirlTracker</raceHediff> </li> </modExtensions> </ThingDef>

You can copy-paste the human like six-finger guy up above. Then copy-paste the legs. If you launch at that point Rimworld will complain that the legs have more coverage than the total body, so reduce the coverage over either the legs (e.g. 50%) or that of other body-parts.

<HediffDef> <defName>SRM_FourLegCatgirlTracker</defName> <description>crime against nature</description> <label>Nyaaaaaaa~</label> <hediffClass>BigAndSmall.RaceTracker</hediffClass> <isBad>false</isBad> <everCurableByItem>false</everCurableByItem> <initialSeverity>1</initialSeverity> <comps> <li Class="BigAndSmall.CompProperties_Race"> <canSwapAwayFrom>true</canSwapAwayFrom> <skinIsHairColor>true</skinIsHairColor> <headDefOverride>Female_AveragePointy</headDefOverride> <headDefOverride_Female>Female_AveragePointy</headDefOverride_Female> <bodyDefOverride>Female</bodyDefOverride> <bodyDefOverride_Female>Female</bodyDefOverride_Female> </li> </comps> <modExtensions> <li Class="BigAndSmall.PawnExtension"> <forceFemaleBody>true</forceFemaleBody> <preventDisfigurement>true</preventDisfigurement> <hediffFilters><banlist><li>Asthma</li></banlist></hediffFilters> <forcedTraits><li>Tough</li></forcedTraits> <traitFilters><blacklist><li>Wimp</li></blacklist></traitFilters> <nullsThoughts><li>Naked</li></nullsThoughts> <aptitudes><Melee>20</Melee></aptitudes> <apparelRestrictions> <apparelLayers> <whitelist> <li>Headgear</li> <li>Utility</li> <li>Overhead</li> </whitelist> </apparelLayers> </apparelRestrictions><geneTagFilters><whitelist/></geneTagFilters> </li> </modExtensions> <renderNodeProperties> <li> <texPath>RaceTextures/Ears/YourCatEars</texPath> <nodeClass>PawnRenderNode_AttachmentHead</nodeClass> <workerClass>PawnRenderNodeWorker_FlipWhenCrawling</workerClass> <useSkinShader>false</useSkinShader> <colorType>Hair</colorType> <drawData><defaultData><layer>80</layer></defaultData></drawData> <parentTagDef>Head</parentTagDef> </li> </renderNodeProperties> </HediffDef>




Originally posted by NotOnMyChristianMinecraftServer:
Only support for vanilla body types? Lame! I think those men should use a certain Oni-mod's female body-type and clothes! :3

Alright, by popular request, you can now use the following in the PawnExtension (instead of bodyDefOverride in the CompProperties_Race)

<li Class="BigAndSmall.PawnExtension"> <bodyTypes> <FemaleBB>Male</FemaleBB> <Female>Female</Female> </bodyTypes> </li>

Do you think god stays in heaven because he lives in fear of what he has created?




If you want more examples write a comment here on my discord. Or check out any of the races I've made.

Now... Time the the actual guide!
Setting up the ThingDef (aka. "RaceDef")
First thing any race with a custom body needs is a "ThingDef". Sometimes called "RaceDef" by modders.This needs to go into a folder titled "Defs", as shown in the image in the first section.

The easiest way to get this set up right and easiest to maintain is to inherit from Ludeon's "Human".

Start with this:

<ThingDef ParentName="Human" BS_Alt="ThingDef_AlienRace">

The BS_Alt="ThingDef_AlienRace" makes it so your race automatically gets patched into a HAR race if the users has HAR active; for compatibility.

Dos
The <race/> xml contains a lot of the stuff you want to play around with. This is where you can supply a custom body, or if you feel like getting fancy you can provide custom AI by changing the thinkTrees.

Don'ts
Be careful messing with the lifeStageAges. Rimworld hardcodes a lot of stuff to ages. If you want a race that is born fully-formed (e.g. robots) it is better to simply make them be born at a chronological age of 0, but a biological age of 20.

Next Step...
If you just want to make a basic body to set via a biotech gene, for example a gene to give a pawn six spider legs instead of human legs, but otherwise not change much? Then you can skip this part. In fact, you can add most of what the "RaceExtension" does to regular genes via the pawnExtension which can be put on any Hediff or Gene.

If you want more advanced behaviour and aren't relying on a gene then you want add an extension like the below.

<modExtensions> <!-- Required to get the Hediff/tracker added. --> <li Class="BigAndSmall.RaceExtension"> <raceHediff>SRM_NekoHarpyTracker</raceHediff> </li> </modExtensions>

Replace SRM_NekoHarpyTracker from the example mod with the name of your own Hedifftracker.

This Hediff will always be present on your race and has a few special powers beyond what Hediffs normally do.
Setting up the BodyDef


If setting up a Humanlike BodyDef the easiest way to go about things is to simply copy the human BodyDef and make modifications.

I'd advice not replacing part defs unless needed. Often it is sufficient to simply change the label, and the player will be none the wiser.

That said, you can replace almost all parts with your own completely new alternatives for most part, the only one to be careful with is the "Head" def:

The Head BodyPartDef can be wherever you want it, but if you don't have a head rimworld won't render a head graphic on your pawn since it is hard-coded to skip that if the head isn't found. Then again, for some races this might not be an issue.

It is also a good idea to include all the standard bodyparts somewhere reasonable. Even if it means marking a snake's tail as "legs": Otherwise Rimworld may have them put on infinite pants. You can blacklist things that go on the legs using the framework, but that will prevent wearing armor covering both the torso and legs, possibly forcing you to make race-specific version.

If you want to import recipes to a new part there is a snippet you can add to it:

<modExtensions> <!-- This imports all recipes of the given part. If you don't want this just remove this part. --> <li Class="BigAndSmall.BodyPartExtension"> <importAllRecipesFrom><li>Arm</li></importAllRecipesFrom> </li> </modExtensions>
Setting up a RaceHediff "RaceTracker" (Optional)


The race tracker is simply a Hediff that is always included with the pawn.

Hediffs themselves are already quite powerful in rimworld, and with the modextension from Big & Small you can do pretty much anything genes can do.

Setup

You're need to put this somewhere in your Hediff:

<hediffClass>BigAndSmall.RaceTracker</hediffClass>

It ensures the code recognizes the hediff as a race and treats it correctly.

Next put these in there:

<isBad>false</isBad> <everCurableByItem>false</everCurableByItem> <initialSeverity>1</initialSeverity>
They make sure healer mechs serums won't try to cure you, etc.

Stages
Having a single entry of "Stages" is useful for doing all sorts of neat stuff. Here is an example:

<stages Inherit="False"> <li> <totalBleedFactor>0</totalBleedFactor> <painFactor>0.5</painFactor> <damageFactors> <Frostbite>0</Frostbite> </damageFactors> <socialFightChanceFactor>0.5</socialFightChanceFactor> <makeImmuneTo> <li>GutWorms</li> <li>FoodPoisoning</li> </makeImmuneTo> </li> </stages>

That code makes the pawn take 50% pain, become immune to frostbite, social-fight less, and not get GutWorms or FoodPoisoning.

Render Properties
This lets you draw almost anything on your pawn that genes would let you. And what they don't have covered the extension below does.

Look through the Neko-Harpy and see how the wings and other parts are set up.

BigAndSmall.PawnExtension
This is where you do most of the special stuff if your race, and it has a few features only enabled for races specifically.

More about this in its own section.
PawnExtension (Optional)


What is it?
The PawnExtension is a node which can do all sorts of things to a pawn. You can add any amount of it to geneDef or hediffDef such as the RaceTracker HediffDef and they will all be considered (and merged where needed)

When on Hediffs
The Extension will always be active, simple as that.

If the Hediff is a race extension it will have some special behaviour described below:

Filters and Forced Genes, Traits, and Hediffs
Races can apply irremovable endogenes that cannot be overriden (immutable endogenes), they can filter or force genes, traits, and hediffs using a fairly sophisticated set of logic.

This behaviour is disabled on regular GeneExtensions mostly to avoid situations like if someone makes a gene that force-adds a gene that another modder's hediff force removes that same gene, causing the pawn to add and remove it every time it refreshes.

Special Treatment
Other pawnExtensions can specify a "pawnDietRacialOverride". This makes it so instead of combining the diets and generally making it more restrictive, it will replace it.

This is used by Simply Robots to make Nuclear Stomachs enable robots to eat regular food instead of being restricted to Android Fuel.

When on Genes
When used on genes it will only be activated when the gene is active (not supressed). It also has logic for what happens when it gets deactivated or removed. For genes that should trigger their events when toggled in the middle of gameplay (i.e not when the player applies a xenogerm or a pawn spawns) you want the below geneClass.

<geneClass>BetterPrerequisites.PGene</geneClass>

The above is also used by genes that toggle races. You'll want to inherit from the abstract "BS_BodySwitch" GeneDef which includes it.

If you intend to write a custom C# gene class relying on its functions then it is advised to make your C# inherit from it.

What can it do in general?

You can force body-apperances, make them be conisdered machines or vampires, add a more powerful type of graphic similar to "furskin", blacklist or force genes, hediffs, traits.

This is also where you can blacklist or force in surgeries. By default you'll get all the human surgeries, but if you add a whitelist of some type you'll get only your listed surgeries.

There are too many features in the PawnExtension to go through them all here. The easiest way to get started is to read through the existing NekoHarpy race, or the robots from Big & Small - Simply Robots.
Okay, but seriously, tell me all the PawnExtension can do.
I'd advise first downloading the sample mod and going through the comments there, but after that you could check this out if you want more information on what is possible:

Right below is the link to the PawnExtension itself. Simply read the Comments and the name of the variable to figure out what they do.

https://github.com/RedMattis/BigSmall_Framework/blob/main/1.5/Main/Source/BetterPrerequisites/ModExtensions/PawnExtension.cs

Example of use for a gene that switches a pawn to a naga-body and gives it a special constrict attack (LS_SnakeTail) specific to that version of the gene:

<li Class="BetterPrerequisites.GeneExtension"> <canWalkOnCreep>true</canWalkOnCreep> <renderCacheOff>true</renderCacheOff> <applyPartHediff> <li> <hediff>LS_SnakeTail</hediff> <bodyparts> <li>BS_SnakeBody</li> </bodyparts> </li> </applyPartHediff> <thingDefSwap>BS_Naga</thingDefSwap> <bodyPosOffset>0.6</bodyPosOffset> <applyBodyHediff MayRequire="OskarPotocki.VanillaFactionsExpanded.Core"> <li> <hediff MayRequire="OskarPotocki.VanillaFactionsExpanded.Core">BS_Slither</hediff> </li> </applyBodyHediff> </li>

Example of an apparel restriction used by a the tv-looking "Ad-bots":

<apparelRestrictions> <apparelLayers> <blacklist> <li>OnSkin</li> </blacklist> </apparelLayers> <bodyPartGroups> <blacklist> <li>FullHead</li> <li>Feet</li> </blacklist> </bodyPartGroups> </apparelRestrictions>

BigAndSmall.CompProperties_Race (Optional)
A very small optional comp which can be added to the race's Hedifftracker.

The sample Neko-Harpy race goes over it fairly well.

It was originally built for shape-shifting abilities (like the "true form (demonic/angelic/goliath" and werewolf forced form), but it has behaviour suitable for races as well, such as forcing skinColor or forcing a particular headDef.

Here is an example for the "Steel Enforcer" robots which use it because they only have one BodyDef, and don't want other genes to be able to turn them into fleshy meatbags.

<comps> <li Class="BigAndSmall.CompProperties_Race"> <!-- Cosmetic --> <bodyDefOverride>Male</bodyDefOverride> <bodyDefOverride_Female>Female</bodyDefOverride_Female> <disableHair>true</disableHair> <disableBeards>true</disableBeards> <canSwapAwayFrom>false</canSwapAwayFrom> </li> </comps>

Bellow are all the available properties of this small comp.

The sub-items are example XML. if there is a value in the parenthesis then it is the default value. Otherwise it is none or empty in the case of lists.

Type of Data
Name
bool (true)
<canSwapAwayFrom>true</canSwapAwayFrom>
If you really don't want to permit change the race via e.g. genes.

colorList
<skinColorOverride><li>(1,0.5,0.5)</li><li>(1,0.5,0.5)</li></skinColorOverride>
colorList
<hairColorOverride><li>(1,0,0)</li>/hairColorOverride >
bool (false)
<skinIsHairColor>true</skinIsHairColor>
Changes the color of skin/hair

defName
<furskinOverride>SRM_FeatherSkin</furskinOverride>
Forces a furskin. Not suggested.
Use the "bodyPaths" on the PawnExtension instead.

defName
<bodyDefOverride>Fat</bodyDefOverride>
defName
<bodyDefOverride_Female>Thin</bodyDefOverride_Female>
defName
<headDefOverride>Female_AveragePointy</headDefOverride>
defName
<headDefOverride_Female>Female_AverageNormal</headDefOverride_Female>
Quick-and-dirty way to force a specific body or head on the pawn

bool (false)
<disableFacialAnims>false</disableFacialAnims >
bool (false)
<disableBeards>false</disableBeards >
bool (false)
<disableHair >false</disableHair >
bool (false)
<hideHead >false</hideHead >
bool (false)
<hideBody>false</hideBody >
Disables or hides a feature

bool (false)
<disableFacialAnims >false</disableFacialAnims >
Disables facial animations from Nal's mod on the pawn.
Stop your animated skeletons from getting quirky faces.

Mask and Colors


Rimworld supports 3 'colors' on the CutoutComplex shader. R, G, B. Which is to say. Red. Green. Black.

Wait what?

Black? That's not a color!?

Indeed, for some reason 'blackness' is a mask channel, and yes that is a terribly idea.

In practice this means sharp transitions from Red->Green will show the underlying texture ("Black" mask). You can somewhat avoid these transitions by making sure your layers don't have gamma correction enabled (so they go Red->Yellow->Green), but this won't fully solve the problem when zoomed out because LUDEON's engine does (It will go Red->Poop->Green)

You can make your life a bit easier by using smooth gradients, matching the underlying color, or adding dark lines between the masks to hide the transitions.



You can use red and green masks to control how a areas of genes, characters, etc. get coloured. If there is no mask then it behaves if everything was painted Red.



Here is a snippet from the Neko-Harpies showing how the second part of the Halo color is set, just to give you an idea of how in-depth you can go if you want.

<colorB> <!-- Set to the main color of the Ideology (or faction if DLC is missing) --> <ideologyColor>true</ideologyColor> <!-- Make sure the value-brightness is maxed out. We don't want poop-brown halos! --> <minBrightness>1</minBrightness> <color>(1,1,1,0.75)</color> <saturation>0.8</saturation> <alts> <li> <!-- If dead...... --> <triggers><li>Dead</li></triggers> <ideologyColor>true</ideologyColor> <maxBrightness>0.2</maxBrightness> <color>(1,1,1,0.2)</color> </li> <li> <!-- But instead, if they are a colonist then do- --> <triggers> <li>Colonist</li> <li>IdeologyDLC</li> </triggers> <!-- Set it to their favorite color! --> <favoriteColor>true</favoriteColor> <color>(1,1,1,0.6)</color> <brightness>1.2</brightness> <saturation>0.8</saturation> <minBrightness>0.8</minBrightness> </li> <li> <!-- Slave? --> <triggers> <li>SlaveOfColony</li> </triggers> <!-- Set it to their favorite color. But muted and faded because slavery sucks! --> <favoriteColor>true</favoriteColor> <color>(1,1,1,0.5)</color> <brightness>1.2</brightness> <saturation>0.5</saturation> <minBrightness>0.5</minBrightness> </li> <li> <triggers><li>Colonist</li></triggers> <!-- No Ideology DLC? Fine, set it to the outfit color. --> <apparelColorOrFavorite>true</apparelColorOrFavorite> <color>(1,1,1,0.6)</color> <brightness>1.2</brightness> <saturation>0.8</saturation> <minBrightness>0.8</minBrightness> </li> </alts> </colorB>
By the end...
https://i.imgur.com/R1Z2ORc.png
We're going to have set up a simple race with wings that act both for locomotion and for wielding tools.

https://i.imgur.com/hxJW7xa.png
The very normal-looking neko-harpies will be weirdly big, have inverted gender-appearances, and custom rules for apparel.

https://i.imgur.com/SVJxuz8.png
Their halos have a colouring system that is positively arcane, but fairly easy to set up.

Since Steam doesn't like my huge images and guides apparently don't like IMG-markup you'll just have to click the images. Terribly sorry about that. :D