From fadcd17022104f512c4034a65f8474bf75c8af1e Mon Sep 17 00:00:00 2001 From: ZTsukei Date: Thu, 9 Feb 2017 23:57:31 -0500 Subject: [PATCH] Some accelcode changes to let CC's work. --- src/d_netcmd.c | 6 ++--- src/d_player.h | 8 +++---- src/k_kart.c | 64 ++++++++++++++++++++++++++------------------------ src/k_kart.h | 1 + src/p_user.c | 12 +++++----- 5 files changed, 47 insertions(+), 44 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index ab7985494..e949358d2 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -207,7 +207,7 @@ static consvar_t cv_fishcake = {"fishcake", "Off", CV_CALL|CV_NOSHOWHELP|CV_REST static consvar_t cv_dummyconsvar = {"dummyconsvar", "Off", CV_CALL|CV_NOSHOWHELP, CV_OnOff, DummyConsvar_OnChange, 0, NULL, NULL, 0, 0, NULL}; -consvar_t cv_restrictskinchange = {"restrictskinchange", "Yes", CV_NETVAR|CV_CHEAT, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; +consvar_t cv_restrictskinchange = {"restrictskinchange", "No", CV_NETVAR|CV_CHEAT, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_allowteamchange = {"allowteamchange", "Yes", CV_NETVAR, CV_YesNo, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_startinglives = {"startinglives", "3", CV_NETVAR|CV_CHEAT, startingliveslimit_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; @@ -1017,8 +1017,8 @@ UINT8 CanChangeSkin(INT32 playernum) if (gametype == GT_COOP) return true; - // Can change skin during initial countdown. // SRB2kart - Can always change skin in the level - if (gametype == GT_RACE || gametype == GT_COMPETITION) // if ((gametype == GT_RACE || gametype == GT_COMPETITION) && leveltime < 4*TICRATE) + // Can change skin during initial countdown. + if ((gametype == GT_RACE || gametype == GT_COMPETITION) && leveltime < 4*TICRATE) return true; if (G_TagGametype()) diff --git a/src/d_player.h b/src/d_player.h index 06792418b..d33947376 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -241,23 +241,23 @@ 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_throwdir, // Held dir of controls; 1 = forward, 0 = none, -1 = backward (was "player->heldDir") k_turndir, // Turn direction for drifting; -1 = Left, 1 = Right, 0 = none k_sounds, // Used this to avoid sounds being played every tic - + k_boosting, // Determines if you're currently shroom-boosting to change how drifting works k_floorboost, // Prevents Mushroom sounds for a breif duration when triggered by a floor panel k_spinout, // Separate confirmation to prevent endless wipeout loops k_spinouttype, // Determines whether to thrust forward or not while spinning out; 0 = move forwards, 1 = stay still - + k_drift, // Drifting Left or Right, plus a bigger counter = sharper turn k_driftcharge, // Charge your drift so you can release a burst of speed 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_lakitu, // > 0 = Lakitu fishing, < 0 = Lakitu lap counter (was "player->airtime") // NOTE: Check for ->lakitu, replace with this k_offroad, // In Super Mario Kart, going offroad has lee-way of about 1 second before you start losing speed - + k_itemroulette, // Used for the roulette when deciding what item to give you (was "pw_kartitem") k_itemclose, // Used to animate the item window closing (was "pw_psychic") diff --git a/src/k_kart.c b/src/k_kart.c index 71210a63e..c87b4cb07 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1051,8 +1051,8 @@ void K_SpinPlayer(player_t *player, mobj_t *source) else player->kartstuff[k_spinouttimer] = 3*TICRATE/2; - if (player->speed < player->normalspeed/4) - P_InstaThrust(player->mo, player->mo->angle, FixedMul(player->normalspeed/4, player->mo->scale)); + if (player->speed < K_GetKartSpeed(player)/4) // player->normalspeed/4) + P_InstaThrust(player->mo, player->mo->angle, FixedMul(K_GetKartSpeed(player)/4, player->mo->scale)); // FixedMul(player->normalspeed/4, player->mo->scale)); S_StartSound(player->mo, sfx_slip); } @@ -1722,23 +1722,24 @@ void K_KartDrift(player_t *player, ticcmd_t *cmd, boolean onground) } } -UINT64 K_GetKartSpeed(player_t *player) +// Game CC - This will become a netgame variable, just here for testing now +fixed_t g_cc = ((2) + 6)*FRACUNIT/8; + +fixed_t K_GetKartSpeed(player_t *player) { - UINT64 k_speed = 47*FRACUNIT + FRACUNIT/2; - - // Speed is a value between 48 and 52, incremented by halves - k_speed += player->kartspeed*FRACUNIT/2; - - return k_speed; + fixed_t k_speed = 151; + + k_speed += player->kartspeed; // 152 - 160 + + return FixedMul(k_speed<<14, g_cc); } -UINT64 K_GetKartAccel(player_t *player) +fixed_t K_GetKartAccel(player_t *player) { - UINT64 k_accel = 45; - - // Acceleration is a given base, minus the speed value. - k_accel -= 3*player->kartspeed; - + fixed_t k_accel = 36; + + k_accel += 3 * (9 - player->kartspeed); // 36 - 60 + return k_accel; } @@ -1746,18 +1747,15 @@ fixed_t K_3dKartMovement(player_t *player, boolean onground) { // If the player isn't on the ground, there is no change in speed if (!onground) return 0; - - fixed_t accelmax = 2000; // AccelMax - fixed_t f_beater = 2*FRACUNIT - (0xE8<<(FRACBITS-8)); //1.10345f; // Friction Beater Friction = (0xE8 << (FRACBITS-8)) - fixed_t g_cc = 1*FRACUNIT; // Game CC - + + fixed_t accelmax = 4000; // AccelMax fixed_t newspeed, oldspeed, finalspeed; fixed_t boostpower = 1*FRACUNIT; fixed_t p_speed = K_GetKartSpeed(player); fixed_t p_accel = K_GetKartAccel(player); - + sector_t *nextsector = R_PointInSubsector(player->mo->x + player->mo->momx*2, player->mo->y + player->mo->momy*2)->sector; - + // Determine boostpower by checking every power. There's probably a cleaner way to do this, but eh whatever. if (!(player->kartstuff[k_startimer] || player->kartstuff[k_bootaketimer] || player->powers[pw_sneakers] || player->kartstuff[k_mushroomtimer] || player->kartstuff[k_growshrinktimer] > 1) && P_IsObjectOnGround(player->mo) && @@ -1769,22 +1767,26 @@ fixed_t K_3dKartMovement(player_t *player, boolean onground) if (player->kartstuff[k_growshrinktimer] > 1) boostpower = FixedMul(boostpower, FRACUNIT+FRACUNIT/3); // Mega Mushroom if (player->kartstuff[k_startimer]) boostpower = FixedMul(boostpower, FRACUNIT+FRACUNIT/2); // Star if (player->kartstuff[k_mushroomtimer]) boostpower = FixedMul(boostpower, FRACUNIT+FRACUNIT/1); // Mushroom - + // Boostpower is applied to each stat individually, and NOT the calculation. // Applying to the calculation fails due to friction never getting beaten, or getting overshot really far. // It's easier this way. - // Similarly, the CC of the game is also multiplied directly. - // This assures a growth in speed without affecting acceleration curving. - p_speed = FixedMul(FixedMul(p_speed, boostpower), g_cc); - p_accel = FixedMul(FixedMul(p_accel, boostpower), g_cc); - accelmax = FixedMul(FixedMul(accelmax, boostpower), g_cc); + p_speed = FixedMul(p_speed, boostpower); + p_accel = FixedMul(p_accel, boostpower); + accelmax = FixedMul(accelmax, boostpower); // Now, the code that made Iceman's eyes rub erotically against a toaster. - oldspeed = FixedMul(FixedMul(P_AproxDistance(player->rmomx, player->rmomy), player->mo->scale), f_beater); - newspeed = FixedMul(FixedDiv(FixedMul(oldspeed, accelmax - p_accel) + FixedMul(p_speed, p_accel), accelmax), f_beater); + oldspeed = 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); finalspeed = newspeed - oldspeed; - return (fixed_t)finalspeed; + CONS_Printf("Game CC = %d\n", g_cc); + CONS_Printf("finalspeed = %d\n", finalspeed); + + // 245498 + // 498024 + + return finalspeed; } void K_MoveKartPlayer(player_t *player, ticcmd_t *cmd, boolean onground) diff --git a/src/k_kart.h b/src/k_kart.h index 014eb5819..1feec6441 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -22,6 +22,7 @@ void K_ExplodePlayer(player_t *player, mobj_t *source); void K_SpawnKartExplosion(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT32 number, mobjtype_t type, angle_t rotangle, boolean spawncenter, boolean ghostit); void K_SpawnDriftTrail(player_t *player); void K_DoMushroom(player_t *player, boolean doPFlag); +fixed_t K_GetKartSpeed(player_t *player); fixed_t K_3dKartMovement(player_t *player, boolean onground); void K_MoveKartPlayer(player_t *player, ticcmd_t *cmd, boolean onground); diff --git a/src/p_user.c b/src/p_user.c index 59d529a21..d72c632a3 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4876,10 +4876,10 @@ static void P_3dMovement(player_t *player) // If "no" to 1, we're not reaching any limits yet, so ignore this entirely! // -Shadow Hog newMagnitude = R_PointToDist2(player->mo->momx - player->cmomx, player->mo->momy - player->cmomy, 0, 0); - if (newMagnitude > topspeed) + if (newMagnitude > K_GetKartSpeed(player)) //topspeed) { fixed_t tempmomx, tempmomy; - if (oldMagnitude > topspeed) + if (oldMagnitude > K_GetKartSpeed(player)) //topspeed) { if (newMagnitude > oldMagnitude) { @@ -4892,8 +4892,8 @@ static void P_3dMovement(player_t *player) } else { - tempmomx = FixedMul(FixedDiv(player->mo->momx - player->cmomx, newMagnitude), topspeed); - tempmomy = FixedMul(FixedDiv(player->mo->momy - player->cmomy, newMagnitude), topspeed); + tempmomx = FixedMul(FixedDiv(player->mo->momx - player->cmomx, newMagnitude), K_GetKartSpeed(player)); //topspeed) + tempmomy = FixedMul(FixedDiv(player->mo->momy - player->cmomy, newMagnitude), K_GetKartSpeed(player)); //topspeed) player->mo->momx = tempmomx + player->cmomx; player->mo->momy = tempmomy + player->cmomy; } @@ -7876,8 +7876,8 @@ static void P_DeathThink(player_t *player) if ((cmd->buttons & BT_JUMP || cmd->buttons & BT_ACCELERATE) && (gametype == GT_RACE || player->spectator)) player->playerstate = PST_REBORN; - // One second respawn in coop. - if ((cmd->buttons & BT_JUMP || cmd->buttons & BT_ACCELERATE) && player->deadtimer > TICRATE && (gametype == GT_COOP || gametype == GT_COMPETITION)) + // One second respawn in coop. // SRB2kart - Race maybe? + if ((cmd->buttons & BT_JUMP || cmd->buttons & BT_ACCELERATE) && player->deadtimer > TICRATE && gametype == GT_RACE)//(gametype == GT_COOP || gametype == GT_COMPETITION)) player->playerstate = PST_REBORN; // Single player auto respawn