// Function: A_JetChase
//
// Description: A_Chase for Jettysyns
//
// var1 = unused
// var2 = unused
//
void A_JetChase(mobj_t *actor)
{
fixed_t thefloor;
#ifdef HAVE_BLUA
if (LUA_CallAction("A_JetChase", actor))
return;
#endif
if (actor->flags2 & MF2_AMBUSH)
return;
if (actor->z >= actor->waterbottom && actor->watertop > actor->floorz
&& actor->z > actor->watertop - FixedMul(256*FRACUNIT, actor->scale))
thefloor = actor->watertop;
else
thefloor = actor->floorz;
if (actor->reactiontime)
actor->reactiontime--;
if (P_RandomChance(FRACUNIT/32))
{
actor->momx = actor->momx / 2;
actor->momy = actor->momy / 2;
actor->momz = actor->momz / 2;
}
// Bounce if too close to floor or ceiling -
// ideal for Jetty-Syns above you on 3d floors
if (actor->momz && ((actor->z - FixedMul((32<<FRACBITS), actor->scale)) < thefloor) && !((thefloor + FixedMul(32*FRACUNIT, actor->scale) + actor->height) > actor->ceilingz))
actor->momz = -actor->momz/2;
if (!actor->target || !(actor->target->flags & MF_SHOOTABLE))
{
// look for a new target
if (P_LookForPlayers(actor, true, false, 0))
return; // got a new target
actor->momx = actor->momy = actor->momz = 0;
P_SetMobjState(actor, actor->info->spawnstate);
return;
}
// modify target threshold
if (actor->threshold)
{
if (!actor->target || actor->target->health <= 0)
actor->threshold = 0;
else
actor->threshold--;
}
// turn towards movement direction if not there yet
actor->angle = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y);
if ((multiplayer || netgame) && !actor->threshold && (actor->target->health <= 0 || !P_CheckSight(actor, actor->target)))
if (P_LookForPlayers(actor, true, false, 0))
return; // got a new target
// If the player is over 3072 fracunits away, then look for another player
if (P_AproxDistance(P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y),
actor->target->z - actor->z) > FixedMul(3072*FRACUNIT, actor->scale) && P_LookForPlayers(actor, true, false, FixedMul(3072*FRACUNIT, actor->scale)))
{
return; // got a new target
}
// chase towards player
if (ultimatemode)
P_Thrust(actor, actor->angle, FixedMul(actor->info->speed/2, actor->scale));
else
P_Thrust(actor, actor->angle, FixedMul(actor->info->speed/4, actor->scale));
// must adjust height
if (ultimatemode)
{
if (actor->z < (actor->target->z + actor->target->height + FixedMul((64<<FRACBITS), actor->scale)))
actor->momz += FixedMul(FRACUNIT/2, actor->scale);
else
actor->momz -= FixedMul(FRACUNIT/2, actor->scale);
}
else
{
if (actor->z < (actor->target->z + actor->target->height + FixedMul((32<<FRACBITS), actor->scale)))
actor->momz += FixedMul(FRACUNIT/2, actor->scale);
else
actor->momz -= FixedMul(FRACUNIT/2, actor->scale);
}
}