Skip to content

AI Agent Interactive Modding Workflow ​

This document defines the end-to-end Standard Operating Procedure (SOP) for AI Coding Agents (such as Claude Code, Cursor, Windsurf, Cline, and OpenChamber) and human developers building custom NPC mods for Probably Stolen.

To build a complete, scanner-compliant mod that loads and runs cleanly, an AI Agent needs two complementary references:

  1. Official Base Modding Guide: from the official repository dragonpan2/probably-stolen-modding (README.md, ModdingGuide.md, and APIChanges.md), which defines folder structure, mandatory manifest.xml tags (<Assemblies> and <Capabilities />), IMod lifecycle, ModLog, asset folders (Textures/Items/, Textures/Paper/, Sounds/, Localization/, LootTables/, Books/), ModHook events, ModScanner capability rules, and Steam Workshop publishing.
  2. Custom NPC Framework Specification: from this documentation site (and the single-file context /llms-full.txt), which defines the zero-reference NpcFrameworkSdk.cs bridge, 5-phase customer generation, per-save storyline state store (cnpcf_), 288×211 customer portrait injection, and all 18 Customer Subsystems.

1. Copy-Paste Starter Prompts for AI Coding Agents ​

Copy and send either of the prompts below to your AI coding assistant so it ingests both the official modding guide and the Custom NPC Framework specification before guiding you step-by-step:

markdown
Please read the following two sets of technical documentation for Probably Stolen modding first:
1. Official Probably Stolen Modding Guide (project layout, mandatory manifest.xml <Assemblies> and <Capabilities /> tags, IMod lifecycle, ModLog, custom items/sounds/localization asset loading, ModHook events, and ModScanner rules):
   - Quick Start: https://raw.githubusercontent.com/dragonpan2/probably-stolen-modding/main/README.md
   - Advanced Modding Guide: https://raw.githubusercontent.com/dragonpan2/probably-stolen-modding/main/ModdingGuide.md
   - API Changes: https://raw.githubusercontent.com/dragonpan2/probably-stolen-modding/main/APIChanges.md
2. Custom NPC Framework Complete Specification (6-step AI Agent workflow, full NpcFrameworkSdk.cs source code, all 18 Customer Subsystems, vanilla item/tag/sprite dictionaries, and full code breakdowns of both example mods):
   - Workflow Guide: https://customnpc.netlify.app/en/guide/agent-workflow
   - Single-File Full Context: https://customnpc.netlify.app/llms-full.txt

After reading, do not write code blindly. Walk me through the [6-Step Interactive Requirement Checklist] to confirm:
1. Mod metadata (Mod ID, display name, author) and whether the mod also needs custom items (GameItem), custom sounds, or loot table edits;
2. The new NPC's identity, faction (clientFaction), and portrait source (built-in SpriteDict pool vs. custom 288x211 PNG in Textures/);
3. Spawn phase (spawnPhase), day window, cooldown days, and spawn probability;
4. Core trade intent (regular BUY, regular SELL, Wholesale lot, BarterOffer, multi-day Procurement contract, or Custom GunOrder);
5. Multi-day storyline state machine (cnpcf_ save keys) and branching outcomes;
6. World integrations (7-digit holophone contact, handwritten note, store terminal request bounty StoreRequest, next-day newspaper headline TriggerNews, interrogation/smart-glasses scan dialogue, wanted arrest cutscene, afterhour events).

Once confirmed, generate the complete Modding/<ModName> project (.csproj, manifest.xml, NpcFrameworkSdk.cs, IMod entry class) and Mods/<ModName> deployment folder following the official manifest and zero-capability scanner rules.

Prompt Template B: Rapid Multi-Act Storyline NPC Generation ​

markdown
Read the official modding guide https://raw.githubusercontent.com/dragonpan2/probably-stolen-modding/main/ModdingGuide.md and the Custom NPC Framework full specification https://customnpc.netlify.app/llms-full.txt .
I want to create a multi-act storyline NPC mod for Probably Stolen named [Character Name]. Ask me to confirm each act's trade intent, items (vanilla item IDs vs. custom items), dialogue branches, and rewards first, then output a complete, buildable C# mod project that passes mod-scan with empty <Capabilities />.

2. Official Base Modding Rules (dragonpan2/probably-stolen-modding) ​

Every mod generated by an AI Agent must follow the base rules established in the official repository:

2.1 Standard Folder Layout ​

Inside the game installation folder (next to Probably Stolen.exe), Modding/ holds source projects and Mods/ holds runtime mod folders:

text
Probably Stolen/
├── Probably Stolen.exe
├── dev.txt                           # Optional empty file: enables F8 Debug Console and F9 Dev Menu
├── Mods/
│   └── MyCustomNPCPack/
│       ├── manifest.xml              # Mandatory: root element must be <Manifest>
│       ├── MyCustomNPCPack.dll       # Mandatory: listed under <Assemblies>
│       ├── preview.png               # Optional: Workshop & Mods menu preview (< 1 MB recommended)
│       ├── Textures/
│       │   ├── my_npc.png            # General texture (288x211 NPC portraits go here; auto-injected into SpriteDict)
│       │   ├── Items/
│       │   │   └── custom_item.png   # Custom item sprite (must sit directly in Textures/Items/)
│       │   └── Paper/
│       │       └── page_bg.png       # Paper book art (must sit directly in Textures/Paper/)
│       ├── Sounds/
│       │   └── custom_sfx.wav        # Custom audio (registered as "<modId>:custom_sfx")
│       └── Localization/
│           ├── en.csv                # English localization (UTF-8, no header: key,text)
│           └── zh.csv                # Chinese localization
└── Modding/
    └── MyCustomNPCPack/
        ├── MyCustomNPCPack.csproj
        ├── manifest.xml
        ├── NpcFrameworkSdk.cs        # Zero-reference bridge SDK file
        └── MyCustomNPCPackMod.cs     # IMod entry class

Note: Asset folder scanning is not recursive. Item sprites must sit directly in Textures/Items/, paper art in Textures/Paper/, general/NPC textures in Textures/, sounds in Sounds/, and localization CSVs in Localization/.

2.2 Mandatory manifest.xml Schema ​

The root element of manifest.xml must be <Manifest>, and both <Assemblies> and <Capabilities /> are mandatory:

xml
<?xml version="1.0" encoding="utf-8"?>
<Manifest>
  <ID>my_custom_npc_pack</ID>
  <Name>我的自定义NPC扩展包 / My Custom NPC Pack</Name>
  <Author>YourName</Author>
  <ModVersion>1.0.0</ModVersion>
  <Description>Custom NPC and storyline add-on built on Custom NPC Framework.</Description>
  <GameVersions>
    <Version>0.46</Version>
  </GameVersions>
  <Prerequisites>
    <Mod>CustomNPCFramework</Mod>
  </Prerequisites>
  <Assemblies>
    <Assembly>MyCustomNPCPack.dll</Assembly>
  </Assemblies>
  <Capabilities />
</Manifest>
  • <ID>: ASCII letters, digits, _, -, and . only (cannot start with ., max 64 chars).
  • <Prerequisites>: list dependencies using <Mod>CustomNPCFramework</Mod>.
  • <Assemblies>: list every DLL in the mod folder; any unlisted DLL or game assembly copy (0Harmony.dll, Assembly-CSharp.dll) refuses activation.
  • <Capabilities />: keep empty (<Capabilities />).

2.3 .csproj Configuration ​

Target netstandard2.1 and set <Private>false</Private> on all game assembly references so they are never copied into Mods/<ModName>/:

xml
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard2.1</TargetFramework>
    <AssemblyName>MyCustomNPCPack</AssemblyName>
    <RootNamespace>MyCustomNPCPack</RootNamespace>
    <LangVersion>latest</LangVersion>
    <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
    <CopyLocalLockFileAssemblies>false</CopyLocalLockFileAssemblies>
    <ManagedDir Condition="'$(ManagedDir)' == ''">$(MSBuildProjectDirectory)/../../Probably Stolen_Data/Managed</ManagedDir>
  </PropertyGroup>

  <ItemGroup>
    <Reference Include="Assembly-CSharp">
      <HintPath>$(ManagedDir)/Assembly-CSharp.dll</HintPath>
      <Private>false</Private>
    </Reference>
    <Reference Include="UnityEngine">
      <HintPath>$(ManagedDir)/UnityEngine.dll</HintPath>
      <Private>false</Private>
    </Reference>
    <Reference Include="UnityEngine.CoreModule">
      <HintPath>$(ManagedDir)/UnityEngine.CoreModule.dll</HintPath>
      <Private>false</Private>
    </Reference>
    <Reference Include="0Harmony">
      <HintPath>$(ManagedDir)/0Harmony.dll</HintPath>
      <Private>false</Private>
    </Reference>
  </ItemGroup>
</Project>

2.4 Combining Custom NPCs with Custom Items (OnModItemDirectoryInit) ​

If your custom NPC needs to buy, sell, or reward a brand-new item not in vanilla:

  1. Place the item sprite PNG in Mods/<ModName>/Textures/Items/<sprite_key>.png (sized to 64px per inventory grid cell);
  2. Subscribe to ModHook.OnModItemDirectoryInit += RegisterItems; in OnEnable() (and unsubscribe in OnDisable());
  3. Inside RegisterItems(), create the item with ItemDirectory.CreateEmptyItem("<item_id>") and bind its sprite and grid shape via item.SetSpriteAndShapeFromMod("<mod_id>", "<sprite_key>");
  4. Reference "<item_id>" in sc.clientBuyingIdList.Add("<item_id>") or PlayerStore.Instance.AddDirectSellingItemToTable("<item_id>", ...).

3. 6-Step Interactive Requirement Checklist for AI Agents ​

  1. Step 1 — Mod Metadata & Custom Assets: confirm <ID>, display name, author, and whether custom items (Textures/Items/) or sounds (Sounds/) are needed alongside the NPC.
  2. Step 2 — Identity, Faction & Portrait: confirm identifier, bilingual display names, clientFaction (from the 8 vanilla factions), and spriteName (70+ built-in SpriteDict methods vs. custom 288×211 PNG in Textures/).
  3. Step 3 — Spawn Scheduling: confirm spawnPhase (1 Early for story acts, 2 Normal for recurring visitors), priority, minDay, cooldownDays, and spawnChancePercent.
  4. Step 4 — Core Trade Intent (ClientIntent): select from regular BUY, regular SELL, Wholesale bundle, BarterOffer, AttachProcurementOffer, BuildCustomGunOrder, or DIALOGUE investigation.
  5. Step 5 — Multi-Day Storyline State Machine: define cnpcf_ save keys (GetSaveInt / SetSaveInt), register an auto-dispatcher entry (minDay = 9999, spawnChancePercent = 0), and advance stages inside acceptDealDialogue, allDoneDialogue, or dialogue choice callbacks.
  6. Step 6 — World Subsystems: confirm optional interogationDialogue, glasseDialogue, realtime scale callbacks (onItemAddedToWeighted), SetWanted + customOnArrestDialogue, RegisterPhoneContact, GiveHandnoteToPlayer, PostStoreRequest, TriggerNews, or RegisterAfterhourEvent.

4. Pre-Publish Verification Checklist ​

  1. Do not touch gameplay singletons inside Init or OnEnable: Init and OnEnable run at the Main Menu before any save is loaded. Only access PlayerStore.Instance or StoreStation.Instance inside clientFactory or gameplay hooks.
  2. Always call sc.CompleteClientCreation(false) before returning a StoreClient (followed by sc.CompleteSecClient() for Security dialogue encounters).
  3. Pass DirectoryMaster.Item("$", true) as the placeholder item in Dialogue.AddChoice, and end non-trade dialogue branches with DialogUIManager.Instance?.CurrentClientLeave(1f).
  4. Keep sc.isAug = false for non-monster characters (isAug = true is reserved for hostile disguised Aug monsters).
  5. Verify zero-capability compliance: run mod-scan <your_mod_id> in the F8 console (with dev.txt present) to confirm the DLL requires no <Capabilities>.

Custom NPC Framework Documentation