From a587ffed57795ec51989d49c8b03c527039f2f4b Mon Sep 17 00:00:00 2001
From: Christoph Oelckers <coelckers@zdoom.fake>
Date: Mon, 13 Jun 2011 10:34:46 +0000
Subject: [PATCH] - added DavidPH's submission for allowing a special state on
 puffs when hitting bleeding actors.

SVN r3234 (trunk)
---
 src/p_local.h  | 3 ++-
 src/p_map.cpp  | 3 +++
 src/p_mobj.cpp | 4 ++++
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/p_local.h b/src/p_local.h
index 9e361168d..b3d58bc3b 100644
--- a/src/p_local.h
+++ b/src/p_local.h
@@ -100,7 +100,8 @@ enum EPuffFlags
 {
 	PF_HITTHING = 1,
 	PF_MELEERANGE = 2,
-	PF_TEMPORARY = 4
+	PF_TEMPORARY = 4,
+	PF_HITTHINGBLEED = 8
 };
 
 AActor *P_SpawnPuff (AActor *source, const PClass *pufftype, fixed_t x, fixed_t y, fixed_t z, angle_t dir, int updown, int flags = 0);
diff --git a/src/p_map.cpp b/src/p_map.cpp
index f72a62004..000946462 100644
--- a/src/p_map.cpp
+++ b/src/p_map.cpp
@@ -3485,6 +3485,9 @@ AActor *P_LineAttack (AActor *t1, angle_t angle, fixed_t distance,
 				(trace.Actor->flags & MF_NOBLOOD) ||
 				(trace.Actor->flags2 & (MF2_INVULNERABLE|MF2_DORMANT)))
 			{
+				if (!(trace.Actor->flags & MF_NOBLOOD))
+					flags |= PF_HITTHINGBLEED;
+
 				// We must pass the unreplaced puff type here 
 				puff = P_SpawnPuff (t1, pufftype, hitx, hity, hitz, angle - ANG180, 2, flags|PF_HITTHING);
 			}
diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp
index 5592e87b8..6016c0487 100644
--- a/src/p_mobj.cpp
+++ b/src/p_mobj.cpp
@@ -4421,6 +4421,10 @@ AActor *P_SpawnPuff (AActor *source, const PClass *pufftype, fixed_t x, fixed_t
 	{
 		puff->SetState (crashstate);
 	}
+	else if ((flags & PF_HITTHINGBLEED) && (crashstate = puff->FindState(NAME_Death, NAME_Extreme, true)) != NULL)
+	{
+		puff->SetState (crashstate);
+	}
 	else if ((flags & PF_MELEERANGE) && puff->MeleeState != NULL)
 	{
 		// handle the hard coded state jump of Doom's bullet puff