Classes:SpectralMonster

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.
Spectral monster base class
Actor type Internal Game MiniStrifeLogoIcon.png (Strife)
DoomEd Number None Class Name SpectralMonster


Classes: SpectralMonster
 →AlienSpectre1
  →AlienSpectre2
  →AlienSpectre3
  →AlienSpectre4
  →AlienSpectre5
 →EntityBoss
 →EntitySecond
The base class for all Spectres and the Entity in Strife. Any monster of this type also has a special attribute where they deal 5 damage to any player who touches them.

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 SpectralMonster : Actor
{
	Default
	{
		Monster;
		+SPECIAL
		+SPECTRAL
		+NOICEDEATH
	}
	
	override void Touch (Actor toucher)
	{
		toucher.DamageMobj (self, self, 5, 'Melee');
	}
	

	//============================================================================

	void A_SpectreChunkSmall ()
	{
		Actor foo = Spawn("AlienChunkSmall", pos + (0, 0, 10), ALLOW_REPLACE);

		if (foo != null)
		{
			int t;

			t = random[SpectreChunk](0, 7);
			foo.Vel.X = t - random[SpectreChunk](0, 15);

			t = random[SpectreChunk](0, 7);
			foo.Vel.Y = t - random[SpectreChunk](0, 15);

			foo.Vel.Z = random[SpectreChunk](0, 15);
		}
	}

	void A_SpectreChunkLarge ()
	{
		Actor foo = Spawn("AlienChunkLarge", pos + (0, 0, 10), ALLOW_REPLACE);

		if (foo != null)
		{
			int t;

			t = random[SpectreChunk](0, 7);
			foo.Vel.X = t - random[SpectreChunk](0, 15);
			
			t = random[SpectreChunk](0, 7);
			foo.Vel.Y = t - random[SpectreChunk](0, 15);

			foo.Vel.Z = random[SpectreChunk](0, 7);
		}
	}

	void A_Spectre3Attack ()
	{
		if (target == null)
			return;

		Actor foo = Spawn("SpectralLightningV2", Pos + (0, 0, 32), ALLOW_REPLACE);
		if (foo != null)
		{
			foo.Vel.Z = -12;
			foo.target = self;
			foo.FriendPlayer = 0;
			foo.tracer = target;
		}

		Angle -= 90.;
		for (int i = 0; i < 20; ++i)
		{
			Angle += 9.;
			SpawnSubMissile ("SpectralLightningBall2", self);
		}
		Angle -= 90.;
	}
	
	//============================================================================
	//
	// A_SpotLightning
	//
	//============================================================================

	void A_SpotLightning()
	{
		if (target == null) return;

		Actor spot = Spawn("SpectralLightningSpot", (target.pos.xy, target.floorz), ALLOW_REPLACE);
		if (spot != null)
		{
			spot.threshold = 25;
			spot.target = self;
			spot.FriendPlayer = 0;
			spot.tracer = target;
		}
	}

}

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 SpectralMonster native
{
  Monster
  +SPECIAL
  +SPECTRAL
  +NOICEDEATH

  action native A_SpectreChunkSmall();
  action native A_SpectreChunkLarge();
  action native A_Spectre3Attack();
  action native A_SpotLightning();
}

See also