A_VultureVtol is an action that is used as part of the thinker for the Bird Aircraft Strike Hazard. The flags MF_NOGRAVITY
and MF_FLOAT
are given to allow the actor to adjust its height to a suitable position to attack its target player (between 1/4 and 3/4 of the player's height), moving with a vertical speed of 2 fracunits/tic up or down. The actor will also face its target (with A_FaceTarget
) and stop any sound it may be currently playing. When the actor has found a good position, it stops all vertical movement, goes to its MissileState
and plays ActiveSound
. If the actor doesn't have a target however, this action does nothing.
Object property |
Use
|
MissileState |
Attacking state
|
ActiveSound |
Attacking sound
|
Code – A_VultureVtol
|
|
// Function: A_VultureVtol
//
// Description: Vulture rising up to match target's height
//
// var1 = unused
// var2 = unused
//
void A_VultureVtol(mobj_t *actor)
{
#ifdef HAVE_BLUA
if (LUA_CallAction("A_VultureVtol", actor))
return;
#endif
if (!actor->target)
return;
actor->flags |= MF_NOGRAVITY;
actor->flags |= MF_FLOAT;
A_FaceTarget(actor);
S_StopSound(actor);
if (actor->z < actor->target->z+(actor->target->height/4) && actor->z + actor->height < actor->ceilingz)
actor->momz = FixedMul(2*FRACUNIT, actor->scale);
else if (actor->z > (actor->target->z+(actor->target->height/4)*3) && actor->z > actor->floorz)
actor->momz = FixedMul(-2*FRACUNIT, actor->scale);
else
{
// Attack!
actor->momz = 0;
P_SetMobjState(actor, actor->info->missilestate);
S_StartSound(actor, actor->info->activesound);
}
}
|
|