How to have an event happen on a spawned monster's death?
Moderator: GZDoom Developers
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.
Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
- JtoTheB
- Posts: 32
- Joined: Sat Aug 09, 2025 9:46 am
- Operating System Version (Optional): Windows 11
- Location: New Jersey
How to have an event happen on a spawned monster's death?
In my mod, I want a cyberdemon fight to occur that gets spawned by a map spot. I've coded it to spawn and I've also coded for the entrance to close up. What I want to do is make it so that when the cyberdemon dies, the entrance is reopened. Any possible way to do this?
Re: How to have an event happen on a spawned monster's death?
Yep.
When you spawn an object (several spawning methods are available) you have the opportunity to give the newly-spawned object a tid/tag. For example, you could use SpawnSpotFacing which spawns an actor at a map spot facing the same direction as the map spot.
e.g. https://zdoom.org/wiki/SpawnSpotFacing
SpawnSpotFacing (str classname, int spottid [, int tid]);
So, the following
SpawnSpotFacing ("Cyberdemon", 1, 2);
Will spawn a cyberdemon at the position of a map spot with a tid/tag of 1 and give the cyberdemon a tid/tag of 2 when it spawns.
From there you can do something like use ThingCount to keep a track of the actor(s) with tid 2 or you can use something like Thing_SetSpecial to give the newly spawned actor a special that will be excuted when it dies.
e.g.
Thing_SetSpecial(2, 80, 20, 0, 0);
Would give an actor with a tid/tag of 2 the special of running a script (special 80 is ACS_Execute) and the script is script 20.
https://zdoom.org/wiki/Thing_SetSpecial
https://zdoom.org/wiki/ACS_Execute
When you spawn an object (several spawning methods are available) you have the opportunity to give the newly-spawned object a tid/tag. For example, you could use SpawnSpotFacing which spawns an actor at a map spot facing the same direction as the map spot.
e.g. https://zdoom.org/wiki/SpawnSpotFacing
SpawnSpotFacing (str classname, int spottid [, int tid]);
So, the following
SpawnSpotFacing ("Cyberdemon", 1, 2);
Will spawn a cyberdemon at the position of a map spot with a tid/tag of 1 and give the cyberdemon a tid/tag of 2 when it spawns.
From there you can do something like use ThingCount to keep a track of the actor(s) with tid 2 or you can use something like Thing_SetSpecial to give the newly spawned actor a special that will be excuted when it dies.
e.g.
Thing_SetSpecial(2, 80, 20, 0, 0);
Would give an actor with a tid/tag of 2 the special of running a script (special 80 is ACS_Execute) and the script is script 20.
https://zdoom.org/wiki/Thing_SetSpecial
https://zdoom.org/wiki/ACS_Execute