From cc2704bc87a05a1349c0a9c9fd326e0d0b810e8a Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Tue, 2 Feb 2021 22:36:56 -0500 Subject: [PATCH 01/11] Death animation Art is missing, but functionality is complete. The kart corpse is also placeable as type 4095. No way to set its color currently, it simply defaults to SKINCOLOR_RED. --- src/dehacked.c | 10 ++++++- src/info.c | 70 +++++++++++++++++++++++++++++++++++++++++--- src/info.h | 14 +++++++-- src/k_kart.c | 8 +++++ src/p_inter.c | 38 ++++++++++++++++++++++-- src/p_map.c | 15 ++++++++++ src/p_mobj.c | 79 +++++++++++++++++++++++++++++++++++++++++++------- src/p_user.c | 2 +- 8 files changed, 215 insertions(+), 21 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index 57571b0c0..d71bc6da6 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -5217,12 +5217,18 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_KART_DRIFT_R_OUT", "S_KART_DRIFT_R_IN", "S_KART_SPINOUT", - "S_KART_SQUISH", + "S_KART_DEAD", "S_KART_SIGN", // technically the player goes here but it's an infinite tic state "S_OBJPLACE_DUMMY", + "S_KART_LEFTOVER", + "S_KART_LEFTOVER_NOTIRES", + + "S_KART_TIRE1", + "S_KART_TIRE2", + // Blue Crawla "S_POSS_STND", "S_POSS_RUN1", @@ -9421,6 +9427,8 @@ static const char *const MOBJTYPE_LIST[] = { // array length left dynamic for s "MT_THOK", // Thok! mobj "MT_PLAYER", + "MT_KART_LEFTOVER", + "MT_KART_TIRE", // Enemies "MT_BLUECRAWLA", // Crawla (Blue) diff --git a/src/info.c b/src/info.c index d804c5978..7e8ad8c17 100644 --- a/src/info.c +++ b/src/info.c @@ -32,6 +32,8 @@ char sprnames[NUMSPRITES + 1][5] = "THOK", // Thok! mobj "PLAY", + "KART", + "TIRE", // Enemies "POSS", // Crawla (Blue) @@ -753,7 +755,7 @@ char spr2names[NUMPLAYERSPRITES][5] = "DRLN", "DRLO", "DRLI", // Drifting left "DRRN", "DRRO", "DRRI", // Drifting right "SPIN", // Spinout - "SQSH", // Squish + "DEAD", // Dead "SIGN", // Finish signpost "XTRA", // Three Faces of Darkness }; @@ -781,7 +783,7 @@ playersprite_t spr2defaults[NUMPLAYERSPRITES] = { SPR2_DRRN, // SPR2_DRRI 0, // SPR2_SPIN - SPR2_SPIN, // SPR2_SQSH + 0, // SPR2_DEAD 0, // SPR2_SIGN }; @@ -827,11 +829,17 @@ state_t states[NUMSTATES] = {SPR_PLAY, SPR2_DRRO, 1, {NULL}, 0, 0, S_KART_DRIFT_R_OUT}, // S_KART_DRIFT_R_OUT {SPR_PLAY, SPR2_DRRI, 1, {NULL}, 0, 0, S_KART_DRIFT_R_IN}, // S_KART_DRIFT_R_IN {SPR_PLAY, SPR2_SPIN|FF_ANIMATE, 350, {NULL}, 0, 1, S_KART_STILL}, // S_KART_SPINOUT - {SPR_PLAY, SPR2_SQSH|FF_ANIMATE, 350, {NULL}, 0, 1, S_KART_STILL}, // S_KART_SQUISH + {SPR_PLAY, SPR2_DEAD, 3, {NULL}, 0, 0, S_KART_DEAD}, // S_KART_DEAD {SPR_PLAY, SPR2_SIGN|FF_PAPERSPRITE, 1, {NULL}, 0, 0, S_KART_SIGN}, // S_KART_SIGN {SPR_NULL, 0, -1, {NULL}, 0, 0, S_OBJPLACE_DUMMY}, // S_OBJPLACE_DUMMY + {SPR_KART, 0, -1, {NULL}, 0, 0, S_NULL}, // S_KART_LEFTOVER + {SPR_KART, 1, -1, {NULL}, 0, 0, S_NULL}, // S_KART_LEFTOVER_NOTIRES + + {SPR_TIRE, 0, -1, {NULL}, 0, 0, S_NULL}, // S_KART_TIRE1 + {SPR_TIRE, 1, -1, {NULL}, 0, 0, S_NULL}, // S_KART_TIRE2 + // Blue Crawla {SPR_POSS, 0, 5, {A_Look}, 0, 0, S_POSS_STND}, // S_POSS_STND {SPR_POSS, 0, 3, {A_Chase}, 0, 0, S_POSS_RUN2}, // S_POSS_RUN1 @@ -5227,7 +5235,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = sfx_None, // painsound S_NULL, // meleestate S_NULL, // missilestate - S_KART_SPINOUT, // deathstate + S_KART_DEAD, // deathstate S_NULL, // xdeathstate sfx_None, // deathsound 1, // speed @@ -5241,6 +5249,60 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = (statenum_t)MT_THOK // raisestate }, + { // MT_KART_LEFTOVER + 4095, // doomednum + S_KART_LEFTOVER, // spawnstate + 2, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 0, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 1, // speed + 16*FRACUNIT, // radius + 48*FRACUNIT, // height + -1, // display offset + 1000, // mass + 0, // damage + sfx_None, // activesound + MF_SOLID|MF_DONTENCOREMAP, // flags + S_NULL // raisestate + }, + + { // MT_KART_TIRE + -1, // doomednum + S_KART_TIRE1, // spawnstate + 1, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 0, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 1, // speed + 6*FRACUNIT, // radius + 12*FRACUNIT, // height + -1, // display offset + 1000, // mass + 0, // damage + sfx_None, // activesound + MF_DONTENCOREMAP, // flags + S_NULL // raisestate + }, + { // MT_BLUECRAWLA 100, // doomednum S_POSS_STND, // spawnstate diff --git a/src/info.h b/src/info.h index 099f9c412..236279097 100644 --- a/src/info.h +++ b/src/info.h @@ -303,6 +303,8 @@ typedef enum sprite SPR_THOK, // Thok! mobj SPR_PLAY, + SPR_KART, + SPR_TIRE, // Enemies SPR_POSS, // Crawla (Blue) @@ -1031,7 +1033,7 @@ typedef enum playersprite SPR2_DRLN, SPR2_DRLO, SPR2_DRLI, SPR2_DRRN, SPR2_DRRO, SPR2_DRRI, SPR2_SPIN, - SPR2_SQSH, + SPR2_DEAD, SPR2_SIGN, SPR2_XTRA, SPR2_FIRSTFREESLOT, @@ -1072,12 +1074,18 @@ typedef enum state S_KART_DRIFT_R_OUT, S_KART_DRIFT_R_IN, S_KART_SPINOUT, - S_KART_SQUISH, + S_KART_DEAD, S_KART_SIGN, // technically the player goes here but it's an infinite tic state S_OBJPLACE_DUMMY, + S_KART_LEFTOVER, + S_KART_LEFTOVER_NOTIRES, + + S_KART_TIRE1, + S_KART_TIRE2, + // Blue Crawla S_POSS_STND, S_POSS_RUN1, @@ -5315,6 +5323,8 @@ typedef enum mobj_type MT_THOK, // Thok! mobj MT_PLAYER, + MT_KART_LEFTOVER, + MT_KART_TIRE, // Enemies MT_BLUECRAWLA, // Crawla (Blue) diff --git a/src/k_kart.c b/src/k_kart.c index 5b259a050..3006d1f66 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1010,6 +1010,14 @@ fixed_t K_GetMobjWeight(mobj_t *mobj, mobj_t *against) break; weight = K_PlayerWeight(mobj, against); break; + case MT_KART_LEFTOVER: + weight = 5*FRACUNIT/2; + + if (mobj->extravalue1 > 0) + { + weight = mobj->extravalue1 * (FRACUNIT >> 1); + } + break; case MT_BUBBLESHIELD: weight = K_PlayerWeight(mobj->target, against); break; diff --git a/src/p_inter.c b/src/p_inter.c index 5be3cc736..9d677069b 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1371,13 +1371,47 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget case MT_PLAYER: { + angle_t flingAngle; + mobj_t *kart; + target->fuse = TICRATE*3; // timer before mobj disappears from view (even if not an actual player) target->momx = target->momy = target->momz = 0; - if (target->player && target->player->pflags & PF_GAMETYPEOVER) - break; + kart = P_SpawnMobjFromMobj(target, 0, 0, 0, MT_KART_LEFTOVER); + if (kart && !P_MobjWasRemoved(kart)) + { + kart->angle = target->angle; + kart->color = target->color; + kart->hitlag = target->hitlag; + P_SetObjectMomZ(kart, 6*FRACUNIT, false); + kart->extravalue1 = target->player->kartweight; + } + + if (source && !P_MobjWasRemoved(source)) + { + flingAngle = R_PointToAngle2( + source->x - source->momx, source->y - source->momy, + target->x, target->y + ); + } + else + { + flingAngle = target->angle + ANGLE_180; + + if (P_RandomByte() & 1) + { + flingAngle -= ANGLE_45; + } + else + { + flingAngle += ANGLE_45; + } + } + + P_InstaThrust(target, flingAngle, 14 * target->scale); P_SetObjectMomZ(target, 14*FRACUNIT, false); + P_PlayDeathSound(target); } break; diff --git a/src/p_map.c b/src/p_map.c index 8c9db9ce4..a8ff6a5a8 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1398,6 +1398,21 @@ static boolean PIT_CheckThing(mobj_t *thing) return false; } + else if (thing->type == MT_KART_LEFTOVER) + { + // see if it went over / under + if (tmthing->z > thing->z + thing->height) + return true; // overhead + if (tmthing->z + tmthing->height < thing->z) + return true; // underneath + + if (P_IsObjectOnGround(thing) && tmthing->momz < 0) + K_KartBouncing(tmthing, thing, true, false); + else + K_KartBouncing(tmthing, thing, false, false); + + return false; + } else if (thing->flags & MF_SOLID) { // see if it went over / under diff --git a/src/p_mobj.c b/src/p_mobj.c index 2cbabfd9a..3033256d5 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -242,7 +242,7 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) player->panim = PA_DASH; break; case S_KART_SPINOUT: - case S_KART_SQUISH: + case S_KART_DEAD: player->panim = PA_PAIN; break; default: @@ -2334,6 +2334,68 @@ boolean P_ZMovement(mobj_t *mo) if (mo->flags2 & MF2_SKULLFLY) // the skull slammed into something mom.z = -mom.z; + else if (mo->type == MT_KART_LEFTOVER) + { + if (mo->health > 1) + { + const fixed_t tireOffset = 32; + const angle_t aOffset = ANGLE_22h; + + UINT8 i; + angle_t tireAngle; + mobj_t *tire; + + // Spawn tires! + mo->health = 1; + P_SetMobjState(mo, S_KART_LEFTOVER_NOTIRES); + + // Front tires + tireAngle = mo->angle - aOffset; + for (i = 0; i < 2; i++) + { + tire = P_SpawnMobjFromMobj( + mo, + tireOffset * FINECOSINE(tireAngle >> ANGLETOFINESHIFT), + tireOffset * FINESINE(tireAngle >> ANGLETOFINESHIFT), + 0, + MT_KART_TIRE + ); + + tire->angle = mo->angle; + tire->fuse = 3*TICRATE; + P_InstaThrust(tire, tireAngle, 4 * mo->scale); + P_SetObjectMomZ(tire, 4*FRACUNIT, false); + + tireAngle += (aOffset * 2); + } + + // Back tires + tireAngle = (mo->angle + ANGLE_180) - aOffset; + for (i = 0; i < 2; i++) + { + tire = P_SpawnMobjFromMobj( + mo, + tireOffset * FINECOSINE(tireAngle >> ANGLETOFINESHIFT), + tireOffset * FINESINE(tireAngle >> ANGLETOFINESHIFT), + 0, + MT_KART_TIRE + ); + + tire->angle = mo->angle; + tire->fuse = 3*TICRATE; + P_InstaThrust(tire, tireAngle, 4 * mo->scale); + P_SetObjectMomZ(tire, 4*FRACUNIT, false); + + P_SetMobjState(tire, S_KART_TIRE2); + + tireAngle += (aOffset * 2); + } + } + } + else if (mo->type == MT_KART_TIRE) + { + mom.z = -mom.z; + } else if (mo->type == MT_BIGTUMBLEWEED || mo->type == MT_LITTLETUMBLEWEED || mo->type == MT_CANNONBALLDECOR @@ -5867,8 +5929,11 @@ static boolean P_MobjDeadThink(mobj_t *mobj) { // Go away. /// \todo Actually go ahead and remove mobj completely, and fix any bugs and crashes doing this creates. Chasecam should stop moving, and F12 should never return to it. mobj->momz = 0; + if (mobj->player) + { mobj->drawflags |= MFD_DONTDRAW; + } else // safe to remove, nobody's going to complain! { P_RemoveMobj(mobj); @@ -5877,16 +5942,6 @@ static boolean P_MobjDeadThink(mobj_t *mobj) } else // Apply gravity to fall downwards. { - if (mobj->player && !(mobj->fuse % 8) && (mobj->player->charflags & SF_MACHINE)) - { - fixed_t r = mobj->radius >> FRACBITS; - mobj_t *explosion = P_SpawnMobj( - mobj->x + (P_RandomRange(r, -r) << FRACBITS), - mobj->y + (P_RandomRange(r, -r) << FRACBITS), - mobj->z + (P_RandomKey(mobj->height >> FRACBITS) << FRACBITS), - MT_SONIC3KBOSSEXPLODE); - S_StartSound(explosion, sfx_s3kb4); - } P_SetObjectMomZ(mobj, -2*FRACUNIT/3, true); } break; @@ -9079,6 +9134,7 @@ static void P_DefaultMobjShadowScale(mobj_t *thing) switch (thing->type) { case MT_PLAYER: + case MT_KART_LEFTOVER: case MT_SMALLMACE: case MT_BIGMACE: case MT_PUMA: @@ -9371,6 +9427,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->color = (P_RandomChance(FRACUNIT/2) ? SKINCOLOR_RED : SKINCOLOR_AQUAMARINE); break; case MT_BALLOON: + case MT_KART_LEFTOVER: mobj->color = SKINCOLOR_RED; break; case MT_EGGROBO1: diff --git a/src/p_user.c b/src/p_user.c index 0df4aa756..adaa9333b 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3075,7 +3075,7 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall mo = player->mo; - if (mo->hitlag > 0) + if (mo->hitlag > 0 || player->playerstate == PST_DEAD) { // Do not move the camera while in hitlag! // The camera zooming out after you got hit makes it hard to focus on the vibration. From c698ddaa6c380bded113ec49c133ad29aaf9e317 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Tue, 2 Feb 2021 22:44:53 -0500 Subject: [PATCH 02/11] Balloons by default will randomly pick CNZ colors Would like this actually for CNZ instead of manually picking them by number & then the numbers get desynced... :v --- src/k_respawn.c | 4 ++-- src/p_mobj.c | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/k_respawn.c b/src/k_respawn.c index ff7830c32..7052fe466 100644 --- a/src/k_respawn.c +++ b/src/k_respawn.c @@ -122,9 +122,9 @@ void K_DoIngameRespawn(player_t *player) // If player was tumbling, set variables so that they don't tumble like crazy after they're done respawning if (player->tumbleBounces > 0) { - player->tumbleBounces = TUMBLEBOUNCES-1; // Max # of bounces-1 (so you still tumble once) + player->tumbleBounces = TUMBLEBOUNCES-1; // Max # of bounces-1 (so you still tumble once) player->tumbleLastBounce = false; // Still force them to bounce at least once for the funny - players->tumbleHeight = 20; // force tumble height + players->tumbleHeight = 20; // force tumble height } P_ResetPlayer(player); diff --git a/src/p_mobj.c b/src/p_mobj.c index 3033256d5..6b5e6fcf4 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9427,6 +9427,18 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->color = (P_RandomChance(FRACUNIT/2) ? SKINCOLOR_RED : SKINCOLOR_AQUAMARINE); break; case MT_BALLOON: + { + static const UINT8 BALLOONCOLORS[] = { + // Carnival Night balloon colors + SKINCOLOR_KETCHUP, + SKINCOLOR_SAPPHIRE, + SKINCOLOR_TANGERINE, + SKINCOLOR_JET + }; + + mobj->color = BALLOONCOLORS[P_RandomKey(sizeof(BALLOONCOLORS))]; + } + break; case MT_KART_LEFTOVER: mobj->color = SKINCOLOR_RED; break; From c178ca6c1a043ebb0ab545a62c870169ecbb28f2 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Tue, 2 Feb 2021 22:47:22 -0500 Subject: [PATCH 03/11] Fix CHECK in splitscreen --- src/k_hud.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/k_hud.c b/src/k_hud.c index 55f84ca4c..ba3a8dcd1 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -2402,6 +2402,7 @@ static void K_drawKartPlayerCheck(void) UINT8 cnum = 0; UINT8 i; INT32 splitflags = V_SNAPTOBOTTOM|V_SPLITSCREEN; + fixed_t y = CHEK_Y * FRACUNIT; if (stplyr == NULL || stplyr->mo == NULL || P_MobjWasRemoved(stplyr->mo)) { @@ -2420,6 +2421,8 @@ static void K_drawKartPlayerCheck(void) if (r_splitscreen) { + y /= 2; + for (i = 1; i <= r_splitscreen; i++) { if (stplyr == &players[displayplayers[i]]) @@ -2492,7 +2495,7 @@ static void K_drawKartPlayerCheck(void) K_ObjectTracking(&x, NULL, &c, thiscam->angle + ANGLE_180, 0, &v, cnum); colormap = R_GetTranslationColormap(TC_DEFAULT, checkplayer->mo->color, GTC_CACHE); - V_DrawFixedPatch(x, CHEK_Y * FRACUNIT, FRACUNIT, V_HUDTRANS|V_SPLITSCREEN|splitflags, kp_check[pnum], colormap); + V_DrawFixedPatch(x, y, FRACUNIT, V_HUDTRANS|V_SPLITSCREEN|splitflags, kp_check[pnum], colormap); } } From bea2724a86058a2335db019d6bafeab4d98d71cf Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Wed, 3 Feb 2021 01:24:00 -0500 Subject: [PATCH 04/11] Glance frames When someone is about to pass you, you'll take a glance at 'em! --- src/dehacked.c | 6 +++ src/info.c | 19 +++++-- src/info.h | 12 +++-- src/k_kart.c | 143 +++++++++++++++++++++++++++++++++++++++++++++++-- 4 files changed, 171 insertions(+), 9 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index d71bc6da6..781c41864 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -5204,12 +5204,18 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_KART_STILL", "S_KART_STILL_L", "S_KART_STILL_R", + "S_KART_STILL_GLANCE_L", + "S_KART_STILL_GLANCE_R", "S_KART_SLOW", "S_KART_SLOW_L", "S_KART_SLOW_R", + "S_KART_SLOW_GLANCE_L", + "S_KART_SLOW_GLANCE_R", "S_KART_FAST", "S_KART_FAST_L", "S_KART_FAST_R", + "S_KART_FAST_GLANCE_L", + "S_KART_FAST_GLANCE_R", "S_KART_DRIFT_L", "S_KART_DRIFT_L_OUT", "S_KART_DRIFT_L_IN", diff --git a/src/info.c b/src/info.c index 7e8ad8c17..1fd77a8f0 100644 --- a/src/info.c +++ b/src/info.c @@ -749,9 +749,9 @@ char sprnames[NUMSPRITES + 1][5] = char spr2names[NUMPLAYERSPRITES][5] = { - "STIN", "STIL", "STIR", // Still - "SLWN", "SLWL", "SLWR", // Slow driving - "FSTN", "FSTL", "FSTR", // Fast driving + "STIN", "STIL", "STIR", "STGL", "STGR", // Still + "SLWN", "SLWL", "SLWR", "SLGL", "SLGR", // Slow driving + "FSTN", "FSTL", "FSTR", "FSGL", "FSGR", // Fast driving "DRLN", "DRLO", "DRLI", // Drifting left "DRRN", "DRRO", "DRRI", // Drifting right "SPIN", // Spinout @@ -765,14 +765,20 @@ playersprite_t spr2defaults[NUMPLAYERSPRITES] = { 0, // SPR2_STIN SPR2_STIN, // SPR2_STIL SPR2_STIN, // SPR2_STIR + SPR2_STIN, // SPR2_STGL + SPR2_STIN, // SPR2_STGR 0, // SPR2_SLWN SPR2_SLWN, // SPR2_SLWL SPR2_SLWN, // SPR2_SLWR + SPR2_SLWN, // SPR2_SLGL + SPR2_SLWN, // SPR2_SLGR 0, // SPR2_FSTN SPR2_FSTN, // SPR2_FSTL SPR2_FSTN, // SPR2_FSTR + SPR2_FSTN, // SPR2_FSGL + SPR2_FSTN, // SPR2_FSGR 0, // SPR2_DRLN SPR2_DRLN, // SPR2_DRLO @@ -786,6 +792,7 @@ playersprite_t spr2defaults[NUMPLAYERSPRITES] = { 0, // SPR2_DEAD 0, // SPR2_SIGN + 0, // SPR2_XTRA }; // Doesn't work with g++, needs actionf_p1 (don't modify this comment) @@ -816,12 +823,18 @@ state_t states[NUMSTATES] = {SPR_PLAY, SPR2_STIN, 1, {NULL}, 0, 0, S_KART_STILL}, // S_KART_STILL {SPR_PLAY, SPR2_STIL, 1, {NULL}, 0, 0, S_KART_STILL_L}, // S_KART_STILL_L {SPR_PLAY, SPR2_STIR, 1, {NULL}, 0, 0, S_KART_STILL_R}, // S_KART_STILL_R + {SPR_PLAY, SPR2_STGL, 1, {NULL}, 0, 0, S_KART_STILL_GLANCE_L}, // S_KART_STILL_GLANCE_L + {SPR_PLAY, SPR2_STGR, 1, {NULL}, 0, 0, S_KART_STILL_GLANCE_R}, // S_KART_STILL_GLANCE_R {SPR_PLAY, SPR2_SLWN, 1, {NULL}, 0, 0, S_KART_SLOW}, // S_KART_SLOW {SPR_PLAY, SPR2_SLWL, 1, {NULL}, 0, 0, S_KART_SLOW_L}, // S_KART_SLOW_L {SPR_PLAY, SPR2_SLWR, 1, {NULL}, 0, 0, S_KART_SLOW_R}, // S_KART_SLOW_R + {SPR_PLAY, SPR2_SLGL, 1, {NULL}, 0, 0, S_KART_SLOW_GLANCE_L}, // S_KART_SLOW_GLANCE_L + {SPR_PLAY, SPR2_SLGR, 1, {NULL}, 0, 0, S_KART_SLOW_GLANCE_R}, // S_KART_SLOW_GLANCE_R {SPR_PLAY, SPR2_FSTN, 1, {NULL}, 0, 0, S_KART_FAST}, // S_KART_FAST {SPR_PLAY, SPR2_FSTL, 1, {NULL}, 0, 0, S_KART_FAST_L}, // S_KART_FAST_L {SPR_PLAY, SPR2_FSTR, 1, {NULL}, 0, 0, S_KART_FAST_R}, // S_KART_FAST_R + {SPR_PLAY, SPR2_FSGL, 1, {NULL}, 0, 0, S_KART_FAST_GLANCE_L}, // S_KART_FAST_GLANCE_L + {SPR_PLAY, SPR2_FSGR, 1, {NULL}, 0, 0, S_KART_FAST_GLANCE_R}, // S_KART_FAST_GLANCE_R {SPR_PLAY, SPR2_DRLN, 1, {NULL}, 0, 0, S_KART_DRIFT_L}, // S_KART_DRIFT_L {SPR_PLAY, SPR2_DRLO, 1, {NULL}, 0, 0, S_KART_DRIFT_L_OUT}, // S_KART_DRIFT_L_OUT {SPR_PLAY, SPR2_DRLI, 1, {NULL}, 0, 0, S_KART_DRIFT_L_IN}, // S_KART_DRIFT_L_IN diff --git a/src/info.h b/src/info.h index 236279097..256c97bee 100644 --- a/src/info.h +++ b/src/info.h @@ -1027,9 +1027,9 @@ typedef enum sprite // Since this is zero-based, there can be at most 128 different SPR2_'s without changing that. typedef enum playersprite { - SPR2_STIN = 0, SPR2_STIL, SPR2_STIR, - SPR2_SLWN, SPR2_SLWL, SPR2_SLWR, - SPR2_FSTN, SPR2_FSTL, SPR2_FSTR, + SPR2_STIN = 0, SPR2_STIL, SPR2_STIR, SPR2_STGL, SPR2_STGR, + SPR2_SLWN, SPR2_SLWL, SPR2_SLWR, SPR2_SLGL, SPR2_SLGR, + SPR2_FSTN, SPR2_FSTL, SPR2_FSTR, SPR2_FSGL, SPR2_FSGR, SPR2_DRLN, SPR2_DRLO, SPR2_DRLI, SPR2_DRRN, SPR2_DRRO, SPR2_DRRI, SPR2_SPIN, @@ -1061,12 +1061,18 @@ typedef enum state S_KART_STILL, S_KART_STILL_L, S_KART_STILL_R, + S_KART_STILL_GLANCE_L, + S_KART_STILL_GLANCE_R, S_KART_SLOW, S_KART_SLOW_L, S_KART_SLOW_R, + S_KART_SLOW_GLANCE_L, + S_KART_SLOW_GLANCE_R, S_KART_FAST, S_KART_FAST_L, S_KART_FAST_R, + S_KART_FAST_GLANCE_L, + S_KART_FAST_GLANCE_R, S_KART_DRIFT_L, S_KART_DRIFT_L_OUT, S_KART_DRIFT_L_IN, diff --git a/src/k_kart.c b/src/k_kart.c index 3006d1f66..956ab711b 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1734,6 +1734,102 @@ void K_SpawnDriftBoostClipSpark(mobj_t *clip) spark->momy = clip->momx/2; } +static SINT8 K_GlanceAtPlayers(player_t *glancePlayer) +{ + const fixed_t maxdistance = FixedMul(1280 * mapobjectscale, K_GetKartGameSpeedScalar(gamespeed)); + const angle_t blindSpotSize = ANG10; // ANG5 + UINT8 i; + SINT8 glanceDir = 0; + SINT8 lastValidGlance = 0; + + // See if there's any players coming up behind us. + // If so, your character will glance at 'em. + for (i = 0; i < MAXPLAYERS; i++) + { + player_t *p; + angle_t back; + angle_t diff; + fixed_t distance; + SINT8 dir = -1; + + if (!playeringame[i]) + { + // Invalid player + continue; + } + + p = &players[i]; + + if (p == glancePlayer) + { + // FOOL! Don't glance at yerself! + continue; + } + + if (!p->mo || P_MobjWasRemoved(p->mo)) + { + // Invalid mobj + continue; + } + + if (p->spectator || p->kartstuff[k_hyudorotimer] > 0) + { + // Not playing / invisible + continue; + } + + distance = R_PointToDist2(glancePlayer->mo->x, glancePlayer->mo->y, p->mo->x, p->mo->y); + + if (distance > maxdistance) + { + continue; + } + + back = glancePlayer->mo->angle + ANGLE_180; + diff = R_PointToAngle2(glancePlayer->mo->x, glancePlayer->mo->y, p->mo->x, p->mo->y) - back; + + if (diff > ANGLE_180) + { + diff = InvAngle(diff); + dir = -dir; + } + + if (diff > ANGLE_90) + { + // Not behind the player + continue; + } + + if (diff < blindSpotSize) + { + // Small blindspot directly behind your back, gives the impression of smoothly turning. + continue; + } + + if (P_CheckSight(glancePlayer->mo, p->mo) == true) + { + // Not blocked by a wall, we can glance at 'em! + // Adds, so that if there's more targets on one of your sides, it'll glance on that side. + glanceDir += dir; + + // That poses a limitation if there's an equal number of targets on both sides... + // In that case, we'll pick the last chosen glance direction. + lastValidGlance = dir; + } + } + + if (glanceDir > 0) + { + return 1; + } + else if (glanceDir < 0) + { + return -1; + } + + return lastValidGlance; +} + /** \brief Handles the state changing for moving players, moved here to eliminate duplicate code \param player player data @@ -1847,6 +1943,14 @@ void K_KartMoveAnimation(player_t *player) } else { + SINT8 glanceDir = 0; + + if (turndir == 0) + { + // Only try glancing if you're driving straight. + glanceDir = K_GlanceAtPlayers(player); + } + if (player->speed >= fastspeed && player->speed >= (player->lastspeed - speedthreshold)) { // Going REAL fast! @@ -1861,7 +1965,18 @@ void K_KartMoveAnimation(player_t *player) } else { - SetState(S_KART_FAST); + if (glanceDir == -1) + { + SetState(S_KART_FAST_GLANCE_R); + } + else if (glanceDir == 1) + { + SetState(S_KART_FAST_GLANCE_L); + } + else + { + SetState(S_KART_FAST); + } } } else @@ -1880,7 +1995,18 @@ void K_KartMoveAnimation(player_t *player) } else { - SetState(S_KART_SLOW); + if (glanceDir == -1) + { + SetState(S_KART_SLOW_GLANCE_R); + } + else if (glanceDir == 1) + { + SetState(S_KART_SLOW_GLANCE_L); + } + else + { + SetState(S_KART_SLOW); + } } } else @@ -1897,7 +2023,18 @@ void K_KartMoveAnimation(player_t *player) } else { - SetState(S_KART_STILL); + if (glanceDir == -1) + { + SetState(S_KART_STILL_GLANCE_R); + } + else if (glanceDir == 1) + { + SetState(S_KART_STILL_GLANCE_L); + } + else + { + SetState(S_KART_STILL); + } } } } From 05838acc3d4d03637700551f4ce7e1949f25a1a3 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Wed, 3 Feb 2021 18:28:23 -0500 Subject: [PATCH 05/11] Big look frames No sheets support this yet, but it will default to glance frames, so no functionality loss without them. --- src/info.c | 29 +++++++++++++++-- src/info.h | 9 +++-- src/k_kart.c | 92 +++++++++++++++++++++++++++++++++++----------------- 3 files changed, 94 insertions(+), 36 deletions(-) diff --git a/src/info.c b/src/info.c index 1fd77a8f0..9c0c35031 100644 --- a/src/info.c +++ b/src/info.c @@ -749,13 +749,24 @@ char sprnames[NUMSPRITES + 1][5] = char spr2names[NUMPLAYERSPRITES][5] = { - "STIN", "STIL", "STIR", "STGL", "STGR", // Still - "SLWN", "SLWL", "SLWR", "SLGL", "SLGR", // Slow driving - "FSTN", "FSTL", "FSTR", "FSGL", "FSGR", // Fast driving + "STIN", "STIL", "STIR", // Still + "STGL", "STGR", // Still (glance back) + "STLL", "STLR", // Still (look back) + + "SLWN", "SLWL", "SLWR", // Slow driving + "SLGL", "SLGR", // Slow (glance back) + "SLLL", "SLLR", // Slow (look back) + + "FSTN", "FSTL", "FSTR", // Fast driving + "FSGL", "FSGR", // Fast (glance back) + "FSLL", "FSLR", // Fast (look back) + "DRLN", "DRLO", "DRLI", // Drifting left "DRRN", "DRRO", "DRRI", // Drifting right + "SPIN", // Spinout "DEAD", // Dead + "SIGN", // Finish signpost "XTRA", // Three Faces of Darkness }; @@ -767,18 +778,24 @@ playersprite_t spr2defaults[NUMPLAYERSPRITES] = { SPR2_STIN, // SPR2_STIR SPR2_STIN, // SPR2_STGL SPR2_STIN, // SPR2_STGR + SPR2_STGL, // SPR2_STLL + SPR2_STGR, // SPR2_STLR 0, // SPR2_SLWN SPR2_SLWN, // SPR2_SLWL SPR2_SLWN, // SPR2_SLWR SPR2_SLWN, // SPR2_SLGL SPR2_SLWN, // SPR2_SLGR + SPR2_SLGL, // SPR2_SLLL + SPR2_SLGR, // SPR2_SLLR 0, // SPR2_FSTN SPR2_FSTN, // SPR2_FSTL SPR2_FSTN, // SPR2_FSTR SPR2_FSTN, // SPR2_FSGL SPR2_FSTN, // SPR2_FSGR + SPR2_FSGL, // SPR2_FSLL + SPR2_FSGR, // SPR2_FSLR 0, // SPR2_DRLN SPR2_DRLN, // SPR2_DRLO @@ -825,16 +842,22 @@ state_t states[NUMSTATES] = {SPR_PLAY, SPR2_STIR, 1, {NULL}, 0, 0, S_KART_STILL_R}, // S_KART_STILL_R {SPR_PLAY, SPR2_STGL, 1, {NULL}, 0, 0, S_KART_STILL_GLANCE_L}, // S_KART_STILL_GLANCE_L {SPR_PLAY, SPR2_STGR, 1, {NULL}, 0, 0, S_KART_STILL_GLANCE_R}, // S_KART_STILL_GLANCE_R + {SPR_PLAY, SPR2_STLL, 1, {NULL}, 0, 0, S_KART_STILL_LOOK_L}, // S_KART_STILL_LOOK_L + {SPR_PLAY, SPR2_STLR, 1, {NULL}, 0, 0, S_KART_STILL_LOOK_R}, // S_KART_STILL_LOOK_R {SPR_PLAY, SPR2_SLWN, 1, {NULL}, 0, 0, S_KART_SLOW}, // S_KART_SLOW {SPR_PLAY, SPR2_SLWL, 1, {NULL}, 0, 0, S_KART_SLOW_L}, // S_KART_SLOW_L {SPR_PLAY, SPR2_SLWR, 1, {NULL}, 0, 0, S_KART_SLOW_R}, // S_KART_SLOW_R {SPR_PLAY, SPR2_SLGL, 1, {NULL}, 0, 0, S_KART_SLOW_GLANCE_L}, // S_KART_SLOW_GLANCE_L {SPR_PLAY, SPR2_SLGR, 1, {NULL}, 0, 0, S_KART_SLOW_GLANCE_R}, // S_KART_SLOW_GLANCE_R + {SPR_PLAY, SPR2_SLLL, 1, {NULL}, 0, 0, S_KART_SLOW_LOOK_L}, // S_KART_SLOW_LOOK_L + {SPR_PLAY, SPR2_SLLR, 1, {NULL}, 0, 0, S_KART_SLOW_LOOK_R}, // S_KART_SLOW_LOOK_R {SPR_PLAY, SPR2_FSTN, 1, {NULL}, 0, 0, S_KART_FAST}, // S_KART_FAST {SPR_PLAY, SPR2_FSTL, 1, {NULL}, 0, 0, S_KART_FAST_L}, // S_KART_FAST_L {SPR_PLAY, SPR2_FSTR, 1, {NULL}, 0, 0, S_KART_FAST_R}, // S_KART_FAST_R {SPR_PLAY, SPR2_FSGL, 1, {NULL}, 0, 0, S_KART_FAST_GLANCE_L}, // S_KART_FAST_GLANCE_L {SPR_PLAY, SPR2_FSGR, 1, {NULL}, 0, 0, S_KART_FAST_GLANCE_R}, // S_KART_FAST_GLANCE_R + {SPR_PLAY, SPR2_FSLL, 1, {NULL}, 0, 0, S_KART_FAST_LOOK_L}, // S_KART_FAST_LOOK_L + {SPR_PLAY, SPR2_FSLR, 1, {NULL}, 0, 0, S_KART_FAST_LOOK_R}, // S_KART_FAST_LOOK_R {SPR_PLAY, SPR2_DRLN, 1, {NULL}, 0, 0, S_KART_DRIFT_L}, // S_KART_DRIFT_L {SPR_PLAY, SPR2_DRLO, 1, {NULL}, 0, 0, S_KART_DRIFT_L_OUT}, // S_KART_DRIFT_L_OUT {SPR_PLAY, SPR2_DRLI, 1, {NULL}, 0, 0, S_KART_DRIFT_L_IN}, // S_KART_DRIFT_L_IN diff --git a/src/info.h b/src/info.h index 256c97bee..a8d278fd8 100644 --- a/src/info.h +++ b/src/info.h @@ -1027,9 +1027,12 @@ typedef enum sprite // Since this is zero-based, there can be at most 128 different SPR2_'s without changing that. typedef enum playersprite { - SPR2_STIN = 0, SPR2_STIL, SPR2_STIR, SPR2_STGL, SPR2_STGR, - SPR2_SLWN, SPR2_SLWL, SPR2_SLWR, SPR2_SLGL, SPR2_SLGR, - SPR2_FSTN, SPR2_FSTL, SPR2_FSTR, SPR2_FSGL, SPR2_FSGR, + SPR2_STIN = 0, SPR2_STIL, SPR2_STIR, + SPR2_STGL, SPR2_STGR, SPR2_STLL, SPR2_STLR, + SPR2_SLWN, SPR2_SLWL, SPR2_SLWR, + SPR2_SLGL, SPR2_SLGR, SPR2_SLLL, SPR2_SLLR, + SPR2_FSTN, SPR2_FSTL, SPR2_FSTR, + SPR2_FSGL, SPR2_FSGR, SPR2_FSLL, SPR2_FSLR, SPR2_DRLN, SPR2_DRLO, SPR2_DRLI, SPR2_DRRN, SPR2_DRRO, SPR2_DRRI, SPR2_SPIN, diff --git a/src/k_kart.c b/src/k_kart.c index 956ab711b..fe08b1e3d 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1949,6 +1949,20 @@ void K_KartMoveAnimation(player_t *player) { // Only try glancing if you're driving straight. glanceDir = K_GlanceAtPlayers(player); + + if (cmd->buttons & BT_LOOKBACK) + { + if (glanceDir == 0) + { + // Look to your right by default + glanceDir = -1; + } + else + { + // Looking back AND glancing? Amplify the look! + glanceDir *= 2; + } + } } if (player->speed >= fastspeed && player->speed >= (player->lastspeed - speedthreshold)) @@ -1965,17 +1979,23 @@ void K_KartMoveAnimation(player_t *player) } else { - if (glanceDir == -1) + switch (glanceDir) { - SetState(S_KART_FAST_GLANCE_R); - } - else if (glanceDir == 1) - { - SetState(S_KART_FAST_GLANCE_L); - } - else - { - SetState(S_KART_FAST); + case -2: + SetState(S_KART_FAST_LOOK_R); + break; + case 2: + SetState(S_KART_FAST_LOOK_L); + break; + case -1: + SetState(S_KART_FAST_GLANCE_R); + break; + case 1: + SetState(S_KART_FAST_GLANCE_L); + break; + default: + SetState(S_KART_FAST); + break; } } } @@ -1995,17 +2015,23 @@ void K_KartMoveAnimation(player_t *player) } else { - if (glanceDir == -1) + switch (glanceDir) { - SetState(S_KART_SLOW_GLANCE_R); - } - else if (glanceDir == 1) - { - SetState(S_KART_SLOW_GLANCE_L); - } - else - { - SetState(S_KART_SLOW); + case -2: + SetState(S_KART_SLOW_LOOK_R); + break; + case 2: + SetState(S_KART_SLOW_LOOK_L); + break; + case -1: + SetState(S_KART_SLOW_GLANCE_R); + break; + case 1: + SetState(S_KART_SLOW_GLANCE_L); + break; + default: + SetState(S_KART_SLOW); + break; } } } @@ -2023,17 +2049,23 @@ void K_KartMoveAnimation(player_t *player) } else { - if (glanceDir == -1) + switch (glanceDir) { - SetState(S_KART_STILL_GLANCE_R); - } - else if (glanceDir == 1) - { - SetState(S_KART_STILL_GLANCE_L); - } - else - { - SetState(S_KART_STILL); + case -2: + SetState(S_KART_STILL_LOOK_R); + break; + case 2: + SetState(S_KART_STILL_LOOK_L); + break; + case -1: + SetState(S_KART_STILL_GLANCE_R); + break; + case 1: + SetState(S_KART_STILL_GLANCE_L); + break; + default: + SetState(S_KART_STILL); + break; } } } From 480e32d369f224e18601482ebd6c8f3c5cc5f020 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Wed, 3 Feb 2021 19:20:27 -0500 Subject: [PATCH 06/11] Properly add states to the tables... Mind's been split everywhere tonight --- src/dehacked.c | 6 ++++++ src/info.h | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/dehacked.c b/src/dehacked.c index 781c41864..857c838f4 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -5206,16 +5206,22 @@ static const char *const STATE_LIST[] = { // array length left dynamic for sanit "S_KART_STILL_R", "S_KART_STILL_GLANCE_L", "S_KART_STILL_GLANCE_R", + "S_KART_STILL_LOOK_L", + "S_KART_STILL_LOOK_R", "S_KART_SLOW", "S_KART_SLOW_L", "S_KART_SLOW_R", "S_KART_SLOW_GLANCE_L", "S_KART_SLOW_GLANCE_R", + "S_KART_SLOW_LOOK_L", + "S_KART_SLOW_LOOK_R", "S_KART_FAST", "S_KART_FAST_L", "S_KART_FAST_R", "S_KART_FAST_GLANCE_L", "S_KART_FAST_GLANCE_R", + "S_KART_FAST_LOOK_L", + "S_KART_FAST_LOOK_R", "S_KART_DRIFT_L", "S_KART_DRIFT_L_OUT", "S_KART_DRIFT_L_IN", diff --git a/src/info.h b/src/info.h index a8d278fd8..3f8590b7c 100644 --- a/src/info.h +++ b/src/info.h @@ -1066,16 +1066,22 @@ typedef enum state S_KART_STILL_R, S_KART_STILL_GLANCE_L, S_KART_STILL_GLANCE_R, + S_KART_STILL_LOOK_L, + S_KART_STILL_LOOK_R, S_KART_SLOW, S_KART_SLOW_L, S_KART_SLOW_R, S_KART_SLOW_GLANCE_L, S_KART_SLOW_GLANCE_R, + S_KART_SLOW_LOOK_L, + S_KART_SLOW_LOOK_R, S_KART_FAST, S_KART_FAST_L, S_KART_FAST_R, S_KART_FAST_GLANCE_L, S_KART_FAST_GLANCE_R, + S_KART_FAST_LOOK_L, + S_KART_FAST_LOOK_R, S_KART_DRIFT_L, S_KART_DRIFT_L_OUT, S_KART_DRIFT_L_IN, From e2e342f3f7b1b80327cf7fc063c64e6282b690eb Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Wed, 3 Feb 2021 19:29:13 -0500 Subject: [PATCH 07/11] Update panim for the new states --- src/d_player.h | 18 +++++------------- src/dehacked.c | 18 +++++------------- src/g_game.c | 2 +- src/p_mobj.c | 26 +++++++++++++++++++------- 4 files changed, 30 insertions(+), 34 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 1c352e3ea..278744127 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -115,19 +115,11 @@ typedef enum { // Are animation frames playing? PA_ETC=0, - PA_IDLE, - PA_EDGE, - PA_WALK, - PA_RUN, - PA_DASH, - PA_PAIN, - PA_ROLL, - PA_JUMP, - PA_SPRING, - PA_FALL, - PA_ABILITY, - PA_ABILITY2, - PA_RIDE + PA_STILL, + PA_SLOW, + PA_FAST, + PA_DRIFT, + PA_HURT } panim_t; // diff --git a/src/dehacked.c b/src/dehacked.c index 857c838f4..d24fd97d0 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -11434,19 +11434,11 @@ struct { // Player animation (panim_t) {"PA_ETC",PA_ETC}, - {"PA_IDLE",PA_IDLE}, - {"PA_EDGE",PA_EDGE}, - {"PA_WALK",PA_WALK}, - {"PA_RUN",PA_RUN}, - {"PA_DASH",PA_DASH}, - {"PA_PAIN",PA_PAIN}, - {"PA_ROLL",PA_ROLL}, - {"PA_JUMP",PA_JUMP}, - {"PA_SPRING",PA_SPRING}, - {"PA_FALL",PA_FALL}, - {"PA_ABILITY",PA_ABILITY}, - {"PA_ABILITY2",PA_ABILITY2}, - {"PA_RIDE",PA_RIDE}, + {"PA_STILL",PA_STILL}, + {"PA_SLOW",PA_SLOW}, + {"PA_FAST",PA_FAST}, + {"PA_DRIFT",PA_DRIFT}, + {"PA_HURT",PA_HURT}, // Value for infinite lives {"INFLIVES",INFLIVES}, diff --git a/src/g_game.c b/src/g_game.c index b62e7a6ce..0a494918f 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2261,7 +2261,7 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps) p->pflags |= PF_JUMPDOWN; p->playerstate = PST_LIVE; - p->panim = PA_IDLE; // standing animation + p->panim = PA_STILL; // standing animation // Check to make sure their color didn't change somehow... if (G_GametypeHasTeams()) diff --git a/src/p_mobj.c b/src/p_mobj.c index 6b5e6fcf4..704e03114 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -221,17 +221,29 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) case S_KART_STILL: case S_KART_STILL_L: case S_KART_STILL_R: - player->panim = PA_IDLE; + case S_KART_STILL_GLANCE_L: + case S_KART_STILL_GLANCE_R: + case S_KART_STILL_LOOK_L: + case S_KART_STILL_LOOK_R: + player->panim = PA_STILL; break; case S_KART_SLOW: case S_KART_SLOW_L: case S_KART_SLOW_R: - player->panim = PA_WALK; + case S_KART_SLOW_GLANCE_L: + case S_KART_SLOW_GLANCE_R: + case S_KART_SLOW_LOOK_L: + case S_KART_SLOW_LOOK_R: + player->panim = PA_SLOW; break; case S_KART_FAST: case S_KART_FAST_L: case S_KART_FAST_R: - player->panim = PA_RUN; + case S_KART_FAST_GLANCE_L: + case S_KART_FAST_GLANCE_R: + case S_KART_FAST_LOOK_L: + case S_KART_FAST_LOOK_R: + player->panim = PA_FAST; break; case S_KART_DRIFT_L: case S_KART_DRIFT_L_OUT: @@ -239,11 +251,11 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) case S_KART_DRIFT_R: case S_KART_DRIFT_R_OUT: case S_KART_DRIFT_R_IN: - player->panim = PA_DASH; + player->panim = PA_DRIFT; break; case S_KART_SPINOUT: case S_KART_DEAD: - player->panim = PA_PAIN; + player->panim = PA_HURT; break; default: player->panim = PA_ETC; @@ -1300,7 +1312,7 @@ static void P_XYFriction(mobj_t *mo, fixed_t oldx, fixed_t oldy) && !(player->mo->standingslope && (!(player->mo->standingslope->flags & SL_NOPHYSICS)) /*&& (abs(player->mo->standingslope->zdelta) >= FRACUNIT/2)*/)) { // if in a walking frame, stop moving - if (player->panim == PA_WALK) + if (player->panim == PA_SLOW) { P_SetPlayerMobjState(mo, S_KART_STILL); } @@ -2695,7 +2707,7 @@ void P_PlayerZMovement(mobj_t *mo) mo->z = mo->floorz; // Get up if you fell. - if (mo->player->panim == PA_PAIN && mo->player->kartstuff[k_spinouttimer] == 0 && mo->player->tumbleBounces == 0) + if (mo->player->panim == PA_HURT && mo->player->kartstuff[k_spinouttimer] == 0 && mo->player->tumbleBounces == 0) P_SetPlayerMobjState(mo, S_KART_STILL); if (!mo->standingslope && (mo->eflags & MFE_VERTICALFLIP ? tmceilingslope : tmfloorslope)) { From b7e578b82b868fd797397bb13377295186100205 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Thu, 4 Feb 2021 00:26:59 -0500 Subject: [PATCH 08/11] Keep look backwards direction in a variable, so it can smoothly rotate --- src/d_clisrv.c | 4 ++++ src/d_clisrv.h | 2 ++ src/d_player.h | 2 ++ src/k_kart.c | 51 ++++++++++++++++++++++++++++++++++++--------- src/lua_playerlib.c | 4 ++++ src/p_saveg.c | 4 ++++ 6 files changed, 57 insertions(+), 10 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 1ebf4960a..fca3b27a4 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -631,6 +631,8 @@ static inline void resynch_write_player(resynch_pak *rsp, const size_t i) rsp->tumbleLastBounce = players[i].tumbleLastBounce; rsp->tumbleSound = players[i].tumbleSound; + rsp->glanceDir = players[i].glanceDir; + // respawnvars_t rsp->respawn_state = players[i].respawn.state; rsp->respawn_pointx = (fixed_t)LONG(players[i].respawn.pointx); @@ -789,6 +791,8 @@ static void resynch_read_player(resynch_pak *rsp) players[i].tumbleLastBounce = (boolean)rsp->tumbleLastBounce; players[i].tumbleSound = (boolean)rsp->tumbleSound; + players[i].glanceDir = (SINT8)rsp->glanceDir; + // respawnvars_t players[i].respawn.state = rsp->respawn_state; players[i].respawn.pointx = (fixed_t)LONG(rsp->respawn_pointx); diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 8e7e9aee9..7d86a70fc 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -295,6 +295,8 @@ typedef struct boolean tumbleLastBounce; boolean tumbleSound; + SINT8 glanceDir; + // respawnvars_t UINT8 respawn_state; fixed_t respawn_pointx; diff --git a/src/d_player.h b/src/d_player.h index 278744127..f352aef5e 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -569,6 +569,8 @@ typedef struct player_s boolean tumbleLastBounce; boolean tumbleSound; + SINT8 glanceDir; // Direction the player is trying to look backwards in + // UINT32 charflags; // Extra abilities/settings for skins (combinable stuff) diff --git a/src/k_kart.c b/src/k_kart.c index fe08b1e3d..64a259c3e 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1849,6 +1849,8 @@ void K_KartMoveAnimation(player_t *player) ticcmd_t *cmd = &player->cmd; const boolean spinningwheels = ((cmd->buttons & BT_ACCELERATE) || (onground && player->speed > 0)); + SINT8 destGlanceDir = 0; + if (cmd->turning < -minturn) { turndir = -1; @@ -1943,27 +1945,46 @@ void K_KartMoveAnimation(player_t *player) } else { - SINT8 glanceDir = 0; - if (turndir == 0) { // Only try glancing if you're driving straight. - glanceDir = K_GlanceAtPlayers(player); + destGlanceDir = K_GlanceAtPlayers(player); if (cmd->buttons & BT_LOOKBACK) { - if (glanceDir == 0) + if (destGlanceDir == 0) { - // Look to your right by default - glanceDir = -1; + if (player->glanceDir != 0) + { + // Keep to the side you were already on. + if (player->glanceDir < 0) + { + destGlanceDir = -1; + } + else + { + destGlanceDir = 1; + } + } + else + { + // Look to your right by default + destGlanceDir = -1; + } } else { // Looking back AND glancing? Amplify the look! - glanceDir *= 2; + destGlanceDir *= 2; } } } + else + { + // Not glancing + destGlanceDir = 0; + player->glanceDir = 0; + } if (player->speed >= fastspeed && player->speed >= (player->lastspeed - speedthreshold)) { @@ -1979,7 +2000,7 @@ void K_KartMoveAnimation(player_t *player) } else { - switch (glanceDir) + switch (player->glanceDir) { case -2: SetState(S_KART_FAST_LOOK_R); @@ -2015,7 +2036,7 @@ void K_KartMoveAnimation(player_t *player) } else { - switch (glanceDir) + switch (player->glanceDir) { case -2: SetState(S_KART_SLOW_LOOK_R); @@ -2049,7 +2070,7 @@ void K_KartMoveAnimation(player_t *player) } else { - switch (glanceDir) + switch (player->glanceDir) { case -2: SetState(S_KART_STILL_LOOK_R); @@ -2070,6 +2091,16 @@ void K_KartMoveAnimation(player_t *player) } } } + + // Update your value to smooth it out. + if (player->glanceDir > destGlanceDir) + { + player->glanceDir--; + } + else if (player->glanceDir < destGlanceDir) + { + player->glanceDir++; + } } } diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 81adeebc5..8cb955448 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -222,6 +222,8 @@ static int player_get(lua_State *L) lua_pushboolean(L, plr->tumbleLastBounce); else if (fastcmp(field,"tumbleSound")) lua_pushboolean(L, plr->tumbleSound); + else if (fastcmp(field,"glanceDir")) + lua_pushinteger(L, plr->glanceDir); else if (fastcmp(field,"trickpanel")) lua_pushinteger(L, plr->trickpanel); else if (fastcmp(field,"trickdelay")) @@ -529,6 +531,8 @@ static int player_set(lua_State *L) plr->tumbleLastBounce = luaL_checkboolean(L, 3); else if (fastcmp(field,"tumbleSound")) plr->tumbleSound = luaL_checkboolean(L, 3); + else if (fastcmp(field,"glanceDir")) + plr->glanceDir = (SINT8)luaL_checkinteger(L, 3); else if (fastcmp(field,"trickpanel")) plr->trickpanel = luaL_checkinteger(L, 3); else if (fastcmp(field,"trickdelay")) diff --git a/src/p_saveg.c b/src/p_saveg.c index 79b99e98f..c27ff10ca 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -271,6 +271,8 @@ static void P_NetArchivePlayers(void) WRITEUINT8(save_p, players[i].tumbleLastBounce); WRITEUINT8(save_p, players[i].tumbleSound); + WRITESINT8(save_p, players[i].glanceDir); + // respawnvars_t WRITEUINT8(save_p, players[i].respawn.state); WRITEUINT32(save_p, K_GetWaypointHeapIndex(players[i].respawn.wp)); @@ -471,6 +473,8 @@ static void P_NetUnArchivePlayers(void) players[i].tumbleLastBounce = (boolean)READUINT8(save_p); players[i].tumbleSound = (boolean)READUINT8(save_p); + players[i].glanceDir = READSINT8(save_p); + // respawnvars_t players[i].respawn.state = READUINT8(save_p); players[i].respawn.wp = (waypoint_t *)(size_t)READUINT32(save_p); From 73c61b10101da5e65fa5a4ca844c7cc96872ba73 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Thu, 4 Feb 2021 20:18:14 -0500 Subject: [PATCH 09/11] Prioritize lookback frames over turn frames if you're pressing lookback --- src/k_kart.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index 64a259c3e..31b2cc644 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1848,6 +1848,7 @@ void K_KartMoveAnimation(player_t *player) ticcmd_t *cmd = &player->cmd; const boolean spinningwheels = ((cmd->buttons & BT_ACCELERATE) || (onground && player->speed > 0)); + const boolean lookback = (cmd->buttons & BT_LOOKBACK); SINT8 destGlanceDir = 0; @@ -1945,12 +1946,18 @@ void K_KartMoveAnimation(player_t *player) } else { + if (lookback == true) + { + // Prioritize looking back over turning + turndir = 0; + } + if (turndir == 0) { // Only try glancing if you're driving straight. destGlanceDir = K_GlanceAtPlayers(player); - if (cmd->buttons & BT_LOOKBACK) + if (lookback == true) { if (destGlanceDir == 0) { From efeab5e80e3d8b681262b8a66d0950763e4968e5 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Thu, 4 Feb 2021 21:11:27 -0500 Subject: [PATCH 10/11] Allow lookback/glancing in the air, glance back while braking --- src/k_kart.c | 186 +++++++++++++++++++++++++++++++-------------------- 1 file changed, 114 insertions(+), 72 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 31b2cc644..6075dcaaa 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1839,18 +1839,19 @@ static SINT8 K_GlanceAtPlayers(player_t *glancePlayer) void K_KartMoveAnimation(player_t *player) { const INT16 minturn = KART_FULLTURN/8; - SINT8 turndir = 0; - const fixed_t fastspeed = (K_GetKartSpeed(player, false) * 17) / 20; // 85% - const fixed_t speedthreshold = player->mo->scale / 8; + fixed_t fastspeed = (K_GetKartSpeed(player, false) * 17) / 20; // 85% + fixed_t speedthreshold = player->mo->scale / 8; - const boolean onground = P_IsObjectOnGround(player->mo); + boolean onground = P_IsObjectOnGround(player->mo); ticcmd_t *cmd = &player->cmd; - const boolean spinningwheels = ((cmd->buttons & BT_ACCELERATE) || (onground && player->speed > 0)); - const boolean lookback = (cmd->buttons & BT_LOOKBACK); + boolean spinningwheels = (((cmd->buttons & BT_ACCELERATE) == BT_ACCELERATE) || (onground && player->speed > 0)); + boolean lookback = ((cmd->buttons & BT_LOOKBACK) == BT_LOOKBACK); + SINT8 turndir = 0; SINT8 destGlanceDir = 0; + SINT8 drift = player->kartstuff[k_drift]; if (cmd->turning < -minturn) { @@ -1861,20 +1862,89 @@ void K_KartMoveAnimation(player_t *player) turndir = 1; } + if (lookback == true && drift == 0) + { + // Prioritize looking back frames over turning + turndir = 0; + } + + if (turndir == 0 && drift == 0) + { + // Only try glancing if you're driving straight. + // This avoids all-players loops when we don't need it. + destGlanceDir = K_GlanceAtPlayers(player); + + if (lookback == true) + { + if (destGlanceDir == 0) + { + if (player->glanceDir != 0) + { + // Keep to the side you were already on. + if (player->glanceDir < 0) + { + destGlanceDir = -1; + } + else + { + destGlanceDir = 1; + } + } + else + { + // Look to your right by default + destGlanceDir = -1; + } + } + else + { + // Looking back AND glancing? Amplify the look! + destGlanceDir *= 2; + } + } + else if (K_GetForwardMove(player) < 0 && destGlanceDir == 0) + { + // Reversing -- like looking back, but doesn't stack on the other glances. + if (player->glanceDir != 0) + { + // Keep to the side you were already on. + if (player->glanceDir < 0) + { + destGlanceDir = -1; + } + else + { + destGlanceDir = 1; + } + } + else + { + // Look to your right by default + destGlanceDir = -1; + } + } + } + else + { + // Not glancing + destGlanceDir = 0; + player->glanceDir = 0; + } + #define SetState(sn) \ if (player->mo->state != &states[sn]) \ P_SetPlayerMobjState(player->mo, sn) - if (!onground) + if (onground == false) { // Only use certain frames in the air, to make it look like your tires are spinning fruitlessly! - if (player->kartstuff[k_drift] > 0) + if (drift > 0) { // Neutral drift SetState(S_KART_DRIFT_L); } - else if (player->kartstuff[k_drift] > 0) + else if (drift < 0) { // Neutral drift SetState(S_KART_DRIFT_R); @@ -1889,22 +1959,41 @@ void K_KartMoveAnimation(player_t *player) { SetState(S_KART_FAST_L); } - else if (turndir == 0) + else { - SetState(S_KART_FAST); + switch (player->glanceDir) + { + case -2: + SetState(S_KART_FAST_LOOK_R); + break; + case 2: + SetState(S_KART_FAST_LOOK_L); + break; + case -1: + SetState(S_KART_FAST_GLANCE_R); + break; + case 1: + SetState(S_KART_FAST_GLANCE_L); + break; + default: + SetState(S_KART_FAST); + break; + } } } if (!spinningwheels) { - // TODO: These should prooobably be different SPR2s - // Just a quick hack to prevent needing to do that :V + // TODO: The "tires still in the air" states should have it's own SPR2s. + // This was a quick hack to get the same functionality with less work, + // but it's really dunderheaded & isn't customizable at all. player->mo->frame = (player->mo->frame & ~FF_FRAMEMASK); + player->mo->tics++; // Makes it properly use frame 0 } } else { - if (player->kartstuff[k_drift] > 0) + if (drift > 0) { // Drifting LEFT! @@ -1924,7 +2013,7 @@ void K_KartMoveAnimation(player_t *player) SetState(S_KART_DRIFT_L); } } - else if (player->kartstuff[k_drift] < 0) + else if (drift < 0) { // Drifting RIGHT! @@ -1946,53 +2035,6 @@ void K_KartMoveAnimation(player_t *player) } else { - if (lookback == true) - { - // Prioritize looking back over turning - turndir = 0; - } - - if (turndir == 0) - { - // Only try glancing if you're driving straight. - destGlanceDir = K_GlanceAtPlayers(player); - - if (lookback == true) - { - if (destGlanceDir == 0) - { - if (player->glanceDir != 0) - { - // Keep to the side you were already on. - if (player->glanceDir < 0) - { - destGlanceDir = -1; - } - else - { - destGlanceDir = 1; - } - } - else - { - // Look to your right by default - destGlanceDir = -1; - } - } - else - { - // Looking back AND glancing? Amplify the look! - destGlanceDir *= 2; - } - } - } - else - { - // Not glancing - destGlanceDir = 0; - player->glanceDir = 0; - } - if (player->speed >= fastspeed && player->speed >= (player->lastspeed - speedthreshold)) { // Going REAL fast! @@ -2098,21 +2140,21 @@ void K_KartMoveAnimation(player_t *player) } } } - - // Update your value to smooth it out. - if (player->glanceDir > destGlanceDir) - { - player->glanceDir--; - } - else if (player->glanceDir < destGlanceDir) - { - player->glanceDir++; - } } } #undef SetState + // Update your glance value to smooth it out. + if (player->glanceDir > destGlanceDir) + { + player->glanceDir--; + } + else if (player->glanceDir < destGlanceDir) + { + player->glanceDir++; + } + // Update lastspeed value -- we use to display slow driving frames instead of fast driving when slowing down. player->lastspeed = player->speed; } From 8e041e7d0bf614876edf4050a8abc2aa7660cef5 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Fri, 5 Feb 2021 17:51:23 -0500 Subject: [PATCH 11/11] Re-add const --- src/k_kart.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 6075dcaaa..d32c45d75 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1840,14 +1840,14 @@ void K_KartMoveAnimation(player_t *player) { const INT16 minturn = KART_FULLTURN/8; - fixed_t fastspeed = (K_GetKartSpeed(player, false) * 17) / 20; // 85% - fixed_t speedthreshold = player->mo->scale / 8; + const fixed_t fastspeed = (K_GetKartSpeed(player, false) * 17) / 20; // 85% + const fixed_t speedthreshold = player->mo->scale / 8; - boolean onground = P_IsObjectOnGround(player->mo); + const boolean onground = P_IsObjectOnGround(player->mo); ticcmd_t *cmd = &player->cmd; - boolean spinningwheels = (((cmd->buttons & BT_ACCELERATE) == BT_ACCELERATE) || (onground && player->speed > 0)); - boolean lookback = ((cmd->buttons & BT_LOOKBACK) == BT_LOOKBACK); + const boolean spinningwheels = (((cmd->buttons & BT_ACCELERATE) == BT_ACCELERATE) || (onground && player->speed > 0)); + const boolean lookback = ((cmd->buttons & BT_LOOKBACK) == BT_LOOKBACK); SINT8 turndir = 0; SINT8 destGlanceDir = 0;