A_Die

From ZDoom Wiki
Jump to navigation Jump to search


Actor

void A_Die(name damagetype = 'none')

Usage

Kills the calling actor if it is not already dead, setting its health value to 0 and sending it to its Death state. This has only an effect if the actor has the SHOOTABLE or VULNERABLE flag set. Optionally, a damage type can be provided.

This has the same effect as calling DamageMobj with pointers to source and inflictor set to null.

Examples

This imp's days are numbered... It will walk around and fire at you normally. But all the while walking on borrowed time, slowly gaining the inventory "DeathTimer" with every action it takes. When the timer reaches 20, the imp will simulate having a violent heart-attack, then trigger A_Die.

class DyingImp : DoomImp
{
	int deathTimer;

	States
	{
	See:
		TROO AABBCCDD 3 A_Chase;
		TNT1 A 0
		{
			deathTimer++;
			// Time to die:
			if (deathTimer >= 20)
			{
				return ResolveState("HeartAttack");
			}
			// Otherwise there's a chance of triggering Pain randomly:
			if (random() < 45)
			{
				return ResolveState("Pain");
			}
			return ResolveState(null);
		}
		Loop;
	Melee:
	Missile:
		TROO EF 8 A_FaceTarget;
		TROO G 6 A_TroopAttack;
		TNT1 A 0
		{
			deathTimer++;
			if (deathTimer >= 20)
			{
				return ResolveState("HeartAttack");
			}
			return ResolveState(null);
		}
		goto See;
	HeartAttack:
		TROO H 2;
		TROO HHHH 20 A_Pain;
		TROO H 2 A_Die;
		goto Death;
	}
}

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.
	void A_Die(name damagetype = "none")
	{
		DamageMobj(null, null, health, damagetype, DMG_FORCED);
	}

See also