- scriptified AÜpwerInvulnerable.

This commit is contained in:
Christoph Oelckers 2017-01-16 23:45:25 +01:00
parent 6990a46daf
commit 8f6571241d
5 changed files with 124 additions and 130 deletions

View file

@ -422,124 +422,6 @@ void APowerup::OwnerDied ()
Destroy ();
}
// Invulnerability Powerup ---------------------------------------------------
IMPLEMENT_CLASS(APowerInvulnerable, false, false)
//===========================================================================
//
// APowerInvulnerable :: InitEffect
//
//===========================================================================
void APowerInvulnerable::InitEffect ()
{
Super::InitEffect();
Owner->effects &= ~FX_RESPAWNINVUL;
Owner->flags2 |= MF2_INVULNERABLE;
if (Mode == NAME_None && Owner->IsKindOf(RUNTIME_CLASS(APlayerPawn)))
{
Mode = static_cast<PClassPlayerPawn *>(Owner->GetClass())->InvulMode;
}
if (Mode == NAME_Reflective)
{
Owner->flags2 |= MF2_REFLECTIVE;
}
}
//===========================================================================
//
// APowerInvulnerable :: DoEffect
//
//===========================================================================
void APowerInvulnerable::DoEffect ()
{
Super::DoEffect ();
if (Owner == NULL)
{
return;
}
if (Mode == NAME_Ghost)
{
if (!(Owner->flags & MF_SHADOW))
{
// Don't mess with the translucency settings if an
// invisibility powerup is active.
Owner->RenderStyle = STYLE_Translucent;
if (!(level.time & 7) && Owner->Alpha > 0 && Owner->Alpha < 1)
{
if (Owner->Alpha == HX_SHADOW)
{
Owner->Alpha = HX_ALTSHADOW;
}
else
{
Owner->Alpha = 0;
Owner->flags2 |= MF2_NONSHOOTABLE;
}
}
if (!(level.time & 31))
{
if (Owner->Alpha == 0)
{
Owner->flags2 &= ~MF2_NONSHOOTABLE;
Owner->Alpha = HX_ALTSHADOW;
}
else
{
Owner->Alpha = HX_SHADOW;
}
}
}
else
{
Owner->flags2 &= ~MF2_NONSHOOTABLE;
}
}
}
//===========================================================================
//
// APowerInvulnerable :: EndEffect
//
//===========================================================================
void APowerInvulnerable::EndEffect ()
{
Super::EndEffect();
if (Owner == NULL)
{
return;
}
Owner->flags2 &= ~MF2_INVULNERABLE;
Owner->effects &= ~FX_RESPAWNINVUL;
if (Mode == NAME_Ghost)
{
Owner->flags2 &= ~MF2_NONSHOOTABLE;
if (!(Owner->flags & MF_SHADOW))
{
// Don't mess with the translucency settings if an
// invisibility powerup is active.
Owner->RenderStyle = STYLE_Normal;
Owner->Alpha = 1.;
}
}
else if (Mode == NAME_Reflective)
{
Owner->flags2 &= ~MF2_REFLECTIVE;
}
if (Owner->player != NULL)
{
Owner->player->fixedcolormap = NOFIXEDCOLORMAP;
}
}
// Speed Powerup -------------------------------------------------------------
IMPLEMENT_CLASS(APowerSpeed, false, false)

View file

@ -57,15 +57,6 @@ public:
double Strength; // Meaning depends on powerup - currently used only by Invisibility
};
class APowerInvulnerable : public APowerup
{
DECLARE_CLASS (APowerInvulnerable, APowerup)
protected:
virtual void InitEffect () override;
virtual void DoEffect () override;
virtual void EndEffect () override;
};
class APowerSpeed : public APowerup
{
DECLARE_CLASS (APowerSpeed, APowerup)

View file

@ -5373,7 +5373,7 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags)
(dmflags2 & DF2_YES_RESPAWN_INVUL) &&
(multiplayer || alwaysapplydmflags))
{
APowerup *invul = static_cast<APowerup*>(p->mo->GiveInventoryType (RUNTIME_CLASS(APowerInvulnerable)));
APowerup *invul = static_cast<APowerup*>(p->mo->GiveInventoryType (PClass::FindActor(NAME_PowerInvulnerable)));
invul->EffectTics = 3*TICRATE;
invul->BlendColor = 0; // don't mess with the view
invul->ItemFlags |= IF_UNDROPPABLE; // Don't drop this

View file

@ -100,6 +100,7 @@ static FFlagDef InternalActorFlagDefs[]=
DEFINE_FLAG(MF6, INTRYMOVE, AActor, flags6),
DEFINE_FLAG(MF7, HANDLENODELAY, AActor, flags7),
DEFINE_FLAG(MF7, FLYCHEAT, AActor, flags7),
DEFINE_FLAG(FX, RESPAWNINVUL, AActor, effects),
};

View file

@ -38,14 +38,134 @@ class Powerup : Inventory native
//
//===========================================================================
class PowerInvulnerable : Powerup native
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;
}
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.time & 7) && alpha > 0 && alpha < 1)
{
if (alpha == HX_SHADOW)
{
alpha = HX_ALTSHADOW;
}
else
{
alpha = 0;
Owner.bNonShootable = true;
}
}
if (!(level.time & 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)