Deactivate

From ZDoom Wiki
Jump to navigation Jump to search

Actor

virtual native void Deactivate(Actor activator)

Usage

Actors call this function when they're deactivated, and it can be overridden to add special behavior to their deactivation. By default it does nothing.

This function can be called on actors directly, through the ACS function Thing_Deactivate, or through USESPECIAL or BUMPSPECIAL flags. Specific conditions are described here.

Parameters

  • Actor activator
A pointer to the actor that performed the deactivation. Determined by the actor's Activation property: by default it's the actor that activated (used/bumped into) this actor, but with THINGSPEC_ThingActs the calling actor is instead considered the activator. If the function is called directly in ZScript, a pointer to any actor can be passed to the call manually.

Examples

Note: Using the Activate() and Deactivate() functions as described below, to create interactive objects, is generally unnecessary. The easier way to set up similar interactions is with the Used() function, which is not tied to specials or activation.

This version of the tech lamp can be manually switched on and off by pressing Use next to it:

class SwitchableLamp : TechLamp
{
	Default
	{
		Activation THINGSPEC_Switch; //can call Activate/Deactivate any number of times
		+USESPECIAL
	}

	override void Activate(Actor activator)
	{
		// Attach dynamic light, play a standard switch sound
		// and move to the LampOn state label:
		A_AttachLight('lamplight', DynamicLight.PulseLight, "DDDDFF", 96, 99, DYNAMICLIGHT.LF_ATTENUATE, (0,0,72), 0.4);
		A_StartSound("switches/normbutn");
		SetStateLabel("LampOn");
	}

	override void Deactivate(Actor activator)
	{
		// Remove the light, play the sound, change states:
		A_RemoveLight('lamplight');
		A_StartSound("switches/normbutn");
		SetStateLabel("Spawn");
	}

	States
	{
	Spawn:
		TLMP C -1;
		stop;
	LampOn:
		// This is how the regular TechLamp looks:
		TLMP ABCD 4 Bright;
		Loop;
	}
}

See also