// Function: A_LobShot
//
// Description: Lob an object at your target.
//
// var1 = object # to lob
// var2:
// var2 >> 16 = height offset
// var2 & 65535 = airtime
//
void A_LobShot(mobj_t *actor)
{
INT32 locvar1 = var1;
INT32 locvar2 = var2 >> 16;
mobj_t *shot, *hitspot;
angle_t an;
fixed_t z;
fixed_t dist;
fixed_t vertical, horizontal;
fixed_t airtime = var2 & 65535;
#ifdef HAVE_BLUA
if (LUA_CallAction("A_LobShot", actor))
return;
#endif
if (!actor->target)
return;
A_FaceTarget(actor);
if (actor->eflags & MFE_VERTICALFLIP)
{
z = actor->z + actor->height - FixedMul(locvar2*FRACUNIT, actor->scale);
if (actor->type == MT_BLACKEGGMAN)
z -= FixedMul(mobjinfo[locvar1].height, actor->scale/2);
else
z -= FixedMul(mobjinfo[locvar1].height, actor->scale);
}
else
z = actor->z + FixedMul(locvar2*FRACUNIT, actor->scale);
shot = P_SpawnMobj(actor->x, actor->y, z, locvar1);
if (actor->type == MT_BLACKEGGMAN)
{
shot->destscale = actor->scale/2;
P_SetScale(shot, actor->scale/2);
}
else
{
shot->destscale = actor->scale;
P_SetScale(shot, actor->scale);
}
// Keep track of where it's going to land
hitspot = P_SpawnMobj(actor->target->x&(64*FRACUNIT-1), actor->target->y&(64*FRACUNIT-1), actor->target->subsector->sector->floorheight, MT_NULL);
hitspot->tics = airtime;
P_SetTarget(&shot->tracer, hitspot);
P_SetTarget(&shot->target, actor); // where it came from
shot->angle = an = actor->angle;
an >>= ANGLETOFINESHIFT;
dist = P_AproxDistance(actor->target->x - shot->x, actor->target->y - shot->y);
horizontal = dist / airtime;
vertical = FixedMul((gravity*airtime)/2, shot->scale);
shot->momx = FixedMul(horizontal, FINECOSINE(an));
shot->momy = FixedMul(horizontal, FINESINE(an));
shot->momz = vertical;
/* Try to adjust when destination is not the same height
if (actor->z != actor->target->z)
{
fixed_t launchhyp;
fixed_t diff;
fixed_t orig;
diff = actor->z - actor->target->z;
{
launchhyp = P_AproxDistance(horizontal, vertical);
orig = FixedMul(FixedDiv(vertical, horizontal), diff);
CONS_Debug(DBG_GAMELOGIC, "orig: %d\n", (orig)>>FRACBITS);
horizontal = dist / airtime;
vertical = (gravity*airtime)/2;
}
dist -= orig;
shot->momx = FixedMul(horizontal, FINECOSINE(an));
shot->momy = FixedMul(horizontal, FINESINE(an));
shot->momz = vertical;
*/
if (shot->info->seesound)
S_StartSound(shot, shot->info->seesound);
if (!(actor->flags & MF_BOSS))
{
if (ultimatemode)
actor->reactiontime = actor->info->reactiontime*TICRATE;
else
actor->reactiontime = actor->info->reactiontime*TICRATE*2;
}
}