Classes:Grenade

From ZDoom Wiki
Jump to navigation Jump to search
Note: Wait! Stop! You do not need to copy this actor's code into your project! Here's why:
  1. This actor is already defined in GZDoom, there's no reason to define it again.
  2. In fact, trying to define an actor with the same name will cause an error (because it already exists).
  3. If you want to make your own version of this actor, use inheritance.
  4. Definitions for existing actors are put on the wiki for reference purpose only.
Grenade
Actor type Explosive Game MiniZDoomLogoIcon.png (ZDoom)
DoomEd Number None Class Name Grenade
Spawn ID 216 Identifier T_GRENADE


Classes: Grenade

Bouncing projectile of the GrenadeLauncher. Contrarily to most projectiles, it is affected by gravity. Previously a Skulltag-exclusive actor, it has been backported for compatibility in development versions as it is used for the default actor of A_FireSTGrenade. Sounds are not, however, included. Since r1824, it also serves as a container for several MBF states related to grenades or explosion.

ZScript definition

Note: The ZScript definition below is for reference and may be different in the current version of GZDoom.The most up-to-date version of this code can be found on GZDoom GitHub.
class Grenade : Actor
{
	Default
	{
		Radius 8;
		Height 8;
		Speed 25;
		Damage 20;
		Projectile;
		-NOGRAVITY
		+RANDOMIZE
		+DEHEXPLOSION
		+GRENADETRAIL
		BounceType "Doom";
		Gravity 0.25;
		SeeSound "weapons/grenlf";
		DeathSound "weapons/grenlx";
		BounceSound "weapons/grbnce";
		Obituary "$OB_GRENADE";
		DamageType "Grenade";
	}
	States
	{
	Spawn:
		SGRN A 1 Bright;
		Loop;
	Death:
		MISL B 8 Bright A_Explode;
		MISL C 6 Bright;
		MISL D 4 Bright;
		Stop;
	Grenade:
		MISL A 1000 A_Die;
		Wait;
	Detonate:
		MISL B 4 A_Scream;
		MISL C 6 A_Detonate;
		MISL D 10;
		Stop;
	Mushroom:
		MISL B 8 A_Mushroom;
		Goto Death+1;
	}
}

DECORATE definition

Note: This is legacy code, kept for archival purposes only. DECORATE is deprecated in GZDoom and is completely superseded by ZScript. GZDoom internally uses the ZScript definition above.
ACTOR Grenade
{
  Radius 8
  Height 8
  Speed 25
  Damage 20
  Projectile
  -NOGRAVITY
  +RANDOMIZE
  +DEHEXPLOSION
  +GRENADETRAIL
  BounceType "Doom"
  Gravity 0.25
  SeeSound "weapons/grenlf"
  DeathSound "weapons/grenlx"
  BounceSound "weapons/grbnce"
  Obituary "$OB_GRENADE" // "%o caught %k's grenade."
  DamageType Grenade
  States
  {
  Spawn:
    SGRN A 1 Bright
    Loop
  Death:
    MISL B 8 Bright A_Explode
    MISL C 6 Bright
    MISL D 4 Bright
    Stop
  Grenade:
    MISL A 1000 A_Die
    Wait
  Detonate:
    MISL B 4 A_Scream
    MISL C 6 A_Detonate
    MISL D 10
    Stop
  Mushroom:
    MISL B 8 A_Mushroom
    Goto Death+1
  }
}