From 8f6571241dfe0bdc5e95e572adeca603eab6d03b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 16 Jan 2017 23:45:25 +0100 Subject: [PATCH] =?UTF-8?q?-=20scriptified=20A=C3=9CpwerInvulnerable.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/g_inventory/a_artifacts.cpp | 118 ------------------ src/g_inventory/a_artifacts.h | 9 -- src/p_mobj.cpp | 2 +- src/scripting/thingdef_data.cpp | 1 + wadsrc/static/zscript/inventory/powerups.txt | 124 ++++++++++++++++++- 5 files changed, 124 insertions(+), 130 deletions(-) diff --git a/src/g_inventory/a_artifacts.cpp b/src/g_inventory/a_artifacts.cpp index 0cd4828b1..8b57d4fe2 100644 --- a/src/g_inventory/a_artifacts.cpp +++ b/src/g_inventory/a_artifacts.cpp @@ -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(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) diff --git a/src/g_inventory/a_artifacts.h b/src/g_inventory/a_artifacts.h index f947e18d5..89088a0be 100644 --- a/src/g_inventory/a_artifacts.h +++ b/src/g_inventory/a_artifacts.h @@ -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) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 9c18ea638..48393caaa 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -5373,7 +5373,7 @@ APlayerPawn *P_SpawnPlayer (FPlayerStart *mthing, int playernum, int flags) (dmflags2 & DF2_YES_RESPAWN_INVUL) && (multiplayer || alwaysapplydmflags)) { - APowerup *invul = static_cast(p->mo->GiveInventoryType (RUNTIME_CLASS(APowerInvulnerable))); + APowerup *invul = static_cast(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 diff --git a/src/scripting/thingdef_data.cpp b/src/scripting/thingdef_data.cpp index a3f5c144c..b99d6e646 100644 --- a/src/scripting/thingdef_data.cpp +++ b/src/scripting/thingdef_data.cpp @@ -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), }; diff --git a/wadsrc/static/zscript/inventory/powerups.txt b/wadsrc/static/zscript/inventory/powerups.txt index b744bfc97..8ad8bdac1 100644 --- a/wadsrc/static/zscript/inventory/powerups.txt +++ b/wadsrc/static/zscript/inventory/powerups.txt @@ -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)