mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
Fix bug with sparkles not being removed properly
This commit is contained in:
parent
85f95d2d78
commit
cf32ebb490
4 changed files with 55 additions and 35 deletions
67
src/k_kart.c
67
src/k_kart.c
|
|
@ -3763,56 +3763,59 @@ void K_SpawnBoostTrail(player_t *player)
|
|||
}
|
||||
}
|
||||
|
||||
void K_SpawnSparkleTrail(mobj_t *mo)
|
||||
mobj_t *K_SpawnSparkleTrail(mobj_t *mo)
|
||||
{
|
||||
const INT32 rad = (mo->radius*3)/FRACUNIT;
|
||||
mobj_t *sparkle;
|
||||
INT32 i;
|
||||
UINT8 invanimnum; // Current sparkle animation number
|
||||
INT32 invtime;// Invincibility time left, in seconds
|
||||
UINT8 index = 1;
|
||||
fixed_t newx, newy, newz;
|
||||
|
||||
I_Assert(mo != NULL);
|
||||
I_Assert(!P_MobjWasRemoved(mo));
|
||||
|
||||
newx = mo->x + (P_RandomRange(-rad, rad)*FRACUNIT);
|
||||
newy = mo->y + (P_RandomRange(-rad, rad)*FRACUNIT);
|
||||
newz = mo->z + (P_RandomRange(0, mo->height>>FRACBITS)*FRACUNIT);
|
||||
|
||||
sparkle = P_SpawnMobj(newx, newy, newz, MT_SPARKLETRAIL);
|
||||
sparkle->angle = R_PointToAngle2(mo->x, mo->y, sparkle->x, sparkle->y);
|
||||
sparkle->movefactor = R_PointToDist2(mo->x, mo->y, sparkle->x, sparkle->y); // Save the distance we spawned away from the player.
|
||||
CONS_Printf("movefactor: %d\n", sparkle->movefactor/FRACUNIT);
|
||||
sparkle->extravalue1 = (sparkle->z - mo->z); // Keep track of our Z position relative to the player's, I suppose.
|
||||
sparkle->extravalue2 = P_RandomRange(0, 1) ? 1 : -1; // Rotation direction?
|
||||
sparkle->cvmem = P_RandomRange(-25, 25)*mo->scale; // Vertical "angle"
|
||||
K_FlipFromObject(sparkle, mo);
|
||||
|
||||
//if (i == 0)
|
||||
//P_SetMobjState(sparkle, S_KARTINVULN_LARGE1);
|
||||
|
||||
P_SetTarget(&sparkle->target, mo);
|
||||
sparkle->destscale = mo->destscale;
|
||||
P_SetScale(sparkle, mo->scale);
|
||||
sparkle->colorized = true;
|
||||
sparkle->color = mo->color;
|
||||
return sparkle;
|
||||
}
|
||||
|
||||
void K_SparkleTrailHandling(mobj_t *mo, player_t *player)
|
||||
{
|
||||
UINT8 invanimnum; // Current sparkle animation number
|
||||
INT32 invtime;// Invincibility time left, in seconds
|
||||
UINT8 index = 1;
|
||||
|
||||
if (leveltime & 2)
|
||||
index = 2;
|
||||
|
||||
invtime = mo->player->kartstuff[k_invincibilitytimer]/TICRATE+1;
|
||||
invtime = player->kartstuff[k_invincibilitytimer]/TICRATE+1;
|
||||
|
||||
//CONS_Printf("%d\n", index);
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
{
|
||||
newx = mo->x + (P_RandomRange(-rad, rad)*FRACUNIT);
|
||||
newy = mo->y + (P_RandomRange(-rad, rad)*FRACUNIT);
|
||||
newz = mo->z + (P_RandomRange(0, mo->height>>FRACBITS)*FRACUNIT);
|
||||
|
||||
sparkle = P_SpawnMobj(newx, newy, newz, MT_SPARKLETRAIL);
|
||||
sparkle->angle = R_PointToAngle2(mo->x, mo->y, sparkle->x, sparkle->y);
|
||||
sparkle->movefactor = R_PointToDist2(mo->x, mo->y, sparkle->x, sparkle->y); // Save the distance we spawned away from the player.
|
||||
CONS_Printf("movefactor: %d\n", sparkle->movefactor/FRACUNIT);
|
||||
sparkle->extravalue1 = (sparkle->z - mo->z); // Keep track of our Z position relative to the player's, I suppose.
|
||||
sparkle->extravalue2 = P_RandomRange(0, 1) ? 1 : -1; // Rotation direction?
|
||||
sparkle->cvmem = P_RandomRange(-25, 25)*mo->scale; // Vertical "angle"
|
||||
K_FlipFromObject(sparkle, mo);
|
||||
|
||||
//if (i == 0)
|
||||
//P_SetMobjState(sparkle, S_KARTINVULN_LARGE1);
|
||||
|
||||
P_SetTarget(&sparkle->target, mo);
|
||||
sparkle->destscale = mo->destscale;
|
||||
P_SetScale(sparkle, mo->scale);
|
||||
}
|
||||
|
||||
invanimnum = (invtime >= 11) ? 11 : invtime;
|
||||
//CONS_Printf("%d\n", invanimnum);
|
||||
P_SetMobjState(sparkle, K_SparkleTrailStartStates[invanimnum][index]);
|
||||
sparkle->colorized = true;
|
||||
sparkle->color = mo->color;
|
||||
|
||||
P_SetMobjState(mo, K_SparkleTrailStartStates[invanimnum][index]);
|
||||
}
|
||||
|
||||
|
||||
void K_SpawnInvincibilitySpeedLines(mobj_t *mo)
|
||||
{
|
||||
mobj_t *fast = P_SpawnMobjFromMobj(mo,
|
||||
|
|
|
|||
|
|
@ -64,7 +64,8 @@ void K_SpawnMineExplosion(mobj_t *source, UINT8 color);
|
|||
void K_RunFinishLineBeam(void);
|
||||
UINT16 K_DriftSparkColor(player_t *player, INT32 charge);
|
||||
void K_SpawnBoostTrail(player_t *player);
|
||||
void K_SpawnSparkleTrail(mobj_t *mo);
|
||||
mobj_t *K_SpawnSparkleTrail(mobj_t *mo);
|
||||
void K_SparkleTrailHandling(mobj_t *mo, player_t *player);
|
||||
void K_SpawnInvincibilitySpeedLines(mobj_t *mo);
|
||||
void K_SpawnWipeoutTrail(mobj_t *mo, boolean translucent);
|
||||
void K_SpawnDraftDust(mobj_t *mo);
|
||||
|
|
|
|||
|
|
@ -3493,7 +3493,20 @@ static int lib_kSpawnSparkleTrail(lua_State *L)
|
|||
NOHUD
|
||||
if (!mo)
|
||||
return LUA_ErrInvalid(L, "mobj_t");
|
||||
K_SpawnSparkleTrail(mo);
|
||||
LUA_PushUserdata(L, K_SpawnSparkleTrail(mo), META_MOBJ);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_kSparkleTrailHandling(lua_State *L)
|
||||
{
|
||||
mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
|
||||
player_t *player = *((player_t **)luaL_checkudata(L, 2, META_PLAYER));
|
||||
NOHUD
|
||||
if (!mo)
|
||||
return LUA_ErrInvalid(L, "mobj_t");
|
||||
if (!player)
|
||||
return LUA_ErrInvalid(L, "player_t");
|
||||
K_SparkleTrailHandling(mo, player);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -3925,6 +3938,7 @@ static luaL_Reg lib[] = {
|
|||
{"K_SpawnMineExplosion",lib_kSpawnMineExplosion},
|
||||
{"K_SpawnBoostTrail",lib_kSpawnBoostTrail},
|
||||
{"K_SpawnSparkleTrail",lib_kSpawnSparkleTrail},
|
||||
{"K_SparkleTrailHandling", lib_kSparkleTrailHandling},
|
||||
{"K_SpawnWipeoutTrail",lib_kSpawnWipeoutTrail},
|
||||
{"K_DriftDustHandling",lib_kDriftDustHandling},
|
||||
{"K_DoSneaker",lib_kDoSneaker},
|
||||
|
|
|
|||
|
|
@ -2376,7 +2376,9 @@ void P_MovePlayer(player_t *player)
|
|||
|
||||
if (player->kartstuff[k_invincibilitytimer] > 0)
|
||||
{
|
||||
K_SpawnSparkleTrail(player->mo);
|
||||
mobj_t *sparkle;
|
||||
sparkle = K_SpawnSparkleTrail(player->mo);
|
||||
K_SparkleTrailHandling(sparkle, player);
|
||||
if (player->kartstuff[k_invincibilitytimer] > 5*TICRATE && player->speed > 10*player->mo->scale && (leveltime % 8) == 0)
|
||||
K_SpawnInvincibilitySpeedLines(player->mo);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue