Nuclide
Software Development Kit for id Technology
Entity Definitions

Entity class declaration system. More...

Detailed Description

Entity class declaration system.

Introduction

An 'entityDef' is a type of Declaration Files containing spawn data. It is used for prefab entity configurations but is also the very definitions base for designing actors, items and weapons.

These definitions are a further abstraction from how we view entity definitions. this system tries to be mostly compatible with the def system in id Tech 4 [1] (Doom 3, Quake 4, Prey, etc.) but does not guarantee to be compatible as-is.

The first references to such a system existing can be found when Team Fortress Software was working on Team Fortress 2, originally on Quake II's engine. [2]

The gist is, that an entity def can set a base spawnclass (e.g. func_door) and populate it with key/value pairs.

Overview

Using this example definition, we can re-invent func_illusionary using an already existing entity class (func_wall), making it non-solid:

"spawnclass" "func_wall"
"solid" "0"
}
Shared-Entity: Non-Solid Brush Model.
Definition: func_illusionary.qc:37
entityDefAPI_t entityDef
Definition: api.h:363

We also have features exclusive to our entityDef format. In the following example, when thebody key equals 1, it will switch skin to id 4. You can have as many conditions as you like.

entityDef foobar {
[...]
when "body" equals 1 {
"skin" "4"
}
}

It essentially allows developers to configure other fields when certain conditions are met.

Another feature exclusive to our entityDef spec is how we can tie model event callbacks to the tried and true I/O system:

entityDef foobar {
[...]
events {
1004 "SpawnDef" "foobar_projectile"
}
}

This way, an animation that is played by a weapon or a monster can call back to in-game events without you having to dig into the source code.

See Also

Classes

struct  entityDef_t
 Data holding EntityDef entries. More...
 

Functions

void EntityDef_Init (void)
 
void EntityDef_DebugList (void)
 
string EntityDef_GetKeyValue (string, string)
 Retrieves the value of a specific key defined within an EntityDef. More...
 
int EntityDef_NetIDFromName (string)
 
string EntityDef_NameFromNetID (int)
 
int EntityDef_IDFromName (string)
 
string EntityDef_GetSpawnData (int)
 
bool EntityDef_HasSpawnClass (string className)
 Checks if an entity class was defined in an EntityDef. More...
 
bool EntityDef_Precache (string)
 
NSEntity EntityDef_SwitchClass (NSEntity target, string className)
 
NSEntity Entity_CreateClass (string className)
 Always returns a valid entity. More...
 
NSEntity EntityDef_NewClassname (string className)
 

Macros

#define ENTITYDEF_MAX   256
 Can be redefined in the server its progs.src file. More...
 

Enumerations

enum  {
  EDEFTWEAK_EQ = 0 , EDEFTWEAK_LT , EDEFTWEAK_GT , EDEFTWEAK_NOT ,
  EDEFTWEAK_CONTAINS
}
 Options for EntityDef checks. More...
 

Function Documentation

◆ Entity_CreateClass()

NSEntity Entity_CreateClass ( string  className)

Always returns a valid entity.

Spawns an entity of a class, guaranteed to be valid.

Even if the entity def does not exist.

◆ EntityDef_DebugList()

void EntityDef_DebugList ( void  )

◆ EntityDef_GetKeyValue()

string EntityDef_GetKeyValue ( string  className,
string  keyName 
)

Retrieves the value of a specific key defined within an EntityDef.

Parameters
classNamespecifies which class definition to look in.
keyNamespecifies the 'key' we want to know its value of.

◆ EntityDef_GetSpawnData()

string EntityDef_GetSpawnData ( int  defNum)

◆ EntityDef_HasSpawnClass()

bool EntityDef_HasSpawnClass ( string  className)

Checks if an entity class was defined in an EntityDef.

You can then use EntityDef_GetKeyValue() to get various key values from said EntityDef.

Parameters
classNamespecifies which class definition to look for.

◆ EntityDef_IDFromName()

int EntityDef_IDFromName ( string  defName)

◆ EntityDef_Init()

void EntityDef_Init ( void  )

◆ EntityDef_NameFromNetID()

string EntityDef_NameFromNetID ( int  defNum)

◆ EntityDef_NetIDFromName()

int EntityDef_NetIDFromName ( string  defName)

◆ EntityDef_NewClassname()

NSEntity EntityDef_NewClassname ( string  className)

◆ EntityDef_Precache()

bool EntityDef_Precache ( string  defName)

◆ EntityDef_SwitchClass()

NSEntity EntityDef_SwitchClass ( NSEntity  target,
string  className 
)

Macro Definition Documentation

◆ ENTITYDEF_MAX

#define ENTITYDEF_MAX   256

Can be redefined in the server its progs.src file.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Options for EntityDef checks.

Enumerator
EDEFTWEAK_EQ 

Equals Check.

EDEFTWEAK_LT 

Less-Than Check.

EDEFTWEAK_GT 

Greater-Than Check.

EDEFTWEAK_NOT 

Not (Invert) Gate.

EDEFTWEAK_CONTAINS 

Contains Bit (&) Check.