Skip to content

Extended How to Use

Matthew Seal edited this page Jul 19, 2020 · 5 revisions

Extended How to Use

Beyond the basic how-to-use, this page outlines some neat features that allow for more in-depth integration of terrain-type movement rules.

Gearing Up

Say you want to be able to keep up with your friend Stuart Little from the How-to-use page in his native environment. Well you'll need to design some new gear in Defs/ThingDefs_Items/SandPowerArmor.xml.

<?xml version="1.0" encoding="utf-8" ?>
<Defs>
  <ThingDef ParentName="ArmorMachineableBase">
    <defName>Apparel_SandDrillerPowerArmor</defName>
    <label>sand-driller plate armor</label>
    <description>Augmented power armor with built-in sand-jets for fast traversal through sand.</description>
    </statBases>
    <equippedStatOffsets>
      <MoveSpeed>-0.3</MoveSpeed>
      <SandDrillingSpeed>3.5</SandDrillingSpeed>
    </equippedStatOffsets>
  </ThingDef>
</Defs>

This will let you keep up with your buddy and slaughter some raiders together!

costPath Specific Textures

Say you want an infant version of the Stuart Little sandworm to be able to walk on and off sand, but you want it to be burrowed when traveling on sand (enter Tremors memes). To do this you have to give your pawn a custom LifeStageDef, as this is the only place we can easily apply texture overwrites from a modExtension.

  <ThingDef ParentName="AnimalThingBase">
    <defName>SandWorm</defName>
    <label>worm</label>
    <description>A large predatory worm that only lurks in sands.</description>
    <statBases>
      <MoveSpeed>1.0</MoveSpeed>
      <SandDrillingSpeed>8.0</SandDrillingSpeed>
    </statBases>
    ...
    <race>
      <lifeStageAges>
      <li>
          <def>SandWorm_BabyTiny</def>
          <minAge>0</minAge>
        </li>
        <li>
          <def>SandWorm_Juvenile</def>
          <minAge>0.22</minAge>
        </li>
        <li>
          <def>SandWorm_Adult</def>
          <minAge>0.45</minAge>
        </li>
      </lifeStageAges>
      ...
    </race>
    ...

These new lifestages need to be created with any custom changes you want. You can copy the original lifestages for the pawn and modify them with the new specific name.

  <LifeStageDef ParentName="AnimalBaby">
    <defName>SandWorm_BabyTiny</defName>
    <bodySizeFactor>0.1</bodySizeFactor>
    <foodMaxFactor>4</foodMaxFactor>
    <modExtensions>
      <li Class="TerrainMovement.TerrainMovementPawnKindGraphics">
        <pawnSpeedStat>pathCostSandDrilling</pawnSpeedStat>
        <bodyGraphicData>
          <texPath>Things/Pawn/Animal/SandWorm/BabySandWormBurrowed</texPath>
          <!-- Other standard modifications to body graphics can be applied here as well -->
          <drawSize>1.2</drawSize>
      </bodyGraphicData>
      </li>
    </modExtensions>
  </LifeStageDef>

Here you can see that we've added a special texture in the Things/Pawn/Animal/SandWorm/BabySandWormBurrowed path, just like any other texture. Whenever Stuart Little is using pathCostSandDrilling as it's pathCost stat, it will render with the BabySandWormBurrowed texture set instead of it's normal texture. You can add multiple TerrainMovementPawnKindGraphics mod extensions to give multiple terrain specific renderings.

Clone this wiki locally