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

Can you make an enemy, when killed, drop a key?

Recommended Posts

Using ZDoom? If so, then it's not too hard. First, give an enemy a tid number. Then give the enemy a trigger command of ACS_Execute (trigger runs once the enemy is killed). Then do something like this:

script 4 (void)
{
    delay(15);
    Thing_SpawnNoFog(5, 85, 0);
}
This will spawn silently a blue key where the monster died. The delay is to make sure that the script waits long enough for the enemy to lose the MF_SOLID flag. I've learned that things generally won't spawn on the same spot as something solid.

Share this post


Link to post
Ichor said:

Using ZDoom? If so, then it's not too hard. First, give an enemy a tid number. Then give the enemy a trigger command of ACS_Execute (trigger runs once the enemy is killed). Then do something like this:

script 4 (void)
{
    delay(15);
    Thing_SpawnNoFog(5, 85, 0);
}
This will spawn silently a blue key where the monster died. The delay is to make sure that the script waits long enough for the enemy to lose the MF_SOLID flag. I've learned that things generally won't spawn on the same spot as something solid.

Thanks -- how would I alter that script if I wanted a red skullkey?

Share this post


Link to post

IIRC you don't even have to make it that complicated. Just try to set the monsters special to Thing_SpawnNoFog with the said parameters and it should work, even though there is no delay.

[edit]
If you write the scripts you're not forced to use the cryptic thing numbers. There are quite a few #defines for spawnable things in zdefs.acs, starting with T_. Also, you can use SpawnSpot to spawn things by their class, but I'm not sure about the parameters you have to supply. Just search this or ZDoom's forum/wiki.

Share this post


Link to post

I've tried that before, and some, if not most, monsters are still solid after the first couple of frames, which prevents anything from spawning.

Share this post


Link to post
Ichor said:

Replace the '85' with '89'.

Thing_SpawnNoFog(5, 89, 0);

Thing_SpawnNoFog(5, T_blabla, 0);
for the constants, see zdefs.h.

Share this post


Link to post

That works too, although for whatever reason I usually just use the numbers.

Share this post


Link to post
Ichor said:

I've tried that before, and some, if not most, monsters are still solid after the first couple of frames, which prevents anything from spawning.


they won't spawn something until they are flagged dead, and when monsters in zdoom are flagged dead they're also flagged noblocking, and that's when they drop the thing

Share this post


Link to post

Cyb, Originally in a Dehacked batch, you could set a monster dead without it unblocking, so after its death you were still incapable of running through it. Did this change in Zdoom.

Share this post


Link to post

Yes, that has always been a problem in the past, which is why I use ACS (as well as using P_DropItem in the source code) to spawn things.

Share this post


Link to post
Cyb said:

they won't spawn something until they are flagged dead, and when monsters in zdoom are flagged dead they're also flagged noblocking, and that's when they drop the thing



No, not quite like this.

When a monster is killed it isn't immediately set nonblocking. That is done a few frames later with an explicit call to a code pointer. ZDoom spawns its dropped items in that code pointer so you can leave a corpse solid but it won't drop any ammo (or anything else.) Of course a solid corpse is still flagged as 'dead'.

Scuba Steve said:

Cyb, Originally in a Dehacked batch, you could set a monster dead without it unblocking, so after its death you were still incapable of running through it. Did this change in Zdoom.


ZDoom has height sensitive checks so a solid corpse isn't infinitely tall. As the height of a corpse is reduced to 1/4 of its original size you can run over them even if they are solid. If you set the 'infinitely tall actors' option they block the same as in Doom.

Share this post


Link to post
Graf Zahl said:

As the height of a corpse is reduced to 1/4 of its original size you can run over them even if they are solid.

Ah HA! /me learns a new.

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
×