Skip to content

NPCs & Spawners

NPCs (Non-Player Characters) are the living inhabitants of your world: enemies to fight, merchants to trade with, quest-givers to talk to. Each NPC is a template from which instances are spawned into rooms.

  • Template: The blueprint stored in the database. Defines name, stats, traits.
  • Instance: A copy created when a spawner activates. Has a unique instance ID.
NPC Template: "Cave Goblin" (ENM0003)
↓ Spawner activates
NPC Instance: "Cave Goblin" (ENM0003-abc123) in Room R0104
↓ Player kills it
Instance deleted, spawner starts respawn timer

Via the Creator UI: NPCs → New

Or via the REST API:

Terminal window
curl -X POST http://localhost:8010/api/npcs \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"name": "Cave Goblin",
"description": "A small, green-skinned creature with yellow eyes and sharp claws.",
"detail": "The goblin watches you with calculating intelligence.",
"enemyTrait": {
"level": 2,
"maxHitPoints": 20,
"currentHitPoints": 20,
"attack": 4,
"defense": 1,
"xpReward": 15,
"goldDrop": 3
}
}'
FieldDescription
nameDisplay name
descriptionWhat players see when they look at the NPC
detailDetailed description when players examine the NPC
dialogIdID of a dialog tree to use when talked to
enemyTraitEnemy combat stats (makes NPC attackable)
merchantTraitMerchant inventory (makes NPC a shopkeeper)

Add the enemy trait to make an NPC attackable in combat:

{
"enemyTrait": {
"level": 3,
"maxHitPoints": 45,
"currentHitPoints": 45,
"attack": 6,
"defense": 2,
"xpReward": 35,
"goldDrop": 10,
"lootTableId": "LT0003"
}
}
FieldDescription
levelEnemy level (affects scaling)
maxHitPointsMax HP
attackBase attack damage
defenseDamage reduction
xpRewardXP given to each killer
goldDropGold dropped in room on death
lootTableIdID of a loot table for item drops

Add the merchant trait to make an NPC a shopkeeper:

{
"merchantTrait": {
"inventory": [
{
"templateId": "ITM0012",
"stock": 10,
"maxStock": 10,
"price": 8,
"restockTime": 3600
}
]
}
}

Players interact via:

> talk merchant
> list — show available items
> buy [item] — purchase an item
> sell [item] — sell an item
> value [item] — check selling price

NPCs automatically get quest dialog options injected when they are the source.npcId for a quest. No special trait needed — any NPC can give quests.

See Quest System for the quest data format.

Spawners are configured on rooms. They automatically create NPC instances:

{
"spawners": [
{
"npcTemplateId": "ENM0003",
"maxCount": 2,
"respawnTime": 90,
"currentCount": 0
}
]
}
FieldDescription
npcTemplateIdThe NPC template to spawn
maxCountMaximum instances in the room at once
respawnTimeSeconds between spawn attempts
currentCountCurrent live instance count (managed by server)

The spawner tick runs every 5 seconds. If currentCount < maxCount and the respawn timer has elapsed, a new instance is created.

NPCs currently support:

  • Idle — standing in the room, waiting to be interacted with
  • Aggressive — attacks players on sight (based on enemy trait)
  • Merchant — sells items when players interact

More complex AI (patrol, flee, conversation-triggered behavior) is on the roadmap.

IDNameLocationRole
NPC0001Mira ThornwoodWeary Wanderer InnInnkeeper, merchant
NPC0002BramwickGeneral StoreMerchant
NPC0003Kara IronhandSmithyBlacksmith
NPC0004Captain AldricGuard PostQuest-giver
NPC0005Guardsman ThomTown GateGuard
NPC0007Archivist MarenArchiveScholar, quest-giver