Skip to content

Commit 253a3cb

Browse files
committed
Better spawn spot randomization from HL25 update.
1 parent 73ac4de commit 253a3cb

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

dlls/player.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2794,6 +2794,8 @@ edict_t *EntSelectSpawnPoint( CBaseEntity *pPlayer )
27942794
CBaseEntity *pSpot;
27952795
edict_t *player;
27962796

2797+
int nNumRandomSpawnsToTry = 10;
2798+
27972799
player = pPlayer->edict();
27982800

27992801
// choose a info_player_deathmatch point
@@ -2808,9 +2810,18 @@ edict_t *EntSelectSpawnPoint( CBaseEntity *pPlayer )
28082810
}
28092811
else if( g_pGameRules->IsDeathmatch() )
28102812
{
2813+
if( !g_pLastSpawn )
2814+
{
2815+
nNumRandomSpawnsToTry = 0;
2816+
CBaseEntity* pEnt = 0;
2817+
2818+
while( ( pEnt = UTIL_FindEntityByClassname( 0, "info_player_deathmatch" )))
2819+
nNumRandomSpawnsToTry++;
2820+
}
2821+
28112822
pSpot = g_pLastSpawn;
28122823
// Randomize the start spot
2813-
for( int i = RANDOM_LONG( 1, 9 ); i > 0; i-- )
2824+
for( int i = RANDOM_LONG( 1, nNumRandomSpawnsToTry - 1 ); i > 0; i-- )
28142825
pSpot = UTIL_FindEntityByClassname( pSpot, "info_player_deathmatch" );
28152826
if( FNullEnt( pSpot ) ) // skip over the null point
28162827
pSpot = UTIL_FindEntityByClassname( pSpot, "info_player_deathmatch" );

0 commit comments

Comments
 (0)