From 8154578fb653d7562de383e8962100833cd4add3 Mon Sep 17 00:00:00 2001
From: mazmazz <mar.marcoz@outlook.com>
Date: Sat, 11 Aug 2018 00:09:02 -0400
Subject: [PATCH] Switch Ideya orbiting state to centered offset states when
 orbiting around Drone

---
 src/p_inter.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/src/p_inter.c b/src/p_inter.c
index 688dc685d..f10d680dd 100644
--- a/src/p_inter.c
+++ b/src/p_inter.c
@@ -799,10 +799,18 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
 				{
 					if (toucher->tracer) // Move the ideya over to the drone!
 					{
+						statenum_t currentstate = toucher->tracer->state - states;
 						mobj_t *hnext = special->hnext;
 						P_SetTarget(&special->hnext, toucher->tracer);
 						P_SetTarget(&special->hnext->hnext, hnext); // Buffalo buffalo Buffalo buffalo buffalo buffalo Buffalo buffalo.
 						P_SetTarget(&special->hnext->target, special);
+
+						// switch to centered orbit states
+						if (currentstate >= mobjinfo[MT_GOTEMERALD].missilestate
+							&& currentstate <= mobjinfo[MT_GOTEMERALD].missilestate + 4)
+							P_SetMobjState(toucher->tracer,
+							                mobjinfo[MT_GOTEMERALD].raisestate + currentstate - mobjinfo[MT_GOTEMERALD].missilestate);
+
 						P_SetTarget(&toucher->tracer, NULL);
 						if (hnext)
 						{
@@ -814,8 +822,18 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
 					if (player->exiting) // ...then move it back?
 					{
 						mobj_t *hnext = special;
+						statenum_t currentstate;
 						while ((hnext = hnext->hnext))
+						{
 							P_SetTarget(&hnext->target, toucher);
+							currentstate = hnext->state - states;
+
+							// switch to regular orbit states
+							if (currentstate >= mobjinfo[MT_GOTEMERALD].raisestate
+								&& currentstate <= mobjinfo[MT_GOTEMERALD].raisestate + 4)
+								P_SetMobjState(hnext,
+								 			   mobjinfo[MT_GOTEMERALD].missilestate + currentstate - mobjinfo[MT_GOTEMERALD].raisestate);
+						}
 					}
 					return;
 				}