Skip to content

NPC Templates

Overview

NPC templates are Abstract role files that define common behavior, stats, and AI logic shared by a family of NPCs. Concrete roles reference a template via the Reference field and selectively override values via Modify. The Parameters system lets templates declare named defaults with documentation that concrete roles can override without changing the template itself.

File Location

Assets/Server/NPC/Roles/_Core/Templates/*.json

The Reference / Modify Pattern

A Variant role file links to a template and overrides specific fields:

{
"Type": "Variant",
"Reference": "Template_Predator",
"Modify": {
"Appearance": "Fox",
"MaxHealth": 38
}
}

The engine merges the template’s full definition with the Modify block. Fields not listed in Modify keep the template’s value. The Reference value is the filename without the .json extension.

The Parameter / Compute System

Templates declare Parameters — named values with a default and a description:

{
"Parameters": {
"MaxHealth": {
"Value": 100,
"Description": "Max health for the NPC"
},
"Appearance": {
"Value": "Bear_Grizzly",
"Description": "Model to be used"
}
}
}

Top-level fields in the template read from these parameters using the Compute shorthand:

{
"MaxHealth": { "Compute": "MaxHealth" },
"Appearance": { "Compute": "Appearance" }
}

A concrete Variant role overrides a parameter by supplying a new value in its own Parameters block inside Modify:

{
"Type": "Variant",
"Reference": "Template_Predator",
"Modify": {
"MaxHealth": 38,
"Appearance": "Fox"
},
"Parameters": {
"NameTranslationKey": {
"Value": "server.npcRoles.Fox.name",
"Description": "Translation key for NPC name display"
}
}
}

Schema — Template (Abstract) fields

FieldTypeDescription
Type"Abstract"Marks this file as a non-spawnable base template.
StartStatestringInitial AI state, e.g. "Idle".
ParametersobjectNamed parameter definitions. Each entry has Value, optional TypeHint, and Description.
AppearanceComputeResolved from Parameters.Appearance.
MaxHealthComputeResolved from Parameters.MaxHealth.
DropListComputeResolved from Parameters.DropList.
NameTranslationKeyComputeResolved from Parameters.NameTranslationKey.
MotionControllerListarrayLocomotion controllers (Walk, Fly, Swim).
InstructionsarrayFull AI behavior tree shared by all variants.
KnockbackScalenumberDefault knockback multiplier.
DisableDamageGroupsstring[]Damage groups blocked by default.

Available Base Templates

TemplateBehavior FamilyKey Defaults
Template_PredatorAggressive hunter, will attack then flee if threatenedViewRange: 24, AlertedRange: 28, FleeIfNotThreatened: true
Template_Animal_NeutralPassive prey animal, flees when threatenedViewRange: 16, AlertedRange: 18, StartState: Idle
Template_LivestockTameable farm animal with grazing and produceAlertedActionRange: 6, GrazingBlockSet: Grass
Template_Birds_PassiveFlying passive bird with flock behaviorFlockArray: ["Template_Birds_Passive"], MotionControllerList: [Fly]
Template_IntelligentFaction NPC with combat AI and call-for-helpAlertedRange: 45, ChanceToBeAlertedWhenReceivingCallForHelp: 70
Template_Beasts_Passive_CritterSmall passive critterMinimal stats, critter-scale flock behavior
Template_Edible_CritterPassive critter that can be eatenExtends critter with food interaction
Template_SpiritSpirit entity with special movementSpirit locomotion, particle defaults
Template_Summoned_AllyPlayer-allied summonFriendly attitude to player by default
Template_Swimming_AggressiveAggressive aquatic NPCSwim locomotion, hostile AI
Template_Swimming_PassivePassive aquatic NPCSwim locomotion, flee behavior
Template_TempleTemple guardian NPCGuardian AI, high health

Example — Template_Animal_Neutral (abbreviated)

This is the template that Chicken, Deer, Moose, and other neutral animals inherit from:

{
"Type": "Abstract",
"StartState": "Idle",
"Parameters": {
"Appearance": {
"Value": "Deer_Stag",
"Description": "The NPC's model."
},
"ViewRange": {
"Value": 16,
"Description": "The view distance of the NPC, in blocks."
},
"ViewSector": {
"Value": 180,
"Description": "The view sector of the NPC, in degrees."
},
"HearingRange": {
"Value": 8,
"Description": "The hearing distance of the NPC, in blocks."
},
"AbsoluteDetectionRange": {
"Value": 4,
"Description": "The range at which a target is guaranteed to be detected, in blocks."
},
"AlertedRange": {
"Value": 18,
"Description": "The range within which the target can be seen when alerted, in blocks."
},
"AlertedActionRange": {
"Value": 8,
"Description": "The range at which an NPC will react to players, in blocks."
},
"DropList": {
"Value": "Empty",
"Description": "The NPC's drop list."
},
"AttractiveItemSet": {
"Value": [],
"TypeHint": "String",
"Description": "Items that are deemed attractive when held nearby."
},
"MaxHealth": {
"Value": 100,
"Description": "Max health for the NPC"
},
"NameTranslationKey": {
"Value": "server.npcRoles.Template.name",
"Description": "Translation key for NPC name display"
}
}
}