A_SuperTurretFire is an action which is used to rapidly fire projectiles like a Turret. It is similar to A_TurretFire
, but strong enough to stop even Super Sonic. The actor will be given the flags MF2_FIRING
and MF2_SUPERFIRE
(the latter is passed on to the missiles themselves), and so begins firing a solid stream of Var1 type Objects at the first player it finds within its distance threshold (the default Object fired is MT_TURRETLASER
), setting that player as its target. It will continue firing even long after this action has been called until A_TurretStop
is called, and will continuously change its angle to face the target. Var2 determines the distance threshold (default value is 2048) – if all players are further away than this when this action is called, the actor will not start firing, though this does not apply once the actor is already firing.
If the target player is playing as NiGHTS Super Sonic, the actor will attempt to predict the player next position based on their current momentum, and will instead fire there. When doing this the actor will also force its missiles' speed to become 60 FU/tic regardless of their Speed
Object property.
Code – A_SuperTurretFire
|
|
// Function: A_SuperTurretFire
//
// Description: Initiates turret fire that even stops Super Sonic.
//
// var1 = object # to repeatedly fire
// var2 = distance threshold
//
void A_SuperTurretFire(mobj_t *actor)
{
INT32 count = 0;
fixed_t dist;
INT32 locvar1 = var1;
INT32 locvar2 = var2;
#ifdef HAVE_BLUA
if (LUA_CallAction("A_SuperTurretFire", actor))
return;
#endif
if (locvar2)
dist = FixedMul(locvar2*FRACUNIT, actor->scale);
else
dist = FixedMul(2048*FRACUNIT, actor->scale);
if (!locvar1)
locvar1 = MT_TURRETLASER;
while (P_SupermanLook4Players(actor) && count < MAXPLAYERS)
{
if (P_AproxDistance(actor->x - actor->target->x, actor->y - actor->target->y) < dist)
{
actor->flags2 |= MF2_FIRING;
actor->flags2 |= MF2_SUPERFIRE;
actor->extravalue1 = locvar1;
break;
}
count++;
}
}
|
|