diff options
-rw-r--r-- | src/game/bg_misc.c | 3 | ||||
-rw-r--r-- | src/game/g_active.c | 3 | ||||
-rw-r--r-- | src/game/g_buildable.c | 40 | ||||
-rw-r--r-- | src/game/g_cmds.c | 3 | ||||
-rw-r--r-- | src/game/g_local.h | 3 |
5 files changed, 26 insertions, 26 deletions
diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index c41344aa..32b821ea 100644 --- a/src/game/bg_misc.c +++ b/src/game/bg_misc.c @@ -3323,8 +3323,7 @@ void BG_PositionBuildableRelativeToPlayer( const playerState_t *ps, // The mask is MASK_DEADSOLID on purpose to avoid collisions with other entities (*trace)( tr, entityOrigin, mins, maxs, targetOrigin, ps->clientNum, MASK_DEADSOLID ); - VectorCopy( tr->endpos, entityOrigin ); - VectorMA( entityOrigin, 0.1f, playerNormal, outOrigin ); + VectorCopy( tr->endpos, outOrigin ); vectoangles( forward, outAngles ); } diff --git a/src/game/g_active.c b/src/game/g_active.c index 9e6a56b0..92366c48 100644 --- a/src/game/g_active.c +++ b/src/game/g_active.c @@ -627,9 +627,10 @@ void ClientTimerActions( gentity_t *ent, int msec ) { int dist = BG_Class( ent->client->ps.stats[ STAT_CLASS ] )->buildDist; vec3_t dummy, dummy2; + int dummy3; if( G_CanBuild( ent, client->ps.stats[ STAT_BUILDABLE ] & ~SB_VALID_TOGGLEBIT, - dist, dummy, dummy2 ) == IBE_NONE ) + dist, dummy, dummy2, &dummy3 ) == IBE_NONE ) client->ps.stats[ STAT_BUILDABLE ] |= SB_VALID_TOGGLEBIT; else client->ps.stats[ STAT_BUILDABLE ] &= ~SB_VALID_TOGGLEBIT; diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index 305fb117..3b237379 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -3342,7 +3342,8 @@ G_CanBuild Checks to see if a buildable can be built ================ */ -itemBuildError_t G_CanBuild( gentity_t *ent, buildable_t buildable, int distance, vec3_t origin, vec3_t normal ) +itemBuildError_t G_CanBuild( gentity_t *ent, buildable_t buildable, int distance, + vec3_t origin, vec3_t normal, int *groundEntNum ) { vec3_t angles; vec3_t entity_origin; @@ -3365,7 +3366,7 @@ itemBuildError_t G_CanBuild( gentity_t *ent, buildable_t buildable, int distance trap_Trace( &tr3, ps->origin, NULL, NULL, entity_origin, ent->s.number, MASK_PLAYERSOLID ); VectorCopy( entity_origin, origin ); - + *groundEntNum = tr1.entityNum; VectorCopy( tr1.plane.normal, normal ); minNormal = BG_Buildable( buildable )->minNormal; invert = BG_Buildable( buildable )->invertNormal; @@ -3496,16 +3497,13 @@ Spawns a buildable ================ */ static gentity_t *G_Build( gentity_t *builder, buildable_t buildable, - const vec3_t origin, const vec3_t normal, const vec3_t angles ) + const vec3_t origin, const vec3_t normal, const vec3_t angles, int groundEntNum ) { gentity_t *built; - vec3_t localOrigin; char readable[ MAX_STRING_CHARS ]; char buildnums[ MAX_STRING_CHARS ]; buildLog_t *log; - VectorCopy( origin, localOrigin ); - if( builder->client ) log = G_BuildLogNew( builder, BF_CONSTRUCT ); else @@ -3524,11 +3522,6 @@ static gentity_t *G_Build( gentity_t *builder, buildable_t buildable, built->buildableTeam = built->s.modelindex2 = BG_Buildable( buildable )->team; BG_BuildableBoundingBox( buildable, built->r.mins, built->r.maxs ); - // when building the initial layout, spawn the entity slightly off its - // target surface so that it can be "dropped" onto it - if( !builder->client ) - VectorMA( localOrigin, 1.0f, normal, localOrigin ); - built->health = 1; built->splashDamage = BG_Buildable( buildable )->splashDamage; @@ -3660,10 +3653,7 @@ static gentity_t *G_Build( gentity_t *builder, buildable_t buildable, else built->builtBy = NULL; - G_SetOrigin( built, localOrigin ); - - // gently nudge the buildable onto the surface :) - VectorScale( normal, -50.0f, built->s.pos.trDelta ); + G_SetOrigin( built, origin ); // set turret angles VectorCopy( builder->s.angles2, built->s.angles2 ); @@ -3672,10 +3662,16 @@ static gentity_t *G_Build( gentity_t *builder, buildable_t buildable, built->s.angles[ PITCH ] = 0.0f; built->s.angles2[ YAW ] = angles[ YAW ]; built->s.angles2[ PITCH ] = MGTURRET_VERTICALCAP; - built->s.pos.trType = BG_Buildable( buildable )->traj; - built->s.pos.trTime = level.time; built->physicsBounce = BG_Buildable( buildable )->bounce; - built->s.groundEntityNum = ENTITYNUM_NONE; + + built->s.groundEntityNum = groundEntNum; + if( groundEntNum == ENTITYNUM_NONE ) + { + built->s.pos.trType = BG_Buildable( buildable )->traj; + built->s.pos.trTime = level.time; + // gently nudge the buildable onto the surface :) + VectorScale( normal, -50.0f, built->s.pos.trDelta ); + } built->s.generic1 = MAX( built->health, 0 ); @@ -3735,13 +3731,14 @@ qboolean G_BuildIfValid( gentity_t *ent, buildable_t buildable ) { float dist; vec3_t origin, normal; + int groundEntNum; dist = BG_Class( ent->client->ps.stats[ STAT_CLASS ] )->buildDist; - switch( G_CanBuild( ent, buildable, dist, origin, normal ) ) + switch( G_CanBuild( ent, buildable, dist, origin, normal, &groundEntNum ) ) { case IBE_NONE: - G_Build( ent, buildable, origin, normal, ent->s.apos.trBase ); + G_Build( ent, buildable, origin, normal, ent->s.apos.trBase, groundEntNum ); return qtrue; case IBE_NOALIENBP: @@ -3825,7 +3822,8 @@ static gentity_t *G_FinishSpawningBuildable( gentity_t *ent, qboolean force ) else VectorSet( normal, 0.0f, 0.0f, 1.0f ); - built = G_Build( ent, buildable, ent->s.pos.trBase, normal, ent->s.angles ); + built = G_Build( ent, buildable, ent->s.pos.trBase, + normal, ent->s.angles, ENTITYNUM_NONE ); built->takedamage = qtrue; built->spawned = qtrue; //map entities are already spawned diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index a83d386a..1a3413a1 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -2407,6 +2407,7 @@ void Cmd_Build_f( gentity_t *ent ) buildable_t buildable; float dist; vec3_t origin, normal; + int groundEntNum; team_t team; if( ent->client->pers.namelog->denyBuild ) @@ -2445,7 +2446,7 @@ void Cmd_Build_f( gentity_t *ent ) ent->client->ps.stats[ STAT_BUILDABLE ] = BA_NONE; //these are the errors displayed when the builder first selects something to use - switch( G_CanBuild( ent, buildable, dist, origin, normal ) ) + switch( G_CanBuild( ent, buildable, dist, origin, normal, &groundEntNum ) ) { // can place right away, set the blueprint and the valid togglebit case IBE_NONE: diff --git a/src/game/g_local.h b/src/game/g_local.h index 2f6fa6da..17492166 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -780,7 +780,8 @@ qboolean G_FindCreep( gentity_t *self ); void G_BuildableThink( gentity_t *ent, int msec ); qboolean G_BuildableRange( vec3_t origin, float r, buildable_t buildable ); void G_ClearDeconMarks( void ); -itemBuildError_t G_CanBuild( gentity_t *ent, buildable_t buildable, int distance, vec3_t origin, vec3_t normal ); +itemBuildError_t G_CanBuild( gentity_t *ent, buildable_t buildable, int distance, + vec3_t origin, vec3_t normal, int *groundEntNum ); qboolean G_BuildIfValid( gentity_t *ent, buildable_t buildable ); void G_SetBuildableAnim( gentity_t *ent, buildableAnimNumber_t anim, qboolean force ); void G_SetIdleBuildableAnim( gentity_t *ent, buildableAnimNumber_t anim ); |