Severity by Nearby Pawns - KonradHeinser/EBSGFramework GitHub Wiki

This hediff comp sets the severity of the hediff to be equal to the number of viable nearby pawns. I use the term viable because you can change what type of pawns it looks for. The basic comp looks like this:

            <li Class="EBSGFramework.HediffCompProperties_SeverityByNearbyPawns">
                <range>15</range> <!--Ignored if there is a rangeStat-->
                <rangeStat>InsertRangeStatDefNameHere</rangeStat> <!--Optional. If this is used, then range is ignored-->
            </li>

The remaining options act like targeting parameters:

  • onlyEnemies : Default (False) : Only adds the target to the list if they are hostile to the pawn
  • onlyDifferentFaction : Default (False) : Only adds the target to the list if they are in a different faction than the pawn, or doesn't have a faction
  • onlySameFaction : Default (False) : Only adds the target to the list if they are in the same faction as the pawn
  • onlyHumanlikes : Default (False) : Only adds the target to the list if Rimworld recognizes them as a humanlike
  • includeSelf : Default (True) : While true, the pawn is always included on the list, creating a minimum severity of 1. If false, then the hediff is removed if there are no viable targets around

Example from SHG - Just the Psionist. This hediff reduces the damage the pawn takes based on how many allies are nearby, and if there are none, it removes the hediff.

    <HediffDef>
        <defName>SHG_Psionist_OneOfAMillion</defName>
        <label>one of a million</label>
        <description>The more player pawns near this pawn, the less damage they will take.</description>
        <hediffClass>HediffWithComps</hediffClass>
        <isBad>false</isBad>
        <stages>
            <li>
                <minSeverity>1</minSeverity>
                <statFactors>
                    <IncomingDamageFactor>0.95</IncomingDamageFactor>
                </statFactors>
            </li>
            <li>
                <minSeverity>2</minSeverity>
                <statFactors>
                    <IncomingDamageFactor>0.90</IncomingDamageFactor>
                </statFactors>
            </li>
            <li>
                <minSeverity>3</minSeverity>
                <statFactors>
                    <IncomingDamageFactor>0.85</IncomingDamageFactor>
                </statFactors>
            </li>
            <li>
                <minSeverity>4</minSeverity>
                <statFactors>
                    <IncomingDamageFactor>0.80</IncomingDamageFactor>
                </statFactors>
            </li>
            <li>
                <minSeverity>6</minSeverity>
                <statFactors>
                    <IncomingDamageFactor>0.70</IncomingDamageFactor>
                </statFactors>
            </li>
            <li>
                <minSeverity>8</minSeverity>
                <statFactors>
                    <IncomingDamageFactor>0.60</IncomingDamageFactor>
                </statFactors>
            </li>
            <li>
                <minSeverity>10</minSeverity>
                <statFactors>
                    <IncomingDamageFactor>0.50</IncomingDamageFactor>
                </statFactors>
            </li>
            <li>
                <minSeverity>12</minSeverity>
                <statFactors>
                    <IncomingDamageFactor>0.40</IncomingDamageFactor>
                </statFactors>
            </li>
            <li>
                <minSeverity>14</minSeverity>
                <statFactors>
                    <IncomingDamageFactor>0.30</IncomingDamageFactor>
                </statFactors>
            </li>
            <li>
                <minSeverity>16</minSeverity>
                <statFactors>
                    <IncomingDamageFactor>0.20</IncomingDamageFactor>
                </statFactors>
            </li>
            <li>
                <minSeverity>18</minSeverity>
                <statFactors>
                    <IncomingDamageFactor>0.10</IncomingDamageFactor>
                </statFactors>
            </li>
            <li>
                <minSeverity>20</minSeverity>
                <statFactors>
                    <IncomingDamageFactor>0.00</IncomingDamageFactor>
                </statFactors>
            </li>
        </stages>
        <comps>
            <li Class="SuperHeroGenesBase.HediffCompProperties_SeverityByNearbyPawns">
                <onlySameFaction>True</onlySameFaction>
                <onlyHumanlikes>True</onlyHumanlikes>
                <includeSelf>False</includeSelf>
                <range>30</range>
            </li>
            <li Class="HediffCompProperties_Disappears">
                <disappearsAfterTicks>60000</disappearsAfterTicks>
                <showRemainingTime>true</showRemainingTime>
            </li>
        </comps>
    </HediffDef>
⚠️ **GitHub.com Fallback** ⚠️