Merge branch 'more-lenient-auto-respawn' into 'master'

Make automatic respawn (from lap cheat prevention) more lenient

See merge request KartKrew/Kart!2013
This commit is contained in:
Oni 2024-03-07 05:30:31 +00:00
commit 31203ff7fd
11 changed files with 58 additions and 13 deletions

View file

@ -834,6 +834,12 @@ consvar_t cv_restrictskinchange = OnlineCheat("restrictskinchange", "Yes").yes_n
consvar_t cv_spbtest = OnlineCheat("spbtest", "Off").on_off().description("SPB can never target a player");
consvar_t cv_showgremlins = OnlineCheat("showgremlins", "No").yes_no().description("Show line collision errors");
consvar_t cv_timescale = OnlineCheat(cvlist_timer)("timescale", "1.0").floating_point().min_max(FRACUNIT/20, 20*FRACUNIT).description("Overclock or slow down the game");
#ifdef DEVELOP
// change the default value in doomdef.h (so it affects release builds too)
consvar_t cv_debugtraversemax = OnlineCheat("debugtraversemax", TOSTR2(TRAVERSE_MAX)).min_max(0, 255).description("Improve line-of-sight detection (waypoints) but may slow down the game");
#endif
consvar_t cv_ufo_follow = OnlineCheat("ufo_follow", "0").min_max(0, MAXPLAYERS).description("Make UFO Catcher folow this player");
consvar_t cv_ufo_health = OnlineCheat("ufo_health", "-1").min_max(-1, 100).description("Override UFO Catcher health -- applied at spawn or when value is changed");

View file

@ -6078,6 +6078,9 @@ static void Got_Cheat(const UINT8 **cp, INT32 playernum)
}
P_MapEnd();
player->pflags |= PF_TRUSTWAYPOINTS;
player->bigwaypointgap = 0;
S_StartSound(player->mo, sfx_mixup);
}

View file

@ -104,8 +104,9 @@ typedef enum
PF_RINGLOCK = 1<<13, // Prevent picking up rings while SPB is locked on
PF_ANALOGSTICK = 1<<14, // This player is using an analog joystick
PF_TRUSTWAYPOINTS = 1<<15, // Do not activate lap cheat prevention next time finish line distance is updated
//15-17 free, was previously itemflags stuff
//16-17 free, was previously itemflags stuff
PF_DRIFTINPUT = 1<<18, // Drifting!
PF_GETSPARKS = 1<<19, // Can get sparks
@ -671,7 +672,7 @@ struct player_t
mobj_t *ringShooter; // DEZ respawner object
tic_t airtime; // Used to track just air time, but has evolved over time into a general "karted" timer. Rename this variable?
tic_t lastairtime;
UINT8 bigwaypointgap; // timer counts down if finish line distance gap is too big to update waypoint
UINT16 bigwaypointgap; // timer counts down if finish line distance gap is too big to update waypoint
UINT8 startboost; // (0 to 125) - Boost you get from start of race
UINT8 dropdashboost; // Boost you get when holding A while respawning

View file

@ -4016,7 +4016,7 @@ const char *const PLAYERFLAG_LIST[] = {
"RINGLOCK", // Prevent picking up rings while SPB is locked on
"ANALOGSTICK", // This player is using an analog joystick
"\x01", // Free
"TRUSTWAYPOINTS", // Do not activate lap cheat prevention next time finish line distance is updated
"\x01", // Free
"\x01", // Free

View file

@ -724,6 +724,9 @@ extern int
#undef UPDATE_ALERT
#endif
// p_sight.c
#define TRAVERSE_MAX 8
/// Other karma comeback modes
//#define OTHERKARMAMODES

View file

@ -360,6 +360,7 @@ typedef UINT32 tic_t;
#endif
#define TOSTR(x) #x
#define TOSTR2(x) TOSTR(x) // expand x first
/* preprocessor dumb and needs second macro to expand input */
#define WSTRING2(s) L ## s

View file

@ -8772,11 +8772,20 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
K_DoIngameRespawn(player);
}
if (player->bigwaypointgap)
// Don't tick down while in damage state.
// There may be some maps where the timer activates for
// a moment during normal play, but would quickly correct
// itself when the player drives forward.
// If the player is in a damage state, they may not be
// able to move in time.
// Always let the respawn prompt appear.
if (player->bigwaypointgap && (player->bigwaypointgap > AUTORESPAWN_THRESHOLD || !P_PlayerInPain(player)))
{
player->bigwaypointgap--;
if (!player->bigwaypointgap)
K_DoIngameRespawn(player);
else if (player->bigwaypointgap == AUTORESPAWN_THRESHOLD)
K_AddMessageForPlayer(player, "Press \xAE to respawn", true, false);
}
if (player->tripwireUnstuck && !player->mo->hitlag)
@ -8797,7 +8806,9 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
if (player->respawn.state == RESPAWNST_NONE && (player->cmd.buttons & BT_RESPAWN) == BT_RESPAWN)
{
player->finalfailsafe++; // Decremented by ringshooter to "freeze" this timer
if (player->finalfailsafe >= 4*TICRATE)
// Part-way through the auto-respawn timer, you can tap Ring Shooter to respawn early
if (player->finalfailsafe >= 4*TICRATE ||
(player->bigwaypointgap && player->bigwaypointgap < AUTORESPAWN_THRESHOLD))
{
K_DoIngameRespawn(player);
player->finalfailsafe = 0;
@ -9976,10 +9987,12 @@ static void K_UpdatePlayerWaypoints(player_t *const player)
player->distancetofinishprev = player->distancetofinish;
K_UpdateDistanceFromFinishLine(player);
// Respawning should be a full reset.
// So should touching the first waypoint ever.
UINT32 delta = u32_delta(player->distancetofinish, player->distancetofinishprev);
if (player->respawn.state == RESPAWNST_NONE && delta > distance_threshold && old_currentwaypoint != NULL)
if (delta > distance_threshold &&
player->respawn.state == RESPAWNST_NONE && // Respawning should be a full reset.
old_currentwaypoint != NULL && // So should touching the first waypoint ever.
player->laps != 0 && // POSITION rooms may have unorthodox waypoints to guide bots.
!(player->pflags & PF_TRUSTWAYPOINTS)) // Special exception.
{
extern consvar_t cv_debuglapcheat;
#define debug_args "Player %s: waypoint ID %d too far away (%u > %u)\n", \
@ -10000,14 +10013,14 @@ static void K_UpdatePlayerWaypoints(player_t *const player)
// Start the auto respawn timer when the distance jumps.
if (!player->bigwaypointgap)
{
player->bigwaypointgap = 35;
player->bigwaypointgap = AUTORESPAWN_TIME;
}
}
}
else
{
// Reset the auto respawn timer if distance changes are back to normal.
if (player->bigwaypointgap == 1)
if (player->bigwaypointgap <= AUTORESPAWN_THRESHOLD + 1)
{
player->bigwaypointgap = 0;
}
@ -10025,6 +10038,8 @@ static void K_UpdatePlayerWaypoints(player_t *const player)
player->lastsafelap = player->laps;
player->lastsafecheatcheck = player->cheatchecknum;
}
player->pflags &= ~PF_TRUSTWAYPOINTS; // clear special exception
}
INT32 K_GetKartRingPower(const player_t *player, boolean boosted)

View file

@ -70,6 +70,11 @@ Make sure this matches the actual number of states
// Delay the wavedash visuals until we're reasonably sure that it's a deliberate turn.
#define HIDEWAVEDASHCHARGE (60)
// Auto-respawn timer for when lap cheating or out of bounds
// is detected.
#define AUTORESPAWN_TIME (10*TICRATE)
#define AUTORESPAWN_THRESHOLD (7*TICRATE)
angle_t K_ReflectAngle(angle_t angle, angle_t against, fixed_t maxspeed, fixed_t yourspeed);
boolean K_IsDuelItem(mobjtype_t type);

View file

@ -418,7 +418,7 @@ static void P_NetArchivePlayers(savebuffer_t *save)
WRITEUINT32(save->p, K_GetWaypointHeapIndex(players[i].nextwaypoint));
WRITEUINT32(save->p, players[i].airtime);
WRITEUINT32(save->p, players[i].lastairtime);
WRITEUINT8(save->p, players[i].bigwaypointgap);
WRITEUINT16(save->p, players[i].bigwaypointgap);
WRITEUINT8(save->p, players[i].startboost);
WRITEUINT8(save->p, players[i].dropdashboost);
@ -1006,7 +1006,7 @@ static void P_NetUnArchivePlayers(savebuffer_t *save)
players[i].nextwaypoint = (waypoint_t *)(size_t)READUINT32(save->p);
players[i].airtime = READUINT32(save->p);
players[i].lastairtime = READUINT32(save->p);
players[i].bigwaypointgap = READUINT8(save->p);
players[i].bigwaypointgap = READUINT16(save->p);
players[i].startboost = READUINT8(save->p);
players[i].dropdashboost = READUINT8(save->p);

View file

@ -52,7 +52,11 @@ typedef struct
static INT32 sightcounts[2];
#define TRAVERSE_MAX (2)
#ifdef DEVELOP
extern consvar_t cv_debugtraversemax;
#undef TRAVERSE_MAX
#define TRAVERSE_MAX (cv_debugtraversemax.value)
#endif
//
// P_DivlineSide

View file

@ -2015,6 +2015,13 @@ static void K_HandleLapIncrement(player_t *player)
SetRandomFakePlayerSkin(player, true);
}
// Always trust waypoints entering the first lap.
// This accounts for special POSITION room setups.
// debuglapcheat can be used to expose errors that would be hidden by this exception.
extern consvar_t cv_debuglapcheat;
if (!cv_debuglapcheat.value && player->laps == 1)
player->pflags |= PF_TRUSTWAYPOINTS;
K_UpdateAllPlayerPositions(); // P_DoPlayerExit calls this
}