diff options
author | Tim Angus <tim@ngus.net> | 2004-01-14 18:32:38 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2004-01-14 18:32:38 +0000 |
commit | c61e168ffb6e3ad28ac7e126ba9ff076984daa27 (patch) | |
tree | 99f21cebafef0371d798e8758f83c73985d4207a /src/game | |
parent | 1a92fbd9fddb8735bee7e22868b50040ca15b601 (diff) |
* Fixed the bug where trem menus were ineffectual
* Rewroted the hovel block testing code to be cleaner and work better
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/bg_misc.c | 2 | ||||
-rw-r--r-- | src/game/g_active.c | 12 | ||||
-rw-r--r-- | src/game/g_buildable.c | 73 | ||||
-rw-r--r-- | src/game/g_local.h | 4 |
4 files changed, 56 insertions, 35 deletions
diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index 69ff92e5..0386c42d 100644 --- a/src/game/bg_misc.c +++ b/src/game/bg_misc.c @@ -1484,7 +1484,7 @@ classAttributes_t bg_classList[ ] = ABUILDER_UPG_REGEN, //int regenRate; SCA_FOVWARPS|SCA_WALLCLIMBER|SCA_ALIENSENSE, //int abilities; WP_ABUILD2, //weapon_t startWeapon - 95.0f, //float buildDist; + 105.0f, //float buildDist; 110, //int fov; 0.001f, //float bob; 2.0f, //float bobCycle; diff --git a/src/game/g_active.c b/src/game/g_active.c index 1ce30162..21ff144e 100644 --- a/src/game/g_active.c +++ b/src/game/g_active.c @@ -1111,24 +1111,14 @@ void ClientThink_real( gentity_t *ent ) if( client->ps.stats[ STAT_STATE ] & SS_HOVELING ) { gentity_t *hovel = client->hovel; - vec3_t newOrigin, newAngles; - vec3_t mins, maxs; - - BG_FindBBoxForClass( client->ps.stats[ STAT_PCLASS ], mins, maxs, NULL, NULL, NULL ); //only let the player out if there is room - if( !AHovel_Blocked( hovel->s.angles, hovel->s.origin, hovel->s.origin2, - mins, maxs, 0, newOrigin, newAngles ) ) + if( !AHovel_Blocked( hovel, ent, qtrue ) ) { //prevent lerping client->ps.eFlags ^= EF_TELEPORT_BIT; client->ps.eFlags &= ~EF_NODRAW; - G_SetOrigin( ent, newOrigin ); - VectorCopy( newOrigin, client->ps.origin ); - VectorCopy( vec3_origin, client->ps.velocity ); - SetClientViewAngle( ent, newAngles ); - //client leaves hovel client->ps.stats[ STAT_STATE ] &= ~SS_HOVELING; diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index c5478aff..02956095 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -857,57 +857,84 @@ void AHive_Think( gentity_t *self ) -#define HOVEL_TRACE_DEPTH 16.0f +#define HOVEL_TRACE_DEPTH 128.0f /* ================ AHovel_Blocked -Is this hovel entrace blocked? +Is this hovel entrance blocked? ================ */ -qboolean AHovel_Blocked( vec3_t srcAngles, vec3_t srcOrigin, vec3_t normal, - vec3_t mins, vec3_t maxs, int entityNum, - vec3_t newOrigin, vec3_t newAngles ) +qboolean AHovel_Blocked( gentity_t *hovel, gentity_t *player, qboolean provideExit ) { - vec3_t forward, origin, start, end, angles, hovelMaxs; + vec3_t forward, normal, origin, start, end, angles, hovelMaxs; + vec3_t mins, maxs; float displacement; trace_t tr; BG_FindBBoxForBuildable( BA_A_HOVEL, NULL, hovelMaxs ); + BG_FindBBoxForClass( player->client->ps.stats[ STAT_PCLASS ], + mins, maxs, NULL, NULL, NULL ); - AngleVectors( srcAngles, forward, NULL, NULL ); + VectorCopy( hovel->s.origin2, normal ); + AngleVectors( hovel->s.angles, forward, NULL, NULL ); VectorInverse( forward ); - displacement = VectorMaxComponent( maxs ) + VectorMaxComponent( hovelMaxs ) + 1.0f; + displacement = VectorMaxComponent( maxs ) * M_ROOT3 + + VectorMaxComponent( hovelMaxs ) * M_ROOT3 + 1.0f; - VectorMA( srcOrigin, displacement, forward, origin ); + VectorMA( hovel->s.origin, displacement, forward, origin ); vectoangles( forward, angles ); VectorMA( origin, HOVEL_TRACE_DEPTH, normal, start ); + + //compute a place up in the air to start the real trace + trap_Trace( &tr, origin, mins, maxs, start, player->s.number, MASK_PLAYERSOLID ); + VectorMA( origin, ( HOVEL_TRACE_DEPTH * tr.fraction ) - 1.0f, normal, start ); VectorMA( origin, -HOVEL_TRACE_DEPTH, normal, end ); - trap_Trace( &tr, start, mins, maxs, end, entityNum, MASK_PLAYERSOLID ); + trap_Trace( &tr, start, mins, maxs, end, player->s.number, MASK_PLAYERSOLID ); if( tr.startsolid ) - return qfalse; + return qtrue; VectorCopy( tr.endpos, origin ); - trap_Trace( &tr, origin, mins, maxs, origin, entityNum, MASK_PLAYERSOLID ); - - if( newOrigin != NULL ) - VectorCopy( origin, newOrigin ); + trap_Trace( &tr, origin, mins, maxs, origin, player->s.number, MASK_PLAYERSOLID ); - if( newAngles != NULL ) - VectorCopy( angles, newAngles ); + if( provideExit ) + { + G_SetOrigin( player, origin ); + VectorCopy( origin, player->client->ps.origin ); + VectorCopy( vec3_origin, player->client->ps.velocity ); + SetClientViewAngle( player, angles ); + } - if( tr.fraction < 1.0 ) + if( tr.fraction < 1.0f ) return qtrue; else return qfalse; } +/* +================ +APropHovel_Blocked + +Wrapper to test a hovel placement for validity +================ +*/ +static qboolean APropHovel_Blocked( vec3_t origin, vec3_t angles, vec3_t normal, + gentity_t *player ) +{ + gentity_t hovel; + + VectorCopy( origin, hovel.s.origin ); + VectorCopy( angles, hovel.s.angles ); + VectorCopy( normal, hovel.s.origin2 ); + + return AHovel_Use( &hovel, player, qfalse ); +} /* ================ @@ -930,6 +957,13 @@ void AHovel_Use( gentity_t *self, gentity_t *other, gentity_t *activator ) else if( ( activator->client->ps.stats[ STAT_PCLASS ] == PCL_A_B_BASE ) || ( activator->client->ps.stats[ STAT_PCLASS ] == PCL_A_B_LEV1 ) ) { + if( AHovel_Blocked( self, activator, qfalse ) ) + { + //you can get in, but you can't get out + G_TriggerMenu( activator->client->ps.clientNum, MN_A_HOVEL_BLOCKED ); + return; + } + self->active = qtrue; G_setBuildableAnim( self, BANIM_ATTACK1, qfalse ); @@ -2020,8 +2054,7 @@ itemBuildError_t G_itemFits( gentity_t *ent, buildable_t buildable, int distance //this assumes the adv builder is the biggest thing that'll use the hovel BG_FindBBoxForClass( PCL_A_B_LEV1, builderMins, builderMaxs, NULL, NULL, NULL ); - if( AHovel_Blocked( angles, origin, normal, builderMins, builderMaxs, - ent->client->ps.clientNum, NULL, NULL ) ) + if( APropHovel_Blocked( angles, origin, normal, ent ) ) reason = IBE_HOVELEXIT; } diff --git a/src/game/g_local.h b/src/game/g_local.h index ad4044e2..64e4a83a 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -573,9 +573,7 @@ typedef enum IBE_MAXERRORS } itemBuildError_t; -qboolean AHovel_Blocked( vec3_t srcAngles, vec3_t srcOrigin, vec3_t normal, - vec3_t mins, vec3_t maxs, int entityNum, - vec3_t newOrigin, vec3_t newAngles ); +qboolean AHovel_Blocked( gentity_t *hovel, gentity_t *player, qboolean provideExit ); 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 ); |