// Function: A_VileAttack
//
// Description: Instantly hurts the actor's target, if it's in the actor's line of sight.
// Originally used by Archviles to cause explosions where their hellfire pillars were, hence the name.
//
// var1 = sound to play
// var2:
// Lower 16 bits = optional explosion object
// Upper 16 bits = If 0, attack only the actor's target. Else, attack all the players. All of them.
//
void A_VileAttack(mobj_t *actor)
{
INT32 locvar1 = var1;
INT32 locvar2 = var2;
sfxenum_t soundtoplay;
mobjtype_t explosionType = MT_NULL;
mobj_t *fire;
INT32 i;
#ifdef HAVE_BLUA
if (LUA_CallAction("A_VileAttack", actor))
return;
#endif
if (!actor->target)
return;
A_FaceTarget(actor);
if (locvar1 <= 0 || locvar1 >= NUMSFX)
soundtoplay = sfx_brakrx;
else
soundtoplay = (sfxenum_t)locvar1;
if ((locvar2 & 0xFFFF) > 0 && (locvar2 & 0xFFFF) <= NUMMOBJTYPES)
{
explosionType = (mobjtype_t)(locvar2 & 0xFFFF);
}
if (!(locvar2 & 0xFFFF0000)) {
if (!P_CheckSight(actor, actor->target))
return;
S_StartSound(actor, soundtoplay);
P_DamageMobj(actor->target, actor, actor, 1, 0);
//actor->target->momz = 1000*FRACUNIT/actor->target->info->mass; // How id did it
actor->target->momz += FixedMul(10*FRACUNIT, actor->scale)*P_MobjFlip(actor->target); // How we're doing it
if (explosionType != MT_NULL)
{
P_SpawnMobj(actor->target->x, actor->target->y, actor->target->z, explosionType);
}
// Extra attack. This was for additional damage in Doom. Doesn't really belong in SRB2, but the heck with it, it's here anyway.
fire = actor->tracer;
if (!fire)
return;
// move the fire between the vile and the player
//fire->x = actor->target->x - FixedMul (24*FRACUNIT, finecosine[an]);
//fire->y = actor->target->y - FixedMul (24*FRACUNIT, finesine[an]);
P_TeleportMove(fire,
actor->target->x - P_ReturnThrustX(fire, actor->angle, FixedMul(24*FRACUNIT, fire->scale)),
actor->target->y - P_ReturnThrustY(fire, actor->angle, FixedMul(24*FRACUNIT, fire->scale)),
fire->z);
P_RadiusAttack(fire, actor, 70*FRACUNIT, 0);
}
else
{
// Oprahvile strikes again, but this time, she brings HOT PAIN
for (i = 0; i < MAXPLAYERS; i++)
{
if (!playeringame[i] || players[i].spectator)
continue;
if (!players[i].mo)
continue;
if (!players[i].mo->health)
continue;
if (!P_CheckSight(actor, players[i].mo))
continue;
S_StartSound(actor, soundtoplay);
P_DamageMobj(players[i].mo, actor, actor, 1, 0);
//actor->target->momz = 1000*FRACUNIT/actor->target->info->mass; // How id did it
players[i].mo->momz += FixedMul(10*FRACUNIT, actor->scale)*P_MobjFlip(players[i].mo); // How we're doing it
if (explosionType != MT_NULL)
{
P_SpawnMobj(players[i].mo->x, players[i].mo->y, players[i].mo->z, explosionType);
}
// Extra attack. This was for additional damage in Doom. Doesn't really belong in SRB2, but the heck with it, it's here anyway.
// However, it ONLY applies to the actor's target. Nobody else matters!
if (actor->target != players[i].mo)
continue;
fire = actor->tracer;
if (!fire)
continue;
// move the fire between the vile and the player
//fire->x = actor->target->x - FixedMul (24*FRACUNIT, finecosine[an]);
//fire->y = actor->target->y - FixedMul (24*FRACUNIT, finesine[an]);
P_TeleportMove(fire,
actor->target->x - P_ReturnThrustX(fire, actor->angle, FixedMul(24*FRACUNIT, fire->scale)),
actor->target->y - P_ReturnThrustY(fire, actor->angle, FixedMul(24*FRACUNIT, fire->scale)),
fire->z);
P_RadiusAttack(fire, actor, 70*FRACUNIT, 0);
}
}
}