// Function: A_Boss3Path
//
// Description: Does pathfinding along Boss 3's nodes.
//
// var1 = unused
// var2 = unused
//
void A_Boss3Path(mobj_t *actor)
{
#ifdef HAVE_BLUA
if (LUA_CallAction("A_Boss3Path", actor))
return;
#endif
if (actor->tracer && actor->tracer->health && actor->tracer->movecount)
actor->movecount |= 1;
else if (actor->movecount & 1)
actor->movecount = 0;
if (actor->movecount & 2) // We've reached a firing point?
{
// Wait here and pretend to be angry or something.
actor->momx = 0;
actor->momy = 0;
actor->momz = 0;
P_SetTarget(&actor->target, actor->tracer->target);
var1 = 0, var2 = 0;
A_FaceTarget(actor);
if (actor->tracer->state == &states[actor->tracer->info->missilestate])
P_SetMobjState(actor, actor->info->missilestate);
return;
}
else if (actor->threshold >= 0) // Traveling mode
{
fixed_t dist = 0;
fixed_t speed;
if (!(actor->flags2 & MF2_STRONGBOX))
{
thinker_t *th;
mobj_t *mo2;
P_SetTarget(&actor->target, NULL);
// scan the thinkers
// to find a point that matches
// the number
for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next)
{
if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed)
continue;
mo2 = (mobj_t *)th;
if (mo2->type != MT_BOSS3WAYPOINT)
continue;
if (!mo2->spawnpoint)
continue;
if (mo2->spawnpoint->angle != actor->threshold)
continue;
if (mo2->spawnpoint->extrainfo != actor->cusval)
continue;
P_SetTarget(&actor->target, mo2);
break;
}
}
if (!actor->target) // Should NEVER happen
{
CONS_Debug(DBG_GAMELOGIC, "Error: Boss 3 Dummy was unable to find specified waypoint: %d, %d\n", actor->threshold, actor->cusval);
return;
}
if (actor->tracer && ((actor->tracer->movedir)
|| (actor->tracer->health <= actor->tracer->info->damage)))
speed = actor->info->speed * 2;
else
speed = actor->info->speed;
if (actor->target->x == actor->x && actor->target->y == actor->y)
{
dist = P_AproxDistance(P_AproxDistance(actor->target->x - actor->x, actor->target->y - actor->y), actor->target->z + actor->movefactor - actor->z);
if (dist < 1)
dist = 1;
actor->momx = FixedMul(FixedDiv(actor->target->x - actor->x, dist), speed);
actor->momy = FixedMul(FixedDiv(actor->target->y - actor->y, dist), speed);
actor->momz = FixedMul(FixedDiv(actor->target->z + actor->movefactor - actor->z, dist), speed);
if (actor->momx != 0 || actor->momy != 0)
actor->angle = R_PointToAngle2(0, 0, actor->momx, actor->momy);
}
if (dist <= speed)
{
// If further away, set XYZ of mobj to waypoint location
P_UnsetThingPosition(actor);
actor->x = actor->target->x;
actor->y = actor->target->y;
actor->z = actor->target->z + actor->movefactor;
actor->momx = actor->momy = actor->momz = 0;
P_SetThingPosition(actor);
if (!actor->movefactor) // firing mode
{
actor->movecount |= 2;
actor->movefactor = -512*FRACUNIT;
actor->flags2 &= ~MF2_STRONGBOX;
}
else if (!(actor->flags2 & MF2_STRONGBOX)) // just spawned or going down
{
actor->flags2 |= MF2_STRONGBOX;
actor->movefactor = -512*FRACUNIT;
}
else if (!(actor->flags2 & MF2_AMBUSH)) // just shifted tube
{
actor->flags2 |= MF2_AMBUSH;
actor->movefactor = 0;
}
else // just hit the bottom of your tube
{
P_RemoveMobj(actor); // Cycle completed. Dummy removed.
return;
}
}
}
}