Generic Needs - KonradHeinser/EBSGFramework GitHub Wiki

This need class allows you to make basic needs that allow you to choose what stat affects the fall rate, if any, and what hediff to apply if the need goes to 0. The NeedDef needs to point to the special EBSG needClass, and the fall rate must be specified in the NeedDef itself rather than the extension. Any extra customization requires the EBSGExtension get added to the NeedDef. For an easy to copy code of all of that:

        <needClass>EBSGFramework.Need_GenericNeed</needClass>
        <fallPerDay>0.10</fallPerDay>

        <modExtensions>
            <li Class="EBSGFramework.EBSGExtension">
            </li>
        </modExtensions>

These are the tags available with the extension:

  • fallStat : Stat to multiply the fallPerDay by
  • hediffWhenEmpty : Hediff to apply if the need hits or remains at 0. This doesn't technically need to be added if the only effect is supposed to be mood based
  • initialSeverity : Default (0.001) : Severity to apply when the hediff is first added
  • risePerDayWhenEmpty : Default (0.2) : Severity added to the hediff over the span of each day that the need is empty
  • fallPerDayWhenNotEmpty : Default (0.1) : Severity removed from the hediff over the span of each day that the need is not empty
  • thresholdPercentages : Default ( [0.3] ) : A list of percentages to place a small marker at
  • displayLowAlert : Default (False) : If true and there is at least one item in the thresholdPercentages list, this will make an alert while the need is below the first point in the list

For a related need thought, see Need Thoughts.


This example creates a "maintenance" need gene that will cause the pawn to go into a coma if another pawn with the same gene does not regularly come by to "maintain" them. The ability uses the offset need ability comp, and the hediff in question starts at a higher value to add a penalty for not keeping up on your maintenance. The EBSG Framework won't gain think tree stuff until Major Update 3.5, but you should be able to set up your own think tree stuff using RimWorld's ThinkNode_ConditionalNeedPercentageAbove to help with auto-casting on themselves:

    <GeneDef ParentName="EBSG_TestGeneBase">
        <defName>MaintenanceNeed</defName>
        <label>maintenance</label>
        <description>Every 10 days, this pawn needs the maintain ability used on them, by another pawn with the maintenance need. Failure to do so will result in the pawn falling into a coma due to a malfunction.</description>
        <causesNeed>MaintenanceNeed</causesNeed>
        <biostatMet>4</biostatMet>
        <minAgeActive>13</minAgeActive>
        <abilities>
            <li>MaintenanceNeed</li>
        </abilities>
    </GeneDef>    

    <NeedDef>
        <defName>MaintenanceNeed</defName>
        <needClass>EBSGFramework.Need_GenericNeed</needClass>
        <label>maintenance</label>
        <description>Every 10 days, this pawn needs the maintain ability used on them.</description>
        <baseLevel>0</baseLevel>
        <colonistAndPrisonersOnly>true</colonistAndPrisonersOnly>
        <onlyIfCausedByGene>true</onlyIfCausedByGene>
        <fallPerDay>0.10</fallPerDay>
        <modExtensions>
            <li Class="EBSGFramework.EBSGExtension">
                <hediffWhenEmpty>MaintenanceNeed_Shutdown</hediffWhenEmpty>
                <initialSeverity>1</initialSeverity>
                <risePerDayWhenEmpty>0.1</risePerDayWhenEmpty>
                <fallPerDayWhenNotEmpty>1</fallPerDayWhenNotEmpty>
                <thresholdPercentages>
                    <li>0.3</li>
                    <li>0.6</li>
                </thresholdPercentages>
                <displayLowAlert>True</displayLowAlert>
            </li>
        </modExtensions>
    </NeedDef>

    <HediffDef>
        <defName>MaintenanceNeed_Shutdown</defName>
        <label>shutdown</label>
        <description>After a malfunction caused by going too long without being maintained, this pawn will remain shutdown for at least 24 hours while it recalibrates, longer if it does not receive maintenance while recalibrating.</description>
        <stages>
            <li>
                <capMods>
                    <li>
                        <capacity>Consciousness</capacity>
                        <setMax>0.1</setMax>
                    </li>
                </capMods>
            </li>
        </stages>
    </HediffDef>
    
    <AbilityDef ParentName="EBSG_TestAbilityBase">
        <defName>MaintenanceNeed</defName>
        <label>maintain</label>
        <description>Fully increases the maintenance need. Will require a think tree to autocast.</description>
        <comps>
            <li Class="EBSGFramework.CompProperties_AbilityOffsetNeed">
                <needOffsets>
                    <li>
                        <need>MaintenanceNeed</need>
                        <offset>1</offset>
                    </li>
                </needOffsets>
            </li>
        </comps>
    </AbilityDef>
⚠️ **GitHub.com Fallback** ⚠️