From ba77b97aaa1ced0063126cda442912c02ab70235 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 12 Aug 2023 15:34:51 -0700 Subject: [PATCH] K_SpawnKartMissile: try to step down for stairs --- src/k_kart.c | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 76b508a51..51ef244de 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4768,14 +4768,15 @@ static mobj_t *K_SpawnKartMissile(mobj_t *source, mobjtype_t type, angle_t an, I th->momy = FixedMul(finalspeed, FINESINE(an>>ANGLETOFINESHIFT)); th->momz = source->momz; - P_CheckPosition(th, x, y, NULL); + // Get floorz and ceilingz + P_SetOrigin(th, x, y, z); if (P_MobjWasRemoved(th)) return NULL; if ((P_IsObjectFlipped(th) - ? tm.ceilingz - source->ceilingz - : tm.floorz - source->floorz) > P_GetThingStepUp(th, x, y)) + ? th->ceilingz - source->ceilingz + : th->floorz - source->floorz) > P_GetThingStepUp(th, x, y)) { // Assuming this is on the boundary of a sector and // the wall is too tall... I'm not bothering with @@ -4795,6 +4796,26 @@ static mobj_t *K_SpawnKartMissile(mobj_t *source, mobjtype_t type, angle_t an, I return NULL; } + if (P_IsObjectOnGround(source)) + { + // If the player is on the ground, make sure the + // missile spawns on the ground, so it smoothly + // travels down stairs. + + // FIXME: This needs a more elegant solution because + // if multiple stairs are crossed, the height + // difference in the end is too great (this affects + // slopes too). + + const fixed_t tz = P_IsObjectFlipped(th) ? th->ceilingz - th->height : th->floorz; + + if (abs(tz - z) <= P_GetThingStepUp(th, x, y)) + { + z = tz; + th->z = z; + } + } + if (source->player != NULL) { th->cusval = source->player->itemscale;