Classes:PowerStrength

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.
Super strength power
Actor type Power Game MiniZDoomLogoIcon.png (ZDoom)
DoomEd Number None Class Name PowerStrength


Classes: InventoryPowerupPowerStrength
   (more)


PowerStrength is one of the many powerups based on the base Powerup class. It's designed specifically for Doom's Berserk item, and thus comes with built-in Berserk-specific effects, such as temporary screen reddening and unlimited duration, so it might not be a very good choice for similar but more generalized effects.

Note: Fist damage increase is NOT a part of this powerup. Fist's function A_Punch simply explicitly checks for the presence of this powerup in the player's inventory, and, if it finds it, the damage of A_Punch is increased. If a custom weapon with a custom punch attack is used, FindInventory or CountInv will be needed to check for the presence of the powerup. If you want to create an actual damage-increasing powerup, see PowerDamage instead.

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 PowerStrength : Powerup
{
	Default
	{
		Powerup.Duration 1;
		Powerup.Color "ff 00 00", 0.5;
		+INVENTORY.HUBPOWER
	}
	
	override bool HandlePickup (Inventory item)
	{
		if (item.GetClass() == GetClass())
		{ // Setting EffectTics to 0 will force Powerup's HandlePickup()
		  // method to reset the tic count so you get the red flash again.
			EffectTics = 0;
		}
		return Super.HandlePickup (item);
	}

	//===========================================================================
	//
	// APowerStrength :: DoEffect
	//
	//===========================================================================

	override void Tick ()
	{
		// Strength counts up to diminish the fade.
		EffectTics += 2;
		Super.Tick();
	}

	//===========================================================================
	//
	// APowerStrength :: GetBlend
	//
	//===========================================================================

	override color GetBlend ()
	{
		// slowly fade the berserk out
		int cnt = 128 - (EffectTics>>3);

		if (cnt > 0)
		{
			return Color(BlendColor.a*cnt/256,
				BlendColor.r, BlendColor.g, BlendColor.b);
		}
		return 0;
	}
	
}

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 PowerStrength : Powerup native
{
  Powerup.Duration 1
  Powerup.Color 255, 0, 0, 0.5
  +INVENTORY.HUBPOWER
}