Skip to content

Your first NPC

This makes a hireable mercenary with a hunting rifle on the built-in survivor body. Three small files.

Mods/
  DSD_NPCUtilities/                 (the framework)
  DSD_NPCUtilities_MyPack/          (your mod: sorts after it)
    ModInfo.xml
    Config/
      entityclasses.xml
      npc.xml
      Localization.txt

ModInfo.xml

<?xml version="1.0" encoding="UTF-8" ?>
<xml>
  <Name value="DSD_NPCUtilities_MyPack" />
  <DisplayName value="My NPC Pack" />
  <Description value="A mercenary for hire. Needs DarkSide NPC Utilities." />
  <Author value="You" />
  <Version value="1.0.0" />
</xml>

Config/entityclasses.xml

<configs>
  <append xpath="/entity_classes">
    <entity_class name="myNpcMercenary" extends="dsdNpcTemplate">
      <property name="UserSpawnType" value="Menu"/>
      <property name="Mesh" value="#@modfolder(DSD_NPCUtilities):Resources/dsdnpcutilities.unity3d?dsdNpcSurvivor"/>
      <property name="PhysicsBody" value="dsdNpcSurvivor"/>
      <property name="NPCID" value="myMercenary"/>
      <property name="Faction" value="dsdSurvivors"/>
      <property name="DSDNpcRole" value="companion"/>
      <property name="DSDNpcHireCost" value="5000"/>
      <property name="DSDNpcHireDays" value="3"/>
      <property name="DSDNpcRepHire" value="500"/>
      <property name="DSDNpcWeapon" value="gunRifleT1HuntingRifle"/>
      <property name="DSDNpcAmmo" value="60"/>
      <property name="DSDNpcAim" value="0.3"/>
      <effect_group name="Base Effects">
        <passive_effect name="HealthMax" operation="base_set" value="300"/>
      </effect_group>
    </entity_class>
  </append>
</configs>
  • Mesh + PhysicsBody: the body. Here the survivor that ships with NPC Utilities.
  • NPCID: links to the npc_info below (name, faction, dialog).
  • DSDNpc...: the NPC's behavior. All of them are listed in NPC settings.
  • effect_group: health, like any entity.

Config/npc.xml

<configs>
  <append xpath="/npc">
    <npc_info id="myMercenary" name="Mercenary" name_key="myNpcMercenary" faction="dsdSurvivors"
      portrait="" greeting_type="nearby" stance="Like" voice_set="" dialog_id="dsdNpcCompanion"
      quest_faction="0" localization_id="myNpcMercenary"/>
  </append>
</configs>

dialog_id="dsdNpcCompanion" uses the ready-made hire / orders / gear dialog. Write your own later with Dialog.

Config/Localization.txt

Key,File,Type,UsedInMainMenu,NoTranslate,english
myNpcMercenary,entityclasses,Entity,,,Mercenary

The key is the entity class name; it's the name players see.

Try it

Start a game, press F1 and run:

dsdnpc spawn myNpcMercenary

Talk to him with E. If "Travel with me" is missing, check your Dukes and standing (dsdnpc rep dsdSurvivors 800 for testing).

Next steps

Give him his own faction, his own lines, a voice or a new face.