Nuclide
Software Development Kit for id Tech
Entity Definitions

Entity class declaration system. More...

Classes

struct  entityDef_t
 Data holding EntityDef entries. More...
 

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...
 

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_IDFromName (string)
 
string EntityDef_NameFromID (int)
 
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 Entity_CreateClass (string className)
 Always returns a valid entity. More...
 

Detailed Description

Entity class declaration system.

Introduction

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 (Doom 3, Quake 4, Prey, etc.)

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.

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) and making it non-solid:

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

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

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

Will allow developers to configure other fields when certain conditions are met.

This is also expanded to include model event callbacks to the tried and true I/O system:

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

See Also

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.

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_NameFromID()

string EntityDef_NameFromID ( int  defNum)

◆ EntityDef_Precache()

bool EntityDef_Precache ( string  defName)