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.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
crowbars82
Posts: 40
Joined: Sun Nov 05, 2017 6:22 pm
Contact:

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

Post by crowbars82 »

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 all

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 all

#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
Posts: 40
Joined: Sun Nov 05, 2017 6:22 pm
Contact:

Re: Trying to dynamically assign TIDs to 1 actor type

Post by crowbars82 »

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...
Nevander
Posts: 2254
Joined: Mon Jan 06, 2014 11:32 pm

Re: Trying to dynamically assign TIDs to 1 actor type

Post by Nevander »

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.
User avatar
phantombeta
Posts: 2088
Joined: Thu May 02, 2013 1:27 am
Operating System Version (Optional): Windows 10
Graphics Processor: nVidia with Vulkan support
Location: Brazil

Re: Trying to dynamically assign TIDs to 1 actor type

Post by phantombeta »

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 [wiki=Named_script]named scripts[/wiki] 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
crowbars82
Posts: 40
Joined: Sun Nov 05, 2017 6:22 pm
Contact:

Re: Trying to dynamically assign TIDs to 1 actor type

Post by crowbars82 »

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

Return to “Scripting”