Remove unused ebrakemask, update throwprediction to be accurate, remove unsued DI code

This commit is contained in:
NepDisk 2024-08-08 18:56:54 -04:00
parent b45cf26215
commit ec59e713b7
6 changed files with 25 additions and 112 deletions

View file

@ -490,8 +490,6 @@ typedef struct player_s
UINT8 confirmVictim; // Player ID that you dealt damage to
UINT8 confirmVictimDelay; // Delay before playing the sound
tic_t ebrakefor; // Ebrake timer, used for visuals.
UINT32 roundscore; // battle score this round
UINT8 emeralds;
UINT8 bumpers;

View file

@ -32,8 +32,6 @@ typedef enum
BT_ATTACK = 1<<4, // Use Item
BT_LOOKBACK = 1<<5, // Look Backward
BT_EBRAKEMASK = (BT_ACCELERATE|BT_BRAKE),
// free: 1<<6 to 1<<12
// Lua garbage

View file

@ -1122,20 +1122,6 @@ static INT32 K_HandleBotReverse(player_t *player, ticcmd_t *cmd, botprediction_t
}
}
#define STEEP_SLOPE (FRACUNIT*11/10)
if (slopeMul > STEEP_SLOPE)
{
// Slope is too steep to reverse -- EBrake.
cmd->forwardmove = 0;
cmd->buttons |= BT_ACCELERATE|BT_BRAKE;
}
else
{
cmd->forwardmove = -MAXPLMOVE;
cmd->buttons |= BT_BRAKE; //|BT_LOOKBACK
}
#undef STEEP_SLOPE
if (anglediff < 10)
{
turnamt = 0;

View file

@ -169,9 +169,30 @@ static player_t *K_PlayerPredictThrow(player_t *player, UINT8 extra)
{
const fixed_t dist = (30 + (extra * 10)) * player->mo->scale;
const UINT32 airtime = FixedDiv(dist + player->mo->momz, gravity);
const fixed_t throwspeed = FixedMul(82 * mapobjectscale, K_GetKartGameSpeedScalar(gamespeed));
const fixed_t estx = player->mo->x + P_ReturnThrustX(NULL, player->mo->angle, (throwspeed + player->speed) * airtime);
const fixed_t esty = player->mo->y + P_ReturnThrustY(NULL, player->mo->angle, (throwspeed + player->speed) * airtime);
fixed_t throwspeed;
UINT8 gsv;
fixed_t estx;
fixed_t esty;
switch (gamespeed)
{
case 0:
throwspeed = 68*mapobjectscale; // Avg Speed is 34
break;
case 2:
throwspeed = 96*mapobjectscale; // Avg Speed is 48
break;
default:
throwspeed = 82*mapobjectscale; // Avg Speed is 41
break;
}
throwspeed = FixedMul(throwspeed, mapobjectscale);
estx = player->mo->x + P_ReturnThrustX(NULL, player->mo->angle, (throwspeed + player->speed) * airtime);
esty = player->mo->y + P_ReturnThrustY(NULL, player->mo->angle, (throwspeed + player->speed) * airtime);
return K_PlayerNearSpot(player, estx, esty, player->mo->radius * 2);
}

View file

@ -2673,7 +2673,7 @@ static void K_GetKartBoostPower(player_t *player)
// Offroad is separate, it's difficult to factor it in with a variable value anyway.
if (K_ApplyOffroad(player) && player->offroad >= 0)
boostpower = FixedDiv(boostpower, FixedMul(player->offroad, K_GetKartGameSpeedScalar(gamespeed)) + FRACUNIT);
boostpower = FixedDiv(boostpower, player->offroad + FRACUNIT);
if (player->bananadrag > TICRATE)
boostpower = (4*boostpower)/5;
@ -8966,93 +8966,4 @@ boolean K_IsSPBInGame(void)
return false;
}
void K_HandleDirectionalInfluence(player_t *player)
{
fixed_t strength = FRACUNIT >> 1; // 1.0 == 45 degrees
ticcmd_t *cmd = NULL;
angle_t sideAngle = ANGLE_MAX;
INT16 inputX, inputY;
INT16 inputLen;
fixed_t diX, diY;
fixed_t diLen;
fixed_t diMul;
fixed_t dot, invDot;
fixed_t finalX, finalY;
fixed_t finalLen;
fixed_t speed;
if (player->playerstate != PST_LIVE || player->spectator)
{
// ded
return;
}
cmd = &player->cmd;
inputX = cmd->throwdir;
inputY = -cmd->turning;
if (player->flipDI == true)
{
// Bananas flip the DI direction.
// Otherwise, DIing bananas is a little brain-dead easy :p
inputX = -inputX;
inputY = -inputY;
}
if (inputX == 0 && inputY == 0)
{
// No DI input, no need to do anything else.
return;
}
inputLen = FixedHypot(inputX, inputY);
if (inputLen > KART_FULLTURN)
{
inputLen = KART_FULLTURN;
}
sideAngle = player->mo->angle - ANGLE_90;
diX = FixedMul(inputX, FINECOSINE(player->mo->angle >> ANGLETOFINESHIFT)) + FixedMul(inputY, FINECOSINE(sideAngle >> ANGLETOFINESHIFT));
diY = FixedMul(inputX, FINESINE(player->mo->angle >> ANGLETOFINESHIFT)) + FixedMul(inputY, FINESINE(sideAngle >> ANGLETOFINESHIFT));
diLen = FixedHypot(diX, diY);
// Normalize
diMul = (KART_FULLTURN * FRACUNIT) / inputLen;
if (diLen > 0)
{
diX = FixedMul(diMul, FixedDiv(diX, diLen));
diY = FixedMul(diMul, FixedDiv(diY, diLen));
}
// Now that we got the DI direction, we can
// actually preform the velocity redirection.
speed = FixedHypot(player->mo->momx, player->mo->momy);
finalX = FixedDiv(player->mo->momx, speed);
finalY = FixedDiv(player->mo->momy, speed);
dot = FixedMul(diX, finalX) + FixedMul(diY, finalY);
invDot = FRACUNIT - abs(dot);
finalX += FixedMul(FixedMul(diX, invDot), strength);
finalY += FixedMul(FixedMul(diY, invDot), strength);
finalLen = FixedHypot(finalX, finalY);
if (finalLen > 0)
{
finalX = FixedDiv(finalX, finalLen);
finalY = FixedDiv(finalY, finalLen);
}
player->mo->momx = FixedMul(speed, finalX);
player->mo->momy = FixedMul(speed, finalY);
}
//}

View file

@ -129,7 +129,6 @@ void K_CheckSpectateStatus(void);
UINT8 K_GetInvincibilityItemFrame(void);
UINT8 K_GetOrbinautItemFrame(UINT8 count);
boolean K_IsSPBInGame(void);
void K_HandleDirectionalInfluence(player_t *player);
// sound stuff for lua
void K_PlayAttackTaunt(mobj_t *source);