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).

This commit is contained in:
toaster 2019-11-30 16:54:51 +00:00
parent bc00380aa4
commit 515600c4d0

View file

@ -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 dist = P_AproxDistance(sonic->x - tails->x, sonic->y - tails->y);
fixed_t zdist = flip * (sonic->z - tails->z); 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 pmom = P_AproxDistance(sonic->momx, sonic->momy);
fixed_t bmom = P_AproxDistance(tails->momx, tails->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 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 comfortheight = 96 * scale;
fixed_t touchdist = 24 * 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 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! // We can't follow Sonic if he's not around!
if (!sonic || sonic->health <= 0) 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 // Check positioning
// Thinker for co-op flight // Thinker for co-op flight
if (!(water || pmom || bmom) if (!(water || pmom || bmom)
&& (dist < touchdist) && (dist < touchdist && !samepos)
&& !(pcmd->forwardmove || pcmd->sidemove || player->dashspeed) && !(pcmd->forwardmove || pcmd->sidemove || player->dashspeed)
&& P_IsObjectOnGround(sonic) && P_IsObjectOnGround(tails) && P_IsObjectOnGround(sonic) && P_IsObjectOnGround(tails)
&& !(player->pflags & PF_STASIS) && !(player->pflags & PF_STASIS)