Sign in to follow this  
Followers 0

ANOTHER scripting question

I have another question. I'm doing my version of E2M8, and when all the enemies are dead, I want a CyberDemon to appear. How would I do this? Thanks.

Share this post


Link to post

Let's see if this works:

Let's say you're going to have Cacodemons, Lost Souls, Demons, Spectres, and a Baron of Hell or two on this map. Then you might do something like this:

script 8 open
{
    if((thingcount(3, 0) == 0) && (thingcount(8, 0)== 0) && (thingcount(9, 0) == 0) && (thingcount(19, 0) == 0) && (thingcount(110, 0) ==))
    {
        Thing_Spawn(114, 53, 128);
    }
    else
    {
        delay(1);
        restart;
    }
}

Share this post


Link to post

Ichor, I think by looking at your script you are counting all the different enemies by type seperately. thingcount can be used to count items with specified tids intead of counting items by type. So, if you give every enemy on the level the same tid, you could just use one instance of thingcount, and specify the tid to be counted as the second arg

thingcount(0, tid)

Share this post


Link to post

Let's see if I can simplify that...Epyo style!

script 3 OPEN  
{
    int hello;

    hello = thingcount(0, 222);
    if(hello == 0)
    {
        Thing_Spawn (/*mapspot's tid/*, T_CYBERDEMON, /*angle/*, /*cyberdemon's tid/*);
        Terminate;
    }
    Delay(35);
    restart;
}
Should work...Replace the words commented with whatever they should be. Leave T_CYBERDEMON there I guess. Make all the monsters in the level have a tid of 222.

Share this post


Link to post

That works too, but I usually use it that way in case I want to have different enemies have different TIDs (for use by other scripts). Also, if this was Doom 2, Lost Souls spawned by Pain Elementals and resurrected enemies (at least I don't think so) would not be counted.

Share this post


Link to post
boris said:

Well, couldn't you just use thingcount(0, 0)? :)

Uh, that would count EVERY thing, not just enemies. You try killing a torch. :P

Share this post


Link to post
ravage said:

Uh, that would count EVERY thing, not just enemies. You try killing a torch. :P

Hehe, yeah. I just tried it out. Even projectiles are counted then :P

Share this post


Link to post

Ok, this script should work fine:

#include "zcommon.acs"

int enemies[17] = {	T_CHAINGUY,		T_BARON,		T_ZOMBIE,
					T_IMP,			T_ARACHNOTRON,	T_SPIDERMASTERMIND,
					T_DEMON,		T_SPECTRE,		T_CACODEMON,
					T_REVENANT,		T_LOSTSOUL,		T_VILE,
					T_MANCUBUS,		T_HELLKNIGHT,	T_CYBERDEMON,
					T_PAINELEMENTAL,T_WOLFSS
				};

script 1 open
{
	int i, count;

	do {
		count=0;
		for(i=0; i < 17; i++) {
			count += thingcount(enemies[i], 0);
			print(s:"monsters: ", d:count);
		}
		delay(1);
	} while(count > 0);

	print(s:"All monsters dead!!!111");
}

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
Sign in to follow this  
Followers 0