Don't allow the player to respawn on a mapthing if it will collide them with another player

Mainly effects battle where match starts are used, race will be effected at the beginning of races though
This commit is contained in:
Sryder13 2017-11-11 03:28:20 +00:00
parent 890637c4ab
commit 1f6877e1e7
3 changed files with 26 additions and 0 deletions

View File

@ -2411,6 +2411,9 @@ static boolean G_CheckSpot(INT32 playernum, mapthing_t *mthing)
if (!P_CheckPosition(players[playernum].mo, x, y))
return false;
if (!K_CheckPlayersRespawnColliding(playernum, x, y))
return false;
return true;
}

View File

@ -2475,6 +2475,28 @@ void K_DoBouncePad(player_t *player, fixed_t vertispeed)
S_StartSound(player->mo, sfx_boing);
}
// Returns false if this player being placed here causes them to collide with any other player
// Used in g_game.c for match etc. respawning
// This does not check along the z because the z is not correctly set for the spawnee at this point
boolean K_CheckPlayersRespawnColliding(INT32 playernum, fixed_t x, fixed_t y)
{
INT32 i;
fixed_t p1radius = players[playernum].mo->radius;
for (i = 0; i < MAXPLAYERS; i++)
{
if (playernum == i || !playeringame[i] || players[i].spectator || !players[i].mo || players[i].mo->health <= 0
|| players[i].playerstate != PST_LIVE || (players[i].mo->flags & MF_NOCLIP) || (players[i].mo->flags & MF_NOCLIPTHING))
continue;
if (abs(x - players[i].mo->x) < (p1radius + players[i].mo->radius)
&& abs(y - players[i].mo->y) < (p1radius + players[i].mo->radius))
{
return false;
}
}
return true;
}
// countersteer is how strong the controls are telling us we are turning
// turndir is the direction the controls are telling us to turn, -1 if turning right and 1 if turning left
static INT16 K_GetKartDriftValue(player_t *player, fixed_t countersteer)

View File

@ -27,6 +27,7 @@ void K_SpawnKartExplosion(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT32
void K_SpawnDriftTrail(player_t *player);
void K_DoMushroom(player_t *player, boolean doPFlag, boolean startboost);
void K_DoBouncePad(player_t *player, fixed_t vertispeed);
boolean K_CheckPlayersRespawnColliding(INT32 playernum, fixed_t x, fixed_t y);
INT16 K_GetKartTurnValue(player_t *player, INT16 turnvalue);
void K_MomentumToFacing(player_t *player);
fixed_t K_GetKartSpeed(player_t *player, boolean doboostpower);