Dynamic TID Assigner
From ZDoom Wiki
Contents |
Assumed Knowledge
It is assumed that before you begin this tutorial, you are familiar with the following concepts:
The Function
We'll start with a map level integer for the base TID to start assigning. For this example we'll use the negative range, from -32767 to -1.
int GiveTID = -32767;
function int NextTID (VOID)
{
for (GiveTID=GiveTID; GiveTID<0; GiveTID++)
{
if (!ThingCount (T_NONE, GiveTID))
return GiveTID;
}
return 0;
}
The Script
This is the script your actor will need to activate to give itself a genuine TID. There are several ways to go about the activation. The script checks for the activator to have no TID, then generates a new one to give it. So, if you have a special TID you need to preserve, the script will not overwrite it. If used correctly, this can be a handy tool for individual actor identification for large scale scenarios.
Script 999 (VOID)
{
if (!ActivatorTID ())
{
Thing_ChangeTID (0, NextTID ());
}
}
Application
This is an example of how to use DECORATE to modify your Imps so that they will assign themselves unique tids.
actor _DoomImp : DoomImp replaces DoomImp
{
states
{
Spawn:
TROO A 0
TROO A 0 ACS_ExecuteAlways (999, 0)
TROO AB 10 A_Look
goto Spawn+2
}
}

