Red shell rework, they always instathrust to their top speed in their current movement direction.

When they get close their top speed starts to decrease to the player's current speed.
Movement direction ends up being adjusted in A_RedShellChase where it Thrusts towards the player at its acceleration speed.
This commit is contained in:
Sryder13 2017-10-22 22:08:07 +01:00
parent 10aa83e614
commit a46093fe9d

View file

@ -35,6 +35,8 @@
#include "p_slopes.h" #include "p_slopes.h"
#endif #endif
#include "k_kart.h"
// protos. // protos.
static CV_PossibleValue_t viewheight_cons_t[] = {{16, "MIN"}, {56, "MAX"}, {0, NULL}}; static CV_PossibleValue_t viewheight_cons_t[] = {{16, "MIN"}, {56, "MAX"}, {0, NULL}};
consvar_t cv_viewheight = {"viewheight", VIEWHEIGHTS, 0, viewheight_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_viewheight = {"viewheight", VIEWHEIGHTS, 0, viewheight_cons_t, NULL, 0, NULL, NULL, 0, 0, NULL};
@ -7505,19 +7507,39 @@ void P_MobjThinker(mobj_t *mobj)
break; break;
case MT_REDITEM: case MT_REDITEM:
{ {
fixed_t magnitude; fixed_t topspeed = 64*FRACUNIT;
fixed_t distbarrier = 512*FRACUNIT;
fixed_t distaway;
if (mobj->threshold > 0) if (mobj->threshold > 0)
mobj->threshold--; mobj->threshold--;
if (leveltime % 7 == 0) if (leveltime % 7 == 0)
S_StartSound(mobj, mobj->info->activesound); S_StartSound(mobj, mobj->info->activesound);
// Do a similar thing to what is done to the player to keep the red shell at a speed cap if (cv_kartcc.value == 50)
magnitude = P_AproxDistance(mobj->momx, mobj->momy);
if (magnitude > 64*FRACUNIT)
{ {
mobj->momx = FixedMul(FixedDiv(mobj->momx, magnitude), 64*FRACUNIT); topspeed = FixedMul(topspeed, FRACUNIT-FRACUNIT/4);
mobj->momy = FixedMul(FixedDiv(mobj->momy, magnitude), 64*FRACUNIT); distbarrier = FixedMul(distbarrier, FRACUNIT-FRACUNIT/4);
} }
else if (cv_kartcc.value == 150)
{
topspeed = FixedMul(topspeed, FRACUNIT+FRACUNIT/4);
distbarrier = FixedMul(distbarrier, FRACUNIT+FRACUNIT/4);
}
if (mobj->tracer)
{
distaway = P_AproxDistance(mobj->tracer->x - mobj->x, mobj->tracer->y - mobj->y);
if (distaway < distbarrier)
{
if (mobj->tracer->player)
{
fixed_t speeddifference = abs(topspeed - min(mobj->tracer->player->speed, K_GetKartSpeed(mobj->tracer->player, false)));
topspeed = topspeed - FixedMul(speeddifference, FRACUNIT-FixedDiv(distaway, distbarrier));
}
}
}
P_InstaThrust(mobj, R_PointToAngle2(0, 0, mobj->momx, mobj->momy), topspeed);
break; break;
} }
case MT_REDITEMDUD: case MT_REDITEMDUD: