From 267b1842b4cf4b52e7e7a76bc5a585cf959d78b4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 31 Dec 2016 01:08:09 +0100 Subject: [PATCH] - scriptified a few more of the simpler powerups. --- src/am_map.cpp | 2 +- src/g_inventory/a_artifacts.cpp | 142 ------------------- src/g_inventory/a_artifacts.h | 36 ----- src/namedef.h | 1 + wadsrc/static/zscript/shared/powerups.txt | 160 +++++++++++++++++++--- 5 files changed, 142 insertions(+), 199 deletions(-) diff --git a/src/am_map.cpp b/src/am_map.cpp index 8fb46ed6b..8c250ee68 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -3050,7 +3050,7 @@ void AM_Drawer () return; bool allmap = (level.flags2 & LEVEL2_ALLMAP) != 0; - bool allthings = allmap && players[consoleplayer].mo->FindInventory(RUNTIME_CLASS(APowerScanner), true) != NULL; + bool allthings = allmap && players[consoleplayer].mo->FindInventory(PClass::FindActor(NAME_PowerScanner), true) != nullptr; if (am_portaloverlay) { diff --git a/src/g_inventory/a_artifacts.cpp b/src/g_inventory/a_artifacts.cpp index 17c2269b2..00efa0579 100644 --- a/src/g_inventory/a_artifacts.cpp +++ b/src/g_inventory/a_artifacts.cpp @@ -1481,10 +1481,6 @@ void APowerBuddha::EndEffect () Owner->player->cheats &= ~CF_BUDDHA; } -// Scanner powerup ---------------------------------------------------------- - -IMPLEMENT_CLASS(APowerScanner, false, false) - // Time freezer powerup ----------------------------------------------------- IMPLEMENT_CLASS( APowerTimeFreezer, false, false) @@ -1747,144 +1743,6 @@ void APowerProtection::ModifyDamage(int damage, FName damageType, int &newdamage } } -// Drain rune ------------------------------------------------------- - -IMPLEMENT_CLASS(APowerDrain, false, false) - -//=========================================================================== -// -// ARuneDrain :: InitEffect -// -//=========================================================================== - -void APowerDrain::InitEffect( ) -{ - Super::InitEffect(); - - if (Owner== NULL || Owner->player == NULL) - return; - - // Give the player the power to drain life from opponents when he damages them. - Owner->player->cheats |= CF_DRAIN; -} - -//=========================================================================== -// -// ARuneDrain :: EndEffect -// -//=========================================================================== - -void APowerDrain::EndEffect( ) -{ - Super::EndEffect(); - - // Nothing to do if there's no owner. - if (Owner != NULL && Owner->player != NULL) - { - // Take away the drain power. - Owner->player->cheats &= ~CF_DRAIN; - } -} - - -// Regeneration rune ------------------------------------------------------- - -IMPLEMENT_CLASS(APowerRegeneration, false, false) - -//=========================================================================== -// -// APowerRegeneration :: DoEffect -// -//=========================================================================== - -void APowerRegeneration::DoEffect() -{ - Super::DoEffect(); - if (Owner != NULL && Owner->health > 0 && (level.time & 31) == 0) - { - if (P_GiveBody(Owner, int(Strength))) - { - S_Sound(Owner, CHAN_ITEM, "*regenerate", 1, ATTN_NORM ); - } - } -} - -// High jump rune ------------------------------------------------------- - -IMPLEMENT_CLASS(APowerHighJump, false, false) - -//=========================================================================== -// -// ARuneHighJump :: InitEffect -// -//=========================================================================== - -void APowerHighJump::InitEffect( ) -{ - Super::InitEffect(); - - if (Owner== NULL || Owner->player == NULL) - return; - - // Give the player the power to jump much higher. - Owner->player->cheats |= CF_HIGHJUMP; -} - -//=========================================================================== -// -// ARuneHighJump :: EndEffect -// -//=========================================================================== - -void APowerHighJump::EndEffect( ) -{ - Super::EndEffect(); - // Nothing to do if there's no owner. - if (Owner != NULL && Owner->player != NULL) - { - // Take away the high jump power. - Owner->player->cheats &= ~CF_HIGHJUMP; - } -} - -// Double firing speed rune --------------------------------------------- - -IMPLEMENT_CLASS(APowerDoubleFiringSpeed, false, false) - -//=========================================================================== -// -// APowerDoubleFiringSpeed :: InitEffect -// -//=========================================================================== - -void APowerDoubleFiringSpeed::InitEffect( ) -{ - Super::InitEffect(); - - if (Owner== NULL || Owner->player == NULL) - return; - - // Give the player the power to shoot twice as fast. - Owner->player->cheats |= CF_DOUBLEFIRINGSPEED; -} - -//=========================================================================== -// -// APowerDoubleFiringSpeed :: EndEffect -// -//=========================================================================== - -void APowerDoubleFiringSpeed::EndEffect( ) -{ - Super::EndEffect(); - // Nothing to do if there's no owner. - if (Owner != NULL && Owner->player != NULL) - { - // Take away the shooting twice as fast power. - Owner->player->cheats &= ~CF_DOUBLEFIRINGSPEED; - } -} - // Morph powerup ------------------------------------------------------ IMPLEMENT_CLASS(APowerMorph, false, true) diff --git a/src/g_inventory/a_artifacts.h b/src/g_inventory/a_artifacts.h index 82f93649c..f68516de7 100644 --- a/src/g_inventory/a_artifacts.h +++ b/src/g_inventory/a_artifacts.h @@ -165,11 +165,6 @@ class APowerMinotaur : public APowerup DECLARE_CLASS (APowerMinotaur, APowerup) }; -class APowerScanner : public APowerup -{ - DECLARE_CLASS (APowerScanner, APowerup) -}; - class APowerTargeter : public APowerup { DECLARE_CLASS (APowerTargeter, APowerup) @@ -226,37 +221,6 @@ protected: virtual void ModifyDamage (int damage, FName damageType, int &newdamage, bool passive) override; }; -class APowerDrain : public APowerup -{ - DECLARE_CLASS( APowerDrain, APowerup ) -protected: - virtual void InitEffect() override; - virtual void EndEffect() override; -}; - -class APowerRegeneration : public APowerup -{ - DECLARE_CLASS( APowerRegeneration, APowerup ) -protected: - virtual void DoEffect() override; -}; - -class APowerHighJump : public APowerup -{ - DECLARE_CLASS( APowerHighJump, APowerup ) -protected: - virtual void InitEffect() override; - virtual void EndEffect() override; -}; - -class APowerDoubleFiringSpeed : public APowerup -{ - DECLARE_CLASS( APowerDoubleFiringSpeed, APowerup ) -protected: - virtual void InitEffect() override; - virtual void EndEffect() override; -}; - class APowerMorph : public APowerup { DECLARE_CLASS( APowerMorph, APowerup ) diff --git a/src/namedef.h b/src/namedef.h index d50f8131d..45e1e67f2 100644 --- a/src/namedef.h +++ b/src/namedef.h @@ -354,6 +354,7 @@ xx(MapSpot) xx(PatrolPoint) xx(PatrolSpecial) xx(Communicator) +xx(PowerScanner) // Textmap properties //xx(X) diff --git a/wadsrc/static/zscript/shared/powerups.txt b/wadsrc/static/zscript/shared/powerups.txt index 255372f91..868951166 100644 --- a/wadsrc/static/zscript/shared/powerups.txt +++ b/wadsrc/static/zscript/shared/powerups.txt @@ -213,7 +213,13 @@ class PowerBuddha : Powerup native } } -class PowerScanner : Powerup native +//=========================================================================== +// +// Scanner (this is active just by being present) +// +//=========================================================================== + +class PowerScanner : Powerup { Default { @@ -246,44 +252,138 @@ class PowerProtection : Powerup native } } -class PowerDrain : Powerup native +//=========================================================================== +// +// Drain +// +//=========================================================================== + +class PowerDrain : Powerup { Default { Powerup.Duration -60; } + + override void InitEffect() + { + Super.InitEffect(); + + if (Owner!= null && Owner.player != null) + { + // Give the player the power to drain life from opponents when he damages them. + Owner.player.cheats |= CF_DRAIN; + } + } + + override void EndEffect() + { + Super.EndEffect(); + + // Nothing to do if there's no owner. + if (Owner!= null && Owner.player != null) + { + // Take away the drain power. + Owner.player.cheats &= ~CF_DRAIN; + } + } + } -class PowerRegeneration : Powerup native +//=========================================================================== +// +// Regeneration +// +//=========================================================================== + +class PowerRegeneration : Powerup { Default { Powerup.Duration -120; Powerup.Strength 5; } -} - -class PowerHighJump : Powerup native {} - -class PowerDoubleFiringSpeed : Powerup native {} - -class PowerMorph : Powerup native -{ - native Class PlayerClass; - native Class MorphFlash, UnMorphFlash; - native int MorphStyle; - native PlayerInfo MorphedPlayer; - native bool bInUndoMorph; - - Default + + override void DoEffect() { - Powerup.Duration -40; + Super.DoEffect(); + if (Owner != null && Owner.health > 0 && (level.time & 31) == 0) + { + if (Owner.GiveBody(int(Strength))) + { + Owner.A_PlaySound("*regenerate", CHAN_ITEM); + } + } } } //=========================================================================== // -// PowerInfiniteAmmo +// HighJump +// +//=========================================================================== + +class PowerHighJump : Powerup +{ + override void InitEffect() + { + Super.InitEffect(); + + if (Owner!= null && Owner.player != null) + { + // Give the player the power to jump much higher. + Owner.player.cheats |= CF_HIGHJUMP; + } + } + + override void EndEffect() + { + Super.EndEffect(); + + // Nothing to do if there's no owner. + if (Owner!= null && Owner.player != null) + { + // Take away the high jump power. + Owner.player.cheats &= ~CF_HIGHJUMP; + } + } +} + +//=========================================================================== +// +// DoubleFiringSpeed +// +//=========================================================================== + +class PowerDoubleFiringSpeed : Powerup +{ + override void InitEffect() + { + Super.InitEffect(); + + if (Owner!= null && Owner.player != null) + { + // Give the player the power to shoot twice as fast. + Owner.player.cheats |= CF_DOUBLEFIRINGSPEED; + } + } + + override void EndEffect() + { + Super.EndEffect(); + + // Nothing to do if there's no owner. + if (Owner!= null && Owner.player != null) + { + // Take away the shooting twice as fast power. + Owner.player.cheats &= ~CF_DOUBLEFIRINGSPEED; + } + } +} + +//=========================================================================== +// +// InfiniteAmmo // //=========================================================================== @@ -318,3 +418,23 @@ class PowerInfiniteAmmo : Powerup } } +//=========================================================================== +// +// PowerMorph +// +//=========================================================================== + +class PowerMorph : Powerup native +{ + native Class PlayerClass; + native Class MorphFlash, UnMorphFlash; + native int MorphStyle; + native PlayerInfo MorphedPlayer; + native bool bInUndoMorph; + + Default + { + Powerup.Duration -40; + } +} +