NiGHTS power-up

From SRB2 Wiki
Jump to: navigation, search
NPRUA0.png NPRUB0.png NPRUC0.png NPRUD0.png NPRUE0.png
NiGHTS power-ups

NiGHTS power-ups are special Objects in SRB2 that are used to award power-ups to the player when flying around a track as Super Sonic in a NiGHTS level. In unmodified SRB2 there are 5 different NiGHTS power-ups available, some of which are based on power-ups found in NiGHTS into Dreams itself.

When placed on a map, these items will initially be completely invisible and cannot be collected by anyone. However, when the player performs a paraloop around the item, it will become visible and can then be collected to be awarded the item's respective power-up. Typically these items are placed within circles of rings and/or wing logos, to give hints as to where they are located in the level.

If the Special flag is checked, a NiGHTS power-up item will only appear if the player has already destroyed the Ideya Capture and is in bonus time. If the Ambush flag is checked, it will be visible and collectible on spawn.

NiGHTS power-ups in SRB2

Custom NiGHTS power-ups

It is possible to make custom NiGHTS power-ups for SRB2 with the use of SOCs and/or Lua. To make an Object behave like and be recognised as a NiGHTS power-up, it needs to be given the MF_NIGHTSITEM flag. Typically a NiGHTS power-up is also given the MF_NOGRAVITY and MF_NOCLIPHEIGHT flags. The following Object properties control the power-up's behavior:

  • SpawnState: The state used for the item when it first spawns on the map; typically this is set to an "invisible" state to mark that the item cannot be collected currently. However, if the Object has the Ambush flag checked, SeeState will be displayed instead on spawn.
  • SeeState: This state is used when the item is to be made "visible", giving the Object the MF_SPECIAL flag and removing the MF_NIGHTSITEM flag.
  • DeathSound: The sound played when the item has been collected.
  • Speed: For all NiGHTS power-ups in unmodified SRB2, this is used to determine the duration of the power-up awarded. For custom NiGHTS power-ups, this will need to be applied manually using Lua if needed.

Object flags

A number of object flags are involved with NiGHTS power-ups:

  • MF_NIGHTSITEM: The main flag required for NiGHTS power-up item behavior. This flag is removed when the Object has been paralooped by a player or the Object has the Ambush flag checked.
  • MF_SPECIAL: This allows the player to touch a NiGHTS power-up item and be awarded the respective power-up for the item. This flag will automatically be given when the Object has been paralooped by a player or the Object has the Ambush flag checked. Note that for custom NiGHTS power-ups, Lua is needed to determine what happens when a NiGHTS item is touched (see below).
  • MF2_STRONGBOX: Prevents a NiGHTS power-up item from being made visible unless the player has destroyed the Ideya Capture and is in bonus time. This flag is given when the Special flag is checked.

Setting up the power-up effects

Lua is required to set up what happens when a player touches a custom NiGHTS power-up item, as otherwise it will simply play DeathSound and disappear without doing anything by default. In particular, the "TouchSpecial" Lua hook is needed here. See the below example code (a re-creation of the Super Paraloop's effect) for a template of how to create a custom NiGHTS power-up:

local function NiGHTSPower(special, toucher)
	local player = toucher.player // "toucher" is the touching object, so here we make "player" the touching player for convenience
	if or not (player.flags & PF_NIGHTSMODE)
		return true // item should not be touched by a bot or a non-NiGHTS player
	// Awarding the power-up to the player(s) //
	if not G_IsSpecialStage() // effects given outside of special stages
		player.powers[pw_nights_superloop] = // award the power-up only to the touching player
	else // effects given when in a special stage
		for p in players.iterate // award the power-up to ALL players playing as NiGHTS
			if p.flags & PF_NIGHTSMODE
				p.powers[pw_nights_superloop] =
		if != sfx_None
			// Play the power-up's collect sound from nowhere, so that all players in the map can hear it!
			// Normally this sound is made to be played by the player that collected the power-up,
			//   the problem with this is that other players could be too far away to hear the sound at the time
	// Displaying a cecho message on-screen, to alert the player(s) that they have just received the power-up //
	if not G_IsSpecialStage() // display power-up cecho message only for the touching player
		// note: the "\\"s are needed in the cecho to offset the text downwards from the top of the screen - 8 pairs of these are typically used here
		COM_BufInsertText(player, "cechoflags "+V_AUTOFADEOUT+"; cechoduration 4; cecho \\\\\\\\\\\\\\\\Super Paraloop")
	else // display the message for ALL players
		for p in players.iterate
			COM_BufInsertText(p, "cechoflags "+V_AUTOFADEOUT+"; cechoduration 4; cecho \\\\\\\\\\\\\\\\Super Paraloop")
addHook("TouchSpecial", NiGHTSPower, MT_NIGHTSSUPERLOOP)
  Object types [view]
General EnemyBossPushableSpringMonitorNiGHTS power-upProjectileAmbient sound effect
Special PlayerShieldsFreed animalsEmblemOverlay
Related links List of Object types