More fundamental Jawz changes.

1.) Instead of prioritizing best angle above all else, it averages both distance and angle to figure out which is the best overall target.
2.) Jawz will completely cut out angles higher than 45 degrees, preventing instances where someone behind you is considered a better target than who you're looking at.
3.) Jawz does the 45 degree angle checking in Race as well, meaning that they will ignore racers that are neck & neck with you, even if they're technically the next place above you, so that Jawz doesn't take a hard left into a wall.
This commit is contained in:
TehRealSalt 2018-08-30 15:30:27 -04:00
parent 59751c81e9
commit 3a9342e2c6

View file

@ -8164,8 +8164,7 @@ void A_ItemPop(mobj_t *actor)
void A_JawzChase(mobj_t *actor) void A_JawzChase(mobj_t *actor)
{ {
INT32 stop; fixed_t best = -1;
INT32 bestang = -1, bestdist = -1;
SINT8 wtarg = -1; SINT8 wtarg = -1;
player_t *player; player_t *player;
#ifdef HAVE_BLUA #ifdef HAVE_BLUA
@ -8176,109 +8175,100 @@ void A_JawzChase(mobj_t *actor)
if (actor->tracer) if (actor->tracer)
{ {
if (!actor->tracer->health) if (!actor->tracer->health)
{
P_SetTarget(&actor->tracer, NULL); P_SetTarget(&actor->tracer, NULL);
}
if (actor->tracer && (actor->tracer->health)) if (actor->tracer && actor->tracer->health)
{ {
P_Thrust(actor, R_PointToAngle2(actor->x, actor->y, actor->tracer->x, actor->tracer->y), actor->info->speed); P_Thrust(actor, R_PointToAngle2(actor->x, actor->y, actor->tracer->x, actor->tracer->y), actor->info->speed);
return; return;
} }
} }
// first time init, this allow minimum lastlook changes if (actor->extravalue1) // Disable looking by setting this
if (actor->lastlook == -1) return;
actor->lastlook = P_RandomFixed();
actor->lastlook %= MAXPLAYERS; for (actor->lastlook = 0; actor->lastlook < MAXPLAYERS; actor->lastlook++)
stop = (actor->lastlook - 1) & PLAYERSMASK;
if (actor->lastlook >= 0)
{ {
for (; ; actor->lastlook = (actor->lastlook + 1) & PLAYERSMASK)
{
if (actor->lastlook == stop)
{
actor->lastlook = -1;
break;
}
if (!playeringame[actor->lastlook]) if (!playeringame[actor->lastlook])
continue; continue;
player = &players[actor->lastlook]; player = &players[actor->lastlook];
if (player->spectator)
continue; // spectator
if (!player->mo) if (!player->mo)
continue; continue;
if (player->mo->health <= 0) if (player->mo->health <= 0)
continue; // dead continue; // dead
if ((netgame || multiplayer) && player->spectator)
continue; // spectator
if (actor->target && actor->target->player) if (actor->target && actor->target->player)
{ {
angle_t thisang;
if (player->mo == actor->target) if (player->mo == actor->target)
continue; continue;
// Don't home in on teammates. // Don't home in on teammates.
if (gametype == GT_CTF if (G_GametypeHasTeams() && actor->target->player->ctfteam == player->ctfteam)
&& actor->target->player->ctfteam == player->ctfteam)
continue; continue;
if (G_RaceGametype()) // Only in races, in match and CTF you should go after any nearby players // Find the angle, see who's got the best.
{ thisang = actor->angle - R_PointToAngle2(actor->x, actor->y, player->mo->x, player->mo->y);
// USER TARGET if (thisang > ANGLE_180)
if (actor->target->player->kartstuff[k_position] == (player->kartstuff[k_position] + 1)) // Jawz only go after the person directly ahead of you -Sryder thisang = InvAngle(thisang);
{
wtarg = player-players;
break;
}
}
if (G_BattleGametype()) if (thisang > ANGLE_45) // Don't go for people who are behind you
continue;
// Jawz only go after the person directly ahead of you in race... sort of literally now!
if (G_RaceGametype())
{ {
angle_t initang; if (player->kartstuff[k_position] >= actor->target->player->kartstuff[k_position]) // Don't pay attention to people behind you
INT32 thisang; continue;
INT32 thisdist; if ((best == -1) || (player->kartstuff[k_position] > best))
{
wtarg = actor->lastlook;
best = player->kartstuff[k_position];
}
}
else
{
fixed_t thisdist;
fixed_t thisavg;
if (player->kartstuff[k_bumper] <= 0) if (player->kartstuff[k_bumper] <= 0)
continue; continue;
initang = actor->angle - R_PointToAngle2(actor->x, actor->y, player->mo->x, player->mo->y); thisdist = P_AproxDistance(P_AproxDistance(player->mo->x - (actor->x + actor->momx),
if (initang > ANGLE_180) player->mo->y - (actor->y + actor->momy)), player->mo->z - (actor->z + actor->momz));
initang = InvAngle(initang);
thisang = AngleFixed(initang)>>FRACBITS;
thisdist = P_AproxDistance(P_AproxDistance(player->mo->x - actor->x,
player->mo->y - actor->y), player->mo->z - actor->z)>>FRACBITS;
if (thisdist > RING_DIST>>FRACBITS) if (thisdist > RING_DIST) // Don't go for people who are too far away
continue; continue;
if ((bestang < 0 || bestdist < 0) thisavg = (AngleFixed(thisang) + thisdist) / 2;
|| (thisang < bestang)
|| (thisang == bestang && thisdist < bestdist)) //CONS_Printf("got avg %d from player # %d\n", thisavg>>FRACBITS, actor->lastlook);
if ((best == -1) || (thisavg < best))
{ {
wtarg = player-players; wtarg = actor->lastlook;
bestang = thisang; best = thisavg;
bestdist = thisdist;
}
} }
} }
} }
} }
if (wtarg > 0 if (wtarg != -1)
&& (G_RaceGametype() // Instantly go after in Race
|| (G_BattleGametype() && bestdist < RING_DIST>>FRACBITS))) // Wait until you're in distance in Battle
{ {
//CONS_Printf("ang: %d, dist: %d, wtarg: %d\n", bestang, bestdist, wtarg); //CONS_Printf("best: %d, final target: %d\n", best, wtarg);
P_SetTarget(&actor->tracer, players[wtarg].mo); P_SetTarget(&actor->tracer, players[wtarg].mo);
} }
if (G_RaceGametype()) // Stop looking after first tic in race
actor->extravalue1 = 1;
return; return;
} }