A_LightningFollowPlayer is an action exclusive to SRB2Kart. It is used by the particles and lighting bolt that spawn when a player detonates a Thunder Shield. This action causes the actor to copy its target's momentum and flags.
Code – A_LightningFollowPlayer
|
|
// A_LightningFollowPlayer:
// Dumb simple function that gives a mobj its target's momentums without updating its angle.
void A_LightningFollowPlayer(mobj_t *actor)
{
fixed_t sx, sy;
#ifdef HAVE_BLUA
if (LUA_CallAction("A_LightningFollowPlayer", actor))
return;
#endif
if (!actor->target)
return;
{
if (actor->extravalue1) // Make the radius also follow the player somewhat accuratly
{
sx = actor->target->x + FixedMul((actor->target->scale*actor->extravalue1), FINECOSINE((actor->angle)>>ANGLETOFINESHIFT));
sy = actor->target->y + FixedMul((actor->target->scale*actor->extravalue1), FINESINE((actor->angle)>>ANGLETOFINESHIFT));
P_TeleportMove(actor, sx, sy, actor->target->z);
}
else // else just teleport to player directly
P_TeleportMove(actor, actor->target->x, actor->target->y, actor->target->z);
K_MatchGenericExtraFlags(actor, actor->target); // copy our target for graviflip
actor->momx = actor->target->momx;
actor->momy = actor->target->momy;
actor->momz = actor->target->momz; // Give momentum since we don't teleport to our player literally every frame.
}
}
|
|