mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Make K_BotTopSpeedRubberband a function
This commit is contained in:
parent
08198ef1b4
commit
fdb13b76d1
4 changed files with 80 additions and 48 deletions
53
src/k_bot.c
53
src/k_bot.c
|
|
@ -394,6 +394,59 @@ fixed_t K_BotRubberband(player_t *player)
|
|||
return rubberband;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------
|
||||
fixed_t K_BotTopSpeedRubberband(player_t *player)
|
||||
|
||||
See header file for description.
|
||||
--------------------------------------------------*/
|
||||
fixed_t K_BotTopSpeedRubberband(player_t *player)
|
||||
{
|
||||
fixed_t rubberband = K_BotRubberband(player);
|
||||
|
||||
if (rubberband < FRACUNIT)
|
||||
{
|
||||
// Never go below your regular top speed
|
||||
rubberband = FRACUNIT;
|
||||
}
|
||||
|
||||
// Only allow you to go faster than your regular top speed if you're facing the right direction
|
||||
if (rubberband > FRACUNIT && player->mo != NULL && player->nextwaypoint != NULL)
|
||||
{
|
||||
const INT16 mindiff = 30;
|
||||
const INT16 maxdiff = 60;
|
||||
INT16 anglediff = 0;
|
||||
fixed_t amt = rubberband - FRACUNIT;
|
||||
angle_t destangle = R_PointToAngle2(
|
||||
player->mo->x, player->mo->y,
|
||||
player->nextwaypoint->mobj->x, player->nextwaypoint->mobj->y
|
||||
);
|
||||
angle_t angle = player->mo->angle - destangle;
|
||||
|
||||
if (angle < ANGLE_180)
|
||||
{
|
||||
anglediff = AngleFixed(angle) >> FRACBITS;
|
||||
}
|
||||
else
|
||||
{
|
||||
anglediff = 360 - (AngleFixed(angle) >> FRACBITS);
|
||||
}
|
||||
|
||||
anglediff = abs(anglediff);
|
||||
|
||||
if (anglediff >= maxdiff)
|
||||
{
|
||||
rubberband = FRACUNIT;
|
||||
}
|
||||
else if (anglediff > mindiff)
|
||||
{
|
||||
amt = (amt * (maxdiff - anglediff)) / mindiff;
|
||||
rubberband = FRACUNIT + amt;
|
||||
}
|
||||
}
|
||||
|
||||
return rubberband;
|
||||
}
|
||||
|
||||
/*--------------------------------------------------
|
||||
fixed_t K_DistanceOfLineFromPoint(fixed_t v1x, fixed_t v1y, fixed_t v2x, fixed_t v2y, fixed_t cx, fixed_t cy)
|
||||
|
||||
|
|
|
|||
22
src/k_bot.h
22
src/k_bot.h
|
|
@ -66,19 +66,35 @@ boolean K_BotCanTakeCut(player_t *player);
|
|||
/*--------------------------------------------------
|
||||
fixed_t K_BotRubberband(player_t *player);
|
||||
|
||||
Gives a multiplier for a bot's rubberbanding. Meant to be used for top speed,
|
||||
acceleration, and handling.
|
||||
Gives a multiplier for a bot's rubberbanding.
|
||||
Meant to be used for acceleration and handling.
|
||||
|
||||
Input Arguments:-
|
||||
player - Player to check.
|
||||
|
||||
Return:-
|
||||
A multiplier in fixed point scale, between 0.875 and 2.0.
|
||||
A multiplier in fixed point scale.
|
||||
--------------------------------------------------*/
|
||||
|
||||
fixed_t K_BotRubberband(player_t *player);
|
||||
|
||||
|
||||
/*--------------------------------------------------
|
||||
fixed_t K_BotTopSpeedRubberband(player_t *player);
|
||||
|
||||
Gives a multiplier for a bot's rubberbanding.
|
||||
Adjusted from K_BotRubberband to be used for top speed.
|
||||
|
||||
Input Arguments:-
|
||||
player - Player to check.
|
||||
|
||||
Return:-
|
||||
A multiplier in fixed point scale.
|
||||
--------------------------------------------------*/
|
||||
|
||||
fixed_t K_BotTopSpeedRubberband(player_t *player);
|
||||
|
||||
|
||||
/*--------------------------------------------------
|
||||
fixed_t K_DistanceOfLineFromPoint(fixed_t v1x, fixed_t v1y, fixed_t v2x, fixed_t v2y, fixed_t cx, fixed_t cy);
|
||||
|
||||
|
|
|
|||
44
src/k_kart.c
44
src/k_kart.c
|
|
@ -2357,49 +2357,7 @@ fixed_t K_GetKartSpeed(player_t *player, boolean doboostpower)
|
|||
{
|
||||
if (K_PlayerUsesBotMovement(player))
|
||||
{
|
||||
fixed_t rubberband = K_BotRubberband(player);
|
||||
|
||||
if (rubberband < FRACUNIT)
|
||||
{
|
||||
rubberband = FRACUNIT;
|
||||
}
|
||||
|
||||
// Only allow you to go fast if you're facing the right direction
|
||||
if (rubberband > FRACUNIT && player->mo != NULL && player->nextwaypoint != NULL)
|
||||
{
|
||||
const INT16 mindiff = 30;
|
||||
const INT16 maxdiff = 60;
|
||||
INT16 anglediff = 0;
|
||||
fixed_t amt = rubberband - FRACUNIT;
|
||||
angle_t destangle = R_PointToAngle2(
|
||||
player->mo->x, player->mo->y,
|
||||
player->nextwaypoint->mobj->x, player->nextwaypoint->mobj->y
|
||||
);
|
||||
angle_t angle = player->mo->angle - destangle;
|
||||
|
||||
if (angle < ANGLE_180)
|
||||
{
|
||||
anglediff = AngleFixed(angle) >> FRACBITS;
|
||||
}
|
||||
else
|
||||
{
|
||||
anglediff = 360 - (AngleFixed(angle) >> FRACBITS);
|
||||
}
|
||||
|
||||
anglediff = abs(anglediff);
|
||||
|
||||
if (anglediff >= maxdiff)
|
||||
{
|
||||
rubberband = FRACUNIT;
|
||||
}
|
||||
else if (anglediff > mindiff)
|
||||
{
|
||||
amt = (amt * (maxdiff - anglediff)) / mindiff;
|
||||
rubberband = FRACUNIT + amt;
|
||||
}
|
||||
}
|
||||
|
||||
finalspeed = FixedMul(finalspeed, rubberband);
|
||||
finalspeed = FixedMul(finalspeed, K_BotTopSpeedRubberband(player));
|
||||
}
|
||||
|
||||
return FixedMul(finalspeed, player->kartstuff[k_boostpower]+player->kartstuff[k_speedboost]);
|
||||
|
|
|
|||
|
|
@ -4170,11 +4170,16 @@ static void P_3dMovement(player_t *player)
|
|||
|
||||
if (K_PlayerUsesBotMovement(player))
|
||||
{
|
||||
fixed_t rubberband = K_BotRubberband(player);
|
||||
fixed_t baserubberband = K_BotRubberband(player);
|
||||
fixed_t rubberband = FixedMul(baserubberband,
|
||||
FixedMul(baserubberband,
|
||||
FixedMul(baserubberband,
|
||||
baserubberband
|
||||
))); // This looks extremely goofy, but we need this really high, but at the same time, proportional.
|
||||
|
||||
if (rubberband > FRACUNIT)
|
||||
{
|
||||
div = FixedMul(div, 4*rubberband);
|
||||
div = FixedMul(div, rubberband);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue