A_MementosTPParticles is an action exclusive to SRB2Kart. It spawns particles and handles the targeting properties of the Mementos Teleporter. Every time the action is called four black or red particles spawn randomly in a 512 fracunit square centered on the actor. The height these particles spawn at can be anywhere from 48 to 256 fracunits above the actor's Z height. These spawned particles will home into the actor. This action will also set the actor's target to be a Mementos Teleporter that is not itself if one exists in the map.
Code – A_MementosTPParticles
|
|
// A_MementosTPParticles
// Mementos teleporters particles effects. Short and simple.
void A_MementosTPParticles(mobj_t *actor)
{
mobj_t *particle;
mobj_t *mo2;
int i = 0;
thinker_t *th;
#ifdef HAVE_BLUA
if (LUA_CallAction("A_MementosTPParticles", (actor)))
return;
#endif
for (; i<4; i++)
{
particle = P_SpawnMobj(actor->x + (P_RandomRange(-256, 256)<<FRACBITS), actor->y + (P_RandomRange(-256, 256)<<FRACBITS), actor->z + (P_RandomRange(48, 256)<<FRACBITS), MT_MEMENTOSPARTICLE);
particle->frame = 0;
particle->color = ((i%2) ? (SKINCOLOR_RED) : (SKINCOLOR_BLACK));
particle->destscale = 1;
P_HomingAttack(particle, actor);
}
// Although this is mostly used to spawn particles, we will also save the OTHER teleport inside actor->target. That way teleporting doesn't require a thinker iteration.
// Doesn't seem like much given the small amount of mobjs this map has but heh.
if (!actor->target)
{
for (th = thinkercap.next; th != &thinkercap; th = th->next)
{
if (th->function.acp1 != (actionf_p1)P_MobjThinker)
continue;
mo2 = (mobj_t *)th;
if (mo2->type == MT_MEMENTOSTP && mo2 != actor)
{
P_SetTarget(&actor->target, mo2); // The main target we're pursing.
break;
}
}
}
}
|
|