From 40f7666c10c71b2e6880f08d8fdc3bda88477a93 Mon Sep 17 00:00:00 2001 From: mittorn Date: Thu, 29 Sep 2016 20:33:29 +0000 Subject: [PATCH] Add way to fixup spawnpoint --- dlls/gamerules.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/dlls/gamerules.cpp b/dlls/gamerules.cpp index 08ca7596..1d14f1d4 100644 --- a/dlls/gamerules.cpp +++ b/dlls/gamerules.cpp @@ -61,6 +61,23 @@ bool CoopGetSpawnPoint( Vector *point, Vector *angles); bool CoopRestorePlayerCoords(CBaseEntity *player, Vector *origin, Vector *angles ); +Vector FixupSpawnPoint(Vector spawn) +{ + int i = 0; + while( i < 10 ) // 10 player heights + { + Vector point = spawn + Vector( 0, 0, 36 * i ); + TraceResult tr; + UTIL_TraceHull( point, point, missile, 1, NULL, &tr ); + if( !tr.fStartSolid ) + return point; + i = -i; + if( i >= 0 ) + i++; + } + return spawn; +} + //========================================================= //========================================================= edict_t *CGameRules::GetPlayerSpawnSpot( CBasePlayer *pPlayer ) @@ -78,6 +95,7 @@ edict_t *CGameRules::GetPlayerSpawnSpot( CBasePlayer *pPlayer ) if( mp_coop_changelevel.value && !CoopRestorePlayerCoords( pPlayer, &pPlayer->pev->origin, &pPlayer->pev->angles )) CoopGetSpawnPoint( &pPlayer->pev->origin, &pPlayer->pev->angles ); pPlayer->pev->fixangle = TRUE; + pPlayer->pev->origin = FixupSpawnPoint( pPlayer->pev->origin ); return pentSpawnSpot; }