From 3b524cbed4aed133fe05ae57881767cc9e3da2c3 Mon Sep 17 00:00:00 2001
From: Christoph Oelckers <coelckers@zdoom.fake>
Date: Sat, 31 Dec 2016 00:20:02 +0100
Subject: [PATCH] - scriptified PowerInfiniteAmmo to test the exported
 functions.

---
 src/g_inventory/a_artifacts.cpp           | 41 +----------------------
 src/g_inventory/a_artifacts.h             |  8 -----
 wadsrc/static/zscript/constants.txt       | 29 ++++++++++++++++
 wadsrc/static/zscript/shared/powerups.txt | 31 ++++++++++++++++-
 4 files changed, 60 insertions(+), 49 deletions(-)

diff --git a/src/g_inventory/a_artifacts.cpp b/src/g_inventory/a_artifacts.cpp
index aac58997e..17c2269b2 100644
--- a/src/g_inventory/a_artifacts.cpp
+++ b/src/g_inventory/a_artifacts.cpp
@@ -259,7 +259,7 @@ DEFINE_ACTION_FUNCTION(APowerup, EndEffect)
 
 void APowerup::CallEndEffect()
 {
-	IFVIRTUAL(APowerup, InitEffect)
+	IFVIRTUAL(APowerup, EndEffect)
 	{
 		VMValue params[1] = { (DObject*)this };
 		VMFrameStack stack;
@@ -1993,42 +1993,3 @@ void APowerMorph::EndEffect( )
 	MorphedPlayer = NULL;
 }
 
-// Infinite Ammo Powerup -----------------------------------------------------
-
-IMPLEMENT_CLASS(APowerInfiniteAmmo, false, false)
-
-//===========================================================================
-//
-// APowerInfiniteAmmo :: InitEffect
-//
-//===========================================================================
-
-void APowerInfiniteAmmo::InitEffect( )
-{
-	Super::InitEffect();
-
-	if (Owner== NULL || Owner->player == NULL)
-		return;
-
-	// Give the player infinite ammo
-	Owner->player->cheats |= CF_INFINITEAMMO;
-}
-
-//===========================================================================
-//
-// APowerInfiniteAmmo :: EndEffect
-//
-//===========================================================================
-
-void APowerInfiniteAmmo::EndEffect( )
-{
-	Super::EndEffect();
-
-	// Nothing to do if there's no owner.
-	if (Owner != NULL && Owner->player != NULL)
-	{
-		// Take away the limitless ammo
-		Owner->player->cheats &= ~CF_INFINITEAMMO;
-	}
-}
-
diff --git a/src/g_inventory/a_artifacts.h b/src/g_inventory/a_artifacts.h
index 36f4d3443..82f93649c 100644
--- a/src/g_inventory/a_artifacts.h
+++ b/src/g_inventory/a_artifacts.h
@@ -257,14 +257,6 @@ protected:
 	virtual void EndEffect() override;
 };
 
-class APowerInfiniteAmmo : public APowerup
-{
-	DECLARE_CLASS( APowerInfiniteAmmo, APowerup )
-protected:
-	virtual void InitEffect() override;
-	virtual void EndEffect() override;
-};
-
 class APowerMorph : public APowerup
 {
 	DECLARE_CLASS( APowerMorph, APowerup )
diff --git a/wadsrc/static/zscript/constants.txt b/wadsrc/static/zscript/constants.txt
index 1d2064aa1..20df35dd7 100644
--- a/wadsrc/static/zscript/constants.txt
+++ b/wadsrc/static/zscript/constants.txt
@@ -1055,3 +1055,32 @@ enum EPuffFlags
 	PF_HITTHINGBLEED = 8,
 	PF_NORANDOMZ = 16
 };
+
+enum EPlayerCheats
+{
+	CF_NOCLIP			= 1 << 0,		// No clipping, walk through barriers.
+	CF_GODMODE			= 1 << 1,		// No damage, no health loss.
+	CF_NOVELOCITY		= 1 << 2,		// Not really a cheat, just a debug aid.
+	CF_NOTARGET			= 1 << 3,		// [RH] Monsters don't target
+	CF_FLY				= 1 << 4,		// [RH] Flying player
+	CF_CHASECAM			= 1 << 5,		// [RH] Put camera behind player
+	CF_FROZEN			= 1 << 6,		// [RH] Don't let the player move
+	CF_REVERTPLEASE		= 1 << 7,		// [RH] Stick camera in player's head if (s)he moves
+	CF_STEPLEFT			= 1 << 9,		// [RH] Play left footstep sound next time
+	CF_FRIGHTENING		= 1 << 10,		// [RH] Scare monsters away
+	CF_INSTANTWEAPSWITCH= 1 << 11,		// [RH] Switch weapons instantly
+	CF_TOTALLYFROZEN	= 1 << 12,		// [RH] All players can do is press +use
+	CF_PREDICTING		= 1 << 13,		// [RH] Player movement is being predicted
+	CF_INTERPVIEW		= 1 << 14,		// [RH] view was changed outside of input, so interpolate one frame
+	CF_DRAIN			= 1 << 16,		// Player owns a drain powerup
+	CF_HIGHJUMP			= 1 << 18,		// more Skulltag flags. Implementation not guaranteed though. ;)
+	CF_REFLECTION		= 1 << 19,
+	CF_PROSPERITY		= 1 << 20,
+	CF_DOUBLEFIRINGSPEED= 1 << 21,		// Player owns a double firing speed artifact
+	CF_EXTREMELYDEAD	= 1 << 22,		// [RH] Reliably let the status bar know about extreme deaths.
+	CF_INFINITEAMMO		= 1 << 23,		// Player owns an infinite ammo artifact
+	CF_BUDDHA2			= 1 << 24,		// [MC] Absolute buddha. No voodoo can kill it either.
+	CF_GODMODE2			= 1 << 25,		// [MC] Absolute godmode. No voodoo can kill it either.
+	CF_BUDDHA			= 1 << 27,		// [SP] Buddha mode - take damage, but don't die
+	CF_NOCLIP2			= 1 << 30,		// [RH] More Quake-like noclip
+};
diff --git a/wadsrc/static/zscript/shared/powerups.txt b/wadsrc/static/zscript/shared/powerups.txt
index 43af361f3..255372f91 100644
--- a/wadsrc/static/zscript/shared/powerups.txt
+++ b/wadsrc/static/zscript/shared/powerups.txt
@@ -281,11 +281,40 @@ class PowerMorph : Powerup native
 	}
 }
 
-class PowerInfiniteAmmo : Powerup native
+//===========================================================================
+//
+// PowerInfiniteAmmo
+//
+//===========================================================================
+
+class PowerInfiniteAmmo : Powerup
 {
 	Default
 	{
 		Powerup.Duration -30;
 	}
+	
+	override void InitEffect()
+	{
+		Super.InitEffect();
+
+		if (Owner!= null && Owner.player != null)
+		{
+			// Give the player infinite ammo
+			Owner.player.cheats |= CF_INFINITEAMMO;
+		}
+	}
+
+	override void EndEffect()
+	{
+		Super.EndEffect();
+
+		// Nothing to do if there's no owner.
+		if (Owner!= null && Owner.player != null)
+		{
+			// Take away the limitless ammo
+			Owner.player.cheats &= ~CF_INFINITEAMMO;
+		}
+	}
 }