000
21.10.2001, 18:13
Basiror
|
edict_t *EntSelectSpawnPoint( CBaseEntity *pPlayer ) { CBaseEntity *pSpot; edict_t *player;
player = pPlayer->edict();
// choose a info_player_deathmatch point if (g_pGameRules->IsCoOp()) { if(pPlayer&&pPlayer->pev->team==TEAM1) { pSpot = UTIL_FindEntityByClassname( g_pLastSpawn, "info_player_team1"); if ( !FNullEnt(pSpot) ) goto ReturnSpot; } else if(pPlayer&&pPlayer->pev->team==TEAM2) { pSpot = UTIL_FindEntityByClassname( g_pLastSpawn, "info_player_team2"); if ( !FNullEnt(pSpot) ) goto ReturnSpot; } else { pSpot = UTIL_FindEntityByClassname( g_pLastSpawn, "info_player_observer"); if ( !FNullEnt(pSpot) ) goto ReturnSpot; } } if ( g_pGameRules->IsDeathmatch() ) { pSpot = g_pLastSpawn; // Randomize the start spot if(pPlayer&&pPlayer->pev->team==TEAM1) { for ( int i = RANDOM_LONG(1,5); i > 0; i-- ) pSpot = UTIL_FindEntityByClassname( pSpot, "info_player_team1" ); if ( FNullEnt( pSpot ) ) // skip over the null point pSpot = UTIL_FindEntityByClassname( pSpot, "info_player_team1" ); } else if(pPlayer&&pPlayer->pev->team==TEAM2) { for ( int i = RANDOM_LONG(1,5); i > 0; i-- ) pSpot = UTIL_FindEntityByClassname( pSpot, "info_player_team2" ); if ( FNullEnt( pSpot ) ) // skip over the null point pSpot = UTIL_FindEntityByClassname( pSpot, "info_player_team2" ); } else { for ( int i = RANDOM_LONG(1,5); i > 0; i-- ) pSpot = UTIL_FindEntityByClassname( pSpot, "info_player_observer" ); if ( FNullEnt( pSpot ) ) // skip over the null point pSpot = UTIL_FindEntityByClassname( pSpot, "info_player_observer" ); }
CBaseEntity *pFirstSpot = pSpot;
do { if ( pSpot ) { // check if pSpot is valid if ( IsSpawnPointValid( pPlayer, pSpot ) ) { if ( pSpot->pev->origin == Vector( 0, 0, 0 ) ) { if(pPlayer&&pPlayer->pev->team==TEAM1) { pSpot = UTIL_FindEntityByClassname( pSpot, "info_player_team1" ); } else if(pPlayer&&pPlayer->pev->team==TEAM2) { pSpot = UTIL_FindEntityByClassname( pSpot, "info_player_team2" ); } else { pSpot = UTIL_FindEntityByClassname( pSpot, "info_player_observer" ); } continue;
}
// if so, go to pSpot goto ReturnSpot; } } // increment pSpot if(pPlayer&&pPlayer->pev->team==TEAM1) { pSpot = UTIL_FindEntityByClassname( pSpot, "info_player_team1" ); } else if(pPlayer&&pPlayer->pev->team==TEAM2) { pSpot = UTIL_FindEntityByClassname( pSpot, "info_player_team2" ); } else { pSpot = UTIL_FindEntityByClassname( pSpot, "info_player_observer" ); } } while ( pSpot != pFirstSpot ); // loop if we're not back to the start
// we haven't found a place to spawn yet, so kill any guy at the first spawn point and spawn there if ( !FNullEnt( pSpot ) ) { CBaseEntity *ent = NULL; while ( (ent = UTIL_FindEntityInSphere( ent, pSpot->pev->origin, 128 )) != NULL ) { // if ent is a client, kill em (unless they are ourselves) if ( ent->IsPlayer() && !(ent->edict() == player) ) ent->TakeDamage( VARS(INDEXENT(0)), VARS(INDEXENT(0)), 300, DMG_GENERIC ); } goto ReturnSpot; } }
// If startspot is set, (re)spawn there. if ( FStringNull( gpGlobals->startspot ) || !strlen(STRING(gpGlobals->startspot))) { pSpot = UTIL_FindEntityByClassname(NULL, "info_player_start"); if ( !FNullEnt(pSpot) ) goto ReturnSpot; } else { pSpot = UTIL_FindEntityByTargetname( NULL, STRING(gpGlobals->startspot) ); if ( !FNullEnt(pSpot) ) goto ReturnSpot; }
ReturnSpot: if ( FNullEnt( pSpot ) ) { ALERT(at_error, "PutClientInServer: no info_player_start on level"); return INDEXENT(0); }
g_pLastSpawn = pSpot; return pSpot->edict(); }
--
Basiror's Labs Game-Development page
Hifle in form von Tutorials, Artikeln und anderem wird dankbar angenommen
|