Check if an actor exists? [split]

Please do not mimic the behavior of the posts shown here.

Moderator: GZDoom Developers

User avatar
determin1st
Posts: 57
Joined: Wed Oct 06, 2021 11:23 am

Check if an actor exists? [split]

Post by determin1st »

to determine if projectile/actor still exists

Code: Select all

GetActorProperty(tid, APROP_Health); // 0=removed
if projectile goes into the sky, it's removed without entering "Death" state, user_* variables start to return zeros, APROP_Health is also zero
User avatar
Rachael
Admin
Posts: 12898
Joined: Tue Jan 13, 2004 1:31 pm
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Preferred Pronouns: She/Her

Re: Check if an actor exists?

Post by Rachael »

determin1st wrote:to determine if projectile/actor still exists

Code: Select all

GetActorProperty(tid, APROP_Health); // 0=removed
if projectile goes into the sky, it's removed without entering "Death" state, user_* variables start to return zeros, APROP_Health is also zero
For one - the original question in this thread was already answered.

For two - this doesn't even answer the original question.
User avatar
determin1st
Posts: 57
Joined: Wed Oct 06, 2021 11:23 am

Re: Check if an actor exists?

Post by determin1st »

Rachael wrote: For one - the original question in this thread was already answered.

For two - this doesn't even answer the original question.
why not answer.. actor (actor's class) may be defined (and even created/spawned), but not exists at the map, one of the meaning of existence word, right? i was searching the "zdoom check actor exists" and got to this post. getting the health property is better, because GetActorClass() results in "None" in this case
User avatar
Rachael
Admin
Posts: 12898
Joined: Tue Jan 13, 2004 1:31 pm
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Preferred Pronouns: She/Her

Re: Check if an actor exists?

Post by Rachael »

You would have been better off making a new thread in that case, and straight up asking. There are better ways of checking for existence of actors than checking their health - you can actually just count them, instead.

You shouldn't rely on health for obvious reasons - first and foremost it may return the health (albeit lacking, if it's dead) of the first actor it finds. Try https://zdoom.org/wiki/ThingCount instead.
User avatar
determin1st
Posts: 57
Joined: Wed Oct 06, 2021 11:23 am

Re: Check if an actor exists?

Post by determin1st »

Rachael wrote:You would have been better off making a new thread in that case, and straight up asking. There are better ways of checking for existence of actors than checking their health - you can actually just count them, instead.

You shouldn't rely on health for obvious reasons - first and foremost it may return the health (albeit lacking, if it's dead) of the first actor it finds. Try https://zdoom.org/wiki/ThingCount instead.
i disagree (better ways, ThingCount).. for obvious reason - i know the count exactly, it's 1, the other inconvenience of this function is it's first argument, it's poorly described what it does and why there is a possibility to specify tid which *assumed* to be unique. yes, i did look around the doc before in hope to find Thing_Exists() or alike, read about ThingCount.. my method is better (in sky + projectile context) :)
User avatar
Rachael
Admin
Posts: 12898
Joined: Tue Jan 13, 2004 1:31 pm
Discord: Rachael#3767
Twitch ID: madamerachelle
Github ID: madame-rachelle
Preferred Pronouns: She/Her

Re: Check if an actor exists?

Post by Rachael »

Either way - it is NOT RELEVANT to this topic. Read the first post - it has nothing to do with your idea.

Please stop bumping topics with unrelated stuff.

Return to “Hall of Unpleasantness”