Trying to dynamically assign TIDs to 1 actor type [SOLVED]

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Trying to dynamically assign TIDs to 1 actor type [SOLVED]

Postby crowbars82 » Mon Nov 06, 2017 3:02 pm

Hi,

I'm working on a mod for Oblige and I have some security cameras that generate into maps.

The camera 'things' TIDs are all initially set to '0', like all monsters and other actors.

I am attempting to assign a unique TID for each camera, so far with success, except that the script from the Wiki not only gives the security cameras unique TIDs, but gives monsters the same TID and carries on assigning all monsters TIDs. (screenshots at bottom of post)

The security camera actor itself defined in DECORATE is as follows:

Code: Select allExpand view
ACTOR DNSecCam 9766    //This number does not clash with any other actor number.
{
    Radius 8
    Height 12
    Scale 0.6
    +SPAWNCEILING
    +NOGRAVITY
    States
    {
    Spawn:
    SECC AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCDDDDDDDDDDDDDDDDEEEEEEEEEEEEEEEEFFFFFFFFFFFFFFFFGGGGGGGGGGGGGGGGHHHHHHHHHHHHHHHH 0 ACS_ExecuteAlways(999, 0)
    SECC AAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCDDDDDDDDDDDDDDDDEEEEEEEEEEEEEEEEFFFFFFFFFFFFFFFFGGGGGGGGGGGGGGGGHHHHHHHHHHHHHHHH 1 A_SetAngle(angle -2)    //This rotates the camera constantly.
    Goto Spawn+129    //I may not need all these frames, but Goto jumps to first frame in SECC line 2.
    }
}


Using the script from the "Dynamic TID Assigner" from the ZDoom wiki, my camera ACS is:

Code: Select allExpand view
#include "zcommon.acs"

int GiveTID = -32767;

function int NextTID (void)
{
    for ( ; GiveTID < 0; GiveTID++)
    {
        if (!ThingCount (T_NONE, GiveTID))
        {
            return GiveTID;
        }
    }
    return 0;
}

Script 999 (void)
{
    if (!ActivatorTID ())
    {
        Thing_ChangeTID (0, NextTID ());
    }
}


When I load up the game, it is unknown how many security cameras are in the TITLEMAP, however, the scripts assigns the TIDs correctly starting from -32767 moving towards 0.

However, when I start a new game on MAP01, the script gives the DNSecCams TIDs correctly, but also gives monsters the same TID numbers and continues to give monsters TIDs until no monsters are left to be given a TID.

Please can anyone explain how or what I can do to have this script only give TIDs to the DNSecCams?

Many thanks!

Image

Image
Last edited by crowbars82 on Mon Nov 06, 2017 4:33 pm, edited 1 time in total.
User avatar
crowbars82
 
Joined: 05 Nov 2017

Re: Trying to dynamically assign TIDs to 1 actor type

Postby crowbars82 » Mon Nov 06, 2017 3:14 pm

UPDATE

Okay, I unloaded the Project Brutality mod, as cool as it is, and am running vanilla Doom 2 + my custom textures and scripts etc.

This script has done it's job correctly without the Project Brutality mod running as well. Only the DNSecCams now have TIDs and I am able to reference them to a security camera texture on the walls.

The plot thickens... I will try with Brutal Doom as well to see if it adds TIDs to the monsters in that mod...
User avatar
crowbars82
 
Joined: 05 Nov 2017

Re: Trying to dynamically assign TIDs to 1 actor type

Postby Nevander » Mon Nov 06, 2017 3:53 pm

What if you were to dynamically assign TIDs to the DNSecCams based on a unique SpawnID in the ThingCount given to the actual camera actor instead? You'd need to modify the code but I'd imagine it should work, any thing that is a camera found by the SpawnID (which is what T_ is) would get a new TID.
Nevander
Self-Banned User
 
Joined: 06 Jan 2014

Re: Trying to dynamically assign TIDs to 1 actor type

Postby phantombeta » Mon Nov 06, 2017 3:58 pm

I believe Brutal Doom (and, of course, BD-derived mods) uses script number 999.
You can easily fix this by using another number. However, even then you might still run into script number conflicts with some other mod, so I recommend using named scripts instead, as those are much less likely to conflict. (You can actually make it almost impossible to conflict by using prefixes and such)
User avatar
phantombeta
Tired of being treated like trash by control freaks
 
Joined: 02 May 2013

Re: Trying to dynamically assign TIDs to 1 actor type

Postby crowbars82 » Mon Nov 06, 2017 4:26 pm

Thank you both Phantombeta and Nevander for your super-prompt replies! This has bugging me for the past 24 hours or so.

I found the culprit mod: "UDV_v2.12_A_BASE.pk3" the UDV visor mod!

I hadn't bothered to check, but when you spoke of script numbers Phantombeta, I changed the script number to 32451 and TIDs from -32767 upwards were still being used. I then unloaded all my custom scripts and found that the UDV visor mod was actually assigning TIDs to all the monsters from precisely -32767 upwards! (facepalm extraordinaire)
So I changed my script to assign TIDs from -40000 upwards and low and behold my cameras and only my cameras have TID -40000, -39999, -39998 and so on.

I am interested in what you said Nevander about using unique SpawnIDs. This would make more sense because then if another mod is used that decides to use TIDs -40000 I would have to change my scripts, so this may perhaps help to make certain that only free TIDs are used for when I want to TID something up.

Thanks again! Another learning experience in coding! This is literally the fastest [SOLVED] I've ever seen.
User avatar
crowbars82
 
Joined: 05 Nov 2017


Return to Scripting

Who is online

Users browsing this forum: No registered users and 3 guests