Nuclide
Software Development Kit for id Technology (BETA)
Activities

Universal look-up system for named animation sequences. More...

Detailed Description

Universal look-up system for named animation sequences.

Instead of hard-coding framegroups/sequences in the code or in the decl we have access to a universal look-up system for named sequences. The system is fully extendable through external means.

Defining New Activities

Global activities can be defined within decls/typeinfo/activities.decl which will look a lot like the following:

typeInfo activities {
"act_reset" "0"
"act_idle" "1"
"act_walk" "2"
"act_run" "3"
}

Behaviour

For example, when entities try to look up GetAct("walk"), it will figure out if an activity with the ID of 2 exists inside for the entity. If not, it will return ACTIVITY_NOTFOUND and the code will skip performing an action altogether.

Generally, if an activity does not exist for an entity/model, said activity never takes place. Neither visually nor functionally.

This system powers NPCs, but also weapons. So some weapon functionality is only available when certain activities exist.

Defining Activities In Models

The primary way of assigning activities to sequences within models is to do so when compiling it. Formats such as Half-Life MDL support activities, others do not.

There is currently no way to assign them to a model per external means.

Defining Activities in EntityDef

An entityDef can override activities or define new activities for an entity on a non-model basis.

For this, you will simply define activities in your entityDef decl as you would in Defining New Activities, but instead of the value being the supposed internal act ID it will have to match the numeric value of the animation sequence in the model that is defined within the decl.

Simply put, if you want the very first animation in the model to be an idle animation, add this line to your entityDef:

"act_idle" "0"

Functions

void Activities_Init (void)
 Initializes the sub-system for Activities. More...
 
void Activities_Shutdown (void)
 Shuts the Activities system down. More...
 
float Activities_GetSequenceForEntity (ncEntity targetEntity, string actNameCheck)
 Looks up the animation sequence for an entity by name of activity. More...
 
float Activities_GetSequenceForEntityDef (ncEntity targetEntity, string actNameCheck, string subDef)
 Looks up the animation sequence by name of activity in another entityDef (or fireInfo), before looking it up in an entity. More...
 

Macros

#define ACTIVITY_NOTFOUND   -1
 Activity does not exist. More...
 

Function Documentation

◆ Activities_GetSequenceForEntity()

float Activities_GetSequenceForEntity ( ncEntity  targetEntity,
string  actNameCheck 
)

Looks up the animation sequence for an entity by name of activity.

Parameters
targetEntitythe entity to query.
actNameCheckthe name of activity to look up for this entity
Returns
The id of this entity's animation sequence that matches said activity. Returns ACTIVITY_NOTFOUND when not valid.

◆ Activities_GetSequenceForEntityDef()

float Activities_GetSequenceForEntityDef ( ncEntity  targetEntity,
string  actNameCheck,
string  subDef 
)

Looks up the animation sequence by name of activity in another entityDef (or fireInfo), before looking it up in an entity.

Parameters
targetEntitythe entity to query.
actNameCheckthe name of activity to look up for this entity
subDefthe name of entityDef in which we'll look it up first
Returns
The id of this entity's animation sequence that matches said activity. Returns ACTIVITY_NOTFOUND when not valid.

◆ Activities_Init()

void Activities_Init ( void  )

Initializes the sub-system for Activities.

◆ Activities_Shutdown()

void Activities_Shutdown ( void  )

Shuts the Activities system down.

Every query will return ACTIVITY_NOTFOUND.

Macro Definition Documentation

◆ ACTIVITY_NOTFOUND

#define ACTIVITY_NOTFOUND   -1

Activity does not exist.