[ACS] ActivatorExists()

Moderator: GZDoom Developers

Post Reply
User avatar
Kate
... in rememberance ...
Posts: 2975
Joined: Tue Jul 15, 2003 8:06 pm

[ACS] ActivatorExists()

Post by Kate »

Nice and simple. It would make my nightmare less of a nightmare. Simply put, when called, returns TRUE when the activator of the script still exists or FALSE if it has disappeared off of the map (items that have been picked up, things forcefully removed from ACS scripts or as part of their state cycle, etc.). ThingCount can't directly reference the activator so it can't reliably be used with scripts that are called directly by actors from DECORATE that don't have Thing IDs. It also can't tell the difference between a dead enemy and an object that has actually disappeared off of the map.

This is pretty much what I'm trying to do (this is called by an object on the map when it's first spawned after the level starts, which has no TID but can sometimes have one in certain cases):

Code: Select all

int FreeTID = 6000;

Script 962 (ThingType)
{
    int SpawnTID = FreeTID;
    FreeTID++;
    If (CheckInventory(SpecialThings[ThingType])) Terminate;
    Spawn("AGiantFingerPointingDown", GetActorX(0), GetActorY(0), GetActorZ(0), SpawnTID, 0);
    While (ActivatorExists()) Delay(8);
    Thing_Remove(SpawnTID);
}
User avatar
Jimmy
 
 
Posts: 4726
Joined: Mon Apr 10, 2006 1:49 pm
Preferred Pronouns: He/Him
Contact:

Re: [ACS] ActivatorExists()

Post by Jimmy »

What about

Code: Select all

ThingCount(T_NONE,ActivatorTid())
?

EDIT: Sorry if this isn't helpful - just read over your post a second time to make sure I know what I'm talking about, and it looks like you want to avoid using this function, but I do believe that it might help a pinch.
User avatar
Macil
Posts: 2529
Joined: Mon Mar 22, 2004 7:00 pm
Preferred Pronouns: He/Him
Location: California, USA. Previously known as "Agent ME".
Contact:

Re: [ACS] ActivatorExists()

Post by Macil »

jimmy91 wrote:What about

Code: Select all

ThingCount(T_NONE,ActivatorTid())
?
If there are multiple things with the same tid, or its tidless, then that won't work.
User avatar
randi
Site Admin
Posts: 7749
Joined: Wed Jul 09, 2003 10:30 pm
Contact:

Re: [ACS] ActivatorExists()

Post by randi »

Scripts that become orphaned are automatically assigned the world as their activator, just like an open script. So technically, ActivatorExists() would always return true, since every script has some sort of actor. I know what you're asking for, and it's quite simple to do, but is there a better name for it? IsActivatorWorld() would accurately describe it, but how easy will it be for people to grasp that that can tell them if their actor-activated script no longer has its actor around?
User avatar
bagheadspidey
Posts: 1490
Joined: Sat Oct 20, 2007 10:31 pm
Contact:

Re: [ACS] ActivatorExists()

Post by bagheadspidey »

OriginalActivatorExists? ActivatorInPlay? =/

Is the world "useful" for anything as an activator? If not, I think the original suggestion is fine...


edit - or maybe ActivatorChanged... could return the opposite of whatever ActivatorExists / IsActivatorWorld would return.
User avatar
HotWax
Posts: 10002
Joined: Fri Jul 18, 2003 6:18 pm
Location: Idaho Falls, ID

Re: [ACS] ActivatorExists()

Post by HotWax »

How about ActivatorType? This could return an int that evaluates to either ISACTOR or ISWORLD.

You could even extend it (if desired) and have it return stuff like ISPLAYER, ISMONSTER, ISBOT, etc.

Code: Select all

script 1 ENTER {
     // Do awesome stuff

     if (ActivatorType() == ISWORLD) terminate;

     restart;
}
User avatar
randi
Site Admin
Posts: 7749
Joined: Wed Jul 09, 2003 10:30 pm
Contact:

Re: [ACS] ActivatorExists()

Post by randi »

I did something like that. The result is ClassifyActor, which returns a bitfield describing the actor. It takes a TID, so use 0 to query about the activator. I've got these all listed in the changelog entry.
User avatar
randi
Site Admin
Posts: 7749
Joined: Wed Jul 09, 2003 10:30 pm
Contact:

Re: [ACS] ActivatorExists()

Post by randi »

I realized I made a slight mistake in the changelog description. ACTOR_NONE is not a bitfield, but a lack of any bits set. So you would test for that with ==, but the others are tested with &.
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”