Merge branch 'force-waypoint-update' into 'master'

Update respawn waypoint on fastfall bounce, reset lap on track reset (resolves #705, #489)

Closes #489 and #705

See merge request KartKrew/Kart!1563
This commit is contained in:
Oni 2023-10-19 07:21:01 +00:00
commit 07298ce94b
8 changed files with 30 additions and 6 deletions

View file

@ -67,7 +67,7 @@ typedef enum
{
PF_GODMODE = 1<<0, // Immortal. No lightsnake from pits either
// free: 1<<1
PF_UPDATEMYRESPAWN = 1<<1, // Scripted sequences / fastfall can set this to force a respawn waypoint update
PF_AUTOROULETTE = 1<<2, // Accessibility: Non-deterministic item box, no manual stop.
@ -852,6 +852,8 @@ struct player_t
UINT8 sliptideZipDelay; // How long since the last sliptide? Only boost once you've been straightened out for a bit.
UINT16 sliptideZipBoost; // The actual boost granted from sliptideZip.
UINT8 lastsafelap;
mobj_t *stumbleIndicator;
mobj_t *sliptideZipIndicator;
mobj_t *whip;

View file

@ -5999,7 +5999,7 @@ const char *const MAPTHINGFLAG_LIST[4] = {
const char *const PLAYERFLAG_LIST[] = {
"GODMODE",
"\x01", // free: 1<<1 (name un-matchable)
"UPDATEMYRESPAWN", // Scripted sequences / fastfall can set this to force a respawn waypoint update
"AUTOROULETTE", // Item box accessibility

View file

@ -5244,11 +5244,12 @@ static void K_DrawWaypointDebugger(void)
if (netgame)
{
V_DrawString(8, 146, 0, va("Online griefing: [%u, %u]", stplyr->griefValue/TICRATE, stplyr->griefStrikes));
V_DrawString(8, 136, 0, va("Online griefing: [%u, %u]", stplyr->griefValue/TICRATE, stplyr->griefStrikes));
}
V_DrawString(8, 156, 0, va("Current Waypoint ID: %d", K_GetWaypointID(stplyr->currentwaypoint)));
V_DrawString(8, 166, 0, va("Next Waypoint ID: %d%s", K_GetWaypointID(stplyr->nextwaypoint), ((stplyr->pflags & PF_WRONGWAY) ? " (WRONG WAY)" : "")));
V_DrawString(8, 146, 0, va("Current Waypoint ID: %d", K_GetWaypointID(stplyr->currentwaypoint)));
V_DrawString(8, 156, 0, va("Next Waypoint ID: %d%s", K_GetWaypointID(stplyr->nextwaypoint), ((stplyr->pflags & PF_WRONGWAY) ? " (WRONG WAY)" : "")));
V_DrawString(8, 166, 0, va("Respawn Waypoint ID: %d", K_GetWaypointID(stplyr->respawn.wp)));
V_DrawString(8, 176, 0, va("Finishline Distance: %d", stplyr->distancetofinish));
if (numcheatchecks > 0)

View file

@ -8953,6 +8953,12 @@ static waypoint_t *K_GetPlayerNextWaypoint(player_t *player)
updaterespawn = false;
}
if (player->pflags & PF_UPDATEMYRESPAWN)
{
updaterespawn = true;
player->pflags &= ~PF_UPDATEMYRESPAWN;
}
// Respawn point should only be updated when we're going to a nextwaypoint
if ((updaterespawn) &&
(player->respawn.state == RESPAWNST_NONE) &&
@ -8962,6 +8968,7 @@ static waypoint_t *K_GetPlayerNextWaypoint(player_t *player)
(K_GetWaypointIsEnabled(bestwaypoint) == true))
{
player->respawn.wp = bestwaypoint;
player->lastsafelap = player->laps;
}
}
@ -10688,6 +10695,8 @@ boolean K_FastFallBounce(player_t *player)
if (player->mo->eflags & MFE_UNDERWATER)
bounce = (117 * bounce) / 200;
player->pflags |= PF_UPDATEMYRESPAWN;
player->mo->momz = bounce * P_MobjFlip(player->mo);
player->fastfall = 0;

View file

@ -289,6 +289,7 @@ void K_DoIngameRespawn(player_t *player)
player->respawn.init = true;
player->respawn.fast = true;
player->respawn.returnspeed = 0;
player->laps = player->lastsafelap;
player->respawn.airtimer = player->airtime;
player->respawn.truedeath = !!(player->pflags & PF_FAULT);
@ -403,7 +404,8 @@ static void K_MovePlayerToRespawnPoint(player_t *player)
P_SetThingPosition(player->mo);
// We are no longer traveling from death location to 1st waypoint, so use standard timings
player->respawn.fast = false;
if (player->respawn.fast)
player->respawn.fast = false;
// At the first valid waypoint, permit extra player control options.
player->respawn.init = false;

View file

@ -329,6 +329,8 @@ static int player_get(lua_State *L)
lua_pushinteger(L, plr->sliptideZipDelay);
else if (fastcmp(field,"sliptideZipBoost"))
lua_pushinteger(L, plr->sliptideZipBoost);
else if (fastcmp(field,"lastsafelap"))
lua_pushinteger(L, plr->lastsafelap);
else if (fastcmp(field,"instaWhipCharge"))
lua_pushinteger(L, plr->instaWhipCharge);
else if (fastcmp(field,"instaWhipCooldown"))
@ -809,6 +811,8 @@ static int player_set(lua_State *L)
plr->sliptideZipDelay = luaL_checkinteger(L, 3);
else if (fastcmp(field,"sliptideZipBoost"))
plr->sliptideZipBoost = luaL_checkinteger(L, 3);
else if (fastcmp(field,"lastsafelap"))
plr->lastsafelap = luaL_checkinteger(L, 3);
else if (fastcmp(field,"instaWhipCharge"))
plr->instaWhipCharge = luaL_checkinteger(L, 3);
else if (fastcmp(field,"instaWhipCooldown"))

View file

@ -539,6 +539,8 @@ static void P_NetArchivePlayers(savebuffer_t *save)
WRITEUINT8(save->p, players[i].sliptideZipDelay);
WRITEUINT16(save->p, players[i].sliptideZipBoost);
WRITEUINT8(save->p, players[i].lastsafelap);
WRITEMEM(save->p, players[i].public_key, PUBKEYLENGTH);
WRITEUINT8(save->p, players[i].instaWhipCharge);
@ -1052,6 +1054,8 @@ static void P_NetUnArchivePlayers(savebuffer_t *save)
players[i].sliptideZipDelay = READUINT8(save->p);
players[i].sliptideZipBoost = READUINT16(save->p);
players[i].lastsafelap = READUINT8(save->p);
READMEM(save->p, players[i].public_key, PUBKEYLENGTH);
players[i].instaWhipCharge = READUINT8(save->p);

View file

@ -2142,6 +2142,8 @@ static void K_HandleLapDecrement(player_t *player)
{
if (player)
{
if (player->respawn.state == RESPAWNST_MOVE)
return;
if ((player->cheatchecknum == 0) && (player->laps > 0))
{
player->cheatchecknum = numcheatchecks;