ExplodeMissile

From ZDoom Wiki
Jump to navigation Jump to search
Note: This feature is for ZScript only.


Actor

void ExplodeMissile(line lin = null, Actor target = null, bool onsky = false)

Usage

Makes the actor explode like a projectile does when it hits something, including setting its appropriate state, setting its pointers based on its flags, spraying decals, etc. Most often used with actors that have the MISSILE flag set.

This should be used instead of SetStateLabel("Death") for manually causing a projectile to go to its Death state sequence, since just changing the state manually will not handle all the other required behavior.

Parameters

  • Line lin
The line that was hit causing the explosion. Default is null.
  • Actor target
The actor that was hit causing the explosion. Default is null.
  • bool onsky
If true, consider the actor to have hit the sky. Default is false.

Examples

This version of the Rocket will explode if it was still flying 2 seconds after its existence:

class TimedRocket : Rocket
{
	override void Tick()
	{
		Super.Tick();
 		// TICRATE is equal to 1 second (currently 35 tics)
		if (InStateSequence(curstate, spawnstate) && GetAge() >= TICRATE * 2)
		{
			ExplodeMissile();
		}
	}
}