Skip to content

Health Modifiers

ilikegoodfood edited this page Aug 9, 2019 · 4 revisions

Body Part Health

Before explaining how to mdofiy the health scale of a pawn it is important to undersand what it is and how it works.

The health of a particular BodyPartDef is defined within the Def, assuming no modifiers are applied. Different race definitons then apply a modifier to this value, thus allowing an elephant's heart to have more health than a human's. It s defined as baseHealthScale in the ThingDef component of a race definition.

RimWorld's core race definitions can be found by navigating to the game's mods folder. From there, go into Core/Defs/ThinDefs_Races and view the XML files in any text editor.

This is the code that amkes RimWorld run. It is vitally important that you do not change anything in these files!

The health of the BodyPart is then displayed to the player as:

BodyPartDef Health * baseHealthScale

A human, with a baseHealthScale of 1 has the same health as defined in the BodyPartDef (30 in the case of an arm or leg). An elephant, with a baseHealthScale of 3.6 has 3.6 times the health as defined in the BodyPartDef (108 in the case of a leg).

BodyPart Specific Modifiers

Due to the current way that RimWorld is coded, it is computationally impossible to provide a mod-compatible means for hediffs, or any other run-time effect, to edit the maximum health of an individual body part.

Whole-Body Effects

VEF Provides three different methods of effecting the overall baseHealthScale of a creature, a HealthModifier Capacity, HealthModifierFactor Capacity and a HealthModifier HediffComp with two fields (healthScaleOffset and healthScaleFactorOffset).

HealthModifier and healthScaleOffset are totalled together and then added to the baseHealthScale. This new value is the multiplied by the total of the HealthModifierFactor and healthScaleFactorOffset.

The final equation is:

HealthScale = (baseHealthScale + totalHealthScaleOffset + (HealthModifier - 1)) * (totalHealthScaleFactorOffset + (HealthModifierFactor - 1))

Health Modifier Capacity

A hidden capacity called HealthModifier has been added to all pawns. This capacity is added to the pawn's baseHealthScale.

This allows for the creation of hediffs or items that change the health scale of the user. It can both increase or decrease the baseHealthScale.

Be very careful not to raise or lower the value too much, as it will greatly effect the endurance of the pawn that it is attached to. It is highly recommended that you use this Capacity only to increase a pawn's health scale, as reducing it may rapidly lead to minimum values.

Health Modifier Factor Capacity

A hidden capacity called HealthModifierFactor has been added to all pawns. This capacity acts as a multiplier to the pawn's baseHealthScale.

This allows for the creation of hediffs or items that change the health scale of the user. It can both increase or decrease the baseHealthScale.

Be very careful not to raise or lower the value too much, as it will greatly effect the endurance of the pawn that it is attached to. It is highly recommended that you use this Capacity only to decrease a pawn's health scale, as reducing it in this way will be much more proportionate to the attached pawn. Increasing it this way will lead to the effect being stronger on pawns with a higher baseHealthScale, which should not be the case.

Health Modifier HediffComp (Legacy)

This hediff remains in order to ensure compatibility for any modded save game that may already be using this HediffComp. It is recommended to use the Capacities above for all new content.

Health conditions, inlcuding infections, prostethics and wounds, are defined by HediffDefs. RimWorld's HediffDefs can be found by navigating to the game's mods folder. From there, go into Core/Defs/HediffDefs and view the XML files in any text editor.

This is the code that amkes RimWorld run. It is vitally important that you do not change anything in these files!

To attach a Health Modifier, you need to use the comp VerbExpansionFramework.VEF_HediffCompProperties_HealthModifier. This comp needs to be added into the root of the HediffDef according to the structure shown below.

This is a placement guide, not functioning code. Do not just copy and paste it.

<HediffDef>
    <!--Contents of HediffDef-->
    <comps>
        <!--Contents of comps-->
        <li Class="VerbExpansionFramework.VEF_HediffCompProperties_HealthModifier">
            <healthScaleOffset></healthScaleOffset>
            <healthSCaleFactorOffset></healthScaleFactorOffset>
        </li>
        <!--Contents of comps-->
    </comps>
    <!--Contents of HediffDef-->
</HediffDef>

healthScaleOffset behaves in exactly the same way as the HealthModifier Capacity.

healthScaleFactorOffset behaves in eactly the same way as the HealthModifierFactor Capacity.