Page 1 of 1

Check if an actor exists?

Posted: Mon Oct 11, 2021 7:04 am
by Enjay
I can see a few threads on this topic, but I can't find anything that definitively answers the question.

Is there a way in ACS to check if an actor actually exists and then only do stuff if the actor is actually real?

Specifically, I'm looking to manipulate the player's inventory and, depending on which mods are loaded, I want it to do different things. However, if mods are not loaded, then certain actors won't even exist as far as the game is concerned, so I don't want to perform operations on non-existant actors.

Code: Select all

if (CheckActorExists("CoolHealthItem") == 1)
      {
            SetHUDSize (640, 480, 0);
            HUDMessageBold (s:"You look like you could use this.";
                  HUDMSG_PLAIN, 44, CR_GREEN, 320.4, 340.0, 3.0);		
            GiveInventory ("CoolHealthItem", 1);
      }
else
      {
            SetHUDSize (640, 480, 0);
            HUDMessageBold (s:"Here, let me patch you up a bit.";
                  HUDMSG_PLAIN, 44, CR_GREEN, 320.4, 340.0, 3.0);		
            HealThing(20);
      }
or something like that.

Possible?

Re: Check if an actor exists?

Posted: Mon Oct 11, 2021 7:44 am
by Blue Shadow

Re: Check if an actor exists?

Posted: Mon Oct 11, 2021 8:21 am
by Enjay
Works perfectly, thank you. :)

[edit] And example added to the Wiki https://zdoom.org/wiki/CheckClass_(ACS) [/edit]