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!

Disabling Default Movement

If you want a pawn to have no default movement option you can set the defaultMovementAllowed attribute on the TerrainMovementPawnRestrictions mod extension. This is useful if your custom terrain movement is slower than default movement speeds and you'd prefer to just disable them all together so the desired movement stat is used. Below is an example for how to set this attribute.

  ...
  </statBases>
  <modExtensions>
    <li Class="TerrainMovement.TerrainMovementPawnRestrictions">
      <defaultMovementAllowed>false</defaultMovementAllowed>
    </li>
  </modExtensions>
  ...

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.

Disabling Movement Stat for Certain Locomotion Urgencies

If you introduce a new stat that has a dramatically different speed than default movement, you may want to be able to disable it when using a certain locomotion. For example, maybe Stuart Little should use default movement and texture when Ambling or Walking, but use SandDrillingSpeed when Jogging or Sprinting. You can combine this with the texture specific to a cost path to enable a texture transition when a pawn goes from wandering to running (or burrowing) to an objective.

Below this is done by applying the TerrainMovementStatDef mod extension to the SandDrillingSpeed stat.

  <StatDef>
    <defName>SandDrillingSpeed</defName>
    <label>sand speed</label>
    ...
    <modExtensions>
      <li Class="TerrainMovement.TerrainMovementStatDef">
        <pawnSpeedStat>SandDrillingSpeed</pawnSpeedStat>
        <terrainPathCostStat>pathCostSandDrilling</terrainPathCostStat>
        <disallowedLocomotionUrgencies>
          <li>None</li>
          <li>Amble</li>
          <li>Walk</li>
        </disallowedLocomotionUrgencies>
      </li>
    </modExtensions>
  </StatDef>

Note that you need to re-specify the pawnSpeedStat and the terrainPathCostStat for the mod extension to work properly. The disallowedLocomotionUrgencies can take any of the motions provided by Verse.AI.LocomotionUrgency: None, Amble, Walk, Jog, and Sprint.

Clone this wiki locally