InitEffect

From ZDoom Wiki
Jump to navigation Jump to search

Powerup

virtual void InitEffect ()

Usage

A virtual function called by powerups when they become active to initialize whatever needs to be done at that stage. The base Powerup class uses it to set up screen blend/colors.

Powerups with the INVENTORY.AUTOACTIVATE flag will call it automatically (since they're activated automatically). Otherwise, it will be called only once the powerup is used from the inventory bar.

Error.gif
Warning: When overriding this function, always remember to call Super.InitEffect(), otherwise the colormap won't be set up properly, which can lead to unintended consequences, such as the player's screen receiving InvulnerabilitySphere's inverse colormap.


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.

The base Powerup class defines it as follows:

	virtual void InitEffect() 
	{
		// initialize this only once instead of recalculating repeatedly.
		Colormap = ((BlendColor & 0xFFFF0000) == SPECIALCOLORMAP_MASK)? BlendColor & 0xffff : PlayerInfo.NOFIXEDCOLORMAP;
	}

Examples

Nuvolachalk.png Note: This article lists no examples. If you make use of this feature in your own project(s) or know of any basic examples that could be shared, please add them. This will make it easier to understand for future authors seeking assistance. Your contributions are greatly appreciated.


See also