A_VileTarget is an action that is used to spawn Brak Eggman's targeting reticule. It was originally used in Doom for the Archvile's fire attack, hence the name.
If Var2's upper 16 bits are set to 0, only the actor's target is targeted by the attack. Otherwise, all players in the game are targeted. Var1 sets the Object type that is spawned; if it is not a valid Object type, MT_CYBRAKDEMON_TARGET_RETICULE
is used instead. The Object is spawned directly at the location of the targeted player(s) and set to the same scale as the targeted player(s). The Object that is spawned on top of the actor's target is set as the actor's tracer. For each spawned Object, the actor is set as its target and the targeted player as its tracer. The spawned Object then calls A_VileFire
.
Code – A_VileTarget
|
|
// Function: A_VileTarget
//
// Description: Spawns an object directly on the target, and sets this object as the actor's tracer.
// Originally used by Archviles to summon a pillar of hellfire, hence the name.
//
// var1 = mobj to spawn
// var2 = If 0, target only the actor's target. Else, target every player, period.
//
void A_VileTarget(mobj_t *actor)
{
INT32 locvar1 = var1;
INT32 locvar2 = var2;
mobj_t *fog;
mobjtype_t fogtype;
INT32 i;
#ifdef HAVE_BLUA
if (LUA_CallAction("A_VileTarget", actor))
return;
#endif
if (!actor->target)
return;
A_FaceTarget(actor);
// Determine object to spawn
if (locvar1 <= 0 || locvar1 >= NUMMOBJTYPES)
fogtype = MT_CYBRAKDEMON_TARGET_RETICULE;
else
fogtype = (mobjtype_t)locvar1;
if (!locvar2)
{
fog = P_SpawnMobj(actor->target->x,
actor->target->y,
actor->target->z + ((actor->target->eflags & MFE_VERTICALFLIP) ? actor->target->height - mobjinfo[fogtype].height : 0),
fogtype);
if (actor->target->eflags & MFE_VERTICALFLIP)
{
fog->eflags |= MFE_VERTICALFLIP;
fog->flags2 |= MF2_OBJECTFLIP;
}
fog->destscale = actor->target->scale;
P_SetScale(fog, fog->destscale);
P_SetTarget(&actor->tracer, fog);
P_SetTarget(&fog->target, actor);
P_SetTarget(&fog->tracer, actor->target);
A_VileFire(fog);
}
else
{
// Our "Archvile" here is actually Oprah. "YOU GET A TARGET! YOU GET A TARGET! YOU ALL GET A TARGET!"
for (i = 0; i < MAXPLAYERS; i++)
{
if (!playeringame[i] || players[i].spectator)
continue;
if (!players[i].mo)
continue;
if (!players[i].mo->health)
continue;
fog = P_SpawnMobj(players[i].mo->x,
players[i].mo->y,
players[i].mo->z + ((players[i].mo->eflags & MFE_VERTICALFLIP) ? players[i].mo->height - mobjinfo[fogtype].height : 0),
fogtype);
if (players[i].mo->eflags & MFE_VERTICALFLIP)
{
fog->eflags |= MFE_VERTICALFLIP;
fog->flags2 |= MF2_OBJECTFLIP;
}
fog->destscale = players[i].mo->scale;
P_SetScale(fog, fog->destscale);
if (players[i].mo == actor->target) // We only care to track the fog targeting who we REALLY hate right now
P_SetTarget(&actor->tracer, fog);
P_SetTarget(&fog->target, actor);
P_SetTarget(&fog->tracer, players[i].mo);
A_VileFire(fog);
}
}
}
|
|