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

Spawn monsters after killing bunch of monsters?

Recommended Posts

Yeap another question i have for you guys. but i know how to work with mapsot but i wondering how to spawn 10 imps after i kill 5 barrons(example) or how to summon key or open door after i kill group of monsters.
is this possible without scripting or scripting is the only way how to do it?

Share this post


Link to post

Scripting is definitely the least hacky way how to do it, so if you are mapping for a port that has scripting, you should use it. Vanilla compatible workarounds involve either DEHACKED modification of an entire monster type to call KeenDie in the monster's death frame to open doors tagged 666 once all monsters of this type are dead, or a restrictive and complicated map setup like this, to open doors after a group of monsters is killed. To "spawn" monsters, use the same trick as above and put those doors into dummy sectors with already active monsters, so that the monsters will walk out and be teleported to the player's area after the doors open - this is not actual spawning, though.

Share this post


Link to post

Here's what I would do using your example:

script 1 OPEN
{
	While(ThingCount(0, 1) > 0) Delay(10);
	Delay(35);

	Thing_SpawnFacing(2, T_IMP, 0, 0);
}
Give the five Barons a TID of 1, and then set the MapSpots all to a TID of 2. Replace T_IMP with whatever you want to spawn, and remove or add MapSpots for the amount.

Share this post


Link to post

A better way that doesn't involve a continually running script would be to let each of the Barons execute a script upon its death (said script's type should be (void) instead of OPEN), the script would check if all Barons are dead (via the same method as in Nevander's script above), if not, the script would immediately terminate itself, and if yes, it would spawn something (also via the same method as in Nevander's script) and then terminate itself. No looping and no Delay involved here.

Share this post


Link to post

Continually running a script does not cause any performance degradation on any PC that's more recent than 1996.
I've done performance benchmarks by running 10000 instances of a script at once, and it only started to lag if I tried to do anything to actors in the level (like SetActorPosition). ThingCount in a single global script won't lag.

Share this post


Link to post

Interesting statement. I'd still go with Scifista's suggestion as it puts you in the right mentality for future code projects outside of the doom engine - It's always good to ask yourself "What is the most efficient way I can make this work?".

Share this post


Link to post

so i try to write this script:

script 1 OPEN
{
	While(ThingCount(3, 1) > 0);
	Delay(3);

	Thing_SpawnFacing(2, 5, 0, 3);
}
but it keep showing me error in line 6 :/ i have no idea what i doing wrong any help?

Share this post


Link to post

1. To make action specials available at all, the first line in the SCRIPTS file should always be:

#include "zcommon.acs"
2. Don't put a semicolon after the while command, it would loop an empty command without delay, and that would make the engine crash.

Share this post


Link to post

If instead of Thing_Spawn*** you just open a door in a remote sector that releases monsters to teleport, you gain some randomness as well, like in Doom.

Share this post


Link to post
printz said:

If instead of Thing_Spawn*** you just open a door in a remote sector that releases monsters to teleport, you gain some randomness as well, like in Doom.


There's an additional benefit of doing things this way: The monster count on the automap is correct, rather than smaller than truth.

Share this post


Link to post

Also, spawning will permanently fail if something is blocking the destination at the moment the function is called.

Share this post


Link to post
Dragonfly said:

There's an additional benefit of doing things this way: The monster count on the automap is correct, rather than smaller than truth.

Well I would counter that by saying that the number of monsters on the map is always true, since if you haven't spawned one yet then it's still the right amount that DID spawn.

It's annoying sometimes in older maps that couldn't utilize spawning functions to say 140/152 and ends up being a monster stuck somewhere in a monster closet and can't get out. Whereas monsters spawned are either spawned in and counted, or blocked and just don't spawn in which case no harm done apart from missing potential monster spawns.

I'd personally prefer to design maps with spawning through code in mind now, since I can control the exact moment they spawn and where.

Share this post


Link to post
Nevander said:

I'd personally prefer to design maps with spawning through code in mind now, since I can control the exact moment they spawn and where.


That is how I work, I was merely outlining the benefits of the other option. :)

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
×