From 4261e0b61a90f887a4a0548aaf4eab2dcb662a7d Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Wed, 30 Jan 2019 00:30:48 +0100 Subject: [PATCH 1/5] Start of a fix for antigrav --- src/k_kart.c | 40 ++++++++++++++++++++++++++++++++-------- src/p_enemy.c | 1 + src/p_mobj.c | 5 ++++- 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 0410a931..bbca029c 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1309,7 +1309,12 @@ static void K_UpdateOffroad(player_t *player) void K_MatchGenericExtraFlags(mobj_t *mo, mobj_t *master) { // flipping + // handle z shifting from there too; mo->eflags = (mo->eflags & ~MFE_VERTICALFLIP)|(master->eflags & MFE_VERTICALFLIP); + if (mo->eflags & MFE_VERTICALFLIP) + mo->z += master->height - FixedMul(master->scale, mo->height); + + // visibility (usually for hyudoro) mo->flags2 = (mo->flags2 & ~MF2_DONTDRAW)|(master->flags2 & MF2_DONTDRAW); mo->eflags = (mo->eflags & ~MFE_DRAWONLYFORP1)|(master->eflags & MFE_DRAWONLYFORP1); @@ -2400,6 +2405,8 @@ void K_SpawnMineExplosion(mobj_t *source, UINT8 color) { INT32 i, radius, height; mobj_t *smoldering = P_SpawnMobj(source->x, source->y, source->z, MT_SMOLDERING); + K_MatchGenericExtraFlags(smoldering, source); + mobj_t *dust; mobj_t *truc; INT32 speed, speed2; @@ -2423,6 +2430,7 @@ void K_SpawnMineExplosion(mobj_t *source, UINT8 color) truc = P_SpawnMobj(source->x + P_RandomRange(-radius, radius)*FRACUNIT, source->y + P_RandomRange(-radius, radius)*FRACUNIT, source->z + P_RandomRange(0, height)*FRACUNIT, MT_BOOMEXPLODE); + K_MatchGenericExtraFlags(truc, source); P_SetScale(truc, source->scale); truc->destscale = source->scale*6; truc->scalespeed = source->scale/12; @@ -2430,7 +2438,7 @@ void K_SpawnMineExplosion(mobj_t *source, UINT8 color) truc->momx = P_RandomRange(-speed, speed)*FRACUNIT; truc->momy = P_RandomRange(-speed, speed)*FRACUNIT; speed = FixedMul(20*FRACUNIT, source->scale)>>FRACBITS; - truc->momz = P_RandomRange(-speed, speed)*FRACUNIT; + truc->momz = P_RandomRange(-speed, speed)*FRACUNIT*P_MobjFlip(truc); truc->color = color; } @@ -2448,6 +2456,7 @@ void K_SpawnMineExplosion(mobj_t *source, UINT8 color) truc = P_SpawnMobj(source->x + P_RandomRange(-radius, radius)*FRACUNIT, source->y + P_RandomRange(-radius, radius)*FRACUNIT, source->z + P_RandomRange(0, height)*FRACUNIT, MT_BOOMPARTICLE); + K_MatchGenericExtraFlags(truc, source); P_SetScale(truc, source->scale); truc->destscale = source->scale*5; truc->scalespeed = source->scale/12; @@ -2456,7 +2465,7 @@ void K_SpawnMineExplosion(mobj_t *source, UINT8 color) truc->momy = P_RandomRange(-speed, speed)*FRACUNIT; speed = FixedMul(15*FRACUNIT, source->scale)>>FRACBITS; speed2 = FixedMul(45*FRACUNIT, source->scale)>>FRACBITS; - truc->momz = P_RandomRange(speed, speed2)*FRACUNIT; + truc->momz = P_RandomRange(speed, speed2)*FRACUNIT*P_MobjFlip(truc); if (P_RandomChance(FRACUNIT/2)) truc->momz = -truc->momz; truc->tics = TICRATE*2; @@ -2722,6 +2731,9 @@ void K_SpawnBoostTrail(player_t *player) P_SetScale(flame, player->mo->scale); flame->eflags = (flame->eflags & ~MFE_VERTICALFLIP)|(player->mo->eflags & MFE_VERTICALFLIP); // not K_MatchGenericExtraFlags so that a stolen sneaker can be seen + if (flame->eflags & MFE_VERTICALFLIP) + flame->z += player->mo->height - FixedMul(player->mo->scale, flame->height); + flame->momx = 8; P_XYMovement(flame); if (P_MobjWasRemoved(flame)) @@ -2761,6 +2773,8 @@ void K_SpawnSparkleTrail(mobj_t *mo) sparkle->destscale = mo->destscale; P_SetScale(sparkle, mo->scale); sparkle->eflags = (sparkle->eflags & ~MFE_VERTICALFLIP)|(mo->eflags & MFE_VERTICALFLIP); // not K_MatchGenericExtraFlags so that a stolen invincibility can be seen + if (sparkle->eflags & MFE_VERTICALFLIP) + sparkle->z += mo->height - FixedMul(mo->scale, sparkle->height); sparkle->color = mo->color; //sparkle->colorized = mo->colorized; } @@ -2782,6 +2796,8 @@ void K_SpawnWipeoutTrail(mobj_t *mo, boolean translucent) dust->destscale = mo->scale; P_SetScale(dust, mo->scale); dust->eflags = (dust->eflags & ~MFE_VERTICALFLIP)|(mo->eflags & MFE_VERTICALFLIP); // not K_MatchGenericExtraFlags because hyudoro shouldn't be able to wipeout + if (dust->eflags & MFE_VERTICALFLIP) + dust->z += mo->height - FixedMul(mo->scale, dust->height); if (translucent) // offroad effect { @@ -2847,10 +2863,10 @@ void K_DriftDustHandling(mobj_t *spawner) fixed_t spawny = P_RandomRange(-spawnrange, spawnrange)<x + spawnx, spawner->y + spawny, spawner->z, MT_DRIFTDUST); - if (spawner->eflags & MFE_VERTICALFLIP) + /*if (spawner->eflags & MFE_VERTICALFLIP) And say something actually bothered supporting it! MatchGenericExtraFlags does this for us now :D { dust->z += spawner->height - dust->height; - } + }*/ dust->momx = FixedMul(spawner->momx + (P_RandomRange(-speedrange, speedrange)<scale)/4); dust->momy = FixedMul(spawner->momy + (P_RandomRange(-speedrange, speedrange)<scale)/4); dust->momz = P_MobjFlip(spawner) * (P_RandomRange(1, 4) * (spawner->scale)); @@ -3355,7 +3371,7 @@ void K_DoPogoSpring(mobj_t *mo, fixed_t vertispeed, UINT8 sound) thrust = 32<momz = FixedMul(FINESINE(ANGLE_22h>>ANGLETOFINESHIFT), FixedMul(thrust, vscale)); + mo->momz = P_MobjFlip(mo)*FixedMul(FINESINE(ANGLE_22h>>ANGLETOFINESHIFT), FixedMul(thrust, vscale)); } else mo->momz = FixedMul(vertispeed, vscale); @@ -3864,11 +3880,15 @@ static void K_MoveHeldObjects(player_t *player) targx = player->mo->x + P_ReturnThrustX(cur, cur->angle + angoffset, cur->extravalue1); targy = player->mo->y + P_ReturnThrustY(cur, cur->angle + angoffset, cur->extravalue1); + K_MatchGenericExtraFlags(cur, player->mo); // Update graviflip in real time thanks. { // bobbing, copy pasted from my kimokawaiii entry const fixed_t pi = (22<>ANGLETOFINESHIFT) & FINEMASK); targz = (player->mo->z + (player->mo->height/2)) + sine; + if (player->mo->eflags & MFE_VERTICALFLIP) + targz -= player->mo->height/2 - FixedMul(player->mo->scale, cur->height); + } if (cur->tracer) @@ -4424,8 +4444,11 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) if (player->kartstuff[k_comebacktimer]) player->kartstuff[k_comebackmode] = 0; - if (P_IsObjectOnGround(player->mo) && player->mo->momz <= 0 && player->kartstuff[k_pogospring]) - player->kartstuff[k_pogospring] = 0; + if (P_IsObjectOnGround(player->mo) && player->kartstuff[k_pogospring]) + { + if ((player->mo->eflags & MFE_VERTICALFLIP && player->mo->momz >= 0) || (!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->momz <= 0)) + player->kartstuff[k_pogospring] = 0; + } if (cmd->buttons & BT_DRIFT) player->kartstuff[k_jmp] = 1; @@ -4670,7 +4693,7 @@ static void K_KartDrift(player_t *player, boolean onground) player->kartstuff[k_driftend] = 0; } - + // Incease/decrease the drift value to continue drifting in that direction if (player->kartstuff[k_spinouttimer] == 0 && player->kartstuff[k_jmp] == 1 && onground && player->kartstuff[k_drift] != 0) @@ -5043,6 +5066,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) for (moloop = 0; moloop < 2; moloop++) { mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_ROCKETSNEAKER); + K_MatchGenericExtraFlags(mo, player->mo); mo->flags |= MF_NOCLIPTHING; mo->angle = player->mo->angle; mo->threshold = 10; diff --git a/src/p_enemy.c b/src/p_enemy.c index 8a6d7597..c2ec211a 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -8640,6 +8640,7 @@ void A_LightningFollowPlayer(mobj_t *actor) else // else just teleport to player directly P_TeleportMove(actor, actor->target->x, actor->target->y, actor->target->z); + K_MatchGenericExtraFlags(actor, actor->target); // copy our target for graviflip actor->momx = actor->target->momx; actor->momy = actor->target->momy; actor->momz = actor->target->momz; // Give momentum since we don't teleport to our player literally every frame. diff --git a/src/p_mobj.c b/src/p_mobj.c index f71ff209..786276d8 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6651,6 +6651,7 @@ void P_MobjThinker(mobj_t *mobj) fixed_t y = P_RandomRange(-35, 35)*mobj->scale; fixed_t z = P_RandomRange(0, 70)*mobj->scale; mobj_t *smoke = P_SpawnMobj(mobj->x + x, mobj->y + y, mobj->z + z, MT_SMOKE); + K_MatchGenericExtraFlags(smoke, mobj); smoke->scale = mobj->scale * 2; smoke->destscale = mobj->scale * 6; smoke->momz = P_RandomRange(4, 9)*FRACUNIT; @@ -6660,10 +6661,11 @@ void P_MobjThinker(mobj_t *mobj) { fixed_t x = P_RandomRange(-16, 16)*mobj->scale; fixed_t y = P_RandomRange(-16, 16)*mobj->scale; - fixed_t z = P_RandomRange(0, 32)*mobj->scale; + fixed_t z = P_RandomRange(0, 32)*mobj->scale*P_MobjFlip(mobj); if (leveltime % 2 == 0) { mobj_t *smoke = P_SpawnMobj(mobj->x + x, mobj->y + y, mobj->z + z, MT_BOSSEXPLODE); + K_MatchGenericExtraFlags(smoke, mobj); P_SetMobjState(smoke, S_QUICKBOOM1); smoke->scale = mobj->scale/2; smoke->destscale = mobj->scale; @@ -6672,6 +6674,7 @@ void P_MobjThinker(mobj_t *mobj) else { mobj_t *smoke = P_SpawnMobj(mobj->x + x, mobj->y + y, mobj->z + z, MT_SMOKE); + K_MatchGenericExtraFlags(smoke, mobj); smoke->scale = mobj->scale; smoke->destscale = mobj->scale*2; } From 4c19c36fbb7f8e43caed50a16d50cf4b8d17f8d9 Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Wed, 30 Jan 2019 15:25:41 +0100 Subject: [PATCH 2/5] Small optimization + item throwing + battle stuff --- src/k_kart.c | 66 +++++++++++++++++++++++++++++----------------------- src/k_kart.h | 1 + src/p_mobj.c | 30 ++++++++++++++++-------- 3 files changed, 58 insertions(+), 39 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index bbca029c..edb1f3c7 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1305,15 +1305,22 @@ static void K_UpdateOffroad(player_t *player) player->kartstuff[k_offroad] = 0; } +// Adds gravity flipping to an object relative to its master and shifts the z coordinate accordingly. +void K_FlipFromObject(mobj_t *mo, mobj_t *master) +{ + mo->eflags = (mo->eflags & ~MFE_VERTICALFLIP)|(master->eflags & MFE_VERTICALFLIP); + mo->flags2 = (mo->flags2 & ~MF2_OBJECTFLIP)|(master->flags2 & MF2_OBJECTFLIP); + + if (mo->eflags & MFE_VERTICALFLIP) + mo->z += master->height - FixedMul(master->scale, mo->height); +} + // These have to go earlier than its sisters because of K_RespawnChecker... void K_MatchGenericExtraFlags(mobj_t *mo, mobj_t *master) { // flipping // handle z shifting from there too; - mo->eflags = (mo->eflags & ~MFE_VERTICALFLIP)|(master->eflags & MFE_VERTICALFLIP); - if (mo->eflags & MFE_VERTICALFLIP) - mo->z += master->height - FixedMul(master->scale, mo->height); - + K_FlipFromObject(mo, master); // visibility (usually for hyudoro) mo->flags2 = (mo->flags2 & ~MF2_DONTDRAW)|(master->flags2 & MF2_DONTDRAW); @@ -2166,7 +2173,7 @@ void K_ExplodePlayer(player_t *player, mobj_t *source, mobj_t *inflictor) // A b if (source && source != player->mo && source->player) K_PlayHitEmSound(source); - player->mo->momz = 18*mapobjectscale; + player->mo->momz = 18*mapobjectscale*P_MobjFlip(player->mo); // please stop forgetting mobjflip checks!!!! player->mo->momx = player->mo->momy = 0; player->kartstuff[k_sneakertimer] = 0; @@ -2729,10 +2736,8 @@ void K_SpawnBoostTrail(player_t *player) flame->fuse = TICRATE*2; flame->destscale = player->mo->scale; P_SetScale(flame, player->mo->scale); - flame->eflags = (flame->eflags & ~MFE_VERTICALFLIP)|(player->mo->eflags & MFE_VERTICALFLIP); // not K_MatchGenericExtraFlags so that a stolen sneaker can be seen - - if (flame->eflags & MFE_VERTICALFLIP) - flame->z += player->mo->height - FixedMul(player->mo->scale, flame->height); + // not K_MatchGenericExtraFlags so that a stolen sneaker can be seen + K_FlipFromObject(flame, player->mo); flame->momx = 8; P_XYMovement(flame); @@ -2765,6 +2770,7 @@ void K_SpawnSparkleTrail(mobj_t *mo) fixed_t newz = mo->z + mo->momz + (P_RandomRange(0, mo->height>>FRACBITS)<target, mo); sparkle->destscale = mo->destscale; P_SetScale(sparkle, mo->scale); - sparkle->eflags = (sparkle->eflags & ~MFE_VERTICALFLIP)|(mo->eflags & MFE_VERTICALFLIP); // not K_MatchGenericExtraFlags so that a stolen invincibility can be seen - if (sparkle->eflags & MFE_VERTICALFLIP) - sparkle->z += mo->height - FixedMul(mo->scale, sparkle->height); sparkle->color = mo->color; //sparkle->colorized = mo->colorized; } @@ -2795,9 +2798,7 @@ void K_SpawnWipeoutTrail(mobj_t *mo, boolean translucent) dust->angle = R_PointToAngle2(0,0,mo->momx,mo->momy); dust->destscale = mo->scale; P_SetScale(dust, mo->scale); - dust->eflags = (dust->eflags & ~MFE_VERTICALFLIP)|(mo->eflags & MFE_VERTICALFLIP); // not K_MatchGenericExtraFlags because hyudoro shouldn't be able to wipeout - if (dust->eflags & MFE_VERTICALFLIP) - dust->z += mo->height - FixedMul(mo->scale, dust->height); + K_FlipFromObject(dust, mo); if (translucent) // offroad effect { @@ -3007,6 +3008,14 @@ static mobj_t *K_ThrowKartItem(player_t *player, boolean missile, mobjtype_t map { // Shoot forward mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z + player->mo->height/2, mapthing); + //K_FlipFromObject(mo, player->mo); + // These are really weird so let's make it a very specific case to make SURE it works... + if (player->mo->eflags & MFE_VERTICALFLIP) + { + mo->z -= player->mo->height; + mo->flags2 |= MF2_OBJECTFLIP; + mo->eflags |= MFE_VERTICALFLIP; + } mo->threshold = 10; P_SetTarget(&mo->target, player->mo); @@ -3016,18 +3025,24 @@ static mobj_t *K_ThrowKartItem(player_t *player, boolean missile, mobjtype_t map if (mo) { angle_t fa = player->mo->angle>>ANGLETOFINESHIFT; - INT32 HEIGHT = (20 + (dir*10))*mapobjectscale + player->mo->momz; + INT32 HEIGHT = (20 + (dir*10))*mapobjectscale + (player->mo->momz*P_MobjFlip(player->mo)); + P_SetObjectMomZ(mo, HEIGHT, false); mo->momx = player->mo->momx + FixedMul(FINECOSINE(fa), (altthrow == 2 ? 2*PROJSPEED/3 : PROJSPEED)); mo->momy = player->mo->momy + FixedMul(FINESINE(fa), (altthrow == 2 ? 2*PROJSPEED/3 : PROJSPEED)); - mo->momz = P_MobjFlip(player->mo) * HEIGHT; - - if (player->mo->eflags & MFE_VERTICALFLIP) - mo->eflags |= MFE_VERTICALFLIP; } + // this is the small graphic effect that plops in you when you throw an item: throwmo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z + player->mo->height/2, MT_FIREDITEM); P_SetTarget(&throwmo->target, player->mo); + // Ditto: + if (player->mo->eflags & MFE_VERTICALFLIP) + { + throwmo->z -= player->mo->height; + throwmo->flags2 |= MF2_OBJECTFLIP; + throwmo->eflags |= MFE_VERTICALFLIP; + } + throwmo->movecount = 0; // above player } else @@ -3053,9 +3068,7 @@ static mobj_t *K_ThrowKartItem(player_t *player, boolean missile, mobjtype_t map } mo = P_SpawnMobj(newx, newy, newz, mapthing); - - if (P_MobjFlip(player->mo) < 0) - mo->z = player->mo->z + player->mo->height - mo->height; + K_FlipFromObject(mo, player->mo); mo->threshold = 10; P_SetTarget(&mo->target, player->mo); @@ -3081,12 +3094,6 @@ static mobj_t *K_ThrowKartItem(player_t *player, boolean missile, mobjtype_t map } } } - - if (mo) - { - if (player->mo->eflags & MFE_VERTICALFLIP) - mo->eflags |= MFE_VERTICALFLIP; - } } } @@ -3793,6 +3800,7 @@ static void K_MoveHeldObjects(player_t *player) targx = targ->x + P_ReturnThrustX(cur, ang + ANGLE_180, dist); targy = targ->y + P_ReturnThrustY(cur, ang + ANGLE_180, dist); targz = targ->z; + speed = FixedMul(R_PointToDist2(cur->x, cur->y, targx, targy), 3*FRACUNIT/4); if (P_IsObjectOnGround(targ)) targz = cur->floorz; diff --git a/src/k_kart.h b/src/k_kart.h index 3f712091..c54fe698 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -23,6 +23,7 @@ void K_RegisterKartStuff(void); boolean K_IsPlayerLosing(player_t *player); boolean K_IsPlayerWanted(player_t *player); void K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2, boolean bounce, boolean solid); +void K_FlipFromObject(mobj_t *mo, mobj_t *master); void K_MatchGenericExtraFlags(mobj_t *mo, mobj_t *master); void K_RespawnChecker(player_t *player); void K_KartMoveAnimation(player_t *player); diff --git a/src/p_mobj.c b/src/p_mobj.c index 786276d8..769663b7 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6637,7 +6637,7 @@ void P_MobjThinker(mobj_t *mobj) case MT_SINK_SHIELD: if ((mobj->health > 0 && (!mobj->target || !mobj->target->player || mobj->target->player->health <= 0 || mobj->target->player->spectator)) - || (mobj->health <= 0 && mobj->z <= mobj->floorz) + || (mobj->health <= 0 && P_IsObjectOnGround(mobj)) || P_CheckDeathPitCollide(mobj)) // When in death state { P_RemoveMobj(mobj); @@ -6654,7 +6654,7 @@ void P_MobjThinker(mobj_t *mobj) K_MatchGenericExtraFlags(smoke, mobj); smoke->scale = mobj->scale * 2; smoke->destscale = mobj->scale * 6; - smoke->momz = P_RandomRange(4, 9)*FRACUNIT; + smoke->momz = P_RandomRange(4, 9)*FRACUNIT*P_MobjFlip(smoke); } break; case MT_BOOMPARTICLE: @@ -6780,7 +6780,7 @@ void P_MobjThinker(mobj_t *mobj) } else if ((mobj->health > 0 && (!mobj->target || !mobj->target->player || !mobj->target->player->mo || mobj->target->player->health <= 0 || mobj->target->player->spectator)) - || (mobj->health <= 0 && mobj->z <= mobj->floorz) + || (mobj->health <= 0 && P_IsObjectOnGround(mobj)) || P_CheckDeathPitCollide(mobj)) // When in death state { P_RemoveMobj(mobj); @@ -7228,6 +7228,9 @@ void P_MobjThinker(mobj_t *mobj) y = mobj->target->y; z = mobj->target->z + (80*mapobjectscale); } + if (mobj->target->eflags & MFE_VERTICALFLIP) + z += mobj->target->height - FixedMul(mobj->target->scale, mobj->height); + P_TeleportMove(mobj, x, y, z); } break; @@ -7423,7 +7426,7 @@ void P_MobjThinker(mobj_t *mobj) case MT_BANANA: case MT_EGGMANITEM: case MT_SPB: - if (mobj->z <= mobj->floorz) + if (P_IsObjectOnGround(mobj)) { P_RemoveMobj(mobj); return; @@ -7436,7 +7439,7 @@ void P_MobjThinker(mobj_t *mobj) break; case MT_JAWZ: case MT_JAWZ_DUD: - if (mobj->z <= mobj->floorz) + if (P_IsObjectOnGround(mobj)) P_SetMobjState(mobj, mobj->info->xdeathstate); // fallthru case MT_JAWZ_SHIELD: @@ -7470,7 +7473,7 @@ void P_MobjThinker(mobj_t *mobj) /* FALLTHRU */ case MT_SMK_MOLE: mobj->flags2 ^= MF2_DONTDRAW; - if (mobj->z <= mobj->floorz) + if (P_IsObjectOnGround(mobj)) { P_RemoveMobj(mobj); return; @@ -7491,7 +7494,7 @@ void P_MobjThinker(mobj_t *mobj) } mobj->flags2 ^= MF2_DONTDRAW; - if (mobj->z <= mobj->floorz) + if (P_IsObjectOnGround(mobj)) { P_RemoveMobj(mobj); return; @@ -8160,7 +8163,7 @@ void P_MobjThinker(mobj_t *mobj) mobj->friction = ORIG_FRICTION/4; if (mobj->momx || mobj->momy) P_SpawnGhostMobj(mobj); - if (mobj->z <= mobj->floorz && mobj->health > 1) + if (P_IsObjectOnGround(mobj) && mobj->health > 1) { S_StartSound(mobj, mobj->info->activesound); mobj->momx = mobj->momy = 0; @@ -8180,7 +8183,7 @@ void P_MobjThinker(mobj_t *mobj) case MT_SINK: if (mobj->momx || mobj->momy) P_SpawnGhostMobj(mobj); - if (mobj->z <= mobj->floorz) + if (P_IsObjectOnGround(mobj)) { S_StartSound(mobj, mobj->info->deathsound); P_SetMobjState(mobj, S_NULL); @@ -8358,6 +8361,7 @@ void P_MobjThinker(mobj_t *mobj) break; case MT_INSTASHIELDB: mobj->flags2 ^= MF2_DONTDRAW; + K_MatchGenericExtraFlags(mobj, mobj->target); /* FALLTHRU */ case MT_INSTASHIELDA: if (!mobj->target || !mobj->target->health || (mobj->target->player && !mobj->target->player->kartstuff[k_instashield])) @@ -8366,6 +8370,7 @@ void P_MobjThinker(mobj_t *mobj) return; } P_TeleportMove(mobj, mobj->target->x, mobj->target->y, mobj->target->z); + K_MatchGenericExtraFlags(mobj, mobj->target); break; case MT_BATTLEPOINT: if (!mobj->target || P_MobjWasRemoved(mobj->target)) @@ -8386,7 +8391,7 @@ void P_MobjThinker(mobj_t *mobj) if (mobj->movefactor < mobj->target->height) mobj->movefactor = mobj->target->height; } - + K_MatchGenericExtraFlags(mobj, mobj->target); P_TeleportMove(mobj, mobj->target->x, mobj->target->y, mobj->target->z + (mobj->target->height/2) + mobj->movefactor); break; case MT_THUNDERSHIELD: @@ -8511,6 +8516,10 @@ void P_MobjThinker(mobj_t *mobj) mobj->flags2 &= ~MF2_DONTDRAW; } + // Update mobj antigravity status: + mobj->eflags = (mobj->eflags & ~MFE_VERTICALFLIP)|(mobj->target->eflags & MFE_VERTICALFLIP); + mobj->flags2 = (mobj->flags2 & ~MF2_OBJECTFLIP)|(mobj->target->flags2 & MF2_OBJECTFLIP); + // Now for the wheels { const fixed_t rad = FixedMul(mobjinfo[MT_PLAYER].radius, mobj->target->scale); @@ -8532,6 +8541,7 @@ void P_MobjThinker(mobj_t *mobj) P_SetScale(cur, mobj->target->scale); cur->color = mobj->target->color; cur->colorized = true; + K_FlipFromObject(cur, mobj->target); if (mobj->flags2 & MF2_DONTDRAW) cur->flags2 |= MF2_DONTDRAW; From 91ce3617ef995560b92c943190c6410258f28642 Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Mon, 18 Feb 2019 14:00:36 +0100 Subject: [PATCH 3/5] Fix respawning in reverse gravity --- src/d_player.h | 1 + src/g_game.c | 3 +++ src/p_inter.c | 1 + src/p_mobj.c | 13 ++++++++++--- src/p_spec.c | 3 ++- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index b430f20a..73279ef0 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -275,6 +275,7 @@ typedef enum k_nextcheck, // Next checkpoint distance; for p_user.c (was "pw_ncd") k_waypoint, // Waypoints. k_starpostwp, // Temporarily stores player waypoint for... some reason. Used when respawning and finishing. + k_starpostflip, // the last starpost we hit requires flipping? k_respawn, // Timer for the DEZ laser respawn effect k_dropdash, // Charge up for respawn Drop Dash diff --git a/src/g_game.c b/src/g_game.c index f0d221ff..02682b27 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2371,6 +2371,7 @@ void G_PlayerReborn(INT32 player) INT32 bumper; INT32 comebackpoints; INT32 wanted; + INT32 respawnflip; boolean songcredit = false; score = players[player].score; @@ -2411,6 +2412,7 @@ void G_PlayerReborn(INT32 player) starposty = players[player].starposty; starpostz = players[player].starpostz; starpostnum = players[player].starpostnum; + respawnflip = players[player].kartstuff[k_starpostflip]; //SRB2KART starpostangle = players[player].starpostangle; jumpfactor = players[player].jumpfactor; thokitem = players[player].thokitem; @@ -2530,6 +2532,7 @@ void G_PlayerReborn(INT32 player) p->kartstuff[k_comebacktimer] = comebacktime; p->kartstuff[k_wanted] = wanted; p->kartstuff[k_eggmanblame] = -1; + p->kartstuff[k_starpostflip] = respawnflip; // Don't do anything immediately p->pflags |= PF_USEDOWN; diff --git a/src/p_inter.c b/src/p_inter.c index dd27858f..adb7e863 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1468,6 +1468,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) player->starpostz = special->z>>FRACBITS; player->starpostangle = special->angle; player->starpostnum = special->health; + player->kartstuff[k_starpostflip] = special->spawnpoint->options & MTF_OBJECTFLIP; // store flipping //S_StartSound(toucher, special->info->painsound); return; diff --git a/src/p_mobj.c b/src/p_mobj.c index 8626e2df..0f5f5de3 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -11137,7 +11137,7 @@ void P_MovePlayerToSpawn(INT32 playernum, mapthing_t *mthing) if (mthing->options >> ZSHIFT) z -= ((mthing->options >> ZSHIFT) << FRACBITS); if (p->kartstuff[k_respawn]) - z -= 128*FRACUNIT; // Too late for v1, but for later: 128*mapobjectscale; + z -= 128*mapobjectscale; } else { @@ -11145,7 +11145,7 @@ void P_MovePlayerToSpawn(INT32 playernum, mapthing_t *mthing) if (mthing->options >> ZSHIFT) z += ((mthing->options >> ZSHIFT) << FRACBITS); if (p->kartstuff[k_respawn]) - z += 128*FRACUNIT; // Too late for v1, but for later: 128*mapobjectscale; + z += 128*mapobjectscale; } if (mthing->options & MTF_OBJECTFLIP) // flip the player! @@ -11206,7 +11206,14 @@ void P_MovePlayerToStarpost(INT32 playernum) #endif sector->ceilingheight; - z = (p->starpostz + 128) << FRACBITS; // Respawn off the ground + if (mobj->player->kartstuff[k_starpostflip]) + z = (p->starpostz<height; + else + z = (p->starpostz<starpostz + 128) << FRACBITS; // reverse gravity exists, pls + mobj->player->kartstuff[k_starpostflip] = 0; + if (z < floor) z = floor; else if (z > ceiling - mobjinfo[MT_PLAYER].height) diff --git a/src/p_spec.c b/src/p_spec.c index 24f56c43..2088d857 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4247,13 +4247,14 @@ DoneSection2: player->starpostx = player->mo->x>>FRACBITS; player->starposty = player->mo->y>>FRACBITS; player->starpostz = player->mo->floorz>>FRACBITS; + player->kartstuff[k_starpostflip] = player->mo->flags2 = MF2_OBJECTFLIP; // store flipping player->starpostangle = player->mo->angle; //R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy); torn; a momentum-based guess is less likely to be wrong in general, but when it IS wrong, it fucks you over entirely... } else { // SRB2kart 200117 // Reset starposts (checkpoints) info - player->starpostangle = player->starpostx = player->starposty = player->starpostz = 0; + player->starpostangle = player->starpostx = player->starposty = player->starpostz = player->kartstuff[k_starpostflip] = 0; } if (P_IsLocalPlayer(player)) From b621723d232ac2300549fa39973ebf95258afbc4 Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Sat, 9 Mar 2019 17:25:42 +0100 Subject: [PATCH 4/5] Fix boost / rocket sneakers for antigrav --- src/info.c | 4 ++-- src/k_kart.c | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/info.c b/src/info.c index 5701f1c9..bba961d2 100644 --- a/src/info.c +++ b/src/info.c @@ -15018,8 +15018,8 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_NULL, // xdeathstate sfx_None, // deathsound 8, // speed - 8*FRACUNIT, // radius - 8*FRACUNIT, // height + 32*FRACUNIT, // radius + 64*FRACUNIT, // height 1, // display offset 100, // mass 0, // damage diff --git a/src/k_kart.c b/src/k_kart.c index 090af863..32133482 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1299,7 +1299,7 @@ void K_FlipFromObject(mobj_t *mo, mobj_t *master) void K_MatchGenericExtraFlags(mobj_t *mo, mobj_t *master) { // flipping - // handle z shifting from there too; + // handle z shifting from there too. This is here since there's no reason not to flip us if needed when we do this anyway; K_FlipFromObject(mo, master); // visibility (usually for hyudoro) @@ -3274,6 +3274,7 @@ void K_DoSneaker(player_t *player, INT32 type) P_SetTarget(&overlay->target, cur); P_SetTarget(&cur->tracer, overlay); P_SetScale(overlay, (overlay->destscale = 3*cur->scale/4)); + K_FlipFromObject(overlay, cur); } cur = cur->hnext; } @@ -3284,6 +3285,7 @@ void K_DoSneaker(player_t *player, INT32 type) mobj_t *overlay = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_BOOSTFLAME); P_SetTarget(&overlay->target, player->mo); P_SetScale(overlay, (overlay->destscale = player->mo->scale)); + K_FlipFromObject(overlay, player->mo); } } @@ -3895,14 +3897,13 @@ static void K_MoveHeldObjects(player_t *player) targx = player->mo->x + P_ReturnThrustX(cur, cur->angle + angoffset, cur->extravalue1); targy = player->mo->y + P_ReturnThrustY(cur, cur->angle + angoffset, cur->extravalue1); - K_MatchGenericExtraFlags(cur, player->mo); // Update graviflip in real time thanks. { // bobbing, copy pasted from my kimokawaiii entry const fixed_t pi = (22<>ANGLETOFINESHIFT) & FINEMASK); targz = (player->mo->z + (player->mo->height/2)) + sine; if (player->mo->eflags & MFE_VERTICALFLIP) - targz -= player->mo->height/2 - FixedMul(player->mo->scale, cur->height); + targz += (player->mo->height/2 - FixedMul(player->mo->scale, 32*FRACUNIT))*6; // No I don't understand why this works either, but it does. } @@ -3920,7 +3921,7 @@ static void K_MoveHeldObjects(player_t *player) } P_TeleportMove(cur, targx, targy, targz); - + K_FlipFromObject(cur, player->mo); // Update graviflip in real time thanks. num = (num+1) % 2; cur = cur->hnext; } From 0e6083cf02831b765404e4e5094a4da8f62ed1eb Mon Sep 17 00:00:00 2001 From: Latapostrophe Date: Mon, 11 Mar 2019 18:53:23 +0100 Subject: [PATCH 5/5] Fix what was discussed, minus the rocksneaker math which is still shady, but let's not break what currently works --- src/k_kart.c | 10 +++------- src/p_spec.c | 2 +- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 32133482..616a6770 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2864,10 +2864,6 @@ void K_DriftDustHandling(mobj_t *spawner) fixed_t spawny = P_RandomRange(-spawnrange, spawnrange)<x + spawnx, spawner->y + spawny, spawner->z, MT_DRIFTDUST); - /*if (spawner->eflags & MFE_VERTICALFLIP) And say something actually bothered supporting it! MatchGenericExtraFlags does this for us now :D - { - dust->z += spawner->height - dust->height; - }*/ dust->momx = FixedMul(spawner->momx + (P_RandomRange(-speedrange, speedrange)<scale)/4); dust->momy = FixedMul(spawner->momy + (P_RandomRange(-speedrange, speedrange)<scale)/4); dust->momz = P_MobjFlip(spawner) * (P_RandomRange(1, 4) * (spawner->scale)); @@ -3900,10 +3896,10 @@ static void K_MoveHeldObjects(player_t *player) { // bobbing, copy pasted from my kimokawaiii entry const fixed_t pi = (22<>ANGLETOFINESHIFT) & FINEMASK); + fixed_t sine = FixedMul(player->mo->scale, 8 * FINESINE((((2*pi*(4*TICRATE)) * leveltime)>>ANGLETOFINESHIFT) & FINEMASK)); targz = (player->mo->z + (player->mo->height/2)) + sine; if (player->mo->eflags & MFE_VERTICALFLIP) - targz += (player->mo->height/2 - FixedMul(player->mo->scale, 32*FRACUNIT))*6; // No I don't understand why this works either, but it does. + targz += (player->mo->height/2 - 32*player->mo->scale)*6; } @@ -4468,7 +4464,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) if (P_IsObjectOnGround(player->mo) && player->kartstuff[k_pogospring]) { - if ((player->mo->eflags & MFE_VERTICALFLIP && player->mo->momz >= 0) || (!(player->mo->eflags & MFE_VERTICALFLIP) && player->mo->momz <= 0)) + if (P_MobjFlip(player->mo)*player->mo->momz <= 0) player->kartstuff[k_pogospring] = 0; } diff --git a/src/p_spec.c b/src/p_spec.c index 2088d857..67bb7472 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4247,7 +4247,7 @@ DoneSection2: player->starpostx = player->mo->x>>FRACBITS; player->starposty = player->mo->y>>FRACBITS; player->starpostz = player->mo->floorz>>FRACBITS; - player->kartstuff[k_starpostflip] = player->mo->flags2 = MF2_OBJECTFLIP; // store flipping + player->kartstuff[k_starpostflip] = player->mo->flags2 & MF2_OBJECTFLIP; // store flipping player->starpostangle = player->mo->angle; //R_PointToAngle2(0, 0, player->mo->momx, player->mo->momy); torn; a momentum-based guess is less likely to be wrong in general, but when it IS wrong, it fucks you over entirely... } else