From bddf02ca99719240d6a47efc3940ec96656eb810 Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Wed, 21 Jan 2004 01:45:59 +0000 Subject: * (Experimental) fix for a remaining broken buildable bug * Decreased door trigger size again * Creep is now triggered by s.time instead of events * Added CVAR_CHEAT cg_drawBBOX to show the bounding boxes of some entities * Prevent sprinting if BUTTON_WALK is down * Increased sprint drain rate * Client spawning code unified with buildable validation code * Spawns are now testing for validity before they are built --- src/game/g_buildable.c | 127 ++++++++++++++++++++++++++++++++++--------------- src/game/g_client.c | 94 +++--------------------------------- src/game/g_cmds.c | 3 ++ src/game/g_local.h | 3 +- src/game/g_mover.c | 8 ++-- src/game/tremulous.h | 4 +- 6 files changed, 107 insertions(+), 132 deletions(-) (limited to 'src/game') diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index fe6d0362..10662feb 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -44,6 +44,66 @@ void G_setIdleBuildableAnim( gentity_t *ent, buildableAnimNumber_t anim ) ent->s.torsoAnim = anim; } +/* +=============== +G_CheckSpawnPoint + +Check if a spawn at a specified point is valid +=============== +*/ +gentity_t *G_CheckSpawnPoint( vec3_t origin, vec3_t normal, buildable_t spawn, vec3_t spawnOrigin ) +{ + float displacement; + vec3_t mins, maxs; + vec3_t cmins, cmaxs; + vec3_t localOrigin; + trace_t tr; + + BG_FindBBoxForBuildable( spawn, mins, maxs ); + + if( spawn == BA_A_SPAWN ) + { + VectorSet( cmins, -MAX_ALIEN_BBOX, -MAX_ALIEN_BBOX, -MAX_ALIEN_BBOX ); + VectorSet( cmaxs, MAX_ALIEN_BBOX, MAX_ALIEN_BBOX, MAX_ALIEN_BBOX ); + + displacement = ( maxs[ 2 ] + MAX_ALIEN_BBOX ) * M_ROOT3; + VectorMA( origin, displacement, normal, localOrigin ); + + trap_Trace( &tr, localOrigin, cmins, cmaxs, localOrigin, -1, MASK_SHOT ); + + if( tr.entityNum == ENTITYNUM_NONE ) + { + if( spawnOrigin != NULL ) + VectorCopy( localOrigin, spawnOrigin ); + + return NULL; + } + else + return &g_entities[ tr.entityNum ]; + } + else if( spawn == BA_H_SPAWN ) + { + BG_FindBBoxForClass( PCL_H_BASE, cmins, cmaxs, NULL, NULL, NULL ); + + VectorCopy( origin, localOrigin ); + localOrigin[ 2 ] += maxs[ 2 ] + fabs( cmins[ 2 ] ) + 1.0f; + + trap_Trace( &tr, localOrigin, cmins, cmaxs, localOrigin, -1, MASK_SHOT ); + + if( tr.entityNum == ENTITYNUM_NONE ) + { + if( spawnOrigin != NULL ) + VectorCopy( localOrigin, spawnOrigin ); + + return NULL; + } + else + return &g_entities[ tr.entityNum ]; + } + + return NULL; +} + #define POWER_REFRESH_TIME 2000 /* @@ -353,6 +413,7 @@ void A_CreepRecede( gentity_t *self ) { self->s.eFlags |= EF_DEAD; G_AddEvent( self, EV_BUILD_DESTROY, 0 ); + self->s.time = -level.time; } //creep is still receeding @@ -387,6 +448,7 @@ void ASpawn_Melt( gentity_t *self ) { self->s.eFlags |= EF_DEAD; G_AddEvent( self, EV_BUILD_DESTROY, 0 ); + self->s.time = -level.time; } //not dead yet @@ -459,34 +521,24 @@ think function for Alien Spawn */ void ASpawn_Think( gentity_t *self ) { - vec3_t mins, maxs, origin; gentity_t *ent; - trace_t tr; - float displacement; if( self->spawned ) { - VectorSet( mins, -MAX_ALIEN_BBOX, -MAX_ALIEN_BBOX, -MAX_ALIEN_BBOX ); - VectorSet( maxs, MAX_ALIEN_BBOX, MAX_ALIEN_BBOX, MAX_ALIEN_BBOX ); - - VectorCopy( self->s.origin, origin ); - displacement = ( self->r.maxs[ 2 ] + MAX_ALIEN_BBOX ) * M_ROOT3; - VectorMA( origin, displacement, self->s.origin2, origin ); - //only suicide if at rest if( self->s.groundEntityNum ) { - trap_Trace( &tr, origin, mins, maxs, origin, self->s.number, MASK_SHOT ); - ent = &g_entities[ tr.entityNum ]; - - if( ent->s.eType == ET_BUILDABLE || ent->s.number == ENTITYNUM_WORLD ) + if( ( ent = G_CheckSpawnPoint( self->s.origin, self->s.origin2, BA_A_SPAWN, NULL ) ) != NULL ) { - G_Damage( self, NULL, NULL, NULL, NULL, 10000, 0, MOD_SUICIDE ); - return; - } + if( ent->s.eType == ET_BUILDABLE || ent->s.number == ENTITYNUM_WORLD ) + { + G_Damage( self, NULL, NULL, NULL, NULL, 10000, 0, MOD_SUICIDE ); + return; + } - if( ent->s.eType == ET_CORPSE ) - G_FreeEntity( ent ); //quietly remove + if( ent->s.eType == ET_CORPSE ) + G_FreeEntity( ent ); //quietly remove + } } } @@ -1896,33 +1948,28 @@ Think for human spawn */ void HSpawn_Think( gentity_t *self ) { - vec3_t mins, maxs, origin; gentity_t *ent; - trace_t tr; - vec3_t up = { 0.0f, 0.0f, 1.0f }; - - BG_FindBBoxForClass( PCL_H_BASE, mins, maxs, NULL, NULL, NULL ); - VectorCopy( self->s.origin, origin ); - origin[ 2 ] += self->r.maxs[ 2 ] + fabs( mins[ 2 ] ) + 1.0f; - //make sure we have power self->powered = findPower( self ); - //only suicide if at rest - if( self->s.groundEntityNum ) + if( self->spawned ) { - trap_Trace( &tr, origin, mins, maxs, origin, self->s.number, MASK_SHOT ); - ent = &g_entities[ tr.entityNum ]; - - if( ent->s.eType == ET_BUILDABLE || ent->s.number == ENTITYNUM_WORLD ) + //only suicide if at rest + if( self->s.groundEntityNum ) { - G_Damage( self, NULL, NULL, NULL, NULL, 10000, 0, MOD_SUICIDE ); - return; - } + if( ( ent = G_CheckSpawnPoint( self->s.origin, self->s.origin2, BA_H_SPAWN, NULL ) ) != NULL ) + { + if( ent->s.eType == ET_BUILDABLE || ent->s.number == ENTITYNUM_WORLD ) + { + G_Damage( self, NULL, NULL, NULL, NULL, 10000, 0, MOD_SUICIDE ); + return; + } - if( ent->s.eType == ET_CORPSE ) - G_FreeEntity( ent ); //quietly remove + if( ent->s.eType == ET_CORPSE ) + G_FreeEntity( ent ); //quietly remove + } + } } self->nextthink = level.time + BG_FindNextThinkForBuildable( self->s.modelindex ); @@ -2043,6 +2090,10 @@ itemBuildError_t G_itemFits( gentity_t *ent, buildable_t buildable, int distance if( tr1.entityNum != ENTITYNUM_WORLD ) return IBE_NORMAL; + //check there is enough room to spawn from (presuming this is a spawn) + if( G_CheckSpawnPoint( origin, normal, buildable, NULL ) != NULL ) + return IBE_NORMAL; + if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS ) { //alien criteria diff --git a/src/game/g_client.c b/src/game/g_client.c index e6a2450a..f6394d41 100644 --- a/src/game/g_client.c +++ b/src/game/g_client.c @@ -276,17 +276,10 @@ gentity_t *SelectAlienSpawnPoint( void ) int count; int selection; gentity_t *spots[ MAX_SPAWN_POINTS ]; - vec3_t mins, maxs, origin; - gentity_t *ent; - trace_t tr; - float displacement; if( level.numAlienSpawns <= 0 ) return NULL; - VectorSet( mins, -MAX_ALIEN_BBOX, -MAX_ALIEN_BBOX, -MAX_ALIEN_BBOX ); - VectorSet( maxs, MAX_ALIEN_BBOX, MAX_ALIEN_BBOX, MAX_ALIEN_BBOX ); - count = 0; spot = NULL; @@ -301,20 +294,8 @@ gentity_t *SelectAlienSpawnPoint( void ) if( !spot->s.groundEntityNum ) continue; - - VectorCopy( spot->s.origin, origin ); - displacement = ( spot->r.maxs[ 2 ] + MAX_ALIEN_BBOX ) * M_ROOT3; - VectorMA( origin, displacement, spot->s.origin2, origin ); - - trap_Trace( &tr, origin, mins, maxs, origin, spot->s.number, MASK_SHOT ); - ent = &g_entities[ tr.entityNum ]; - //spawn will suicide itself in the next 100ms - if( ent->s.eType == ET_BUILDABLE || ent->s.number == ENTITYNUM_WORLD ) - continue; - - //spawn is blocked - if( tr.fraction < 1.0f || tr.startsolid ) + if( G_CheckSpawnPoint( spot->s.origin, spot->s.origin2, BA_A_SPAWN, NULL ) != NULL ) continue; spots[ count ] = spot; @@ -342,15 +323,10 @@ gentity_t *SelectHumanSpawnPoint( void ) int count; int selection; gentity_t *spots[ MAX_SPAWN_POINTS ]; - vec3_t mins, maxs, origin; - gentity_t *ent; - trace_t tr; if( level.numHumanSpawns <= 0 ) return NULL; - BG_FindBBoxForClass( PCL_H_BASE, mins, maxs, NULL, NULL, NULL ); - count = 0; spot = NULL; @@ -366,18 +342,7 @@ gentity_t *SelectHumanSpawnPoint( void ) if( !spot->s.groundEntityNum ) continue; - VectorCopy( spot->s.origin, origin ); - origin[ 2 ] += spot->r.maxs[ 2 ] + fabs( mins[ 2 ] ) + 1.0f; - - trap_Trace( &tr, origin, mins, maxs, origin, spot->s.number, MASK_SHOT ); - ent = &g_entities[ tr.entityNum ]; - - //spawn will suicide itself in the next 100ms - if( ent->s.eType == ET_BUILDABLE || ent->s.number == ENTITYNUM_WORLD ) - continue; - - //spawn is blocked - if( tr.fraction < 1.0f || tr.startsolid ) + if( G_CheckSpawnPoint( spot->s.origin, spot->s.origin2, BA_H_SPAWN, NULL ) != NULL ) continue; spots[ count ] = spot; @@ -402,34 +367,6 @@ Chooses a player start, deathmatch start, etc gentity_t *SelectSpawnPoint( vec3_t avoidPoint, vec3_t origin, vec3_t angles ) { return SelectRandomFurthestSpawnPoint( avoidPoint, origin, angles ); - - /* - gentity_t *spot; - gentity_t *nearestSpot; - - nearestSpot = SelectNearestDeathmatchSpawnPoint( avoidPoint ); - - spot = SelectRandomDeathmatchSpawnPoint ( ); - if ( spot == nearestSpot ) { - // roll again if it would be real close to point of death - spot = SelectRandomDeathmatchSpawnPoint ( ); - if ( spot == nearestSpot ) { - // last try - spot = SelectRandomDeathmatchSpawnPoint ( ); - } - } - - // find a single player start spot - if (!spot) { - G_Error( "Couldn't find a spawn point" ); - } - - VectorCopy (spot->s.origin, origin); - origin[2] += 9; - VectorCopy (spot->s.angles, angles); - - return spot; - */ } @@ -440,12 +377,9 @@ SelectTremulousSpawnPoint Chooses a player start, deathmatch start, etc ============ */ -gentity_t *SelectTremulousSpawnPoint( int team, vec3_t origin, vec3_t angles ) +gentity_t *SelectTremulousSpawnPoint( pTeam_t team, vec3_t origin, vec3_t angles ) { gentity_t *spot; - float displacement; - vec3_t classMins, classMaxs, spawnMins, spawnMaxs; - vec3_t normal = { 0, 0, 1 }; if( team == PTE_ALIENS ) spot = SelectAlienSpawnPoint( ); @@ -456,27 +390,13 @@ gentity_t *SelectTremulousSpawnPoint( int team, vec3_t origin, vec3_t angles ) if( !spot ) return NULL; - VectorCopy( spot->s.pos.trBase, origin ); - VectorCopy( spot->s.angles, angles ); - - angles[ ROLL ] = 0; - if( team == PTE_ALIENS ) - { - BG_FindBBoxForBuildable( BA_A_SPAWN, spawnMins, spawnMaxs ); - - //TA: really a *safe* extreme upper limit - displacement = ( spawnMaxs[ 2 ] + MAX_ALIEN_BBOX ) * M_ROOT3; - VectorMA( origin, displacement, spot->s.origin2, origin ); - } + G_CheckSpawnPoint( spot->s.origin, spot->s.origin2, BA_A_SPAWN, origin ); else if( team == PTE_HUMANS ) - { - BG_FindBBoxForClass( PCL_H_BASE, classMins, classMaxs, NULL, NULL, NULL ); - BG_FindBBoxForBuildable( BA_H_SPAWN, spawnMins, spawnMaxs ); + G_CheckSpawnPoint( spot->s.origin, spot->s.origin2, BA_H_SPAWN, origin ); - displacement = spawnMaxs[ 2 ] + fabs( classMins[ 2 ] ) + 1.0f; - origin[ 2 ] += displacement; - } + VectorCopy( spot->s.angles, angles ); + angles[ ROLL ] = 0; return spot; diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 1f4de832..c63eee1a 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -1642,6 +1642,9 @@ void Cmd_Boost_f( gentity_t *ent ) BG_activated( UP_JETPACK, ent->client->ps.stats ) ) return; + if( ent->client->pers.cmd.buttons & BUTTON_WALKING ) + return; + if( ( ent->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) && ( ent->client->ps.stats[ STAT_STAMINA ] > 0 ) ) ent->client->ps.stats[ STAT_STATE ] |= SS_SPEEDBOOST; diff --git a/src/game/g_local.h b/src/game/g_local.h index 16b40896..9ca44a71 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -574,6 +574,7 @@ typedef enum } itemBuildError_t; qboolean AHovel_Blocked( gentity_t *hovel, gentity_t *player, qboolean provideExit ); +gentity_t *G_CheckSpawnPoint( vec3_t origin, vec3_t normal, buildable_t spawn, vec3_t spawnOrigin ); qboolean G_BuildableRange( vec3_t origin, float r, buildable_t buildable ); itemBuildError_t G_itemFits( gentity_t *ent, buildable_t buildable, int distance, vec3_t origin ); @@ -698,7 +699,7 @@ void ChargeAttack( gentity_t *ent, gentity_t *victim ); // team_t TeamCount( int ignoreClientNum, int team ); void SetClientViewAngle( gentity_t *ent, vec3_t angle ); -gentity_t *SelectTremulousSpawnPoint( int team, vec3_t origin, vec3_t angles ); +gentity_t *SelectTremulousSpawnPoint( pTeam_t team, vec3_t origin, vec3_t angles ); gentity_t *SelectSpawnPoint( vec3_t avoidPoint, vec3_t origin, vec3_t angles ); void SpawnCorpse( gentity_t *ent ); void respawn( gentity_t *ent ); diff --git a/src/game/g_mover.c b/src/game/g_mover.c index 3bc4e94b..404453ed 100644 --- a/src/game/g_mover.c +++ b/src/game/g_mover.c @@ -1209,8 +1209,8 @@ static void manualDoorTriggerSpectator( gentity_t *door, gentity_t *player ) best = i; } - maxs[ best ] += 60; - mins[ best ] -= 60; + maxs[ best ] += 30; + mins[ best ] -= 30; VectorCopy( mins, triggerHull.r.absmin ); VectorCopy( maxs, triggerHull.r.absmax ); @@ -1340,8 +1340,8 @@ void Think_SpawnNewDoorTrigger( gentity_t *ent ) best = i; } - maxs[ best ] += 60; - mins[ best ] -= 60; + maxs[ best ] += 30; + mins[ best ] -= 30; // create a trigger with this size other = G_Spawn( ); diff --git a/src/game/tremulous.h b/src/game/tremulous.h index bb8031ac..9e9c0534 100644 --- a/src/game/tremulous.h +++ b/src/game/tremulous.h @@ -516,8 +516,8 @@ #define STAMINA_STOP_RESTORE 20 #define STAMINA_WALK_RESTORE 10 -#define STAMINA_SPRINT_TAKE 6 -#define STAMINA_LARMOUR_TAKE 3 +#define STAMINA_SPRINT_TAKE 8 +#define STAMINA_LARMOUR_TAKE 4 /* * Misc -- cgit