-
Notifications
You must be signed in to change notification settings - Fork 91
Making custom races CE compatible
If your mod adds new animals they will need to be patched to work with the new melee and projectile system. Here is a guide on what settings you need to set and how to calculate them.
MoveSpeed: This should roughly be IRL speed in kilometers per hour divided by 10, e.g. if your animal has a top speed of 55kp/h its MoveSpeed stat should be 5.5. Extreme outliers might need to be adjusted downwards/upwards at your discretion.
ArmorRating: Especially tough animals like bears or rhinos should have natural armor against blunt and sharp damage. For reference, a bear in CE has 0.13 blunt and 0.15 sharp armor rating. Your animals shouldn't exceed 0.2 or so by much unless you want them to deflect handgun rounds.
BaseBodySize: To calculate this, use the your animal's height in meters, divide by its body shape's height multiplier (see below) and divide the result by 1.75. For example if we say a muffalo stands at 1.85m tall, its quadruped body type has a height multiplier of 0.5 its body size would be: 1.85 / 0.5 / 1.75 ~= 2.11
(round results to second decimal).
If you only know your animal's length use the same formula but use the body shape width multiplier instead of height.
BaseHealthScale: For most animals, this should be the same as health scale. If an animal is especially fragile/tough it should be offset, e.g. birds get only 80% of their body size in health scale, bears get 120%.
All CE animals will produce an error unless they have the RacePropertiesExtension mod extension with a valid body shape specified. The body shape determines the dimensions of your animal's hit box, if left unspecified they will be treated as a 1x1 cube by the game.
<Operation Class="PatchOperationAddModExtension">
<xpath>*/ThingDef[defName="Muffalo"]</xpath>
<value>
<li Class="CombatExtended.RacePropertiesExtensionCE">
<bodyShape>Quadruped</bodyShape>
</li>
</value>
</Operation>
You can find all the currently included body shapes in CE's Defs/Bodies/BodyShapes.xml file. As of time of this writing they are:
- Humanoid: For anything that is shaped like a human, e.g. humans (who'd have thought?), monkeys, terminators, etc.
- Quadruped: Quadruped animals that whose height is about 50% legs and 50% body. Most vanilla animals like Muffalo, deer, etc. fall into this category.
- QuadrupedLow: Quadruped animals whose legs don't lift them off the ground very much, e.g. hares, squirrels, etc.
- Serpentine: Animals that have especially long and thin bodies, such as snakes and iguanas.
- Birdlike: animals with relatively cuboid bodies and long necks, e.g. birds, Thrumbos.
In order to integrate animals with the CE system you need to do two things: add stats for melee dodge, critical and parry chances, and change the natural tools to CE ones.
<Operation Class="PatchOperationAdd">
<xpath>*/ThingDef[defName="Muffalo"]/statBases</xpath>
<value>
<MeleeDodgeChance>0.12</MeleeDodgeChance>
<MeleeCritChance>0.27</MeleeCritChance>
<MeleeParryChance>0.20</MeleeParryChance>
</value>
</Operation>
MeleeDodgeChance: how evasive this animal is in combat.
MeleeCritChance: how likely your animal is to score a knockdown.
MeleeParryChance: the animal's ability to 'parry' blows and how difficult their attacks are to parry.
To calculate the dodge, crit and parry chances for your animals, use this spreadsheet.
To calculate the armor penetration of your animals' attacks, use this spreadsheet. This is also relevant to melee weapons.
<Operation Class="PatchOperationReplace">
<xpath>*/ThingDef[defName="Muffalo"]/verbs</xpath>
<value>
<tools>
<li Class="CombatExtended.ToolCE">
<label>head</label>
<capacities>
<li>Blunt</li>
</capacities>
<power>18</power>
<cooldownTime>1.65</cooldownTime>
<linkedBodyPartsGroup>HeadAttackTool</linkedBodyPartsGroup>
<commonality>0.2</commonality>
<armorPenetration>0.178</armorPenetration>
</li>
</tools>
</value>
</Operation>
Most of these work the same as in vanilla, with only a few changes:
li Class: This needs to be set to ToolCE for your animal to use the new melee system.
capacities: CE adds a new DamageDef called Slash. Slash acts the same as scratch, except if it is deflected by armor it will still do blunt damage, whereas scratch will be nullified by armor completely. If your animal's Scratch tool has a lot of blunt force behind it (e.g. bear claws) this should be changed to Slash. For small animals like cats leave it as Scratch.
meleeArmorPenetration: This determines how effective this attack will be against armor. As a rule of thumb, if penetration matches armor rating it will have a 50% chance of being deflected. The spreadsheet linked above calculates armor piercing based on damage type and amount.
If you're adding a humanlike (e.g. sentient Aliens) race or a new type of Mechanoid you need to add additional comps to your race def.
<Operation Class="PatchOperationAdd">
<xpath>*/ThingDef[defName="Human"]/comps</xpath>
<value>
<li>
<compClass>CombatExtended.CompPawnGizmo</compClass>
</li>
<li Class="CombatExtended.CompProperties_Suppressable" />
</value>
</Operation>
CompPawnGizmo: allows displaying various pawn gizmos such as ranged weapons' ammo display. This should be on anything that can hold a gun, including Mechanoids.
CompSuppressable: handles suppression mechanic. This should be on anything with fear reactions to gunfire, e.g. sentient Aliens. Leave this out for things that don't care about incoming fire, e.g. Mechanoids, terminators, robots, etc.
If your custom pawn defs are inheriting from vanilla's BasePawn (or any abstract def named BasePawn for that matter) this should happen automatically. If not you'll need to manually add inventory support to your pawn.
<Operation Class="PatchOperationReplace">
<xpath>*/ThingDef[@Name="BasePawn"]/inspectorTabs/li[.="ITab_Pawn_Gear"]</xpath>
<value>
<li>CombatExtended.ITab_Inventory</li>
</value>
</Operation>
<Operation Class="PatchOperationAdd">
<xpath>*/ThingDef[@Name="BasePawn"]/comps</xpath>
<value>
<li Class="CombatExtended.CompProperties_Inventory" />
</value>
</Operation>
If your pawn is using vanilla's ITab_Pawn_Gear you need to replace it with CE's ITab_Inventory in order for the weight/bulk bars to show up. Beyond that all you need to do is add CompInventory to your pawn, no further configuration needed.
Note that if your humanlike has his own pawnKindDef that can spawn as visitor/raider/etc. it might need custom loadout data added. For further info on how to do this, see the page on adding loadouts to PawnKinds
Once you have created your xpath patch you can submit it to us through github or on the forums for inclusion in the main CE mod.