diff --git a/src/k_kart.c b/src/k_kart.c index 9059c1ba..37f1a43d 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1842,18 +1842,6 @@ static mobj_t *K_SpawnKartMissile(mobj_t *source, mobjtype_t type, angle_t angle th->flags2 |= flags2; - if (P_IsObjectOnGround(source)) - { - // spawn on the ground if the player is on the ground - if (P_MobjFlip(source) < 0) - { - th->z = th->ceilingz - th->height; - th->eflags |= MFE_VERTICALFLIP; - } - else - th->z = th->floorz; - } - th->threshold = 10; #ifdef WEAPON_SFX @@ -1868,6 +1856,21 @@ static mobj_t *K_SpawnKartMissile(mobj_t *source, mobjtype_t type, angle_t angle P_SetTarget(&th->target, source); + if (P_IsObjectOnGround(source)) + { + // floorz and ceilingz aren't properly set to account for FOFs and Polyobjects on spawn + // This should set it for FOFs + P_TeleportMove(th, th->x, th->y, th->z); + // spawn on the ground if the player is on the ground + if (P_MobjFlip(source) < 0) + { + th->z = th->ceilingz - th->height; + th->eflags |= MFE_VERTICALFLIP; + } + else + th->z = th->floorz; + } + th->angle = an; th->momx = FixedMul(speed, FINECOSINE(an>>ANGLETOFINESHIFT)); th->momy = FixedMul(speed, FINESINE(an>>ANGLETOFINESHIFT)); @@ -2072,9 +2075,34 @@ static mobj_t *K_ThrowKartItem(player_t *player, boolean missile, mobjtype_t map mo = P_SpawnMobj(newx, newy, player->mo->z, mapthing); + if (P_MobjFlip(player->mo) < 0) + mo->z = player->mo->z + player->mo->height - mo->height; + mo->threshold = 10; P_SetTarget(&mo->target, player->mo); + if (P_IsObjectOnGround(player->mo)) + { + // floorz and ceilingz aren't properly set to account for FOFs and Polyobjects on spawn + // This should set it for FOFs + P_TeleportMove(mo, mo->x, mo->y, mo->z); + + if (P_MobjFlip(mo) > 0) + { + if (mo->floorz > mo->target->z - mo->height) + { + mo->z = mo->floorz; + } + } + else + { + if (mo->ceilingz < mo->target->z + mo->target->height + mo->height) + { + mo->z = mo->ceilingz - mo->height; + } + } + } + if (mo) { if (player->mo->eflags & MFE_VERTICALFLIP) diff --git a/src/p_mobj.c b/src/p_mobj.c index 8370fb64..aa2d0ff3 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2303,6 +2303,14 @@ static boolean P_ZMovement(mobj_t *mo) case MT_BIGTUMBLEWEED: case MT_LITTLETUMBLEWEED: case MT_SHELL: + // SRB2kart stuff that should die in pits + // Shouldn't stop moving along the Z if there's no speed though! + case MT_FAKEITEM: + case MT_BANANAITEM: + case MT_GREENITEM: + case MT_REDITEM: + case MT_REDITEMDUD: + case MT_FIREBALL: // Remove stuff from death pits. if (P_CheckDeathPitCollide(mo)) { @@ -2329,13 +2337,6 @@ static boolean P_ZMovement(mobj_t *mo) case MT_FLINGCOIN: case MT_FLINGRANDOMITEM: case MT_FLINGEMERALD: - // SRB2kart stuff that should die in pits - case MT_RANDOMITEM: - case MT_BANANAITEM: - case MT_GREENITEM: - case MT_REDITEM: - case MT_REDITEMDUD: - case MT_FIREBALL: // Remove flinged stuff from death pits. if (P_CheckDeathPitCollide(mo)) {