diff options
Diffstat (limited to 'src/game/g_buildable.c')
-rw-r--r-- | src/game/g_buildable.c | 40 |
1 files changed, 19 insertions, 21 deletions
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 |