From 65f2d4b80f857d25aab7961968c6fdfa1c8d3cd4 Mon Sep 17 00:00:00 2001
From: Yukita Mayako <catgirl@goddess.moe>
Date: Wed, 27 May 2015 05:59:42 -0400
Subject: [PATCH] Add PF_SHIELDABILITY

This flag is used as a distinction between the
character ability CA_HOMINGTHOK and the attract
shield's active ability.
---
 src/d_player.h |  3 +--
 src/p_map.c    |  4 ++--
 src/p_mobj.c   |  2 +-
 src/p_user.c   | 30 ++++++++++--------------------
 4 files changed, 14 insertions(+), 25 deletions(-)

diff --git a/src/d_player.h b/src/d_player.h
index b9fcdef75f..5ef19c9ac3 100644
--- a/src/d_player.h
+++ b/src/d_player.h
@@ -152,8 +152,7 @@ typedef enum
 	/*** misc ***/
 	PF_FORCESTRAFE       = 1<<29, // Turning inputs are translated into strafing inputs
 	PF_ANALOGMODE        = 1<<30, // Analog mode?
-
-	// free: 1<<30 and 1<<31
+	PF_SHIELDABILITY     = 1<<31  // Thokked with shield ability
 } pflags_t;
 
 typedef enum
diff --git a/src/p_map.c b/src/p_map.c
index 46e32e3854..ab2b1662ca 100644
--- a/src/p_map.c
+++ b/src/p_map.c
@@ -121,7 +121,7 @@ void P_DoSpring(mobj_t *spring, mobj_t *object)
 		/*Someone want to make these work like bumpers?*/
 		return;
 	}
-	
+
 	object->eflags |= MFE_SPRUNG; // apply this flag asap!
 	spring->flags &= ~(MF_SOLID|MF_SPECIAL); // De-solidify
 
@@ -188,7 +188,7 @@ void P_DoSpring(mobj_t *spring, mobj_t *object)
 				localangle2 = spring->angle;
 		}
 
-		pflags = object->player->pflags & (PF_JUMPED|PF_SPINNING|PF_THOKKED); // I still need these.
+		pflags = object->player->pflags & (PF_JUMPED|PF_SPINNING|PF_THOKKED|PF_SHIELDABILITY); // I still need these.
 		P_ResetPlayer(object->player);
 
 		if (P_MobjFlip(object)*vertispeed > 0)
diff --git a/src/p_mobj.c b/src/p_mobj.c
index b793500926..26ff7b92be 100644
--- a/src/p_mobj.c
+++ b/src/p_mobj.c
@@ -2183,7 +2183,7 @@ static void P_PlayerZMovement(mobj_t *mo)
 
 					if (!(mo->player->pflags & PF_GLIDING))
 						mo->player->pflags &= ~PF_JUMPED;
-					mo->player->pflags &= ~PF_THOKKED;
+					mo->player->pflags &= ~(PF_THOKKED|PF_SHIELDABILITY);
 					//mo->player->pflags &= ~PF_GLIDING;
 					mo->player->jumping = 0;
 					mo->player->secondjump = 0;
diff --git a/src/p_user.c b/src/p_user.c
index ad0b7b76a6..089c0dc9b3 100644
--- a/src/p_user.c
+++ b/src/p_user.c
@@ -661,7 +661,7 @@ void P_NightserizePlayer(player_t *player, INT32 nighttime)
 		player->mo->height = player->mo->tracer->height;
 	}
 
-	player->pflags &= ~(PF_USEDOWN|PF_JUMPDOWN|PF_ATTACKDOWN|PF_STARTDASH|PF_GLIDING|PF_JUMPED|PF_THOKKED|PF_SPINNING|PF_DRILLING);
+	player->pflags &= ~(PF_USEDOWN|PF_JUMPDOWN|PF_ATTACKDOWN|PF_STARTDASH|PF_GLIDING|PF_JUMPED|PF_THOKKED|PF_SHIELDABILITY|PF_SPINNING|PF_DRILLING);
 	player->homing = 0;
 	player->mo->fuse = 0;
 	player->speed = 0;
@@ -874,7 +874,7 @@ void P_DoPlayerPain(player_t *player, mobj_t *source, mobj_t *inflictor)
 // Useful when you want to kill everything the player is doing.
 void P_ResetPlayer(player_t *player)
 {
-	player->pflags &= ~(PF_ROPEHANG|PF_ITEMHANG|PF_MACESPIN|PF_SPINNING|PF_JUMPED|PF_GLIDING|PF_THOKKED|PF_CARRIED);
+	player->pflags &= ~(PF_ROPEHANG|PF_ITEMHANG|PF_MACESPIN|PF_SPINNING|PF_JUMPED|PF_GLIDING|PF_THOKKED|PF_SHIELDABILITY|PF_CARRIED);
 	player->jumping = 0;
 	player->secondjump = 0;
 	player->glidetime = 0;
@@ -6797,7 +6797,7 @@ static void P_MovePlayer(player_t *player)
 				{
 					if (!(player->pflags & PF_THOKKED))
 					{
-						player->pflags |= PF_THOKKED;
+						player->pflags |= PF_THOKKED|PF_SHIELDABILITY;
 						player->homing = 2;
 						if (P_LookForEnemies(player, false) && player->mo->tracer)
 							player->homing = 3*TICRATE;
@@ -6818,25 +6818,15 @@ static void P_MovePlayer(player_t *player)
 		}
 	}
 
-	if ((player->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT)
-	{
-		if (player->homing && player->mo->tracer)
-		{
-			if (!(player->pflags & PF_JUMPED)
-			|| player->mo->tracer->health <= 0
-			|| player->mo->tracer->flags2 & MF2_FRET)
-				player->homing = 0;
-			else
-				P_HomingAttack(player->mo, player->mo->tracer);
-		}
-	}
 	// HOMING option.
-	else if (player->charability == CA_HOMINGTHOK)
+	if (player->charability == CA_HOMINGTHOK
+	|| (player->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT)
 	{
 		// If you've got a target, chase after it!
 		if (player->homing && player->mo->tracer)
 		{
-			P_SpawnThokMobj(player);
+			if (!(player->pflags & PF_SHIELDABILITY))
+				P_SpawnThokMobj(player);
 			P_HomingAttack(player->mo, player->mo->tracer);
 
 			// But if you don't, then stop homing.
@@ -6852,7 +6842,7 @@ static void P_MovePlayer(player_t *player)
 				if (player->mo->tracer->flags2 & MF2_FRET)
 					P_InstaThrust(player->mo, player->mo->angle, -(player->speed>>3));
 
-				if (!(player->mo->tracer->flags & MF_BOSS))
+				if (!(player->pflags & PF_SHIELDABILITY) && !(player->mo->tracer->flags & MF_BOSS))
 					player->pflags &= ~PF_THOKKED;
 			}
 		}
@@ -7549,9 +7539,9 @@ void P_HomingAttack(mobj_t *source, mobj_t *enemy) // Home in on your target
 	}
 	else if (source->player)
 	{
-		if (source->player->charability == CA_HOMINGTHOK)
+		if (source->player->charability == CA_HOMINGTHOK && !(source->player->pflags & PF_SHIELDABILITY))
 			ns = FixedDiv(FixedMul(source->player->actionspd, source->scale), 3*FRACUNIT/2);
-		else //if ((player->powers[pw_shield] & SH_NOSTACK) == SH_ATTRACT)
+		else
 			ns = FixedMul(80*FRACUNIT, source->scale);
 	}
 
-- 
GitLab