Terrain Cost Override - KonradHeinser/EBSGFramework GitHub Wiki

This hediff comp that allows you to set how much a specific terrain type costs to a pawn (see pathCost on the vanilla TerrainDefs), or set a universal one that applies to all terrains not included. Only the first applicable hediff applies to the pawn, but specific terrain overrides can be locked behind things like hediffs. The basic comp looks like this:

        <comps>
            <li Class="EBSGFramework.HediffCompProperties_TerrainCostOverride">
            </li>
        </comps>

Conditional tags within the class itself apply to the entire comp. The full list of tags available is:

  • universalCostOverride : Integer that replaces all path costs not included in terrainSets (will replace those costs anyway if the individual item's conditions aren't met)

  • pawnHasAnyOfGenes : List of GeneDefs that the pawn requires at least one of for the this comp to activate

  • pawnHasAllOfGenes : List of GeneDefs that the pawn needs to have all of for the this comp to activate

  • pawnHasNoneOfGenes : List of GeneDefs that prevent all overrides if the pawn has any of them

  • pawnHasAnyOfHediffs : List of HediffDefs that the pawn requires at least one of for the this comp to activate

  • pawnHasAllOfHediffs : List of HediffDefs that the pawn needs to have all of for the this comp to activate

  • pawnHasNoneOfHediffs : List of HediffDefs that prevent all overrides if the pawn has any of them

  • pawnCapLimiters : Special list of PawnCapacityDefs that uses the DefName for the tag, and the valid range for the value. If only a single number is entered, then any value above that number also qualifies

  • pawnSkillLimiters : Special list of SkillDefs that uses the DefName for the tag, and the valid range for the value. If only a single number is entered, then any value above that number also qualifies

  • pawnStatLimiters : Special list of StatDefs that uses the DefName for the tag, and the valid range for the value. If only a single number is entered, then any value above that number also qualifies

  • pawnNeedLevels : Special list of NeedDefs that uses the DefName for the tag, and the valid range for the value. If only a single number is entered, then any value above that number also qualifies


These are the tags for each individual terrainSet:

  • terrain : The TerrainDef to check for

  • terrains : A list of TerrainDefs to check for

  • newCost : Default (0) : The new pathCost to apply to that terrain

  • pawnHasAnyOfGenes : List of GeneDefs that the pawn requires at least one of for the this item to activate

  • pawnHasAllOfGenes : List of GeneDefs that the pawn needs to have all of for the this item to activate

  • pawnHasNoneOfGenes : List of GeneDefs that stops this item if the pawn has any of them

  • pawnHasAnyOfHediffs : List of HediffDefs that the pawn requires at least one of for the this item to activate

  • pawnHasAllOfHediffs : List of HediffDefs that the pawn needs to have all of for the this item to activate

  • pawnHasNoneOfHediffs : List of HediffDefs that stops this item if the pawn has any of them

  • pawnCapLimiters : Special list of PawnCapacityDefs that uses the DefName for the tag, and the valid range for the value. If only a single number is entered, then any value above that number also qualifies

  • pawnSkillLimiters : Special list of SkillDefs that uses the DefName for the tag, and the valid range for the value. If only a single number is entered, then any value above that number also qualifies

  • pawnStatLimiters : Special list of StatDefs that uses the DefName for the tag, and the valid range for the value. If only a single number is entered, then any value above that number also qualifies

  • pawnNeedLevels : Special list of NeedDefs that uses the DefName for the tag, and the valid range for the value. If only a single number is entered, then any value above that number also qualifies


Note 1 : If universal floating/flight is your only goal, VFE has a comp dedicated to only that. That is the equivalent of setting universalCostOverride to 0 and doing nothing else. This only has use if you want a slower flight rate (by setting a universal above 0), or want to add qualifiers to when the pawn can fly.

Note 2 : Pawn pathing is weird. There will be times when the pawn decides that a path is faster when it isn't really. Pawns will still move at the speeds influenced by this comp, and this issue tends to be less notable when the pawn is moving long distances.

Note 3 : Pawns still can't pass impassable things. This is intentional, as at the moment I don't want to risk complications from overriding that. It is also worth noting that if there is a mod that makes them passable, this comp will probably apply to them properly, barring the issue mentioned in Note 2.

Note 4 : Always remember that only the first instance of this comp that is found will apply. If you want pathings to be influenced by multiple comps, make a core hediff that has terrainSets that are only active when those other hediffs are active. Those other hediffs shouldn't have the comp on them, but will instead follow the instructions of the core hediff. You can make this core hediff invisible if so desired.


These two examples show both a universal and a specific terrain cost override. The first one allows the pawn to ignore all terrain costs, but only if they can see perfectly (don't want to "risk running into things" or something). The second one allows the pawn to ignore any marshy soil and marsh:

    <HediffDef>
        <defName>Flight</defName>
        <label>flight</label>
        <description>Flight if you can see just fine.</description>
        <everCurableByItem>false</everCurableByItem>
        <initialSeverity>0.001</initialSeverity>
        <stages />
        <hediffClass>HediffWithComps</hediffClass>
        <comps>
            <li Class="EBSGFramework.HediffCompProperties_TerrainCostOverride">
                <universalCostOverride>0</universalCostOverride>
                <pawnCapLimiters>
                    <Sight>1</Sight>
                </pawnCapLimiters>
            </li>
        </comps>
    </HediffDef>

    <HediffDef>
        <defName>MarshWalk</defName>
        <label>marsh walk</label>
        <description>Ignore marsh path costs.</description>
        <everCurableByItem>false</everCurableByItem>
        <initialSeverity>0.001</initialSeverity>
        <stages />
        <hediffClass>HediffWithComps</hediffClass>
        <comps>
            <li Class="EBSGFramework.HediffCompProperties_TerrainCostOverride">
                <terrainSets>
                    <li>
                        <terrains>
                            <li>MarshyTerrain</li>
                            <li>Marsh</li>
                        </terrains>
                    </li>
                </terrainSets>
            </li>
        </comps>
    </HediffDef>

⚠️ **GitHub.com Fallback** ⚠️