WorldThingRevived
Jump to navigation
Jump to search
void WorldThingRevived (WorldEvent e)
Usage
An event handler virtual function that is called when an actor that was dead is resurrected (for example, by Doom's Arch-Vile).
Passed values
This event gets a pointer to the WorldEvent struct and can read the following from it by preceding the value with e.
:
- Actor thing
- Pointer to the actor that was resurrected.
Examples
This event handler puts all bosses in an array (which is globally accessible by finding the event handler with EventHandler.Find()), and removes them when they're killed (and re-adds when they're revived):
class MyEventHandler : EventHandler
{
array<Actor> allBosses;
override void WorldThingSpawned(WorldEvent e)
{
// if the actor has the ISMONSTER and BOSS flags,
// put it into the array:
if (e.thing.bIsMonster && e.thing.bBoss)
{
allBosses.Push(e.thing);
}
}
override void WorldThingDied(WorldEvent e)
{
// when an actor is killed, check if it was in the array,
// and if so, remove it from it:
int index = allBosses.Find(e.thing);
if (index < allBosses.Size())
{
allBosses.Delete(index);
}
}
override void WorldThingRevived(WorldEvent e)
{
// if the actor is revived, put it into the array again
// (just in case, check that it's not yet in the array):
if (e.thing.bIsMonster && e.thing.bBoss && allBosses.Find(e.thing) == allBosses.Size())
{
allBosses.Push(e.thing);
}
}
}
// Example of reading it from elsewhere in the code:
let handler = MyEventHandler(EventHandler.Find('MyEventHandler'));
if (handler)
{
// do something with allBosses.allProjectiles here
}