Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
cyber-menace

50 Enemy Trigger

Recommended Posts

I was wondering if by using Zdoom is there any way to have a script activate after the player kills 50 enemies, 100, etc? Or would I have to do something like tag every monster with say 1 and tell the script to wait until all those are killed. If anyone knows how please either post an example script or make an example wad. I don't have much of a clue how I would do this so I need an example of some kind.

Share this post


Link to post

I am only familiar with Fraggle Script for Legacy, and only partially for that matter, but I am pretty sure you should be able to write a script that waits for the last IMP or what ever to be killed to perform a certain action.

Share this post


Link to post

Or would I have to do something like tag every monster with say 1 and tell the script to wait until all those are killed. If anyone knows how please either post an example script or make an example wad. I don't have much of a clue how I would do this so I need an example of some kind.


Not necessarily.

You can use the thingcount() function to count all the live monsters of the types that are present in your map. Unless there are no Arch-Viles and Pain Elementals which create new monsters this is probably the easiest way. Otherwise you have to be a little more careful.

Here's a small example:

        // wait for all imps to die
        while (thingcount(T_IMP,0)>0)
        {
        	delay(10);
        }
        // do your stuff here
Remember, you have to check all monster types you are interested in!

Share this post


Link to post

So if I were to use multiple thingcounts in the same script it would wait until all of them are finished to activate the last bit correct?

Share this post


Link to post

You could either give every monster a tid number and do it that way, or if you're spawning enemies, you could give them a tid number as they spawn (not exactly sure how to do that in ZDoom).

Share this post


Link to post

Actually, you can't spawn enemies with tids in Hexen (they always spawn with no tid), but you can with ZDoom. I don't know the exact command though.

Share this post


Link to post

The Thingcount script doesn't work. I have two imps. I tried both < and > but one did the script right off the bat and the other didn't do anything. is the 0 beside the T_IMP supposed to refer to the number < is comparing the other 0 to? I need to figure this out in order to proceed in my level.

Share this post


Link to post
Ichor said:

Actually, you can't spawn enemies with tids in Hexen (they always spawn with no tid), but you can with ZDoom. I don't know the exact command though.

THING_SPAWN(mapspot's tid, what, direction, with a tid of);
Heh, I hope I don't have "direction" and "with a tid of" switched up :)

cyber-menace said:

I was wondering if by using Zdoom is there any way to have a script activate after the player kills 50 enemies, 100, etc? Or would I have to do something like tag every monster with say 1 and tell the script to wait until all those are killed. If anyone knows how please either post an example script or make an example wad. I don't have much of a clue how I would do this so I need an example of some kind.

Alright well how about this

script 1 OPEN
{
 int whee;
 
 whee = Thingcount(0, 222); // all monsters should have tid of 222
 ACS_EXECUTE(2, 0, 0, 0, 0);
}

script 2 (void)
{
 int woo;
 
 woo = thingcount(0, 222);
 
 whee - woo = kills;
 
 if (kills => 50)// if there's 50 kills then do the following:
 {
  //put your stuff here;
  terminate;
 }
 delay(1);
 restart;
}

Share this post


Link to post

I don't believe there's a function that returns the number of monsters killed (though there might be, there's one to return almost everything else) but what you can do is something like this:

#define TOTAL 200 //200 monsters total

script 100 (void)
{
   int x = thingcount(T_IMP, 0) + thingcount(T_CACODEMON, 0) + 
thingcount(T_BARON, 0) + thingcount(T_DEMON, 0);

   while(x)
   {
      if(x < TOTAL / 8) //25 left
         acs_execute(1, 0);
      else if(x < TOTAL / 4) //50 left
         acs_execute(2, 0);
      else if(x < TOTAL / 2) //100 left
         acs_execute(3, 0);
      delay(1);
      restart;
}
that's sort of similar to what I did in helm's deep with the waves of monsters, only instead of counting the entire population of monsters (btw you'll need a thingcount for every specific monster on the map) it counted populations of monsters with a certain tid and preformed an action after a certain amount was dead. this is a bit more involving, but not quite as complex. the #define TOTAL by the way is the total number of monsters on the map which I put that was so you don't have to change a million constants in the script every time you add or remove a monster.

oh and epyo you can make script 2 into:
script 2 (void)
{
 if (whee - thingcount(0, 222) => 50)// if there's 50 kills then do the following:
 {
  //put your stuff here;
  terminate;
 }
 delay(1);
 restart;
}
and also wee - whoo = kills is incorrect, it needs to be kills = wee - whoo, since wee - whoo = kills is assigning the value kills to the variable wee - whoo which isn't a variable but a statement... unless acs allows that but I don't think it does

keeping with the editing heh, spawnspot and spawn work in the hexen game mode of zdoom (not vanilla hexen of course)

Share this post


Link to post

Ok NOW I'm REALLY getting annoyed! Here's what I have so far:

script 9 OPEN
{
imps = Thingcount (T_IMP, 600);
ACS_Execute (10, 0, 0, 0);
}

script 10 (void)
{
dimps = Thingcount (T_IMP, 600);
kills = imps - dimps;
if (kills => 2);
{
ChangeCamera (3, 1, 0);
Delay (1*35);
Door_Open (3, 20);
print (s:"Objective Complete!");
Delay (2*35);
ChangeCamera (0, 1, 0);
print (s:"Proceed to Security Room for info.");
terminate;
}
}
But whenever I try to compile it it gets as far as if (kills => 2); and then it says either "=> invalid statement" or "=> missing )" If I add the } I get the Invalied statement! WHAT IS GOING ON HERE?! I NEED TO KNOW SOON PLEASE?!

Share this post


Link to post
cyber-menace said:

Ok NOW I'm REALLY getting annoyed! Here's what I have so far:

script 9 OPEN
{
imps = Thingcount (T_IMP, 600);
ACS_Execute (10, 0, 0, 0);
}

script 10 (void)
{
dimps = Thingcount (T_IMP, 600);
kills = imps - dimps;
if (kills => 2);
{
ChangeCamera (3, 1, 0);
Delay (1*35);
Door_Open (3, 20);
print (s:"Objective Complete!");
Delay (2*35);
ChangeCamera (0, 1, 0);
print (s:"Proceed to Security Room for info.");
terminate;
}
}
But whenever I try to compile it it gets as far as if (kills => 2); and then it says either "=> invalid statement" or "=> missing )" If I add the } I get the Invalied statement! WHAT IS GOING ON HERE?! I NEED TO KNOW SOON PLEASE?!



I don't know how strict the syntax check of ACC is but you should at least remove the semicolon behind the 'if' statement. Even if the compiler takes it this will produce incorrect code.

Share this post


Link to post

Bah I've tried nearly everything I can think of on that id statement! And ACC still won't except the = symbol. I can't think of anything to do with the script I put above. How can I fix this?

Share this post


Link to post
Cyb said:

and also wee - whoo = kills is incorrect, it needs to be kills = wee - whoo

Oops I had it backwords then heh.

Cyber-menace said:

scripts and stuff


Yeah, what Graf Zahl said, and have you tried (kills > 1)? Also I think maybe you forgot to put

}
delay(1);
restart;
}

at the bottom there? instead of just

}
}

But that won't make a difference in the error checker thing. Just your level. Fix!

Share this post


Link to post

I did all that but it still doesn't work. If I change < to > it works, but it happens before anything else. Wouldn't imps - dimps always equal zero. I mean if there are two imp it would be 2 - 2 = 0 and 1 - 1 = 0 and 0 - 0 = 0 right? There must be something wrong with the kills varible kills = imps - dimps is what I have. Wait a minute... is my Thingcount (T_IMP, 600); even correct? Maybe I need the Imp number or 0 or something can anyone find out what's wrong.

Share this post


Link to post

YES! I AM INVINCIBLE! Ahem........... I got it working!

script 9 OPEN
{
imps = Thingcount (5, 600);
ACS_Execute (10, 0, 0, 0);
}

script 10 (void)
{
dimps = Thingcount (5, 600);
kills = imps - dimps;
if (kills>1)
{
Delay (2*35);
ChangeCamera (3, 1, 0);
Delay (1*35);
Door_Open (3, 20);
print (s:"Objective Complete!");
Delay (2*35);
ChangeCamera (0, 1, 0);
print (s:"Proceed to Security Room for info.");
terminate;
}
delay (1);
restart;
}
I need to put dimps in script 10 so when script 10 restarted it would read the number of imps again! I then understood how kills could be greater than 1 because imps "2" would stay the same while dimps "?" would change as the script restarted after an imp was killed. THAT was quite difficult and after nearly a whole day's worth of trial and error I got it working! Thank you very much for your help. Using a lot of Epyo's script and his last suggestion and a little bit from Cyb I got it working. That was a tough one. Later!

Share this post


Link to post

Just a few programming tips for the future. ACS uses a very C-like syntax. This means the following:

An equality comparison is not '=' but '=='. '=' is only an assignment.
'=>' is not a valid operator. It has to be '>='!

It seems this was the cause of most of your problems.

Share this post


Link to post

Maybe I should have asked my friend Cody about that one... he knows a few things about programming and he might have known what was wrong. I guess being a programmer really pays off when it comes to DOOM scripting eh?

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
×