From e60ba92a9211371ad89b7530959e556385ab65e2 Mon Sep 17 00:00:00 2001
From: fickleheart <fickle@tinted.red>
Date: Sat, 11 Jan 2020 22:30:07 -0600
Subject: [PATCH] Checkpoint players at star post exact location with Ambush
 flag

---
 src/p_inter.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/p_inter.c b/src/p_inter.c
index 4aa84ba843..d6a47c78f6 100644
--- a/src/p_inter.c
+++ b/src/p_inter.c
@@ -1453,6 +1453,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
 
 			if (cv_coopstarposts.value && G_GametypeUsesCoopStarposts() && (netgame || multiplayer))
 			{
+				mobj_t *checkbase = (special->spawnpoint && (special->spawnpoint->options & MTF_AMBUSH)) ? special : toucher;
 				for (i = 0; i < MAXPLAYERS; i++)
 				{
 					if (playeringame[i])
@@ -1461,8 +1462,8 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
 							continue;
 
 						players[i].starposttime = leveltime;
-						players[i].starpostx = player->mo->x>>FRACBITS;
-						players[i].starposty = player->mo->y>>FRACBITS;
+						players[i].starpostx = checkbase->x>>FRACBITS;
+						players[i].starposty = checkbase->y>>FRACBITS;
 						players[i].starpostz = special->z>>FRACBITS;
 						players[i].starpostangle = special->angle;
 						players[i].starpostscale = player->mo->destscale;
@@ -1483,8 +1484,16 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
 			{
 				// Save the player's time and position.
 				player->starposttime = leveltime;
-				player->starpostx = toucher->x>>FRACBITS;
-				player->starposty = toucher->y>>FRACBITS;
+				if (special->spawnpoint && (special->spawnpoint->options & MTF_AMBUSH))
+				{
+					player->starpostx = special->x>>FRACBITS;
+					player->starposty = special->y>>FRACBITS;
+				}
+				else
+				{
+					player->starpostx = toucher->x>>FRACBITS;
+					player->starposty = toucher->y>>FRACBITS;
+				}
 				player->starpostz = special->z>>FRACBITS;
 				player->starpostangle = special->angle;
 				player->starpostscale = player->mo->destscale;
-- 
GitLab