Classes:SectorAction

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.
Sector action
Actor type Internal Game MiniZDoomLogoIcon.png (ZDoom)
DoomEd Number None Class Name SectorAction


Classes: ActorSectorAction
 →MusicChanger
 →SecActEnter
 →SecActExit
 →SecActEyesAboveC
 →SecActEyesBelowC
 →SecActEyesDive
 →SecActEyesSurface
 →SecActHitCeil
 →SecActHitFakeFloor
 →SecActHitFloor
 →SecActUse
 →SecActUseWall

Base class for all sector action classes. This thing is not used directly, instead one of its derived classes is used.

See also: Thing executed specials

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 SectorAction : Actor
{
	// self class uses health to define the activation type.
	enum EActivation
	{
		SECSPAC_Enter		= 1<< 0,
		SECSPAC_Exit		= 1<< 1,
		SECSPAC_HitFloor	= 1<< 2,
		SECSPAC_HitCeiling	= 1<< 3,
		SECSPAC_Use		= 1<< 4,
		SECSPAC_UseWall		= 1<< 5,
		SECSPAC_EyesDive	= 1<< 6,
		SECSPAC_EyesSurface 	= 1<< 7,
		SECSPAC_EyesBelowC	= 1<< 8,
		SECSPAC_EyesAboveC	= 1<< 9,
		SECSPAC_HitFakeFloor	= 1<<10,
		SECSPAC_DamageFloor	= 1<<11,
		SECSPAC_DamageCeiling	= 1<<12,
		SECSPAC_DeathFloor	= 1<<13,
		SECSPAC_DeathCeiling	= 1<<14,
		SECSPAC_Damage3D	= 1<<15,
		SECSPAC_Death3D		= 1<<16
	};

	default
	{
		+NOBLOCKMAP
		+NOSECTOR
		+NOGRAVITY
		+DONTSPLASH
		+NOTONAUTOMAP
	}
	
	override void OnDestroy ()
	{
		if (CurSector != null)
		{
			// Remove ourself from self CurSector's list of actions
			if (CurSector.SecActTarget == self)
			{
				CurSector.SecActTarget = SectorAction(tracer);
			}
			else
			{
				Actor probe = CurSector.SecActTarget;
				if (null != probe)
				{
					while (probe.tracer != self && probe.tracer != null)
					{
						probe = probe.tracer;
					}
					if (probe.tracer == self)
					{
						probe.tracer = tracer;
					}
				}
			}
		}
		Super.OnDestroy();
	}

	override void BeginPlay ()
	{
		Super.BeginPlay ();

		// Add ourself to self CurSector's list of actions
		tracer = CurSector.SecActTarget;
		CurSector.SecActTarget = self;
	}

	override void Activate (Actor source)
	{
		bDormant = false;	// Projectiles cannot trigger
	}

	override void Deactivate (Actor source)
	{
		bDormant = true;	// Projectiles can trigger
	}

	virtual bool TriggerAction (Actor triggerer, int activationType)
	{
		if ((activationType & health) && CanTrigger(triggerer))
		{
			return triggerer.A_CallSpecial(special, args[0], args[1], args[2], args[3], args[4]);
		}
		return false;
	}

	virtual bool CanTrigger (Actor triggerer)
	{
		return special &&
			((triggerer.player && !bFriendly) ||
			(bAmbush && triggerer.bActivateMCross) ||
			(bDormant && triggerer.bActivatePCross));
	}
}

DECORATE definition

Nuvolabomb.png Warning: 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 SectorAction native
{
  +NOBLOCKMAP
  +NOSECTOR
  +NOGRAVITY
  +DONTSPLASH
}