Classes:PowerInvulnerable
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:
|
Invulnerability power | |||
---|---|---|---|
Actor type | Power | Game | ![]() |
DoomEd Number | None | Class Name | PowerInvulnerable |
Classes: Inventory→Powerup→PowerInvulnerable
(more)
One of the many powerups, i.e. items based on the Powerup class. While an item of this class is placed in an actor's inventory, the actor will be affected by it. Usually powerups are given through a PowerupGiver, but they can be given directly as well (see here for more details).
PowerInvulnerable prevents its owner from receiving any damage.
The basic behavior can be further customized by setting the following values to its Powerup.Mode property:
- 'Reflective' — the REFLECTIVE flag will be given to the owner, causing them to reflect projectiles that hit them
- 'Ghost' — the NONSHOOTABLE flag will be given to the owner, causing any projectiles fired at them to pass through
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 PowerInvulnerable : Powerup
{
Default
{
Powerup.Duration -30;
inventory.icon "SPSHLD0";
}
//===========================================================================
//
// APowerInvulnerable :: InitEffect
//
//===========================================================================
override void InitEffect ()
{
Super.InitEffect();
Owner.bRespawnInvul = false;
Owner.bInvulnerable = true;
if (Mode == 'None' && Owner is "PlayerPawn")
{
Mode = PlayerPawn(Owner).InvulMode;
}
if (Mode == 'Reflective')
{
Owner.bReflective = true;
}
}
//===========================================================================
//
// APowerInvulnerable :: DoEffect
//
//===========================================================================
override void DoEffect ()
{
Super.DoEffect ();
if (Owner == NULL)
{
return;
}
Owner.bInvulnerable = true;
if (Mode == 'Reflective')
{
Owner.bReflective = true;
}
if (Mode == 'Ghost')
{
if (!Owner.bShadow)
{
// Don't mess with the translucency settings if an
// invisibility powerup is active.
let alpha = Owner.Alpha;
if (!(Level.maptime & 7) && alpha > 0 && alpha < 1)
{
if (alpha == HX_SHADOW)
{
alpha = HX_ALTSHADOW;
}
else
{
alpha = 0;
Owner.bNonShootable = true;
}
}
if (!(Level.maptime & 31))
{
if (alpha == 0)
{
Owner.bNonShootable = false;
alpha = HX_ALTSHADOW;
}
else
{
alpha = HX_SHADOW;
}
}
Owner.A_SetRenderStyle(alpha, STYLE_Translucent);
}
else
{
Owner.bNonShootable = false;
}
}
}
//===========================================================================
//
// APowerInvulnerable :: EndEffect
//
//===========================================================================
override void EndEffect ()
{
Super.EndEffect();
if (Owner == NULL)
{
return;
}
Owner.bRespawnInvul = false;
Owner.bInvulnerable = false;
if (Mode == 'Ghost')
{
Owner.bNonShootable = false;
if (!bShadow)
{
// Don't mess with the translucency settings if an
// invisibility powerup is active.
Owner.A_SetRenderStyle(1, STYLE_Normal);
}
}
else if (Mode == 'Reflective')
{
Owner.bReflective = false;
}
if (Owner.player != NULL)
{
Owner.player.fixedcolormap = PlayerInfo.NOFIXEDCOLORMAP;
}
}
//===========================================================================
//
// APowerInvulnerable :: AlterWeaponSprite
//
//===========================================================================
override void AlterWeaponSprite (VisStyle vis, in out int changed)
{
if (Owner != NULL)
{
if (Mode == 'Ghost' && !(Owner.bShadow))
{
vis.Alpha = min(0.25 + Owner.Alpha * 0.75, 1.);
}
}
}
}
DECORATE definition
![]() |
Warning: 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 PowerInvulnerable : Powerup native { Powerup.Duration -30 Inventory.Icon "SPSHLD0" }