The Half-Life Unified SDK replaces the hard-coded NPC classification system from the original game with a fully data-driven one that level designers and mod authors can customise. Rather than having relationships between NPC types compiled into the game binary, all classification relationships are defined in a JSON configuration file that can be swapped out on a per-map basis. Classifications are comparable to factions. For example, theDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/twhl-community/halflife-unified-sdk/llms.txt
Use this file to discover all available pages before exploring further.
human_passive classification (scientists) fears human_military (human grunts) and will flee from them, while human_military dislikes human_passive and will attack on sight. Any of these relationships can be changed or new classifications added without touching C++ code.
The entity classifications system uses the logger named
ent.classify. Enable it at the appropriate log level to trace classification lookups and relationship resolution during development.Configuration File
The default classification configuration is loaded fromcfg/default_entity_classes.json. A custom file can be specified in the map configuration file using the EntityClassifications section, allowing different maps or campaigns to use entirely different faction setups.
Only one configuration file is active at a time.
Relationship Types
Each classification defines how it relates to every other classification through one of the following relationship types.| Relationship | Behaviour |
|---|---|
ally | Friends. A good alternative to none when the relationship should be positive. |
fear | The NPC will flee from members of this classification. |
none | Complete disregard — the NPC ignores members of this classification. |
dislike | The NPC will attack members of this classification when it sees them. |
hate | The NPC will attack members of this classification in preference to any dislike targets. |
nemesis | The NPC will always attack members of this classification regardless of any other targets. |
none unless explicitly specified or overridden with DefaultRelationshipToTarget.
The special classification
none is always present and should never have relationships defined for it. Entities rely on it to be completely ignored.JSON Syntax
A classification configuration file is a JSON object. Each key is a classification name and its value is an object with two optional fields:| Field | Description |
|---|---|
DefaultRelationshipToTarget | Sets the default relationship this classification has towards all other classifications. Useful when a faction is hostile or fearful of everything except specific exceptions. |
Relationships | An object mapping individual classification names to specific relationship types, overriding the default. |
Minimal Example
Theinsect classification below fears everything by default, but has none (disregard) towards a handful of classifications it coexists with:
Full Example
Below is an excerpt from a complete classification file showing several factions with their relationships. Classifications not listed inRelationships fall back to DefaultRelationshipToTarget, or none if that is also absent.
Per-Entity Classification Overrides
Individual entity instances can override their classification using keyvalues, without needing to change the global configuration file.| Keyvalue | Description |
|---|---|
classification | Overrides this entity’s classification with the named classification from the config file. |
child_classification | Overrides the classification of entities spawned by this entity. Supports !owner and !owner_or_default. |
is_player_ally | Shorthand override for the entity’s relationship to the player. 0 = default, 1 = always hostile, 2 = always friendly. |