A_FlickySoar is an action similar to A_FlickyFly but specific to the Puffin's and the Dove's movement. Var1 sets the speed of movement, while Var2 determines how far ahead the target should be considered from the actor's location; if unspecified, this distance is of 16 fracunits by default.
This action will also call A_FlickyAim internally with preset values. If the actor has no target or its fuse is below 2 seconds (2*TICRATE
), the actor will tend to fly towards the ceiling (or floor, in case of reverse gravity) of the current sector; otherwise it will ascend or descend depending on the position of its target. This action will also adjust the Puffin flicky's animation if it's ascending.
Code – A_FlickySoar
|
|
// Function: A_FlickySoar
//
// Description: Flicky soaring function - specific to puffin.
//
// var1 = how fast to fly
// var2 = how far ahead the target should be considered
//
void A_FlickySoar(mobj_t *actor)
{
INT32 locvar1 = var1;
INT32 locvar2 = var2;
if (LUA_CallAction(A_FLICKYSOAR, actor))
return;
P_InternalFlickyFly(actor, locvar1, locvar2,
2*(FRACUNIT/2 - abs(FINECOSINE((((actor->fuse % 144) * 5*ANG1/2) >> ANGLETOFINESHIFT) & FINEMASK)))
);
if (P_MobjFlip(actor)*actor->momz > 0 && actor->frame == 1 && actor->sprite == SPR_FL10)
actor->frame = 3;
}
|
|
Code – P_InternalFlickyFly
|
|
//Internal Flicky flying function. Also usuable as an underwater swim thrust.
void P_InternalFlickyFly(mobj_t *actor, fixed_t flyspeed, fixed_t targetdist, fixed_t chasez)
{
angle_t vertangle;
flyspeed = FixedMul(flyspeed, actor->scale);
actor->flags |= MF_NOGRAVITY;
var1 = ANG30;
var2 = 32*FRACUNIT;
A_FlickyAim(actor);
chasez *= 8;
if (!actor->target || !(actor->fuse > 2*TICRATE))
chasez += ((actor->eflags & MFE_VERTICALFLIP) ? actor->ceilingz - 24*FRACUNIT : actor->floorz + 24*FRACUNIT);
else
{
fixed_t add = actor->target->z + (actor->target->height - actor->height)/2;
if (add > (actor->ceilingz - 24*actor->scale - actor->height))
add = actor->ceilingz - 24*actor->scale - actor->height;
else if (add < (actor->floorz + 24*actor->scale))
add = actor->floorz + 24*actor->scale;
chasez += add;
}
if (!targetdist)
targetdist = 16*FRACUNIT; //Default!
if (actor->target && abs(chasez - actor->z) > targetdist)
targetdist = P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y);
if (actor->target
&& P_IsFlickyCenter(actor->target->type)
&& (actor->target->flags & MF_SLIDEME))
vertangle = 0;
else
vertangle = (R_PointToAngle2(0, actor->z, targetdist, chasez) >> ANGLETOFINESHIFT) & FINEMASK;
P_InstaThrust(actor, actor->angle, FixedMul(FINECOSINE(vertangle), flyspeed));
actor->momz = FixedMul(FINESINE(vertangle), flyspeed);
}
|
|