Merge branch 'bot-maint-2' into 'master'

Bot maintenance 2

See merge request KartKrew/Kart!516
This commit is contained in:
Sal 2022-01-13 00:47:54 +00:00
commit fa6d4bfb2d
4 changed files with 77 additions and 31 deletions

View file

@ -662,7 +662,10 @@ fixed_t K_DistanceOfLineFromPoint(fixed_t v1x, fixed_t v1y, fixed_t v2x, fixed_t
--------------------------------------------------*/ --------------------------------------------------*/
static botprediction_t *K_CreateBotPrediction(player_t *player) static botprediction_t *K_CreateBotPrediction(player_t *player)
{ {
const INT16 handling = K_GetKartTurnValue(player, KART_FULLTURN); // Reduce prediction based on how fast you can turn // Stair janking makes it harder to steer, so attempt to steer harder.
const UINT8 jankDiv = (player->stairjank > 0 ? 2 : 1);
const INT16 handling = K_GetKartTurnValue(player, KART_FULLTURN) / jankDiv; // Reduce prediction based on how fast you can turn
const INT16 normal = KART_FULLTURN; // "Standard" handling to compare to const INT16 normal = KART_FULLTURN; // "Standard" handling to compare to
const tic_t futuresight = (TICRATE * normal) / max(1, handling); // How far ahead into the future to try and predict const tic_t futuresight = (TICRATE * normal) / max(1, handling); // How far ahead into the future to try and predict

View file

@ -382,6 +382,8 @@ static void K_BotItemGenericTap(player_t *player, ticcmd_t *cmd)
--------------------------------------------------*/ --------------------------------------------------*/
static boolean K_BotRevealsGenericTrap(player_t *player, INT16 turnamt, boolean mine) static boolean K_BotRevealsGenericTrap(player_t *player, INT16 turnamt, boolean mine)
{ {
const fixed_t coneDist = FixedMul(1280 * mapobjectscale, K_GetKartGameSpeedScalar(gamespeed));
if (abs(turnamt) >= KART_FULLTURN/2) if (abs(turnamt) >= KART_FULLTURN/2)
{ {
// DON'T reveal on turns, we can place bananas on turns whenever we have multiple to spare, // DON'T reveal on turns, we can place bananas on turns whenever we have multiple to spare,
@ -404,7 +406,7 @@ static boolean K_BotRevealsGenericTrap(player_t *player, INT16 turnamt, boolean
} }
// Check your behind. // Check your behind.
if (K_PlayerInCone(player, player->mo->radius * 16, 10, true) != NULL) if (K_PlayerInCone(player, coneDist, 15, true) != NULL)
{ {
return true; return true;
} }
@ -536,16 +538,19 @@ static void K_BotItemRocketSneaker(player_t *player, ticcmd_t *cmd)
--------------------------------------------------*/ --------------------------------------------------*/
static void K_BotItemBanana(player_t *player, ticcmd_t *cmd, INT16 turnamt) static void K_BotItemBanana(player_t *player, ticcmd_t *cmd, INT16 turnamt)
{ {
const fixed_t coneDist = FixedMul(1280 * mapobjectscale, K_GetKartGameSpeedScalar(gamespeed));
SINT8 throwdir = -1; SINT8 throwdir = -1;
boolean tryLookback = false;
player_t *target = NULL; player_t *target = NULL;
player->botvars.itemconfirm++; player->botvars.itemconfirm++;
target = K_PlayerInCone(player, player->mo->radius * 16, 10, true); target = K_PlayerInCone(player, coneDist, 15, true);
if (target != NULL) if (target != NULL)
{ {
K_ItemConfirmForTarget(player, target, player->botvars.difficulty); K_ItemConfirmForTarget(player, target, player->botvars.difficulty);
throwdir = -1; throwdir = -1;
tryLookback = true;
} }
if (abs(turnamt) >= KART_FULLTURN/2) if (abs(turnamt) >= KART_FULLTURN/2)
@ -564,7 +569,12 @@ static void K_BotItemBanana(player_t *player, ticcmd_t *cmd, INT16 turnamt)
} }
} }
if (player->botvars.itemconfirm > 2*TICRATE || player->bananadrag >= TICRATE) if (tryLookback == true && throwdir == -1)
{
cmd->buttons |= BT_LOOKBACK;
}
if (player->botvars.itemconfirm > 10*TICRATE || player->bananadrag >= TICRATE)
{ {
K_BotGenericPressItem(player, cmd, throwdir); K_BotGenericPressItem(player, cmd, throwdir);
} }
@ -585,12 +595,14 @@ static void K_BotItemBanana(player_t *player, ticcmd_t *cmd, INT16 turnamt)
--------------------------------------------------*/ --------------------------------------------------*/
static void K_BotItemMine(player_t *player, ticcmd_t *cmd, INT16 turnamt) static void K_BotItemMine(player_t *player, ticcmd_t *cmd, INT16 turnamt)
{ {
const fixed_t coneDist = FixedMul(1280 * mapobjectscale, K_GetKartGameSpeedScalar(gamespeed));
SINT8 throwdir = 0; SINT8 throwdir = 0;
boolean tryLookback = false;
player_t *target = NULL; player_t *target = NULL;
player->botvars.itemconfirm++; player->botvars.itemconfirm++;
target = K_PlayerInCone(player, player->mo->radius * 16, 10, true); target = K_PlayerInCone(player, coneDist, 15, true);
if (target != NULL) if (target != NULL)
{ {
K_ItemConfirmForTarget(player, target, player->botvars.difficulty); K_ItemConfirmForTarget(player, target, player->botvars.difficulty);
@ -601,6 +613,7 @@ static void K_BotItemMine(player_t *player, ticcmd_t *cmd, INT16 turnamt)
{ {
player->botvars.itemconfirm += player->botvars.difficulty / 2; player->botvars.itemconfirm += player->botvars.difficulty / 2;
throwdir = -1; throwdir = -1;
tryLookback = true;
} }
else else
{ {
@ -619,7 +632,12 @@ static void K_BotItemMine(player_t *player, ticcmd_t *cmd, INT16 turnamt)
} }
} }
if (player->botvars.itemconfirm > 2*TICRATE || player->bananadrag >= TICRATE) if (tryLookback == true && throwdir == -1)
{
cmd->buttons |= BT_LOOKBACK;
}
if (player->botvars.itemconfirm > 10*TICRATE || player->bananadrag >= TICRATE)
{ {
K_BotGenericPressItem(player, cmd, throwdir); K_BotGenericPressItem(player, cmd, throwdir);
} }
@ -640,6 +658,7 @@ static void K_BotItemMine(player_t *player, ticcmd_t *cmd, INT16 turnamt)
--------------------------------------------------*/ --------------------------------------------------*/
static void K_BotItemLandmine(player_t *player, ticcmd_t *cmd, INT16 turnamt) static void K_BotItemLandmine(player_t *player, ticcmd_t *cmd, INT16 turnamt)
{ {
const fixed_t coneDist = FixedMul(1280 * mapobjectscale, K_GetKartGameSpeedScalar(gamespeed));
player_t *target = NULL; player_t *target = NULL;
player->botvars.itemconfirm++; player->botvars.itemconfirm++;
@ -649,13 +668,14 @@ static void K_BotItemLandmine(player_t *player, ticcmd_t *cmd, INT16 turnamt)
player->botvars.itemconfirm += player->botvars.difficulty / 2; player->botvars.itemconfirm += player->botvars.difficulty / 2;
} }
target = K_PlayerInCone(player, player->mo->radius * 16, 10, true); target = K_PlayerInCone(player, coneDist, 15, true);
if (target != NULL) if (target != NULL)
{ {
K_ItemConfirmForTarget(player, target, player->botvars.difficulty); K_ItemConfirmForTarget(player, target, player->botvars.difficulty);
cmd->buttons |= BT_LOOKBACK;
} }
if (player->botvars.itemconfirm > 2*TICRATE) if (player->botvars.itemconfirm > 10*TICRATE)
{ {
K_BotGenericPressItem(player, cmd, -1); K_BotGenericPressItem(player, cmd, -1);
} }
@ -675,8 +695,10 @@ static void K_BotItemLandmine(player_t *player, ticcmd_t *cmd, INT16 turnamt)
--------------------------------------------------*/ --------------------------------------------------*/
static void K_BotItemEggman(player_t *player, ticcmd_t *cmd) static void K_BotItemEggman(player_t *player, ticcmd_t *cmd)
{ {
const fixed_t coneDist = FixedMul(1280 * mapobjectscale, K_GetKartGameSpeedScalar(gamespeed));
const UINT8 stealth = K_EggboxStealth(player->mo->x, player->mo->y); const UINT8 stealth = K_EggboxStealth(player->mo->x, player->mo->y);
SINT8 throwdir = -1; SINT8 throwdir = -1;
boolean tryLookback = false;
player_t *target = NULL; player_t *target = NULL;
player->botvars.itemconfirm++; player->botvars.itemconfirm++;
@ -688,11 +710,12 @@ static void K_BotItemEggman(player_t *player, ticcmd_t *cmd)
throwdir = 1; throwdir = 1;
} }
target = K_PlayerInCone(player, player->mo->radius * 16, 10, true); target = K_PlayerInCone(player, coneDist, 15, true);
if (target != NULL) if (target != NULL)
{ {
K_ItemConfirmForTarget(player, target, player->botvars.difficulty); K_ItemConfirmForTarget(player, target, player->botvars.difficulty);
throwdir = -1; throwdir = -1;
tryLookback = true;
} }
if (stealth > 1 || player->itemroulette > 0) if (stealth > 1 || player->itemroulette > 0)
@ -701,7 +724,12 @@ static void K_BotItemEggman(player_t *player, ticcmd_t *cmd)
throwdir = -1; throwdir = -1;
} }
if (player->botvars.itemconfirm > 2*TICRATE || player->bananadrag >= TICRATE) if (tryLookback == true && throwdir == -1)
{
cmd->buttons |= BT_LOOKBACK;
}
if (player->botvars.itemconfirm > 10*TICRATE || player->bananadrag >= TICRATE)
{ {
K_BotGenericPressItem(player, cmd, throwdir); K_BotGenericPressItem(player, cmd, throwdir);
} }
@ -720,6 +748,7 @@ static void K_BotItemEggman(player_t *player, ticcmd_t *cmd)
--------------------------------------------------*/ --------------------------------------------------*/
static boolean K_BotRevealsEggbox(player_t *player) static boolean K_BotRevealsEggbox(player_t *player)
{ {
const fixed_t coneDist = FixedMul(1280 * mapobjectscale, K_GetKartGameSpeedScalar(gamespeed));
const UINT8 stealth = K_EggboxStealth(player->mo->x, player->mo->y); const UINT8 stealth = K_EggboxStealth(player->mo->x, player->mo->y);
player_t *target = NULL; player_t *target = NULL;
@ -737,7 +766,7 @@ static boolean K_BotRevealsEggbox(player_t *player)
} }
// Check your behind. // Check your behind.
target = K_PlayerInCone(player, player->mo->radius * 16, 10, true); target = K_PlayerInCone(player, coneDist, 15, true);
if (target != NULL) if (target != NULL)
{ {
return true; return true;
@ -810,8 +839,9 @@ static void K_BotItemEggmanExplosion(player_t *player, ticcmd_t *cmd)
static void K_BotItemOrbinaut(player_t *player, ticcmd_t *cmd) static void K_BotItemOrbinaut(player_t *player, ticcmd_t *cmd)
{ {
const fixed_t topspeed = K_GetKartSpeed(player, false); const fixed_t topspeed = K_GetKartSpeed(player, false);
fixed_t radius = (player->mo->radius * 32); fixed_t radius = FixedMul(2560 * mapobjectscale, K_GetKartGameSpeedScalar(gamespeed));
SINT8 throwdir = -1; SINT8 throwdir = -1;
boolean tryLookback = false;
UINT8 snipeMul = 2; UINT8 snipeMul = 2;
player_t *target = NULL; player_t *target = NULL;
@ -823,24 +853,30 @@ static void K_BotItemOrbinaut(player_t *player, ticcmd_t *cmd)
player->botvars.itemconfirm++; player->botvars.itemconfirm++;
target = K_PlayerInCone(player, radius, 10, false); target = K_PlayerInCone(player, radius, 15, false);
if (target != NULL) if (target != NULL)
{ {
K_ItemConfirmForTarget(player, target, player->botvars.difficulty * snipeMul); K_ItemConfirmForTarget(player, target, player->botvars.difficulty * snipeMul);
throwdir = 1; throwdir = 1;
} }
else if (K_PlayerInCone(player, radius, 10, true)) else
{ {
target = K_PlayerInCone(player, radius, 10, true); target = K_PlayerInCone(player, radius, 15, true);
if (target != NULL) if (target != NULL)
{ {
K_ItemConfirmForTarget(player, target, player->botvars.difficulty); K_ItemConfirmForTarget(player, target, player->botvars.difficulty);
throwdir = -1; throwdir = -1;
tryLookback = true;
} }
} }
if (player->botvars.itemconfirm > 5*TICRATE) if (tryLookback == true && throwdir == -1)
{
cmd->buttons |= BT_LOOKBACK;
}
if (player->botvars.itemconfirm > 25*TICRATE)
{ {
K_BotGenericPressItem(player, cmd, throwdir); K_BotGenericPressItem(player, cmd, throwdir);
} }
@ -861,8 +897,9 @@ static void K_BotItemOrbinaut(player_t *player, ticcmd_t *cmd)
static void K_BotItemJawz(player_t *player, ticcmd_t *cmd) static void K_BotItemJawz(player_t *player, ticcmd_t *cmd)
{ {
const fixed_t topspeed = K_GetKartSpeed(player, false); const fixed_t topspeed = K_GetKartSpeed(player, false);
fixed_t radius = (player->mo->radius * 32); fixed_t radius = FixedMul(2560 * mapobjectscale, K_GetKartGameSpeedScalar(gamespeed));
SINT8 throwdir = 1; SINT8 throwdir = 1;
boolean tryLookback = false;
UINT8 snipeMul = 2; UINT8 snipeMul = 2;
INT32 lastTarg = player->lastjawztarget; INT32 lastTarg = player->lastjawztarget;
player_t *target = NULL; player_t *target = NULL;
@ -875,11 +912,12 @@ static void K_BotItemJawz(player_t *player, ticcmd_t *cmd)
player->botvars.itemconfirm++; player->botvars.itemconfirm++;
target = K_PlayerInCone(player, radius, 10, true); target = K_PlayerInCone(player, radius, 15, true);
if (target != NULL) if (target != NULL)
{ {
K_ItemConfirmForTarget(player, target, player->botvars.difficulty); K_ItemConfirmForTarget(player, target, player->botvars.difficulty);
throwdir = -1; throwdir = -1;
tryLookback = true;
} }
if (lastTarg != -1 if (lastTarg != -1
@ -913,7 +951,12 @@ static void K_BotItemJawz(player_t *player, ticcmd_t *cmd)
} }
} }
if (player->botvars.itemconfirm > 5*TICRATE) if (tryLookback == true && throwdir == -1)
{
cmd->buttons |= BT_LOOKBACK;
}
if (player->botvars.itemconfirm > 25*TICRATE)
{ {
K_BotGenericPressItem(player, cmd, throwdir); K_BotGenericPressItem(player, cmd, throwdir);
} }
@ -1007,7 +1050,7 @@ static void K_BotItemBubble(player_t *player, ticcmd_t *cmd)
} }
else if (player->bubbleblowup >= bubbletime) else if (player->bubbleblowup >= bubbletime)
{ {
if (player->botvars.itemconfirm >= 10*TICRATE) if (player->botvars.itemconfirm > 10*TICRATE)
{ {
hold = true; hold = true;
} }

View file

@ -619,7 +619,7 @@ void K_NudgePredictionTowardsObjects(botprediction_t *predict, player_t *player)
fixed_t avgX = 0, avgY = 0; fixed_t avgX = 0, avgY = 0;
fixed_t avgDist = 0; fixed_t avgDist = 0;
const fixed_t baseNudge = 128 * mapobjectscale; const fixed_t baseNudge = predict->radius;
fixed_t maxNudge = distToPredict; fixed_t maxNudge = distToPredict;
fixed_t nudgeDist = 0; fixed_t nudgeDist = 0;
angle_t nudgeDir = 0; angle_t nudgeDir = 0;

View file

@ -2231,6 +2231,10 @@ void K_KartMoveAnimation(player_t *player)
SINT8 destGlanceDir = 0; SINT8 destGlanceDir = 0;
SINT8 drift = player->drift; SINT8 drift = player->drift;
if (!lookback)
{
player->pflags &= ~PF_LOOKDOWN;
// Uses turning over steering -- it's important to show player feedback immediately. // Uses turning over steering -- it's important to show player feedback immediately.
if (player->cmd.turning < -minturn) if (player->cmd.turning < -minturn)
{ {
@ -2240,10 +2244,6 @@ void K_KartMoveAnimation(player_t *player)
{ {
turndir = 1; turndir = 1;
} }
if (!lookback)
{
player->pflags &= ~PF_LOOKDOWN;
} }
else if (drift == 0) else if (drift == 0)
{ {