diff --git a/src/d_player.h b/src/d_player.h index 80e633dc..60727fca 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -260,6 +260,7 @@ typedef enum k_boostcharge, // Charge-up for boosting at the start of the race, or when Lakitu drops you k_jmp, // In Mario Kart, letting go of the jump button stops the drift k_offroad, // In Super Mario Kart, going offroad has lee-way of about 1 second before you start losing speed + k_brakestop, // Wait until you've made a complete stop for a few tics before letting brake go in reverse. k_itemroulette, // Used for the roulette when deciding what item to give you (was "pw_kartitem") k_roulettetype, // Used for the roulette, for deciding type (currently only used for Battle, to give you better items from Karma items) diff --git a/src/d_ticcmd.h b/src/d_ticcmd.h index 0a751148..afb052ce 100644 --- a/src/d_ticcmd.h +++ b/src/d_ticcmd.h @@ -25,18 +25,13 @@ typedef enum { BT_ACCELERATE = 1, // Accelerate - BT_DRIFT = 1<<2, // Drift (direction is cmd->angleturn) + BT_DRIFT = 1<<2, // Drift (direction is cmd->driftturn) BT_BRAKE = 1<<3, // Brake BT_ATTACK = 1<<4, // Use Item BT_FORWARD = 1<<5, // Aim Item Forward BT_BACKWARD = 1<<6, // Aim Item Backward - //BT_SPECTATE = 1<<7, // Toggle Spectate - // Want more button space? Help get rid of this hack :V - BT_DRIFTLEFT = 1<<7, // Drift left hack - BT_DRIFTRIGHT = 1<<8, // Drift right hack - - // free: 1<<9 to 1<<12 + // free: 1<<7 to 1<<12 // Lua garbage BT_CUSTOM1 = 1<<13, @@ -64,6 +59,7 @@ typedef struct INT16 angleturn; // <<16 for angle delta - saved as 1 byte into demos INT16 aiming; // vertical aiming, see G_BuildTicCmd UINT16 buttons; + INT16 driftturn; // SRB2Kart: Used for getting drift turn speed } ATTRPACK ticcmd_t; #if defined(_MSC_VER) diff --git a/src/dehacked.c b/src/dehacked.c index be3c2d75..4eb0ecd1 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -8031,9 +8031,6 @@ struct { {"BT_ATTACK",BT_ATTACK}, {"BT_FORWARD",BT_FORWARD}, {"BT_BACKWARD",BT_BACKWARD}, - //{"BT_SPECTATE",BT_SPECTATE}, - {"BT_DRIFTLEFT",BT_DRIFTLEFT}, - {"BT_DRIFTRIGHT",BT_DRIFTRIGHT}, {"BT_CUSTOM1",BT_CUSTOM1}, // Lua customizable {"BT_CUSTOM2",BT_CUSTOM2}, // Lua customizable {"BT_CUSTOM3",BT_CUSTOM3}, // Lua customizable diff --git a/src/g_game.c b/src/g_game.c index f9e92a4f..4f41d117 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -1150,16 +1150,15 @@ angle_t localangle, localangle2, localangle3, localangle4; boolean camspin, camspin2, camspin3, camspin4; static fixed_t forwardmove[2] = {25<>16, 50<>16}; -static fixed_t sidemove[2] = {25<>16, 50<>16}; // faster! +static fixed_t sidemove[2] = {2<>16, 4<>16}; static fixed_t angleturn[3] = {400, 800, 200}; // + slow turn void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) { - boolean forcestrafe = false; INT32 laim, th, tspeed, forward, side, axis; //i const INT32 speed = 1; // these ones used for multiple conditions - boolean turnleft, turnright, invertmouse, mouseaiming, lookaxis, analog, analogjoystickmove, gamepadjoystickmove, kbl, rd; + boolean turnleft, turnright, invertmouse, mouseaiming, lookaxis, analogjoystickmove, gamepadjoystickmove, kbl, rd; player_t *player; camera_t *thiscam; angle_t lang; @@ -1231,7 +1230,6 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) lookaxis = cv_lookaxis2.value; analogjoystickmove = cv_usejoystick2.value && !Joystick2.bGamepadStyle; gamepadjoystickmove = cv_usejoystick2.value && Joystick2.bGamepadStyle; - analog = cv_analog2.value; break; case 3: mouseaiming = false; @@ -1239,7 +1237,6 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) lookaxis = cv_lookaxis3.value; analogjoystickmove = cv_usejoystick3.value && !Joystick3.bGamepadStyle; gamepadjoystickmove = cv_usejoystick3.value && Joystick3.bGamepadStyle; - analog = cv_analog3.value; break; case 4: mouseaiming = false; @@ -1247,7 +1244,6 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) lookaxis = cv_lookaxis4.value; analogjoystickmove = cv_usejoystick4.value && !Joystick4.bGamepadStyle; gamepadjoystickmove = cv_usejoystick4.value && Joystick4.bGamepadStyle; - analog = cv_analog4.value; break; case 1: default: @@ -1256,7 +1252,6 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) lookaxis = cv_lookaxis.value; analogjoystickmove = cv_usejoystick.value && !Joystick.bGamepadStyle; gamepadjoystickmove = cv_usejoystick.value && Joystick.bGamepadStyle; - analog = cv_analog.value; break; } @@ -1292,49 +1287,66 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) else tspeed = speed; + cmd->driftturn = 0; + // let movement keys cancel each other out - if (analog) // Analog + if (turnright && !(turnleft)) { - if (turnright) - cmd->angleturn = (INT16)(cmd->angleturn - angleturn[tspeed]); - if (turnleft) - cmd->angleturn = (INT16)(cmd->angleturn + angleturn[tspeed]); + cmd->angleturn = (INT16)(cmd->angleturn - angleturn[tspeed]); + cmd->driftturn = (INT16)(cmd->driftturn - angleturn[tspeed]); + } + else if (turnleft && !(turnright)) + { + cmd->angleturn = (INT16)(cmd->angleturn + angleturn[tspeed]); + cmd->driftturn = (INT16)(cmd->driftturn + angleturn[tspeed]); } - if (analog || twodlevel - || (player->mo && (player->mo->flags2 & MF2_TWOD)) - || (!demoplayback && (player->climbing - || (player->pflags & PF_NIGHTSMODE) - || (player->pflags & PF_SLIDING) - || (player->pflags & PF_FORCESTRAFE)))) // Analog - forcestrafe = true; + if (analogjoystickmove && axis != 0) + { + // JOYAXISRANGE should be 1023 (divide by 1024) + cmd->angleturn = (INT16)(cmd->angleturn - ((axis * angleturn[1]) >> 10)); // ANALOG! + cmd->driftturn = (INT16)(cmd->driftturn - ((axis * angleturn[1]) >> 10)); + } - if (forcestrafe) // Analog + // Specator mouse turning + if (player->spectator) + { + cmd->angleturn = (INT16)(cmd->angleturn - (mousex*(mirrormode ? -1 : 1)*8)); + cmd->driftturn = (INT16)(cmd->driftturn - (mousex*(mirrormode ? -1 : 1)*8)); + } + + // Bounce pad strafing + if (!demoplayback && ((player->pflags & PF_FORCESTRAFE) || (player->kartstuff[k_feather] & 2))) { if (turnright) - side += sidemove[speed]; + side += sidemove[1]; if (turnleft) - side -= sidemove[speed]; - + side -= sidemove[1]; if (analogjoystickmove && axis != 0) { // JOYAXISRANGE is supposed to be 1023 (divide by 1024) - side += ((axis * sidemove[1]) >> 10); + side += ((axis * sidemove[0]) >> 10); } } - else - { - if (turnright && !(turnleft)) - cmd->angleturn = (INT16)(cmd->angleturn - angleturn[tspeed]); - else if (turnleft && !(turnright)) - cmd->angleturn = (INT16)(cmd->angleturn + angleturn[tspeed]); - if (analogjoystickmove && axis != 0) - { - // JOYAXISRANGE should be 1023 (divide by 1024) - cmd->angleturn = (INT16)(cmd->angleturn - ((axis * angleturn[1]) >> 10)); // ANALOG! - } - } + //{ SRB2kart - Drift support + // limit turning to angleturn[1] to stop mouselook letting you look too fast + if (cmd->angleturn > angleturn[1]) + cmd->angleturn = angleturn[1]; + else if (cmd->angleturn < -angleturn[1]) + cmd->angleturn = -angleturn[1]; + + if (cmd->driftturn > angleturn[1]) + cmd->driftturn = angleturn[1]; + else if (cmd->driftturn < -angleturn[1]) + cmd->driftturn = -angleturn[1]; + + if (player->mo) + cmd->angleturn = K_GetKartTurnValue(player, cmd->angleturn); + + // SRB2kart - no additional angle if not moving + if ((player->mo && player->speed > 0) || (leveltime > 140 && cmd->buttons & BT_ACCELERATE && cmd->buttons & BT_BRAKE) || (player->spectator || objectplacing)) + lang += (cmd->angleturn<<16); if (player->spectator || objectplacing) // SRB2Kart: spectators need special controls { @@ -1392,7 +1404,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (InputDown(gc_fire, ssplayer) || (cv_usejoystick.value && axis > 0)) cmd->buttons |= BT_ATTACK; - // drift button + // drift with any button/key axis = JoyAxis(AXISDRIFT, ssplayer); if (InputDown(gc_drift, ssplayer) || (cv_usejoystick.value && axis > 0)) cmd->buttons |= BT_DRIFT; @@ -1405,6 +1417,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) if (InputDown(gc_custom3, ssplayer)) cmd->buttons |= BT_CUSTOM3; + // Reset camera if (InputDown(gc_camreset, ssplayer)) { if (thiscam->chase && !rd) @@ -1414,7 +1427,7 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) else rd = false; - // player aiming shit, ahhhh... + // spectator aiming shit, ahhhh... { INT32 player_invert = invertmouse ? -1 : 1; INT32 screen_invert = @@ -1463,15 +1476,13 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) cmd->aiming = G_ClipAimingPitch(&laim); } - if (player->spectator) - cmd->angleturn = (INT16)(cmd->angleturn - (mousex*(mirrormode ? -1 : 1)*8)); - mousex = mousey = mlooky = 0; if (forward > MAXPLMOVE) forward = MAXPLMOVE; else if (forward < -MAXPLMOVE) forward = -MAXPLMOVE; + if (side > MAXPLMOVE) side = MAXPLMOVE; else if (side < -MAXPLMOVE) @@ -1479,86 +1490,20 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer) // No additional acceleration when moving forward/backward and strafing simultaneously. // do this AFTER we cap to MAXPLMOVE so people can't find ways to cheese around this. - if (!forcestrafe && forward && side) + // SRB2Kart: We don't need this; we WANT bounce strafing to plain stack on top of normal movement. + /*if (!bouncestrafe && forward && side) { forward = FixedMul(forward, 3*FRACUNIT/4); side = FixedMul(side, 3*FRACUNIT/4); - } + }*/ - //Silly hack to make 2d mode *somewhat* playable with no chasecam. - if ((twodlevel || (player->mo && player->mo->flags2 & MF2_TWOD)) && !thiscam->chase) - { - INT32 temp = forward; - forward = side; - side = temp; - } - - if (cmd->buttons & BT_BRAKE && !forward) // Sal: If you're not accelerating, but going forward, then you should just lose your momentum. Request from Sev - { - cmd->forwardmove = (SINT8)(cmd->forwardmove / 2); - cmd->sidemove = (SINT8)(cmd->sidemove / 2); - } - else + if (forward || side) { cmd->forwardmove = (SINT8)(cmd->forwardmove + forward); - if (mirrormode) - cmd->sidemove = (SINT8)(cmd->sidemove - side); - else - cmd->sidemove = (SINT8)(cmd->sidemove + side); + cmd->sidemove = (SINT8)(cmd->sidemove + side); } - if (ssplayer == 2 && player->bot == 1) { - if (!player->powers[pw_tailsfly] && (cmd->forwardmove || cmd->sidemove || cmd->buttons)) - { - player->bot = 2; // A player-controlled bot. Returns to AI when it respawns. - //CV_SetValue(&cv_analog2, true); - } - else - { - G_CopyTiccmd(cmd, I_BaseTiccmd2(), 1); // empty, or external driver - B_BuildTiccmd(player, cmd); - } - } - - //{ SRB2kart - Drift support - axis = JoyAxis(AXISTURN, ssplayer); - if (mirrormode) - axis = -axis; - - // TODO: Remove this hack please :( - if (cmd->angleturn > 0) // Drifting to the left - cmd->buttons |= BT_DRIFTLEFT; - else - cmd->buttons &= ~BT_DRIFTLEFT; - - if (cmd->angleturn < 0) // Drifting to the right - cmd->buttons |= BT_DRIFTRIGHT; - else - cmd->buttons &= ~BT_DRIFTRIGHT; - //} - - if (analog) { - cmd->angleturn = (INT16)(thiscam->angle >> 16); - if (player->awayviewtics) - cmd->angleturn = (INT16)(player->awayviewmobj->angle >> 16); - } - else - { - // limit turning to angleturn[1] to stop mouselook letting you look too fast - if (cmd->angleturn > angleturn[1]) - cmd->angleturn = angleturn[1]; - else if (cmd->angleturn < -angleturn[1]) - cmd->angleturn = -angleturn[1]; - - if (player->mo) - cmd->angleturn = K_GetKartTurnValue(player, cmd->angleturn); - - // SRB2kart - no additional angle if not moving - if ((player->mo && player->speed > 0) || (leveltime > 140 && cmd->buttons & BT_ACCELERATE && cmd->buttons & BT_BRAKE) || (player->spectator || objectplacing)) - lang += (cmd->angleturn<<16); - - cmd->angleturn = (INT16)(lang >> 16); - } + cmd->angleturn = (INT16)(lang >> 16); if (!hu_stopped) { @@ -4197,6 +4142,7 @@ char *G_BuildMapTitle(INT32 mapnum) #define ZT_ANGLE 0x04 #define ZT_BUTTONS 0x08 #define ZT_AIMING 0x10 +#define ZT_DRIFT 0x20 #define DEMOMARKER 0x80 // demoend static ticcmd_t oldcmd; @@ -4254,6 +4200,7 @@ ticcmd_t *G_MoveTiccmd(ticcmd_t* dest, const ticcmd_t* src, const size_t n) dest[i].angleturn = SHORT(src[i].angleturn); dest[i].aiming = (INT16)SHORT(src[i].aiming); dest[i].buttons = (UINT16)SHORT(src[i].buttons); + dest[i].driftturn = (INT16)SHORT(src[i].driftturn); } return dest; } @@ -4277,6 +4224,8 @@ void G_ReadDemoTiccmd(ticcmd_t *cmd, INT32 playernum) oldcmd.buttons = (oldcmd.buttons & (BT_FORWARD|BT_BACKWARD)) | (READUINT16(demo_p) & ~(BT_FORWARD|BT_BACKWARD)); if (ziptic & ZT_AIMING) oldcmd.aiming = READINT16(demo_p); + if (ziptic & ZT_DRIFT) + oldcmd.driftturn = READINT16(demo_p); G_CopyTiccmd(cmd, &oldcmd, 1); @@ -4333,6 +4282,13 @@ void G_WriteDemoTiccmd(ticcmd_t *cmd, INT32 playernum) ziptic |= ZT_AIMING; } + if (cmd->driftturn != oldcmd.driftturn) + { + WRITEINT16(demo_p,cmd->driftturn); + oldcmd.driftturn = cmd->driftturn; + ziptic |= ZT_DRIFT; + } + *ziptic_p = ziptic; // attention here for the ticcmd size! @@ -4705,6 +4661,8 @@ void G_GhostTicker(void) g->p += 2; if (ziptic & ZT_AIMING) g->p += 2; + if (ziptic & ZT_DRIFT) + g->p += 2; // Grab ghost data. ziptic = READUINT8(g->p); diff --git a/src/k_kart.c b/src/k_kart.c index 06f32a9e..06e10436 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -947,11 +947,11 @@ void K_KartMoveAnimation(player_t *player) // Standing frames - S_KART_STND1 S_KART_STND1_L S_KART_STND1_R if (player->speed == 0) { - if (cmd->buttons & BT_DRIFTRIGHT && !(player->mo->state >= &states[S_KART_STND1_R] && player->mo->state <= &states[S_KART_STND2_R])) + if (cmd->driftturn < 0 && !(player->mo->state >= &states[S_KART_STND1_R] && player->mo->state <= &states[S_KART_STND2_R])) P_SetPlayerMobjState(player->mo, S_KART_STND1_R); - else if (cmd->buttons & BT_DRIFTLEFT && !(player->mo->state >= &states[S_KART_STND1_L] && player->mo->state <= &states[S_KART_STND2_L])) + else if (cmd->driftturn > 0 && !(player->mo->state >= &states[S_KART_STND1_L] && player->mo->state <= &states[S_KART_STND2_L])) P_SetPlayerMobjState(player->mo, S_KART_STND1_L); - else if (!(cmd->buttons & BT_DRIFTRIGHT || cmd->buttons & BT_DRIFTLEFT) && !(player->mo->state >= &states[S_KART_STND1] && player->mo->state <= &states[S_KART_STND2])) + else if (cmd->driftturn == 0 && !(player->mo->state >= &states[S_KART_STND1] && player->mo->state <= &states[S_KART_STND2])) P_SetPlayerMobjState(player->mo, S_KART_STND1); } // Drifting Left - S_KART_DRIFT1_L @@ -969,21 +969,21 @@ void K_KartMoveAnimation(player_t *player) // Run frames - S_KART_RUN1 S_KART_RUN1_L S_KART_RUN1_R else if (player->speed > FixedMul(player->runspeed, player->mo->scale)) { - if (cmd->buttons & BT_DRIFTRIGHT && !(player->mo->state >= &states[S_KART_RUN1_R] && player->mo->state <= &states[S_KART_RUN2_R])) + if (cmd->driftturn < 0 && !(player->mo->state >= &states[S_KART_RUN1_R] && player->mo->state <= &states[S_KART_RUN2_R])) P_SetPlayerMobjState(player->mo, S_KART_RUN1_R); - else if (cmd->buttons & BT_DRIFTLEFT && !(player->mo->state >= &states[S_KART_RUN1_L] && player->mo->state <= &states[S_KART_RUN2_L])) + else if (cmd->driftturn > 0 && !(player->mo->state >= &states[S_KART_RUN1_L] && player->mo->state <= &states[S_KART_RUN2_L])) P_SetPlayerMobjState(player->mo, S_KART_RUN1_L); - else if (!(cmd->buttons & BT_DRIFTRIGHT || cmd->buttons & BT_DRIFTLEFT) && !(player->mo->state >= &states[S_KART_RUN1] && player->mo->state <= &states[S_KART_RUN2])) + else if (cmd->driftturn == 0 && !(player->mo->state >= &states[S_KART_RUN1] && player->mo->state <= &states[S_KART_RUN2])) P_SetPlayerMobjState(player->mo, S_KART_RUN1); } // Walk frames - S_KART_WALK1 S_KART_WALK1_L S_KART_WALK1_R else if (player->speed <= FixedMul(player->runspeed, player->mo->scale)) { - if (cmd->buttons & BT_DRIFTRIGHT && !(player->mo->state >= &states[S_KART_WALK1_R] && player->mo->state <= &states[S_KART_WALK2_R])) + if (cmd->driftturn < 0 && !(player->mo->state >= &states[S_KART_WALK1_R] && player->mo->state <= &states[S_KART_WALK2_R])) P_SetPlayerMobjState(player->mo, S_KART_WALK1_R); - else if (cmd->buttons & BT_DRIFTLEFT && !(player->mo->state >= &states[S_KART_WALK1_L] && player->mo->state <= &states[S_KART_WALK2_L])) + else if (cmd->driftturn > 0 && !(player->mo->state >= &states[S_KART_WALK1_L] && player->mo->state <= &states[S_KART_WALK2_L])) P_SetPlayerMobjState(player->mo, S_KART_WALK1_L); - else if (!(cmd->buttons & BT_DRIFTRIGHT || cmd->buttons & BT_DRIFTLEFT) && !(player->mo->state >= &states[S_KART_WALK1] && player->mo->state <= &states[S_KART_WALK2])) + else if (cmd->driftturn == 0 && !(player->mo->state >= &states[S_KART_WALK1] && player->mo->state <= &states[S_KART_WALK2])) P_SetPlayerMobjState(player->mo, S_KART_WALK1); } } @@ -1344,6 +1344,15 @@ fixed_t K_3dKartMovement(player_t *player, boolean onground, fixed_t forwardmove if (!onground) return 0; // If the player isn't on the ground, there is no change in speed + if (forwardmove <= 0 && player->kartstuff[k_brakestop] < 6) // Don't start reversing with brakes until you've made a stop first + { + if (player->speed < 8*FRACUNIT) + player->kartstuff[k_brakestop]++; + return 0; + } + else if (forwardmove > 0) + player->kartstuff[k_brakestop] = 0; + // ACCELCODE!!!1!11! oldspeed = R_PointToDist2(0, 0, player->rmomx, player->rmomy); // FixedMul(P_AproxDistance(player->rmomx, player->rmomy), player->mo->scale); newspeed = FixedDiv(FixedDiv(FixedMul(oldspeed, accelmax - p_accel) + FixedMul(p_speed, p_accel), accelmax), ORIG_FRICTION); @@ -2423,7 +2432,7 @@ static void K_KartDrift(player_t *player, boolean onground) kartspeed = 1; // IF YOU CHANGE THESE: MAKE SURE YOU UPDATE THE SAME VALUES IN p_mobjc, "case MT_DRIFT:" - dsone = 26*4 + kartspeed*2 + (9 - player->kartweight); + dsone = (26*4 + kartspeed*2 + (9 - player->kartweight))*8; dstwo = dsone*2; // Drifting is actually straffing + automatic turning. @@ -2457,7 +2466,7 @@ static void K_KartDrift(player_t *player, boolean onground) } // Drifting: left or right? - if ((player->cmd.buttons & BT_DRIFTLEFT) && player->speed > FixedMul(10<<16, player->mo->scale) && player->kartstuff[k_jmp] == 1 + if ((player->cmd.driftturn > 0) && player->speed > FixedMul(10<<16, player->mo->scale) && player->kartstuff[k_jmp] == 1 && (player->kartstuff[k_drift] == 0 || player->kartstuff[k_driftend] == 1)) // && player->kartstuff[k_drift] != 1) { // Starting left drift @@ -2465,7 +2474,7 @@ static void K_KartDrift(player_t *player, boolean onground) player->kartstuff[k_driftend] = 0; player->kartstuff[k_driftcharge] = 0; } - else if ((player->cmd.buttons & BT_DRIFTRIGHT) && player->speed > FixedMul(10<<16, player->mo->scale) && player->kartstuff[k_jmp] == 1 + else if ((player->cmd.driftturn < 0) && player->speed > FixedMul(10<<16, player->mo->scale) && player->kartstuff[k_jmp] == 1 && (player->kartstuff[k_drift] == 0 || player->kartstuff[k_driftend] == 1)) // && player->kartstuff[k_drift] != -1) { // Starting right drift @@ -2494,7 +2503,7 @@ static void K_KartDrift(player_t *player, boolean onground) if (player->kartstuff[k_spinouttimer] == 0 && player->kartstuff[k_jmp] == 1 && onground && player->kartstuff[k_drift] != 0) { - fixed_t driftadditive = 3; + fixed_t driftadditive = 24; if (player->kartstuff[k_drift] >= 1) // Drifting to the left { @@ -2502,10 +2511,10 @@ static void K_KartDrift(player_t *player, boolean onground) if (player->kartstuff[k_drift] > 5) player->kartstuff[k_drift] = 5; - if (player->cmd.buttons & BT_DRIFTLEFT) // Inward - driftadditive++; - if (player->cmd.buttons & BT_DRIFTRIGHT) // Outward - driftadditive--; + if (player->cmd.driftturn > 0) // Inward + driftadditive += (player->cmd.driftturn/800)/8; + if (player->cmd.driftturn < 0) // Outward + driftadditive -= (player->cmd.driftturn/800)/8; } else if (player->kartstuff[k_drift] <= -1) // Drifting to the right { @@ -2513,10 +2522,10 @@ static void K_KartDrift(player_t *player, boolean onground) if (player->kartstuff[k_drift] < -5) player->kartstuff[k_drift] = -5; - if (player->cmd.buttons & BT_DRIFTRIGHT) // Inward - driftadditive++; - if (player->cmd.buttons & BT_DRIFTLEFT) // Outward - driftadditive--; + if (player->cmd.driftturn < 0) // Inward + driftadditive += (player->cmd.driftturn/800)/4; + if (player->cmd.driftturn > 0) // Outward + driftadditive -= (player->cmd.driftturn/800)/4; } // This spawns the drift sparks @@ -3325,24 +3334,10 @@ void K_MoveKartPlayer(player_t *player, boolean onground) K_KartDrift(player, onground); - // Feather strafing - if (player->kartstuff[k_feather] & 2) - { - fixed_t strafe = 0; - fixed_t strength = FRACUNIT/32; - if (cmd->buttons & BT_DRIFTLEFT) - strafe--; - if (cmd->buttons & BT_DRIFTRIGHT) - strafe++; - strength += FixedDiv(player->speed, K_GetKartSpeed(player, true)); - P_Thrust(player->mo, player->mo->angle-ANGLE_90, strafe*strength); - } - // Quick Turning // You can't turn your kart when you're not moving. // So now it's time to burn some rubber! - if (player->speed < 2 && leveltime > 140 && cmd->buttons & BT_ACCELERATE && cmd->buttons & BT_BRAKE - && ((cmd->buttons & BT_DRIFTLEFT) || (cmd->buttons & BT_DRIFTRIGHT))) + if (player->speed < 2 && leveltime > 140 && cmd->buttons & BT_ACCELERATE && cmd->buttons & BT_BRAKE && cmd->driftturn != 0) { if (leveltime % 20 == 0) S_StartSound(player->mo, sfx_mkslid); diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 0d488fdb..1eed10b0 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -733,6 +733,8 @@ static int ticcmd_get(lua_State *L) lua_pushinteger(L, cmd->aiming); else if (fastcmp(field,"buttons")) lua_pushinteger(L, cmd->buttons); + else if (fastcmp(field,"driftturn")) + lua_pushinteger(L, cmd->driftturn); else return NOFIELD; @@ -759,6 +761,8 @@ static int ticcmd_set(lua_State *L) cmd->aiming = (INT16)luaL_checkinteger(L, 3); else if (fastcmp(field,"buttons")) cmd->buttons = (UINT16)luaL_checkinteger(L, 3); + else if (fastcmp(field,"driftturn")) + cmd->driftturn = (INT16)luaL_checkinteger(L, 3); else return NOFIELD; diff --git a/src/p_mobj.c b/src/p_mobj.c index 2ba98af0..4176881e 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2891,6 +2891,12 @@ static void P_PlayerZMovement(mobj_t *mo) mo->momx = mo->momx/2; mo->momy = mo->momy/2; } + + if (mo->player->cmd.buttons & BT_BRAKE && !(mo->player->cmd.forwardmove)) // FURTHER slowdown if you're braking. + { + mo->momx = mo->momx/2; + mo->momy = mo->momy/2; + } } if (mo->health) @@ -6559,7 +6565,7 @@ void P_MobjThinker(mobj_t *mobj) if (G_BattleGametype() && mobj->target->player->kartstuff[k_balloon] <= 0) kartspeed = 1; - dsone = 26*4 + kartspeed*2 + (9 - mobj->target->player->kartweight); + dsone = (26*4 + kartspeed*2 + (9 - mobj->target->player->kartweight))*8; dstwo = dsone*2; if (mobj->target->player->kartstuff[k_driftcharge] < dsone) diff --git a/src/p_user.c b/src/p_user.c index 80da049f..20a0e4eb 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4684,7 +4684,6 @@ static void P_3dMovement(player_t *player) angle_t movepushangle, movepushsideangle; // Analog //INT32 topspeed, acceleration, thrustfactor; fixed_t movepushforward = 0, movepushside = 0; - INT32 mforward = 0, mbackward = 0; angle_t dangle; // replaces old quadrants bits //boolean dangleflip = false; // SRB2kart - toaster //fixed_t normalspd = FixedMul(player->normalspeed, player->mo->scale); @@ -4772,12 +4771,6 @@ static void P_3dMovement(player_t *player) //dangleflip = true; } - // now use it to determine direction! - if (dangle <= ANGLE_45) // angles 0-45 or 315-360 - mforward = 1; // going forwards - else if (dangle >= ANGLE_135) // angles 135-225 - mbackward = 1; // going backwards - // anything else will leave both at 0, so no need to do anything else //{ SRB2kart 220217 - Toaster Code for misplaced thrust @@ -4803,104 +4796,13 @@ static void P_3dMovement(player_t *player) cmd->forwardmove = 0; // Do not let the player control movement if not onground. - onground = P_IsObjectOnGround(player->mo); - - // SRB2Kart: shhhhhhh don't question me, feather and speed bumps are supposed to control like you're on the ground :p - if (player->kartstuff[k_feather] & 2) - onground = true; + // SRB2Kart: feather and speed bumps are supposed to control like you're on the ground + onground = (P_IsObjectOnGround(player->mo) || (player->kartstuff[k_feather] & 2)); player->aiming = cmd->aiming<pflags & PF_SLIDING) - { - normalspd = FixedMul(36<mo->scale); - thrustfactor = 5; - acceleration = 96 + (FixedDiv(player->speed, player->mo->scale)>>FRACBITS) * 40; - topspeed = normalspd; - } - else if (player->bot) - { // Bot steals player 1's stats - normalspd = FixedMul(players[consoleplayer].normalspeed, player->mo->scale); - thrustfactor = players[consoleplayer].thrustfactor; - acceleration = players[consoleplayer].accelstart + (FixedDiv(player->speed, player->mo->scale)>>FRACBITS) * players[consoleplayer].acceleration; - - if (player->powers[pw_tailsfly]) - topspeed = normalspd/2; - else if (player->mo->eflags & (MFE_UNDERWATER|MFE_GOOWATER)) - { - topspeed = normalspd/2; - acceleration = 2*acceleration/3; - } - else - topspeed = normalspd; - } - else if (player->powers[pw_super] || player->powers[pw_sneakers] || player->kartstuff[k_startimer] || player->kartstuff[k_mushroomtimer]) - { - if (player->powers[pw_sneakers] && (player->kartstuff[k_growshrinktimer] > 0 || player->kartstuff[k_mushroomtimer] > 0 || player->kartstuff[k_startimer] > 0)) - thrustfactor = player->thrustfactor*3; - else - thrustfactor = player->thrustfactor*2; - acceleration = player->accelstart/2 + (FixedDiv(player->speed, player->mo->scale)>>FRACBITS) * player->acceleration/2; - - - if (player->powers[pw_tailsfly]) - topspeed = normalspd; - else if (player->mo->eflags & (MFE_UNDERWATER|MFE_GOOWATER)) - { - topspeed = normalspd; - acceleration = 2*acceleration/3; - } - - if (cmd->forwardmove < 0) - topspeed = 5<<16; - else - topspeed = (normalspd * 3)/2; //> 60<<16 ? 60<<16 : normalspd * 2; - } - else - { - thrustfactor = player->thrustfactor; - acceleration = player->accelstart + (FixedDiv(player->speed, player->mo->scale)>>FRACBITS) * player->acceleration; - - - if (player->powers[pw_tailsfly]) - topspeed = normalspd/2; - else if (player->mo->eflags & (MFE_UNDERWATER|MFE_GOOWATER)) - { - topspeed = normalspd/2; - acceleration = 2*acceleration/3; - } - if (cmd->forwardmove < 0) - topspeed = 5<<16; - else - topspeed = normalspd; - } - - // Better maneuverability while flying - //if(player->powers[pw_tailsfly]) - //{ - // thrustfactor = player->thrustfactor*2; - // acceleration = player->accelstart + (FixedDiv(player->speed, player->mo->scale)>>FRACBITS) * player->acceleration; - //} - - if (player->mo->movefactor != FRACUNIT) // Friction-scaled acceleration... - acceleration = FixedMul(acceleration<mo->movefactor)>>FRACBITS; - */ - // Forward movement - if (player->climbing) - { - if (cmd->forwardmove) - { - P_SetObjectMomZ(player->mo, FixedDiv(cmd->forwardmove*FRACUNIT, 10*FRACUNIT), false); - if (player->powers[pw_super] && ALL7EMERALDS(player->powers[pw_emeralds])) - player->mo->momz *= 2; - } - } - else if (!analogmove - //&& cmd->forwardmove != 0 - && !(player->pflags & PF_GLIDING || player->exiting - || (P_PlayerInPain(player) && !onground))) + if (!(player->exiting || (P_PlayerInPain(player) && !onground))) { //movepushforward = cmd->forwardmove * (thrustfactor * acceleration); movepushforward = K_3dKartMovement(player, onground, cmd->forwardmove); @@ -4909,25 +4811,14 @@ static void P_3dMovement(player_t *player) if (!onground) movepushforward >>= 2; // proper air movement - // Allow a bit of movement while spinning - if (player->pflags & PF_SPINNING) - { - if ((mforward && cmd->forwardmove > 0) || (mbackward && cmd->forwardmove < 0)) - movepushforward = 0; - else if (!(player->pflags & PF_STARTDASH)) - movepushforward = FixedDiv(movepushforward, 16*FRACUNIT); - else - movepushforward = 0; - } - // don't need to account for scale here with kart accel code //movepushforward = FixedMul(movepushforward, player->mo->scale); if (player->mo->movefactor != FRACUNIT) // Friction-scaled acceleration... movepushforward = FixedMul(movepushforward, player->mo->movefactor); - //if (mforward && cmd->forwardmove < 0) // SRB2kart - braking isn't instant - // movepushforward /= 32; + if (cmd->buttons & BT_BRAKE && !cmd->forwardmove) // SRB2kart - braking isn't instant + movepushforward /= 64; #ifdef ESLOPE totalthrust.x += P_ReturnThrustX(player->mo, movepushangle, movepushforward); @@ -4940,91 +4831,14 @@ static void P_3dMovement(player_t *player) { K_MomentumToFacing(player); } + // Sideways movement - if (player->climbing) + if (cmd->sidemove != 0 && !(player->exiting || (P_PlayerInPain(player)))) { - if (player->powers[pw_super] && ALL7EMERALDS(player->powers[pw_emeralds])) - P_InstaThrust(player->mo, player->mo->angle-ANGLE_90, FixedMul(FixedDiv(cmd->sidemove*FRACUNIT, 5*FRACUNIT), player->mo->scale)); - else - P_InstaThrust(player->mo, player->mo->angle-ANGLE_90, FixedMul(FixedDiv(cmd->sidemove*FRACUNIT, 10*FRACUNIT), player->mo->scale)); - } - // Analog movement control - else if (analogmove) - { - if (!(player->pflags & PF_GLIDING || player->exiting || P_PlayerInPain(player))) - { - angle_t controldirection; - - // Calculate the angle at which the controls are pointing - // to figure out the proper mforward and mbackward. - // (Why was it so complicated before? ~Red) - controldirection = R_PointToAngle2(0, 0, cmd->forwardmove*FRACUNIT, -cmd->sidemove*FRACUNIT)+movepushangle; - - //movepushforward = max(abs(cmd->sidemove), abs(cmd->forwardmove)) * (thrustfactor * acceleration); - movepushforward = K_3dKartMovement(player, onground, max(abs(cmd->sidemove), abs(cmd->forwardmove))); - - // allow very small movement while in air for gameplay - if (!onground) - movepushforward >>= 2; // proper air movement - - // Allow a bit of movement while spinning - if (player->pflags & PF_SPINNING) - { - // Stupid little movement prohibitor hack - // that REALLY shouldn't belong in analog code. - if ((mforward && cmd->forwardmove > 0) || (mbackward && cmd->forwardmove < 0)) - movepushforward = 0; - else if (!(player->pflags & PF_STARTDASH)) - movepushforward = FixedDiv(movepushforward, 16*FRACUNIT); - else - movepushforward = 0; - } - - movepushsideangle = controldirection; - - // don't need to account for scale here with kart accel code - //movepushforward = FixedMul(movepushforward, player->mo->scale); - - //if (mforward && cmd->forwardmove < 0) // SRB2kart - braking isn't instant - // movepushforward /= 32; - -#ifdef ESLOPE - totalthrust.x += P_ReturnThrustX(player->mo, controldirection, movepushforward); - totalthrust.y += P_ReturnThrustY(player->mo, controldirection, movepushforward); -#else - P_Thrust(player->mo, controldirection, movepushforward); -#endif - } - } - else if (cmd->sidemove && !(player->pflags & PF_GLIDING) && !player->exiting && !P_PlayerInPain(player)) - { - //movepushside = cmd->sidemove * (thrustfactor * acceleration); if (cmd->sidemove > 0) - movepushside = K_3dKartMovement(player, onground, 50); + movepushside = (cmd->sidemove * FRACUNIT/128) + FixedDiv(player->speed, K_GetKartSpeed(player, true)); else - movepushside = -(K_3dKartMovement(player, onground, 50)); - - if (!onground) - { - movepushside >>= 2; - - // Reduce movepushslide even more if over "max" flight speed - if (player->powers[pw_tailsfly] && player->speed > K_GetKartSpeed(player, true)) //topspeed) - movepushside >>= 2; - } - - // Allow a bit of movement while spinning - if (player->pflags & PF_SPINNING) - { - if (!(player->pflags & PF_STARTDASH)) - movepushside = FixedDiv(movepushside,16*FRACUNIT); - else - movepushside = 0; - } - - // Finally move the player now that his speed/direction has been decided. - // don't need to account for scale here with kart accel code - //movepushside = FixedMul(movepushside, player->mo->scale); + movepushside = (cmd->sidemove * FRACUNIT/128) - FixedDiv(player->speed, K_GetKartSpeed(player, true)); #ifdef ESLOPE totalthrust.x += P_ReturnThrustX(player->mo, movepushsideangle, movepushside); @@ -6496,13 +6310,13 @@ void P_ElementalFireTrail(player_t *player) } } -static void P_SkidStuff(player_t *player) +/*static void P_SkidStuff(player_t *player) { fixed_t pmx = player->rmomx + player->cmomx; fixed_t pmy = player->rmomy + player->cmomy; // Knuckles glides into the dirt. - /* // SRB2kart - don't need + // SRB2kart - don't need if (player->pflags & PF_GLIDING && player->skidtime) { // Fell off a ledge... @@ -6540,7 +6354,7 @@ static void P_SkidStuff(player_t *player) } } // Skidding! - else*/if (onground && !(player->mo->eflags & MFE_GOOWATER) && !(player->pflags & (PF_JUMPED|PF_SPINNING|PF_SLIDING)) && !(player->charflags & SF_NOSKID)) + elseif (onground && !(player->mo->eflags & MFE_GOOWATER) && !(player->pflags & (PF_JUMPED|PF_SPINNING|PF_SLIDING)) && !(player->charflags & SF_NOSKID)) { if (player->skidtime) { @@ -6587,7 +6401,7 @@ static void P_SkidStuff(player_t *player) S_StopSound(player->mo); } } -} +}*/ // // P_MovePlayer @@ -6762,7 +6576,7 @@ static void P_MovePlayer(player_t *player) if (maptol & TOL_2D) runspd = FixedMul(runspd, 2*FRACUNIT/3); - P_SkidStuff(player); + //P_SkidStuff(player); ///////////////////////// // MOVEMENT ANIMATIONS //