From ae36a6d72dadfb730edae74019a23f046d6e2952 Mon Sep 17 00:00:00 2001
From: AJ Martinez <aj@worldsbe.st>
Date: Sat, 4 May 2024 17:29:35 -0700
Subject: [PATCH] Great Value Flame Dash (+ some bubble softening)

---
 src/d_player.h      |  2 ++
 src/k_kart.c        | 23 ++++++++++++++++++-----
 src/lua_playerlib.c |  4 ++++
 src/p_saveg.c       |  2 ++
 4 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/src/d_player.h b/src/d_player.h
index c17b8d48d6..4742002fc3 100644
--- a/src/d_player.h
+++ b/src/d_player.h
@@ -779,6 +779,8 @@ struct player_t
 	UINT16 flamemeter;	// Flame Shield dash meter left
 	UINT8 flamelength;	// Flame Shield dash meter, number of segments
 
+	UINT16 counterdash;	// Flame Shield boost without the flame, largely. Used in places where awarding thrust would affect player control.
+
 	UINT16 ballhogcharge;	// Ballhog charge up -- the higher this value, the more projectiles
 	boolean ballhogtap;		// Ballhog released during charge: used to allow semirapid tapfire
 
diff --git a/src/k_kart.c b/src/k_kart.c
index 571816340b..e231548d42 100644
--- a/src/k_kart.c
+++ b/src/k_kart.c
@@ -3483,6 +3483,16 @@ static void K_GetKartBoostPower(player_t *player)
 		);
 	}
 
+	if (player->counterdash) // "Fake Flame" (bubble, voltage)
+	{
+		fixed_t dash = K_FlameShieldDashVar(player->counterdash);
+		ADDBOOST(
+			dash, // + infinite top speed
+			3*FRACUNIT, // + 300% acceleration
+			FixedMul(FixedDiv(dash, FRACUNIT/2), SLIPTIDEHANDLING/2) // + infinite handling
+		);
+	}
+
 	if (player->wavedashboost)
 	{
 		// NB: This is intentionally under the 25% handleboost threshold required to initiate a sliptide
@@ -8920,6 +8930,9 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
 			S_StartSoundAtVolume(player->mo, sfx_fshld3, 255/3);
 	}
 
+	if (player->counterdash)
+		player->counterdash--;
+
 	if (player->sneakertimer && player->wipeoutslow > 0 && player->wipeoutslow < wipeoutslowtime+1)
 		player->wipeoutslow = wipeoutslowtime+1;
 
@@ -10867,7 +10880,7 @@ static void K_KartDrift(player_t *player, boolean onground)
 			if (player->trickcharge && dokicker)
 			{
 				// 2.2 - Egg-friendly trick stuff
-				if (G_CompatLevel(0x000A))
+				if (G_CompatLevel(0x000B))
 				{
 					player->driftboost += 20;
 					player->wavedashboost += 10;
@@ -10877,7 +10890,7 @@ static void K_KartDrift(player_t *player, boolean onground)
 				else
 				{
 					player->driftboost += TICRATE;
-					player->flamedash += TICRATE/2;
+					player->counterdash += TICRATE/2;
 					P_Thrust(player->mo, pushdir, player->speed / 6);
 				}
 
@@ -13201,11 +13214,11 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
 									{
 										K_ThrowKartItem(player, (player->throwdir > 0), MT_BUBBLESHIELDTRAP, -1, 0, 0);
 										if (player->throwdir == -1)
-										{
-											P_InstaThrust(player->mo, player->mo->angle, player->speed + (80 * mapobjectscale));
+										{		
+											player->counterdash += TICRATE/2;
 											player->wavedashboost += TICRATE;
 											player->wavedashpower = FRACUNIT;
-											player->fakeBoost = TICRATE/2;
+											player->fakeBoost += TICRATE/2;
 										}
 										K_PlayAttackTaunt(player->mo);
 										player->bubbleblowup = 0;
diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c
index d0ba8e5827..432af513a3 100644
--- a/src/lua_playerlib.c
+++ b/src/lua_playerlib.c
@@ -428,6 +428,8 @@ static int player_get(lua_State *L)
 		lua_pushinteger(L, plr->bubbleblowup);
 	else if (fastcmp(field,"flamedash"))
 		lua_pushinteger(L, plr->flamedash);
+	else if (fastcmp(field,"counterdash"))
+		lua_pushinteger(L, plr->counterdash);
 	else if (fastcmp(field,"flamemeter"))
 		lua_pushinteger(L, plr->flamemeter);
 	else if (fastcmp(field,"flamelength"))
@@ -984,6 +986,8 @@ static int player_set(lua_State *L)
 		plr->bubbleblowup = luaL_checkinteger(L, 3);
 	else if (fastcmp(field,"flamedash"))
 		plr->flamedash = luaL_checkinteger(L, 3);
+	else if (fastcmp(field,"counterdash"))
+		plr->counterdash = luaL_checkinteger(L, 3);
 	else if (fastcmp(field,"flamemeter"))
 		plr->flamemeter = luaL_checkinteger(L, 3);
 	else if (fastcmp(field,"flamelength"))
diff --git a/src/p_saveg.c b/src/p_saveg.c
index bef745fdbd..a5a8773189 100644
--- a/src/p_saveg.c
+++ b/src/p_saveg.c
@@ -508,6 +508,7 @@ static void P_NetArchivePlayers(savebuffer_t *save)
 		WRITEUINT8(save->p, players[i].bubblecool);
 		WRITEUINT8(save->p, players[i].bubbleblowup);
 		WRITEUINT16(save->p, players[i].flamedash);
+		WRITEUINT16(save->p, players[i].counterdash);
 		WRITEUINT16(save->p, players[i].flamemeter);
 		WRITEUINT8(save->p, players[i].flamelength);
 
@@ -1109,6 +1110,7 @@ static void P_NetUnArchivePlayers(savebuffer_t *save)
 		players[i].bubblecool = READUINT8(save->p);
 		players[i].bubbleblowup = READUINT8(save->p);
 		players[i].flamedash = READUINT16(save->p);
+		players[i].counterdash = READUINT16(save->p);
 		players[i].flamemeter = READUINT16(save->p);
 		players[i].flamelength = READUINT8(save->p);
 
-- 
GitLab