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

Check a script's activator?

Recommended Posts

Hi yall,

 

I've come back to modding after a 5 year break and have found that I've lost most of what I learned way back. Anyhoo I'm trying to make this script sequence where endless amounts of lost souls are being continuosly spawned in a big outdoor map until the player kills a set amount of them. The problem is that the souls keep killing each other and ending the sequence on their own.

 

There must be a way to work around this? Id like the counter to only tick down when the player (or another set tID) activates the script, i.e. kills the lost souls.

 

The script in question:

 

int lostsoulstokill = 30

script 67 (void) // script that spawns endless lost souls
{
spawn("lostsoul",(65536*random(-2368,4096)),(65536*random(-4544,2496)),(65536*random(24,300)),80);
SetThingSpecial(80,80,68); // spawned souls activate script 68 on death
delay(5);
restart;
}

 

script 68 (void) // kill a lost soul
{
    if (lostsoulstokill==0) 
    {
        ACS_Terminate(67,0);
        Thing_Damage(80,1000);

    hudmessage (s:" ";HUDMSG_plain,10,CR_tan,0.5,0.23,0);
    }
    delay(1);
    lostsoulstokill--;
            SetFont("bigfont");
    hudmessage (i:lostsoulstokill;HUDMSG_plain,10,CR_tan,0.5,0.23,0);

}

Share this post


Link to post

Cheers mate! That did the trick. Usually the problems I come up with seem to be fairly simple if you know what you're doing but I don't know what to search for in ZDoom Wiki. 

Edited by Herska

Share this post


Link to post

On a sort of related subject: is there a way to check whether a thing was succesfully spawned OR count the number of things with a specific tID on a map? Earlier I tried to make a similar serial spawner script where things would spawn at a specific point at the map but as the spawn point would be occupied all the required monsters couldn't spawn.

I was trying to make a script where exactly 10 cacodemons would spawn (and would need to be killed for a script to trigger). I'd need to make the script "try again" if the spawn would be unsuccesful or loop until 10 things with the set tID would come to existence.

Share this post


Link to post

The ACS Spawn... functions return the number of spawned actors, so if this is 0, nothing got spawned.

Of course you can count most of what you need with the ThingCount... family of functions.

 

Share this post


Link to post

It would be cool if you could work with actor pointers directly in more ACS functions instead of simply working at the TID level, like if spawn() returned both the number of spawned actors and an actor */thing * or array of actor * for each thing spawned, or make a "getActorsInTID" function that returns a list of pointers for all things with a particular TID Yeah it wouldn't really be useful for a lot of people but as someone who likes lower level programming (but isn't particularly great at it yet lol) it would be cool to have that option imo. Just a thought i had the other day and I figured now would be the perfect time to bring it up :)

Share this post


Link to post

Since you can call down to ZScript from ACS I don't really see much of a point to implement such a thing now.

 

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
×