Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
  • 0
Bauul

[ACS] Check if a monster is awake

Question

Is there a way to check in ACS if a monster is awake?

 

I thought CheckActorState might work, but that just checks if a state exists at all.

 

I then thought perhaps check the monster's TargetID, but as the player doesn't have an id, that doesn't shift from 0 once the monster wakes up.

 

Anyone got any more ideas?  I presumed this would be relatively easy!

Share this post


Link to post

3 answers to this question

Recommended Posts

  • 0

Thanks for the suggestions guys!

 

The only thing was that I was trying to avoid giving the player an TID only because it can mess up mods quite badly (and I'm trying to make this as much a pure mapset and less a mod as possible).

 

I asked over on Discord and Gutawer came to the rescue (again!).  He built the following ZScript:

class ActorTargetChecker {
    static bool hasTarget(Actor activator, int tid) {
        ActorIterator it = ActorIterator.create(tid);
        Actor mo = it.next();
        if (mo != NULL) return mo.target != NULL;
        else return false;
    }
}

Which then feeds into the following ACS:

int MonsterCheck=1;

Script 1 (void)
{
    while (MonsterCheck<101)
        {
        int isAwake = ScriptCall("ActorTargetChecker", "hasTarget", MonsterCheck);
        If (isAwake == 0)
            {
            Thing_Remove(MonsterCheck);
            }
        MonsterCheck++;
        }
}

This code works through individual monsters tagged 1 to 100 and in each case removes it if it hasn't assigned itself a target.

Share this post


Link to post
  • 0

The entire difference between a sleeping monster and an awake one is whether they have a null target pointer or not. And ACS doesn't let you access pointer values directly.

 

A possibility is to simply give the player a TID in an ENTER or OPEN script.

Share this post


Link to post
  • 0
3 hours ago, Gez said:

The entire difference between a sleeping monster and an awake one is whether they have a null target pointer or not. And ACS doesn't let you access pointer values directly.

 

A possibility is to simply give the player a TID in an ENTER or OPEN script.

You should use an ENTER script for stuff that involves players because if the map is played in coop, a player might join the game after all the OPEN scripts have already run. Also, use a RESPAWN script. Here's a ZDoom Wiki page that talks about giving players a TID:

https://zdoom.org/wiki/About_Multiplayer,_Scripts,_and_TIDs

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×