Merge branch 'bots-auughhgh' into 'master'

Bots (scream)

Closes #752, #780, #741, and #753

See merge request KartKrew/Kart!1693
This commit is contained in:
Oni 2023-12-22 20:14:38 +00:00
commit 27ff4ea4cb
4 changed files with 87 additions and 24 deletions

View file

@ -500,7 +500,7 @@ fixed_t K_BotMapModifier(void)
const fixed_t complexity_value = std::clamp<fixed_t>(
FixedDiv(K_GetTrackComplexity(), complexity_scale),
-modifier_max,
modifier_max * 2
modifier_max
);
return FRACUNIT + complexity_value;
@ -1606,6 +1606,7 @@ static void K_BuildBotTiccmdNormal(player_t *player, ticcmd_t *cmd)
destangle = player->mo->angle;
boolean forcedDir = false;
if (botController != nullptr && (botController->flags & TMBOT_FORCEDIR) == TMBOT_FORCEDIR)
{
const fixed_t dist = DEFAULT_WAYPOINT_RADIUS * player->mo->scale;
@ -1616,6 +1617,8 @@ static void K_BuildBotTiccmdNormal(player_t *player, ticcmd_t *cmd)
predict->x = player->mo->x + FixedMul(dist, FINECOSINE(botController->forceAngle >> ANGLETOFINESHIFT));
predict->y = player->mo->y + FixedMul(dist, FINESINE(botController->forceAngle >> ANGLETOFINESHIFT));
predict->radius = (DEFAULT_WAYPOINT_RADIUS / 4) * mapobjectscale;
forcedDir = true;
}
if (P_IsObjectOnGround(player->mo) == false)
@ -1633,7 +1636,13 @@ static void K_BuildBotTiccmdNormal(player_t *player, ticcmd_t *cmd)
//return; // Don't allow bots to turn in the air.
}
if (leveltime <= starttime && finishBeamLine != nullptr)
if (forcedDir == true)
{
destangle = R_PointToAngle2(player->mo->x, player->mo->y, predict->x, predict->y);
turnamt = K_HandleBotTrack(player, cmd, predict, destangle);
trySpindash = false;
}
else if (leveltime <= starttime && finishBeamLine != nullptr)
{
// Handle POSITION!!
const fixed_t distBase = 480*mapobjectscale;

View file

@ -9233,8 +9233,8 @@ static waypoint_t *K_GetPlayerNextWaypoint(player_t *player)
// Bots that aren't able to take a shortcut will ignore shortcut waypoints.
// (However, if they're already on a shortcut, then we want them to keep going.)
if (player->nextwaypoint == NULL
|| K_GetWaypointIsShortcut(player->nextwaypoint) == false)
if (player->nextwaypoint != NULL
&& K_GetWaypointIsShortcut(player->nextwaypoint) == false)
{
continue;
}
@ -11191,23 +11191,26 @@ fixed_t K_PlayerBaseFriction(player_t *player, fixed_t original)
);
fixed_t frict = original;
if (K_PodiumSequence() == true)
if (player->dashpadcooldown == 0) // attempt to fix Hot Shelter
{
frict -= FixedMul(FRACUNIT >> 4, factor);
}
else if (K_PlayerUsesBotMovement(player) == true)
{
// A bit extra friction to help them without drifting.
// Remove this line once they can drift.
frict -= FixedMul(FRACUNIT >> 5, factor);
// Bots gain more traction as they rubberband.
fixed_t traction_value = FixedMul(player->botvars.rubberband, max(FRACUNIT, K_BotMapModifier()));
if (traction_value > FRACUNIT)
if (K_PodiumSequence() == true)
{
const fixed_t extraFriction = FixedMul(FRACUNIT >> 5, factor);
const fixed_t mul = traction_value - FRACUNIT;
frict -= FixedMul(extraFriction, mul);
frict -= FixedMul(FRACUNIT >> 4, factor);
}
else if (K_PlayerUsesBotMovement(player) == true)
{
// A bit extra friction to help them without drifting.
// Remove this line once they can drift.
frict -= FixedMul(FRACUNIT >> 5, factor);
// Bots gain more traction as they rubberband.
fixed_t traction_value = FixedMul(player->botvars.rubberband, max(FRACUNIT, K_BotMapModifier()));
if (traction_value > FRACUNIT)
{
const fixed_t extraFriction = FixedMul(FRACUNIT >> 5, factor);
const fixed_t mul = traction_value - FRACUNIT;
frict -= FixedMul(extraFriction, mul);
}
}
}

View file

@ -409,7 +409,49 @@ waypoint_t *K_GetBestWaypointForMobj(mobj_t *const mobj, waypoint_t *const hint)
checkdist = P_AproxDistance(
(mobj->x / FRACUNIT) - (checkwaypoint->mobj->x / FRACUNIT),
(mobj->y / FRACUNIT) - (checkwaypoint->mobj->y / FRACUNIT));
checkdist = P_AproxDistance(checkdist, ((mobj->z / FRACUNIT) - (checkwaypoint->mobj->z / FRACUNIT)) * 4);
UINT8 zMultiplier = 4; // Heavily weight z distance, for the sake of overlapping paths
if (hint != NULL)
{
boolean connectedToHint = (checkwaypoint == hint);
if (connectedToHint == false && hint->numnextwaypoints > 0)
{
for (size_t i = 0U; i < hint->numnextwaypoints; i++)
{
if (hint->nextwaypoints[i] == checkwaypoint)
{
connectedToHint = true;
break;
}
}
}
if (connectedToHint == false && hint->numprevwaypoints > 0)
{
for (size_t i = 0U; i < hint->numprevwaypoints; i++)
{
if (hint->prevwaypoints[i] == checkwaypoint)
{
connectedToHint = true;
break;
}
}
}
// Do not consider z height for next/prev waypoints of current waypoint.
// This helps the current waypoint not be behind you when you're taking a jump.
if (connectedToHint == true)
{
zMultiplier = 0;
}
}
if (zMultiplier > 0)
{
checkdist = P_AproxDistance(checkdist, ((mobj->z / FRACUNIT) - (checkwaypoint->mobj->z / FRACUNIT)) * zMultiplier);
}
fixed_t rad = (checkwaypoint->mobj->radius / FRACUNIT);
@ -2432,6 +2474,15 @@ static INT32 K_CalculateTrackComplexity(void)
waypoint_t *const mid = (waypoint_t *)path.array[ i ].nodedata;
waypoint_t *const end = (waypoint_t *)path.array[ i + 1 ].nodedata;
// would it be better to just check mid?
if (K_GetWaypointIsSpawnpoint(start) == false
|| K_GetWaypointIsSpawnpoint(mid) == false
|| K_GetWaypointIsSpawnpoint(end) == false)
{
CONS_Debug(DBG_SETUP, "%s", fmt::format("TURN [{}]: skipped\n", i).c_str());
continue;
}
const fixed_t start_mid_dist = R_PointToDist2(
start->mobj->x, start->mobj->y,
mid->mobj->x, mid->mobj->y
@ -2585,7 +2636,7 @@ static INT32 K_CalculateTrackComplexity(void)
FixedToFloat(FixedMul(FixedMul(dist_factor, radius_factor), wall_factor)),
(delta / FRACUNIT)
);
CONS_Printf("%s", msg.c_str());
CONS_Debug(DBG_SETUP, "%s", msg.c_str());
trackcomplexity += (delta / FRACUNIT);
}
@ -2666,10 +2717,10 @@ static INT32 K_CalculateTrackComplexity(void)
}
}
CONS_Printf("%s", fmt::format("Num sneaker panel sets: {}\n", sneaker_panels.size()).c_str());
CONS_Debug(DBG_SETUP, "%s", fmt::format("Num sneaker panel sets: {}\n", sneaker_panels.size()).c_str());
trackcomplexity -= sneaker_panels.size() * 1250;
CONS_Printf(" ** COMPLEXITY: %d\n", trackcomplexity);
CONS_Debug(DBG_SETUP, " ** MAP COMPLEXITY: %d\n", trackcomplexity);
}
return trackcomplexity;

View file

@ -2115,7 +2115,7 @@ static void P_3dMovement(player_t *player)
fixed_t newspeed;
// Make rubberbanding bots slow down faster
if (K_PlayerUsesBotMovement(player))
if (K_PlayerUsesBotMovement(player) && player->dashpadcooldown == 0)
{
fixed_t rubberband = player->botvars.rubberband - FRACUNIT;