From cc593a6ac709d505157a640d62d8476d049e106e Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Tue, 30 Aug 2016 14:50:03 +0100 Subject: [PATCH] Did a few things with spindashing: * Fixed bug where being pushed off a platform whilst charging a spindash would leave you in your charging frames instead of your rolling ones when you hit the ground (http://gfycat.com/MassiveThreadbareItalianbrownbear) * Fixed bug where spindashing on top of a bubble spawnpoint led to you being able to move around in spindash frames (no gif since obvious desired behaviour is obvious) * Spindash animation speeds up the faster you'll shoot off. * The spin charging mechanism is now scale-independent, and only multiplies by scale when shooting off - less FixedMul calls, and potentially deals with weird quirks of changing scale whilst spindashing that nobody's discovered because there's no place to find that in the main game! Also: * Climbing animation defaults to rolling instead of walking, because what. --- src/p_mobj.c | 61 ++++++++++++++++++++++++++++++++-------------------- src/p_user.c | 26 ++++++++++++---------- 2 files changed, 53 insertions(+), 34 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 4f9807cf6..4aff6d2f9 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -253,7 +253,7 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) player->panim = PA_PAIN; break; case S_PLAY_SPIN: - case S_PLAY_DASH: + //case S_PLAY_DASH: -- everyone can ROLL thanks to zoom tubes... case S_PLAY_SUPER_SPIN: player->panim = PA_ROLL; break; @@ -275,6 +275,7 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) case S_PLAY_TWINSPIN: player->panim = PA_ABILITY; break; + case S_PLAY_DASH: // ...but the act of SPINDASHING is charability2 specific. case S_PLAY_MELEE: case S_PLAY_MELEE_FINISH: player->panim = PA_ABILITY2; @@ -309,15 +310,8 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) // Adjust the player's animation speed to match their velocity. if (!(disableSpeedAdjust || player->charflags & SF_NOSPEEDADJUST)) { - fixed_t speed = FixedDiv(player->speed, mobj->scale); - if (player->panim == PA_ROLL || player->panim == PA_JUMP) - { - if (speed > 16<tics = 1; - else - mobj->tics = 2; - } - else if (player->panim == PA_FALL) + fixed_t speed;// = FixedDiv(player->speed, mobj->scale); + if (player->panim == PA_FALL) { speed = FixedDiv(abs(mobj->momz), mobj->scale); if (speed < 10<tics = 1; } - else if (P_IsObjectOnGround(mobj) || player->powers[pw_super]) // Only if on the ground or superflying. + else if (player->panim == PA_ABILITY2 && player->charability2 == CA2_SPINDASH) { - if (player->panim == PA_WALK) + speed = player->maxdash/3; // We're using dashspeed as the variable to check against, but reusing speed to reduce the number of calculations done. + if (player->dashspeed > 2*speed) + mobj->tics = 1; + else if (player->dashspeed > speed) + mobj->tics = 2; + else + mobj->tics = 3; + } + else + { + speed = FixedDiv(player->speed, mobj->scale); + if (player->panim == PA_ROLL || player->panim == PA_JUMP) { - if (speed > 12<tics = 2; - else if (speed > 6<tics = 3; - else - mobj->tics = 4; - } - else if ((player->panim == PA_RUN) || (player->panim == PA_PEEL)) - { - if (speed > 52< 16<tics = 1; else mobj->tics = 2; } + else if (P_IsObjectOnGround(mobj) || player->powers[pw_super]) // Only if on the ground or superflying. + { + if (player->panim == PA_WALK) + { + if (speed > 12<tics = 2; + else if (speed > 6<tics = 3; + else + mobj->tics = 4; + } + else if ((player->panim == PA_RUN) || (player->panim == PA_PEEL)) + { + if (speed > 52<tics = 1; + else + mobj->tics = 2; + } + } } } @@ -408,7 +423,7 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) spr2 = SPR2_FLY; break; case SPR2_CLMB: - spr2 = SPR2_WALK; + spr2 = SPR2_SPIN; break; case SPR2_CLNG: spr2 = SPR2_CLMB; diff --git a/src/p_user.c b/src/p_user.c index 0a1686f25..b6b5f15e6 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -900,7 +900,7 @@ void P_DoPlayerPain(player_t *player, mobj_t *source, mobj_t *inflictor) // Useful when you want to kill everything the player is doing. void P_ResetPlayer(player_t *player) { - player->pflags &= ~(PF_ROPEHANG|PF_ITEMHANG|PF_MACESPIN|PF_SPINNING|PF_JUMPED|PF_GLIDING|PF_THOKKED|PF_CARRIED); + player->pflags &= ~(PF_ROPEHANG|PF_ITEMHANG|PF_MACESPIN|PF_SPINNING|PF_STARTDASH|PF_JUMPED|PF_GLIDING|PF_THOKKED|PF_CARRIED); player->jumping = 0; player->secondjump = 0; player->glidetime = 0; @@ -3727,18 +3727,18 @@ static void P_DoSpinAbility(player_t *player, ticcmd_t *cmd) player->mo->momx = player->cmomx; player->mo->momy = player->cmomy; player->pflags |= PF_STARTDASH|PF_SPINNING; - player->dashspeed = FixedMul(FRACUNIT, player->mo->scale); + player->dashspeed = FRACUNIT; player->dashtime = 0; P_SetPlayerMobjState(player->mo, S_PLAY_DASH); player->pflags |= PF_USEDOWN; } else if ((cmd->buttons & BT_USE) && (player->pflags & PF_STARTDASH)) { - player->dashspeed += FixedMul(FRACUNIT, player->mo->scale); + player->dashspeed += FRACUNIT; if (!(player->dashtime++ % 5)) { - if (!player->spectator && player->dashspeed < FixedMul(player->maxdash, player->mo->scale)) + if (!player->spectator && player->dashspeed < player->maxdash) S_StartSound(player->mo, sfx_spndsh); // Make the rev sound! // Now spawn the color thok circle. @@ -3800,7 +3800,7 @@ static void P_DoSpinAbility(player_t *player, ticcmd_t *cmd) if (player->dashspeed) { P_SetPlayerMobjState(player->mo, S_PLAY_SPIN); - P_InstaThrust(player->mo, player->mo->angle, player->dashspeed); // catapult forward ho!! + P_InstaThrust(player->mo, player->mo->angle, FixedMul(player->dashspeed, player->mo->scale)); // catapult forward ho!! } else { @@ -3815,8 +3815,11 @@ static void P_DoSpinAbility(player_t *player, ticcmd_t *cmd) player->dashspeed = 0; } - if (onground && player->pflags & PF_STARTDASH && player->mo->state-states != S_PLAY_DASH) - P_SetPlayerMobjState(player->mo, S_PLAY_DASH); + if (onground && player->pflags & PF_STARTDASH) + { + if (player->mo->state-states != S_PLAY_DASH) + P_SetPlayerMobjState(player->mo, S_PLAY_DASH); + } else if (onground && player->pflags & PF_SPINNING && !(player->panim == PA_ROLL)) P_SetPlayerMobjState(player->mo, S_PLAY_SPIN); @@ -3829,6 +3832,7 @@ static void P_DoSpinAbility(player_t *player, ticcmd_t *cmd) #endif ) { + P_ResetPlayer(player); player->mo->z += P_MobjFlip(player->mo); player->mo->momx = player->cmomx = 0; player->mo->momy = player->cmomy = 0; @@ -6566,10 +6570,10 @@ static void P_MovePlayer(player_t *player) // Cap the speed limit on a spindash // Up the 60*FRACUNIT number to boost faster, you speed demon you! - if (player->dashspeed > FixedMul(player->maxdash, player->mo->scale)) - player->dashspeed = FixedMul(player->maxdash, player->mo->scale); - else if (player->dashspeed > 0 && player->dashspeed < FixedMul(player->mindash, player->mo->scale)) - player->dashspeed = FixedMul(player->mindash, player->mo->scale); + if (player->dashspeed > player->maxdash) + player->dashspeed = player->maxdash; + else if (player->dashspeed > 0 && player->dashspeed < player->mindash) + player->dashspeed = player->mindash; if (!(player->charability == CA_GLIDEANDCLIMB) || player->gotflag) // If you can't glide, then why the heck would you be gliding? {