Classes:Grenade

From ZDoom Wiki
Jump to navigation Jump to search
Note: Wait! Stop! Before you copy this actor's definition into your mod, remember the following things:
  1. You do NOT need to copy that actor, since it is already defined.
  2. In fact, it's not just useless, it will cause problems.
  3. If you want to modify it, or use a modified version, using inheritance is the way to go.
  4. The actor definitions here are put on the wiki for reference purpose only. Learn from them, don't copy them.
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
  }
}