From 515600c4d076546d16420963481912ecb8dfb83d Mon Sep 17 00:00:00 2001 From: toaster Date: Sat, 30 Nov 2019 16:54:51 +0000 Subject: [PATCH] Attempt to detect Tailsbot and Sonic spawning at the same coords and restrict some undesirable stuff happening, just in case we miss any situations (or for the sake of mods). --- src/b_bot.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/b_bot.c b/src/b_bot.c index 895c8d18d..2a546b119 100644 --- a/src/b_bot.c +++ b/src/b_bot.c @@ -56,7 +56,7 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm fixed_t dist = P_AproxDistance(sonic->x - tails->x, sonic->y - tails->y); fixed_t zdist = flip * (sonic->z - tails->z); - angle_t ang = R_PointToAngle2(tails->x, tails->y, sonic->x, sonic->y); + angle_t ang = sonic->angle; fixed_t pmom = P_AproxDistance(sonic->momx, sonic->momy); fixed_t bmom = P_AproxDistance(tails->momx, tails->momy); fixed_t followmax = 128 * 8 * scale; // Max follow distance before AI begins to enter "panic" state @@ -65,6 +65,10 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm fixed_t comfortheight = 96 * scale; fixed_t touchdist = 24 * scale; boolean stalled = (bmom < scale >> 1) && dist > followthres; // Helps to see if the AI is having trouble catching up + boolean samepos = (sonic->x == tails->x && sonic->y == tails->y); + + if (!samepos) + ang = R_PointToAngle2(tails->x, tails->y, sonic->x, sonic->y); // We can't follow Sonic if he's not around! if (!sonic || sonic->health <= 0) @@ -154,7 +158,7 @@ static inline void B_BuildTailsTiccmd(mobj_t *sonic, mobj_t *tails, ticcmd_t *cm // Check positioning // Thinker for co-op flight if (!(water || pmom || bmom) - && (dist < touchdist) + && (dist < touchdist && !samepos) && !(pcmd->forwardmove || pcmd->sidemove || player->dashspeed) && P_IsObjectOnGround(sonic) && P_IsObjectOnGround(tails) && !(player->pflags & PF_STASIS)