|| This article or section is incomplete. It doesn't have all of the necessary core information on this topic. Please help the SRB2 Wiki by finishing this article.
A_InstaLoop is an action that makes the actor move along a 2D horizontal polygon. The number of edges is defined by the upper 16 bits of Var1, the current edge is defined by the lower 16 bits of Var1. Edges begin at the lowest point and then rotate counterclockwise. Force is determined by Var2. The higher the step maximum, the more states you need, but the more accurate the loop becomes. If you choose, for example, 12 as maximum step, keep it and cycle twelve states with the current steps counting from 1 up to 12 one after another with the same duration to perform one complete loop. You can make the flight path more elliptic by not giving all states the same duration.
This action originates from the v2.0 modification SRB2Morphed and was added to SRB2 itself in v2.1.
Code – A_InstaLoop
// Function: A_InstaLoop
// Description: Makes the object move along a 2d (view angle, z) polygon.
// lower 16 bits = current step
// upper 16 bits = maximum step #
// var2 = force
void A_InstaLoop(mobj_t *actor)
INT32 locvar1 = var1;
INT32 locvar2 = var2;
fixed_t force = max(locvar2, 1)*FRACUNIT; // defaults to 1 if var2 < 1
const UINT16 loc1lw = (UINT16)(locvar1 & 65535);
const UINT16 loc1up = (UINT16)(locvar1 >> 16);
const angle_t fa = FixedAngleC(loc1lw*FRACUNIT*360, loc1up*FRACUNIT)>>ANGLETOFINESHIFT;
const fixed_t ac = FINECOSINE(fa);
const fixed_t as = FINESINE(fa);
if (LUA_CallAction("A_InstaLoop", actor))
P_InstaThrust(actor, actor->angle, FixedMul(ac, FixedMul(force, actor->scale)));
P_SetObjectMomZ(actor, FixedMul(as, force), false);