Classes:SecurityCamera

From ZDoom Wiki
(Redirected from Security camera)
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.
Security camera
Actor type Script thing Game MiniZDoomLogoIcon.png (ZDoom)
DoomEd Number 9025 Class Name SecurityCamera


Classes: SecurityCamera
 →AimingCamera

Usage

The SecurityCamera is a camera that pans from side to side, much like the security camera in Duke Nukem 3D. It is a great addition to either a single player or multiplayer map.

Place the camera in the map and set the thing angle to point in the direction you want the camera to face. Set the three arguments of the camera and give the camera a unique TID.

The camera is activated by using the ChangeCamera (237) special or by a SetCameraToTexture in ACS.

Arguments

The security camera takes three arguments:

  • args[0] → pitch of camera in degrees, equal to the angle subtracted from 256.
  • args[1] → number of degrees camera will rotate in either direction from its original orientation.
  • args[2] → number of octics to complete one cycle of turning.

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 SecurityCamera : Actor
{
	default
	{
		+NOBLOCKMAP 
		+NOGRAVITY
		+DONTSPLASH
		RenderStyle "None";
		CameraHeight 0;
	}

	double Center;
	double Acc;
	double Delta;
	double Range;
	
	override void PostBeginPlay ()
	{
		Super.PostBeginPlay ();
		Center = Angle;
		if (args[2])
			Delta = 360. / (args[2] * TICRATE / 8);
		else
			Delta = 0.;
		if (args[1])
			Delta /= 2;
		Acc = 0.;
		int arg = (args[0] << 24) >> 24;	// make sure the value has the intended sign.
		Pitch = clamp(arg, -89, 89);
		Range = args[1];
	}

	override void Tick ()
	{
		Acc += Delta;
		if (Range != 0)
			Angle = Center + Range * sin(Acc);
		else if (Delta != 0)
			Angle = Acc;
	}

	
}

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 SecurityCamera native 
{
  +NOBLOCKMAP 
  +NOGRAVITY
  +DONTSPLASH
  RenderStyle None
  CameraHeight 0
}