A_TurretFire is an action which is used to rapidly fire projectiles like a Turret. The actor will be given the flag
MF2_FIRING, 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_TurretFire
// Function: A_TurretFire
// Description: Initiates turret fire.
// var1 = object # to repeatedly fire
// var2 = distance threshold
void A_TurretFire(mobj_t *actor)
INT32 count = 0;
INT32 locvar1 = var1;
INT32 locvar2 = var2;
if (LUA_CallAction("A_TurretFire", actor))
dist = FixedMul(locvar2*FRACUNIT, actor->scale);
dist = FixedMul(2048*FRACUNIT, actor->scale);
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->extravalue1 = locvar1;