mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Add a function for retrieving drift spark color, to simplify a lot of code & add transition colors to everything
This commit is contained in:
parent
3093a3078e
commit
4174d9a23e
3 changed files with 102 additions and 88 deletions
178
src/k_kart.c
178
src/k_kart.c
|
|
@ -3133,6 +3133,59 @@ static mobj_t *K_SpawnKartMissile(mobj_t *source, mobjtype_t type, angle_t an, I
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UINT8 K_DriftSparkColor(player_t *player, INT32 charge)
|
||||||
|
{
|
||||||
|
INT32 ds = K_GetKartDriftSparkValue(player);
|
||||||
|
UINT8 color = SKINCOLOR_NONE;
|
||||||
|
|
||||||
|
if (charge < 0)
|
||||||
|
{
|
||||||
|
// Stage 0: Yellow
|
||||||
|
color = SKINCOLOR_GOLD;
|
||||||
|
}
|
||||||
|
else if (charge >= ds*4)
|
||||||
|
{
|
||||||
|
// Stage 3: Rainbow
|
||||||
|
if (charge <= (ds*4)+(32*3))
|
||||||
|
{
|
||||||
|
// transition
|
||||||
|
color = SKINCOLOR_SILVER;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
color = (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (charge >= ds*2)
|
||||||
|
{
|
||||||
|
// Stage 2: Blue
|
||||||
|
if (charge <= (ds*2)+(32*3))
|
||||||
|
{
|
||||||
|
// transition
|
||||||
|
color = SKINCOLOR_PURPLE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
color = SKINCOLOR_SAPPHIRE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (charge >= ds)
|
||||||
|
{
|
||||||
|
// Stage 1: Red
|
||||||
|
if (charge <= (ds)+(32*3))
|
||||||
|
{
|
||||||
|
// transition
|
||||||
|
color = SKINCOLOR_RASPBERRY;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
color = SKINCOLOR_KETCHUP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
static void K_SpawnDriftSparks(player_t *player)
|
static void K_SpawnDriftSparks(player_t *player)
|
||||||
{
|
{
|
||||||
fixed_t newx;
|
fixed_t newx;
|
||||||
|
|
@ -3159,6 +3212,7 @@ static void K_SpawnDriftSparks(player_t *player)
|
||||||
|
|
||||||
for (i = 0; i < 2; i++)
|
for (i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
|
INT32 ds = K_GetKartDriftSparkValue(player);
|
||||||
SINT8 size = 1;
|
SINT8 size = 1;
|
||||||
UINT8 trail = 0;
|
UINT8 trail = 0;
|
||||||
|
|
||||||
|
|
@ -3175,62 +3229,51 @@ static void K_SpawnDriftSparks(player_t *player)
|
||||||
spark->momy = player->mo->momy/2;
|
spark->momy = player->mo->momy/2;
|
||||||
//spark->momz = player->mo->momz/2;
|
//spark->momz = player->mo->momz/2;
|
||||||
|
|
||||||
|
spark->color = K_DriftSparkColor(player, player->kartstuff[k_driftcharge]);
|
||||||
|
|
||||||
if (player->kartstuff[k_driftcharge] < 0)
|
if (player->kartstuff[k_driftcharge] < 0)
|
||||||
{
|
{
|
||||||
// Stage 0: Yellow
|
// Stage 0: Yellow
|
||||||
spark->color = SKINCOLOR_GOLD;
|
|
||||||
size = 0;
|
size = 0;
|
||||||
}
|
}
|
||||||
else if (player->kartstuff[k_driftcharge] >= K_GetKartDriftSparkValue(player)*4)
|
else if (player->kartstuff[k_driftcharge] >= ds*4)
|
||||||
{
|
{
|
||||||
// Stage 3: Rainbow
|
// Stage 3: Rainbow
|
||||||
size = 2;
|
size = 2;
|
||||||
trail = 2;
|
trail = 2;
|
||||||
|
|
||||||
if (player->kartstuff[k_driftcharge] <= (K_GetKartDriftSparkValue(player)*4)+(32*3))
|
if (player->kartstuff[k_driftcharge] <= (ds*4)+(32*3))
|
||||||
{
|
{
|
||||||
// transition
|
// transition
|
||||||
spark->color = SKINCOLOR_SILVER;
|
|
||||||
P_SetScale(spark, (spark->destscale = spark->scale*3/2));
|
P_SetScale(spark, (spark->destscale = spark->scale*3/2));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
spark->color = (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1)));
|
|
||||||
spark->colorized = true;
|
spark->colorized = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (player->kartstuff[k_driftcharge] >= K_GetKartDriftSparkValue(player)*2)
|
else if (player->kartstuff[k_driftcharge] >= ds*2)
|
||||||
{
|
{
|
||||||
// Stage 2: Blue
|
// Stage 2: Blue
|
||||||
size = 2;
|
size = 2;
|
||||||
trail = 1;
|
trail = 1;
|
||||||
|
|
||||||
if (player->kartstuff[k_driftcharge] <= (K_GetKartDriftSparkValue(player)*2)+(32*3))
|
if (player->kartstuff[k_driftcharge] <= (ds*2)+(32*3))
|
||||||
{
|
{
|
||||||
// transition
|
// transition
|
||||||
spark->color = SKINCOLOR_PURPLE;
|
|
||||||
P_SetScale(spark, (spark->destscale = spark->scale*3/2));
|
P_SetScale(spark, (spark->destscale = spark->scale*3/2));
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
spark->color = SKINCOLOR_SAPPHIRE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Stage 1: Red
|
// Stage 1: Red
|
||||||
size = 1;
|
size = 1;
|
||||||
|
|
||||||
if (player->kartstuff[k_driftcharge] <= (K_GetKartDriftSparkValue(player))+(32*3))
|
if (player->kartstuff[k_driftcharge] <= (ds)+(32*3))
|
||||||
{
|
{
|
||||||
// transition
|
// transition
|
||||||
spark->color = SKINCOLOR_RASPBERRY;
|
|
||||||
P_SetScale(spark, (spark->destscale = spark->scale*2));
|
P_SetScale(spark, (spark->destscale = spark->scale*2));
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
spark->color = SKINCOLOR_KETCHUP;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((player->kartstuff[k_drift] > 0 && player->cmd.driftturn > 0) // Inward drifts
|
if ((player->kartstuff[k_drift] > 0 && player->cmd.driftturn > 0) // Inward drifts
|
||||||
|
|
@ -3597,28 +3640,16 @@ void K_DriftDustHandling(mobj_t *spawner)
|
||||||
UINT8 c = SKINCOLOR_NONE;
|
UINT8 c = SKINCOLOR_NONE;
|
||||||
boolean rainbow = false;
|
boolean rainbow = false;
|
||||||
|
|
||||||
if (dc < 0)
|
if (dc >= 0)
|
||||||
{
|
{
|
||||||
c = SKINCOLOR_GOLD;
|
dc += warntime;
|
||||||
}
|
}
|
||||||
else if (dc >= (driftval - warntime))
|
|
||||||
|
c = K_DriftSparkColor(spawner->player, dc);
|
||||||
|
|
||||||
|
if (dc > (4*driftval)+(32*3))
|
||||||
{
|
{
|
||||||
if (dc >= ((2*driftval) - warntime))
|
rainbow = true;
|
||||||
{
|
|
||||||
if (dc >= ((4*driftval) - warntime))
|
|
||||||
{
|
|
||||||
c = (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1)));
|
|
||||||
rainbow = true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
c = SKINCOLOR_SAPPHIRE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
c = SKINCOLOR_KETCHUP;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c != SKINCOLOR_NONE)
|
if (c != SKINCOLOR_NONE)
|
||||||
|
|
@ -9754,57 +9785,44 @@ static void K_drawKartFirstPerson(void)
|
||||||
|
|
||||||
if (stplyr->mo)
|
if (stplyr->mo)
|
||||||
{
|
{
|
||||||
INT32 dsone = K_GetKartDriftSparkValue(stplyr);
|
UINT8 driftcolor = K_DriftSparkColor(stplyr, stplyr->kartstuff[k_driftcharge]);
|
||||||
INT32 dstwo = dsone*2;
|
const angle_t ang = R_PointToAngle2(0, 0, stplyr->rmomx, stplyr->rmomy) - stplyr->frameangle;
|
||||||
INT32 dsthree = dstwo*2;
|
// yes, the following is correct. no, you do not need to swap the x and y.
|
||||||
|
fixed_t xoffs = -P_ReturnThrustY(stplyr->mo, ang, (BASEVIDWIDTH<<(FRACBITS-2))/2);
|
||||||
|
fixed_t yoffs = -(P_ReturnThrustX(stplyr->mo, ang, 4*FRACUNIT) - 4*FRACUNIT);
|
||||||
|
|
||||||
#ifndef DONTLIKETOASTERSFPTWEAKS
|
if (splitscreen)
|
||||||
|
xoffs = FixedMul(xoffs, scale);
|
||||||
|
|
||||||
|
xoffs -= (tn)*scale;
|
||||||
|
xoffs -= (dr)*scale;
|
||||||
|
|
||||||
|
if (stplyr->frameangle == stplyr->mo->angle)
|
||||||
{
|
{
|
||||||
const angle_t ang = R_PointToAngle2(0, 0, stplyr->rmomx, stplyr->rmomy) - stplyr->frameangle;
|
const fixed_t mag = FixedDiv(stplyr->speed, 10*stplyr->mo->scale);
|
||||||
// yes, the following is correct. no, you do not need to swap the x and y.
|
|
||||||
fixed_t xoffs = -P_ReturnThrustY(stplyr->mo, ang, (BASEVIDWIDTH<<(FRACBITS-2))/2);
|
|
||||||
fixed_t yoffs = -(P_ReturnThrustX(stplyr->mo, ang, 4*FRACUNIT) - 4*FRACUNIT);
|
|
||||||
|
|
||||||
if (splitscreen)
|
if (mag < FRACUNIT)
|
||||||
xoffs = FixedMul(xoffs, scale);
|
|
||||||
|
|
||||||
xoffs -= (tn)*scale;
|
|
||||||
xoffs -= (dr)*scale;
|
|
||||||
|
|
||||||
if (stplyr->frameangle == stplyr->mo->angle)
|
|
||||||
{
|
{
|
||||||
const fixed_t mag = FixedDiv(stplyr->speed, 10*stplyr->mo->scale);
|
xoffs = FixedMul(xoffs, mag);
|
||||||
|
if (!splitscreen)
|
||||||
if (mag < FRACUNIT)
|
yoffs = FixedMul(yoffs, mag);
|
||||||
{
|
|
||||||
xoffs = FixedMul(xoffs, mag);
|
|
||||||
if (!splitscreen)
|
|
||||||
yoffs = FixedMul(yoffs, mag);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stplyr->mo->momz > 0) // TO-DO: Draw more of the kart so we can remove this if!
|
|
||||||
yoffs += stplyr->mo->momz/3;
|
|
||||||
|
|
||||||
if (encoremode)
|
|
||||||
x -= xoffs;
|
|
||||||
else
|
|
||||||
x += xoffs;
|
|
||||||
if (!splitscreen)
|
|
||||||
y += yoffs;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// drift sparks!
|
if (stplyr->mo->momz > 0) // TO-DO: Draw more of the kart so we can remove this if!
|
||||||
if ((leveltime & 1) && (stplyr->kartstuff[k_driftcharge] >= dsthree))
|
yoffs += stplyr->mo->momz/3;
|
||||||
colmap = R_GetTranslationColormap(TC_RAINBOW, (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1))), GTC_CACHE);
|
|
||||||
else if ((leveltime & 1) && (stplyr->kartstuff[k_driftcharge] >= dstwo))
|
if (encoremode)
|
||||||
colmap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_KETCHUP, GTC_CACHE);
|
x -= xoffs;
|
||||||
else if ((leveltime & 1) && (stplyr->kartstuff[k_driftcharge] >= dsone))
|
|
||||||
colmap = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_SAPPHIRE, GTC_CACHE);
|
|
||||||
else
|
else
|
||||||
#endif
|
x += xoffs;
|
||||||
// invincibility/grow/shrink!
|
if (!splitscreen)
|
||||||
if (stplyr->mo->colorized && stplyr->mo->color)
|
y += yoffs;
|
||||||
|
|
||||||
|
|
||||||
|
if ((leveltime & 1) && (driftcolor != SKINCOLOR_NONE)) // drift sparks!
|
||||||
|
colmap = R_GetTranslationColormap(TC_RAINBOW, driftcolor, GTC_CACHE);
|
||||||
|
else if (stplyr->mo->colorized && stplyr->mo->color) // invincibility/grow/shrink!
|
||||||
colmap = R_GetTranslationColormap(TC_RAINBOW, stplyr->mo->color, GTC_CACHE);
|
colmap = R_GetTranslationColormap(TC_RAINBOW, stplyr->mo->color, GTC_CACHE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@ void K_ExplodePlayer(player_t *player, mobj_t *source, mobj_t *inflictor);
|
||||||
void K_StealBumper(player_t *player, player_t *victim, boolean force);
|
void K_StealBumper(player_t *player, player_t *victim, boolean force);
|
||||||
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, 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, mobj_t *source);
|
||||||
void K_SpawnMineExplosion(mobj_t *source, UINT8 color);
|
void K_SpawnMineExplosion(mobj_t *source, UINT8 color);
|
||||||
|
UINT8 K_DriftSparkColor(player_t *player, INT32 charge);
|
||||||
void K_SpawnBoostTrail(player_t *player);
|
void K_SpawnBoostTrail(player_t *player);
|
||||||
void K_SpawnSparkleTrail(mobj_t *mo);
|
void K_SpawnSparkleTrail(mobj_t *mo);
|
||||||
void K_SpawnWipeoutTrail(mobj_t *mo, boolean translucent);
|
void K_SpawnWipeoutTrail(mobj_t *mo, boolean translucent);
|
||||||
|
|
|
||||||
11
src/p_mobj.c
11
src/p_mobj.c
|
|
@ -8363,6 +8363,7 @@ void P_MobjThinker(mobj_t *mobj)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
UINT8 driftcolor = K_DriftSparkColor(mobj->target->player, mobj->target->player->kartstuff[k_driftcharge]);
|
||||||
fixed_t newx, newy;
|
fixed_t newx, newy;
|
||||||
angle_t travelangle;
|
angle_t travelangle;
|
||||||
|
|
||||||
|
|
@ -8375,14 +8376,8 @@ void P_MobjThinker(mobj_t *mobj)
|
||||||
mobj->angle = travelangle - ((ANGLE_90/5)*mobj->target->player->kartstuff[k_drift]);
|
mobj->angle = travelangle - ((ANGLE_90/5)*mobj->target->player->kartstuff[k_drift]);
|
||||||
P_SetScale(mobj, (mobj->destscale = mobj->target->scale));
|
P_SetScale(mobj, (mobj->destscale = mobj->target->scale));
|
||||||
|
|
||||||
if (mobj->target->player->kartstuff[k_driftcharge] >= K_GetKartDriftSparkValue(mobj->target->player)*4)
|
if (driftcolor != SKINCOLOR_NONE)
|
||||||
mobj->color = (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1)));
|
mobj->color = driftcolor;
|
||||||
else if (mobj->target->player->kartstuff[k_driftcharge] >= K_GetKartDriftSparkValue(mobj->target->player)*2)
|
|
||||||
mobj->color = SKINCOLOR_SAPPHIRE;
|
|
||||||
else if (mobj->target->player->kartstuff[k_driftcharge] >= K_GetKartDriftSparkValue(mobj->target->player))
|
|
||||||
mobj->color = SKINCOLOR_KETCHUP;
|
|
||||||
else if (mobj->target->player->kartstuff[k_driftcharge] < 0)
|
|
||||||
mobj->color = SKINCOLOR_GOLD;
|
|
||||||
else
|
else
|
||||||
mobj->color = SKINCOLOR_SILVER;
|
mobj->color = SKINCOLOR_SILVER;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue