diff options
author | Tim Angus <tim@ngus.net> | 2001-08-28 18:35:20 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2001-08-28 18:35:20 +0000 |
commit | 0ec416c5c51458d1faac712884c2d7cbddd2eb43 (patch) | |
tree | 04dd2d2387857a7d5583f70a13bd5b6717796420 | |
parent | 5af435dc4a2c87798f1b72b1e113209e1d1c2de4 (diff) |
Ceiling eggs
-rw-r--r-- | src/cgame/cg_buildable.c | 40 | ||||
-rw-r--r-- | src/cgame/cg_local.h | 2 | ||||
-rw-r--r-- | src/cgame/cg_players.c | 24 | ||||
-rw-r--r-- | src/cgame/cg_predict.c | 33 | ||||
-rw-r--r-- | src/game/bg_misc.c | 106 | ||||
-rw-r--r-- | src/game/bg_public.h | 7 | ||||
-rw-r--r-- | src/game/g_buildable.c | 29 | ||||
-rw-r--r-- | src/game/g_client.c | 15 | ||||
-rw-r--r-- | src/game/g_cmds.c | 27 | ||||
-rw-r--r-- | src/game/g_local.h | 4 |
10 files changed, 234 insertions, 53 deletions
diff --git a/src/cgame/cg_buildable.c b/src/cgame/cg_buildable.c index 7e8ed9c8..efe56a8a 100644 --- a/src/cgame/cg_buildable.c +++ b/src/cgame/cg_buildable.c @@ -286,6 +286,7 @@ static void CG_BuildableAnimation( centity_t *cent, int *old, int *now, float *b *backLerp = cent->lerpFrame.backlerp; } +#define TRACE_DEPTH 128.0f /* ================== @@ -297,6 +298,8 @@ void CG_Buildable( centity_t *cent ) refEntity_t ent; refEntity_t ent2; entityState_t *es; + vec3_t forward, surfNormal, end, start, mins, maxs; + trace_t tr; es = ¢->currentState; if ( es->modelindex >= bg_numItems ) @@ -312,13 +315,40 @@ void CG_Buildable( centity_t *cent ) memset ( &ent, 0, sizeof( ent ) ); - VectorCopy( es->angles, cent->lerpAngles ); - AnglesToAxis( cent->lerpAngles, ent.axis ); + VectorCopy( cent->lerpOrigin, ent.origin ); + VectorCopy( cent->lerpOrigin, ent.oldorigin ); - ent.hModel = cg_items[es->modelindex].models[0]; + VectorCopy( es->origin2, surfNormal ); + BG_FindBBoxForBuildable( es->clientNum, mins, maxs ); + + if( surfNormal[ 2 ] != 1.0f ) + { + AngleVectors( cent->lerpAngles, forward, NULL, NULL ); + VectorCopy( surfNormal, ent.axis[2] ); + ProjectPointOnPlane( ent.axis[0], forward, ent.axis[2] ); + if( !VectorNormalize( ent.axis[0] ) ) + { + AngleVectors( cent->lerpAngles, NULL, NULL, forward ); + ProjectPointOnPlane( ent.axis[0], forward, ent.axis[2] ); + VectorNormalize( ent.axis[0] ); + } + CrossProduct( ent.axis[0], ent.axis[2], ent.axis[1] ); + ent.axis[1][0] = -ent.axis[1][0]; + ent.axis[1][1] = -ent.axis[1][1]; + ent.axis[1][2] = -ent.axis[1][2]; + + VectorMA( ent.origin, -TRACE_DEPTH, surfNormal, end ); + VectorMA( ent.origin, 1.0f, surfNormal, start ); + CG_CapTrace( &tr, start, mins, maxs, end, es->number, MASK_PLAYERSOLID ); + VectorMA( ent.origin, tr.fraction * -TRACE_DEPTH, surfNormal, ent.origin ); + + VectorCopy( ent.origin, ent.lightingOrigin ); + VectorCopy( ent.origin, ent.oldorigin ); // don't positionally lerp at all + } + else + AnglesToAxis( es->angles, ent.axis ); - VectorCopy( cent->lerpOrigin, ent.origin); - VectorCopy( cent->lerpOrigin, ent.oldorigin); + ent.hModel = cg_items[es->modelindex].models[0]; ent.nonNormalizedAxes = qfalse; diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index 74d7f6b6..f87d1b90 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -1357,6 +1357,8 @@ void CG_BuildSolidList( void ); int CG_PointContents( const vec3_t point, int passEntityNum ); void CG_Trace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int skipNumber, int mask ); +void CG_CapTrace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, + int skipNumber, int mask ); void CG_PredictPlayerState( void ); void CG_LoadDeferredPlayers( void ); diff --git a/src/cgame/cg_players.c b/src/cgame/cg_players.c index c876ed17..7dba674c 100644 --- a/src/cgame/cg_players.c +++ b/src/cgame/cg_players.c @@ -1781,6 +1781,7 @@ int CG_AmbientLight( vec3_t point ) return (int)((float)( result[0] + result[1] + result[2] ) / 3.0f ); } +#define TRACE_DEPTH 128.0f /* =============== @@ -1793,10 +1794,11 @@ void CG_Player( centity_t *cent ) refEntity_t legs; refEntity_t torso; refEntity_t head; - int clientNum; - int renderfx; - qboolean shadow; - float shadowPlane; + int clientNum; + int renderfx; + qboolean shadow; + float shadowPlane; + entityState_t *es = ¢->currentState; // the client number is stored in clientNum. It can't be derived // from the entity number, because a single client may have @@ -1870,17 +1872,12 @@ void CG_Player( centity_t *cent ) !( cent->currentState.eFlags & EF_DEAD ) && !( cg.intermissionStarted ) ) { - vec3_t forward, surfNormal; + vec3_t forward, surfNormal, start, end, mins, maxs; trace_t tr; VectorCopy( cent->currentState.angles2, surfNormal ); + BG_FindBBoxForClass( ( es->powerups >> 8 ) & 0xFF, mins, maxs, NULL, NULL, NULL ); - /*CG_Printf( "%d: ", cent->currentState.number ); - CG_Printf( "%f ", surfNormal[ 0 ] ); - CG_Printf( "%f ", surfNormal[ 1 ] ); - CG_Printf( "%f ", surfNormal[ 2 ] ); - CG_Printf( "\n" );*/ - AngleVectors( cent->lerpAngles, forward, NULL, NULL ); VectorCopy( surfNormal, legs.axis[2] ); ProjectPointOnPlane( legs.axis[0], forward, legs.axis[2] ); @@ -1895,6 +1892,11 @@ void CG_Player( centity_t *cent ) legs.axis[1][1] = -legs.axis[1][1]; legs.axis[1][2] = -legs.axis[1][2]; + VectorMA( legs.origin, -TRACE_DEPTH, surfNormal, end ); + VectorMA( legs.origin, 1.0f, surfNormal, start ); + CG_CapTrace( &tr, start, mins, maxs, end, es->number, MASK_PLAYERSOLID ); + VectorMA( legs.origin, tr.fraction * -TRACE_DEPTH, surfNormal, legs.origin ); + VectorCopy( legs.origin, legs.lightingOrigin ); VectorCopy( legs.origin, legs.oldorigin ); // don't positionally lerp at all } diff --git a/src/cgame/cg_predict.c b/src/cgame/cg_predict.c index 71045d16..3ff351ad 100644 --- a/src/cgame/cg_predict.c +++ b/src/cgame/cg_predict.c @@ -87,7 +87,7 @@ CG_ClipMoveToEntities ==================== */ static void CG_ClipMoveToEntities ( const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, - int skipNumber, int mask, trace_t *tr ) { + int skipNumber, int mask, trace_t *tr, qboolean capsule ) { int i, x, zd, zu; trace_t trace; entityState_t *ent; @@ -126,8 +126,16 @@ static void CG_ClipMoveToEntities ( const vec3_t start, const vec3_t mins, const } - trap_CM_TransformedBoxTrace ( &trace, start, end, - mins, maxs, cmodel, mask, origin, angles); + if( capsule ) + { + trap_CM_TransformedCapsuleTrace ( &trace, start, end, + mins, maxs, cmodel, mask, origin, angles); + } + else + { + trap_CM_TransformedBoxTrace ( &trace, start, end, + mins, maxs, cmodel, mask, origin, angles); + } if (trace.allsolid || trace.fraction < tr->fraction) { trace.entityNum = ent->number; @@ -153,7 +161,24 @@ void CG_Trace( trace_t *result, const vec3_t start, const vec3_t mins, const ve trap_CM_BoxTrace ( &t, start, end, mins, maxs, 0, mask); t.entityNum = t.fraction != 1.0 ? ENTITYNUM_WORLD : ENTITYNUM_NONE; // check all other solid models - CG_ClipMoveToEntities (start, mins, maxs, end, skipNumber, mask, &t); + CG_ClipMoveToEntities (start, mins, maxs, end, skipNumber, mask, &t, qfalse); + + *result = t; +} + +/* +================ +CG_CapTrace +================ +*/ +void CG_CapTrace( trace_t *result, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, + int skipNumber, int mask ) { + trace_t t; + + trap_CM_CapsuleTrace ( &t, start, end, mins, maxs, 0, mask); + t.entityNum = t.fraction != 1.0 ? ENTITYNUM_WORLD : ENTITYNUM_NONE; + // check all other solid models + CG_ClipMoveToEntities (start, mins, maxs, end, skipNumber, mask, &t, qtrue); *result = t; } diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index 4741f15d..408be48c 100644 --- a/src/game/bg_misc.c +++ b/src/game/bg_misc.c @@ -1165,6 +1165,8 @@ buildableAttributes_t bg_buildableList[ ] = 0, //int turretFireSpeed; 0, //int turretRange; WP_NONE, //weapon_t turretProjType; + 0.5f, //float minNormal; + qtrue, //qboolean invertNormal; qfalse, //qboolean creepTest; qfalse //qboolean reactorTest; }, @@ -1189,6 +1191,8 @@ buildableAttributes_t bg_buildableList[ ] = 0, //int turretFireSpeed; 0, //int turretRange; WP_NONE, //weapon_t turretProjType; + 0.707f, //float minNormal; + qfalse, //qboolean invertNormal; qtrue, //qboolean creepTest; qfalse //qboolean reactorTest; }, @@ -1213,6 +1217,8 @@ buildableAttributes_t bg_buildableList[ ] = 1500, //int turretFireSpeed; 500, //int turretRange; WP_SAWBLADE_LAUNCHER, //weapon_t turretProjType; + 0.707f, //float minNormal; + qfalse, //qboolean invertNormal; qtrue, //qboolean creepTest; qfalse //qboolean reactorTest; }, @@ -1237,6 +1243,8 @@ buildableAttributes_t bg_buildableList[ ] = 0, //int turretFireSpeed; 0, //int turretRange; WP_NONE, //weapon_t turretProjType; + 0.707f, //float minNormal; + qfalse, //qboolean invertNormal; qfalse, //qboolean creepTest; qtrue //qboolean reactorTest; }, @@ -1261,6 +1269,8 @@ buildableAttributes_t bg_buildableList[ ] = 0, //int turretFireSpeed; 0, //int turretRange; WP_NONE, //weapon_t turretProjType; + 0.707f, //float minNormal; + qfalse, //qboolean invertNormal; qfalse, //qboolean creepTest; qfalse //qboolean reactorTest; }, @@ -1285,6 +1295,8 @@ buildableAttributes_t bg_buildableList[ ] = 500, //int turretFireSpeed; 500, //int turretRange; WP_PLASMAGUN, //weapon_t turretProjType; + 0.707f, //float minNormal; + qfalse, //qboolean invertNormal; qfalse, //qboolean creepTest; qfalse //qboolean reactorTest; }, @@ -1309,6 +1321,8 @@ buildableAttributes_t bg_buildableList[ ] = 50, //int turretFireSpeed; 300, //int turretRange; WP_MACHINEGUN, //weapon_t turretProjType; + 0.707f, //float minNormal; + qfalse, //qboolean invertNormal; qfalse, //qboolean creepTest; qfalse //qboolean reactorTest; }, @@ -1333,6 +1347,8 @@ buildableAttributes_t bg_buildableList[ ] = 4000, //int turretFireSpeed; 1500, //int turretRange; WP_RAILGUN, //weapon_t turretProjType; + 0.707f, //float minNormal; + qfalse, //qboolean invertNormal; qfalse, //qboolean creepTest; qfalse //qboolean reactorTest; }, @@ -1357,6 +1373,8 @@ buildableAttributes_t bg_buildableList[ ] = 0, //int turretFireSpeed; 0, //int turretRange; WP_NONE, //weapon_t turretProjType; + 0.707f, //float minNormal; + qfalse, //qboolean invertNormal; qfalse, //qboolean creepTest; qfalse //qboolean reactorTest; }, @@ -1381,6 +1399,8 @@ buildableAttributes_t bg_buildableList[ ] = 0, //int turretFireSpeed; 0, //int turretRange; WP_NONE, //weapon_t turretProjType; + 0.707f, //float minNormal; + qfalse, //qboolean invertNormal; qfalse, //qboolean creepTest; qtrue //qboolean reactorTest; }, @@ -1405,6 +1425,8 @@ buildableAttributes_t bg_buildableList[ ] = 0, //int turretFireSpeed; 0, //int turretRange; WP_NONE, //weapon_t turretProjType; + 0.707f, //float minNormal; + qfalse, //qboolean invertNormal; qfalse, //qboolean creepTest; qfalse //qboolean reactorTest; }, @@ -1429,6 +1451,8 @@ buildableAttributes_t bg_buildableList[ ] = 0, //int turretFireSpeed; 0, //int turretRange; WP_NONE, //weapon_t turretProjType; + 0.707f, //float minNormal; + qfalse, //qboolean invertNormal; qfalse, //qboolean creepTest; qfalse //qboolean reactorTest; } @@ -1844,6 +1868,46 @@ weapon_t BG_FindProjTypeForBuildable( int bclass ) /* ============== +BG_FindMinNormalForBuildable +============== +*/ +float BG_FindMinNormalForBuildable( int bclass ) +{ + int i; + + for( i = 0; i < bg_numBuildables; i++ ) + { + if( bg_buildableList[ i ].buildNum == bclass ) + { + return bg_buildableList[ i ].minNormal; + } + } + + return 0.707f; +} + +/* +============== +BG_FindInvertNormalForBuildable +============== +*/ +qboolean BG_FindInvertNormalForBuildable( int bclass ) +{ + int i; + + for( i = 0; i < bg_numBuildables; i++ ) + { + if( bg_buildableList[ i ].buildNum == bclass ) + { + return bg_buildableList[ i ].invertNormal; + } + } + + return qfalse; +} + +/* +============== BG_FindCreepTestForBuildable ============== */ @@ -1901,6 +1965,7 @@ classAttributes_t bg_classList[ ] = 0, //int armor; SCA_TAKESFALLDAMAGE|SCA_FOVWARPS, //int abilities; 50.0f, //float buildDist; + 1000.0f, //float launchSpeed; 80, //int fov; 0.015f, //float bob; 350, //int steptime; @@ -1925,6 +1990,7 @@ classAttributes_t bg_classList[ ] = 10, //int armor; SCA_CANJUMP|SCA_FOVWARPS, //int abilities; 50.0f, //float buildDist; + 0.0f, //float launchSpeed; 110, //int fov; 0.005f, //float bob; 200, //int steptime; @@ -1949,6 +2015,7 @@ classAttributes_t bg_classList[ ] = 40, //int armor; SCA_TAKESFALLDAMAGE|SCA_FOVWARPS, //int abilities; 50.0f, //float buildDist; + 0.0f, //float launchSpeed; 90, //int fov; 0.015f, //float bob; 350, //int steptime; @@ -1973,6 +2040,7 @@ classAttributes_t bg_classList[ ] = 40, //int armor; SCA_CANJUMP|SCA_FOVWARPS, //int abilities; 50.0f, //float buildDist; + 0.0f, //float launchSpeed; 120, //int fov; 0.002f, //float bob; 350, //int steptime; @@ -1997,6 +2065,7 @@ classAttributes_t bg_classList[ ] = 40, //int armor; SCA_CANJUMP|SCA_FOVWARPS, //int abilities; 50.0f, //float buildDist; + 0.0f, //float launchSpeed; 100, //int fov; 0.015f, //float bob; 350, //int steptime; @@ -2021,6 +2090,7 @@ classAttributes_t bg_classList[ ] = 0, //int armor; SCA_WALLCLIMBER|SCA_CANJUMP|SCA_NOWEAPONDRIFT|SCA_FOVWARPS, //int abilities; 0.0f, //float buildDist; + 0.0f, //float launchSpeed; 140, //int fov; 0.0f, //float bob; 25, //int steptime; @@ -2045,6 +2115,7 @@ classAttributes_t bg_classList[ ] = 5, //int armor; SCA_CANJUMP|SCA_NOWEAPONDRIFT|SCA_FOVWARPS, //int abilities; 0.0f, //float buildDist; + 0.0f, //float launchSpeed; 120, //int fov; 0.001f, //float bob; 25, //int steptime; @@ -2069,6 +2140,7 @@ classAttributes_t bg_classList[ ] = 10, //int armor; SCA_CANJUMP|SCA_NOWEAPONDRIFT|SCA_FOVWARPS, //int abilities; 0.0f, //float buildDist; + 0.0f, //float launchSpeed; 120, //int fov; 0.0005f, //float bob; 25, //int steptime; @@ -2093,6 +2165,7 @@ classAttributes_t bg_classList[ ] = 20, //int armor; SCA_CANJUMP|SCA_NOWEAPONDRIFT|SCA_FOVWARPS, //int abilities; 0.0f, //float buildDist; + 0.0f, //float launchSpeed; 130, //int fov; 0.0f, //float bob; 60, //int steptime; @@ -2117,6 +2190,7 @@ classAttributes_t bg_classList[ ] = 30, //int armor; SCA_CANJUMP|SCA_NOWEAPONDRIFT|SCA_FOVWARPS, //int abilities; 0.0f, //float buildDist; + 0.0f, //float launchSpeed; 130, //int fov; 0.0f, //float bob; 60, //int steptime; @@ -2141,6 +2215,7 @@ classAttributes_t bg_classList[ ] = 40, //int armor; SCA_CANJUMP|SCA_NOWEAPONDRIFT|SCA_FOVWARPS, //int abilities; 0.0f, //float buildDist; + 0.0f, //float launchSpeed; 120, //int fov; 0.0f, //float bob; 200, //int steptime; @@ -2165,6 +2240,7 @@ classAttributes_t bg_classList[ ] = 50, //int armor; SCA_CANJUMP|SCA_NOWEAPONDRIFT|SCA_FOVWARPS, //int abilities; 0.0f, //float buildDist; + 0.0f, //float launchSpeed; 120, //int fov; 0.0f, //float bob; 200, //int steptime; @@ -2189,6 +2265,7 @@ classAttributes_t bg_classList[ ] = 60, //int armor; SCA_CANJUMP|SCA_NOWEAPONDRIFT|SCA_FOVWARPS, //int abilities; 0.0f, //float buildDist; + 0.0f, //float launchSpeed; 120, //int fov; 0.0f, //float bob; 200, //int steptime; @@ -2213,6 +2290,7 @@ classAttributes_t bg_classList[ ] = 0, //int armor; SCA_WALLCLIMBER|SCA_CANJUMP|SCA_NOWEAPONDRIFT|SCA_FOVWARPS, //int abilities; 0.0f, //float buildDist; + 0.0f, //float launchSpeed; 90, //int fov; 0.0f, //float bob; 25, //int steptime; @@ -2237,6 +2315,7 @@ classAttributes_t bg_classList[ ] = 50, //int armor; SCA_CANJUMP|SCA_NOWEAPONDRIFT|SCA_FOVWARPS, //int abilities; 0.0f, //float buildDist; + 0.0f, //float launchSpeed; 100, //int fov; 0.0f, //float bob; 25, //int steptime; @@ -2261,6 +2340,7 @@ classAttributes_t bg_classList[ ] = 50, //int armor; SCA_CANJUMP|SCA_NOWEAPONDRIFT|SCA_FOVWARPS, //int abilities; 0.0f, //float buildDist; + 0.0f, //float launchSpeed; 100, //int fov; 0.0f, //float bob; 25, //int steptime; @@ -2285,6 +2365,7 @@ classAttributes_t bg_classList[ ] = 50, //int armor; SCA_CANJUMP|SCA_NOWEAPONDRIFT|SCA_FOVWARPS, //int abilities; 0.0f, //float buildDist; + 0.0f, //float launchSpeed; 110, //int fov; 0.0f, //float bob; 25, //int steptime; @@ -2309,6 +2390,7 @@ classAttributes_t bg_classList[ ] = 50, //int armor; SCA_CANJUMP|SCA_NOWEAPONDRIFT|SCA_FOVWARPS, //int abilities; 0.0f, //float buildDist; + 0.0f, //float launchSpeed; 110, //int fov; 0.0f, //float bob; 25, //int steptime; @@ -2333,6 +2415,7 @@ classAttributes_t bg_classList[ ] = 50, //int armor; SCA_CANJUMP|SCA_NOWEAPONDRIFT|SCA_FOVWARPS, //int abilities; 0.0f, //float buildDist; + 0.0f, //float launchSpeed; 130, //int fov; 0.0f, //float bob; 25, //int steptime; @@ -2357,6 +2440,7 @@ classAttributes_t bg_classList[ ] = 50, //int armor; SCA_CANJUMP|SCA_NOWEAPONDRIFT|SCA_FOVWARPS, //int abilities; 0.0f, //float buildDist; + 0.0f, //float launchSpeed; 130, //int fov; 0.0f, //float bob; 25, //int steptime; @@ -2381,6 +2465,7 @@ classAttributes_t bg_classList[ ] = 50, //int armor; SCA_CANJUMP|SCA_NOWEAPONDRIFT|SCA_FOVWARPS, //int abilities; 0.0f, //float buildDist; + 0.0f, //float launchSpeed; 130, //int fov; 0.0f, //float bob; 25, //int steptime; @@ -2405,6 +2490,7 @@ classAttributes_t bg_classList[ ] = 0, //int armor; SCA_TAKESFALLDAMAGE|SCA_CANJUMP, //int abilities; 80.0f, //float buildDist; + 0.0f, //float launchSpeed; 90, //int fov; 0.002f, //float bob; 200, //int steptime; @@ -2739,6 +2825,26 @@ float BG_FindBuildDistForClass( int pclass ) /* ============== +BG_FindLaunchSpeedForClass +============== +*/ +float BG_FindLaunchSpeedForClass( int pclass ) +{ + int i; + + for( i = 0; i < bg_numPclasses; i++ ) + { + if( bg_classList[ i ].classNum == pclass ) + { + return bg_classList[ i ].launchSpeed; + } + } + + return 0.0f; +} + +/* +============== BG_ClassCanEvolveFromTo ============== */ diff --git a/src/game/bg_public.h b/src/game/bg_public.h index 1c068d35..1a78753a 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -832,6 +832,7 @@ typedef struct int abilities; float buildDist; + float launchSpeed; int fov; float bob; @@ -879,6 +880,9 @@ typedef struct int turretRange; weapon_t turretProjType; + float minNormal; + qboolean invertNormal; + qboolean creepTest; qboolean reactorTest; } buildableAttributes_t; @@ -948,6 +952,8 @@ int BG_FindNextThinkForBuildable( int bclass ); int BG_FindFireSpeedForBuildable( int bclass ); int BG_FindRangeForBuildable( int bclass ); weapon_t BG_FindProjTypeForBuildable( int bclass ); +float BG_FindMinNormalForBuildable( int bclass ); +qboolean BG_FindInvertNormalForBuildable( int bclass ); int BG_FindCreepTestForBuildable( int bclass ); int BG_FindUniqueTestForBuildable( int bclass ); @@ -965,6 +971,7 @@ float BG_FindStickyForClass( int pclass ); int BG_FindSteptimeForClass( int pclass ); qboolean BG_ClassHasAbility( int pclass, int ability ); float BG_FindBuildDistForClass( int pclass ); +float BG_FindLaunchSpeedForClass( int pclass ); qboolean BG_ClassCanEvolveFromTo( int fclass, int tclass ); int BG_FindEvolveTimeForClass( int pclass ); int BG_FindValueOfClass( int pclass ); diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index bd1332e2..289a65eb 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -1111,12 +1111,12 @@ void HSpawn_Think( gentity_t *self ) /* ================ -itemFits +G_itemFits Checks to see if an item fits in a specific area ================ */ -itemBuildError_t itemFits( gentity_t *ent, buildable_t buildable, int distance ) +itemBuildError_t G_itemFits( gentity_t *ent, buildable_t buildable, int distance ) { vec3_t forward; vec3_t angles; @@ -1149,10 +1149,8 @@ itemBuildError_t itemFits( gentity_t *ent, buildable_t buildable, int distance ) if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_DROIDS ) { //droid criteria - if( level.droidBuildPoints - BG_FindBuildPointsForBuildable( buildable ) < 0 ) - reason = IBE_NOASSERT; - //check there is creep near by for building on + if( BG_FindCreepTestForBuildable( buildable ) ) { for ( i = 1, tempent = g_entities + i; i < level.num_entities; i++, tempent++ ) @@ -1198,12 +1196,15 @@ itemBuildError_t itemFits( gentity_t *ent, buildable_t buildable, int distance ) } } } + + if( level.droidBuildPoints - BG_FindBuildPointsForBuildable( buildable ) < 0 ) + reason = IBE_NOASSERT; + + G_Printf( "%d %d\n", level.droidBuildPoints ); } else if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) { //human criteria - if( level.humanBuildPoints - BG_FindBuildPointsForBuildable( buildable ) < 0 ) - reason = IBE_NOPOWER; closestPower = g_entities + 1; //FIXME @@ -1274,6 +1275,9 @@ itemBuildError_t itemFits( gentity_t *ent, buildable_t buildable, int distance ) } } } + + if( level.humanBuildPoints - BG_FindBuildPointsForBuildable( buildable ) < 0 ) + reason = IBE_NOPOWER; } return reason; @@ -1282,12 +1286,13 @@ itemBuildError_t itemFits( gentity_t *ent, buildable_t buildable, int distance ) /* ================ -Build_Item +G_buildItem -Spawns an item and tosses it forward +Spawns a buildable ================ */ -gentity_t *Build_Item( gentity_t *ent, buildable_t buildable, int distance ) { +gentity_t *G_buildItem( gentity_t *ent, buildable_t buildable, int distance, float speed ) +{ vec3_t forward; vec3_t angles; vec3_t origin; @@ -1410,6 +1415,10 @@ gentity_t *Build_Item( gentity_t *ent, buildable_t buildable, int distance ) { built->s.pos.trType = BG_FindTrajectoryForBuildable( buildable ); built->physicsBounce = BG_FindBounceForBuildable( buildable ); built->s.pos.trTime = level.time; + AngleVectors( ent->s.apos.trBase, built->s.pos.trDelta, NULL, NULL ); + + VectorScale( built->s.pos.trDelta, speed, built->s.pos.trDelta ); + VectorSet( built->s.origin2, 0.0f, 0.0f, 1.0f ); G_AddEvent( built, EV_BUILD_CONSTRUCT, BANIM_CONSTRUCT1 ); diff --git a/src/game/g_client.c b/src/game/g_client.c index 9a6d1226..d9928cc4 100644 --- a/src/game/g_client.c +++ b/src/game/g_client.c @@ -384,23 +384,16 @@ gentity_t *SelectTremulousSpawnPoint( int team, vec3_t origin, vec3_t angles ) //no available spots if( !spot ) - { return NULL; - } - - // find a single player start spot - if (!spot) { - //G_Error( "Couldn't find a spawn point" ); - } //TA: why isn't spot->s.origin being set? - VectorCopy (spot->s.pos.trBase, origin); - VectorCopy (spot->s.angles, angles); + VectorCopy( spot->s.pos.trBase, origin ); + VectorCopy( spot->s.angles, angles ); if( team == PTE_DROIDS ) - origin[2] += 40; + VectorMA( origin, 40.0f, spot->s.origin2, origin ); else if( team == PTE_HUMANS ) - origin[2] += 29; + VectorMA( origin, 29.0f, spot->s.origin2, origin ); return spot; diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 29b1f27c..35a453a4 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -2004,23 +2004,30 @@ Cmd_Build_f void Cmd_Build_f( gentity_t *ent ) { char s[ MAX_TOKEN_CHARS ]; + char s1[ MAX_TOKEN_CHARS ]; buildable_t buildable; weapon_t weapon; - float dist; + float dist, speed, maxspeed; trap_Argv( 1, s, sizeof( s ) ); + trap_Argv( 2, s1, sizeof( s1 ) ); buildable = BG_FindBuildNumForName( s ); + speed = atof( s1 ); + maxspeed = BG_FindLaunchSpeedForClass( ent->client->ps.stats[ STAT_PCLASS ] ); + + if( speed > maxspeed ) + speed = maxspeed; if( buildable != BA_NONE && ( 1 << ent->client->ps.weapon ) & BG_FindBuildWeaponForBuildable( buildable ) ) { dist = BG_FindBuildDistForClass( ent->client->ps.stats[ STAT_PCLASS ] ); - switch( itemFits( ent, buildable, dist ) ) + switch( G_itemFits( ent, buildable, dist ) ) { case IBE_NONE: - Build_Item( ent, buildable, dist ); + G_buildItem( ent, buildable, dist, speed ); break; case IBE_NOCREEP: @@ -2039,11 +2046,6 @@ void Cmd_Build_f( gentity_t *ent ) G_AddPredictableEvent( ent, EV_MENU, MN_D_HIVEMIND ); break; - case IBE_SPWNWARN: - G_AddPredictableEvent( ent, EV_MENU, MN_D_SPWNWARN ); - Build_Item( ent, buildable, dist ); - break; - case IBE_REACTOR: G_AddPredictableEvent( ent, EV_MENU, MN_H_REACTOR ); break; @@ -2063,14 +2065,19 @@ void Cmd_Build_f( gentity_t *ent ) G_AddPredictableEvent( ent, EV_MENU, MN_H_NOPOWER ); break; + case IBE_SPWNWARN: + G_AddPredictableEvent( ent, EV_MENU, MN_D_SPWNWARN ); + G_buildItem( ent, buildable, dist, speed ); + break; + case IBE_RPLWARN: G_AddPredictableEvent( ent, EV_MENU, MN_H_RPLWARN ); - Build_Item( ent, buildable, dist ); + G_buildItem( ent, buildable, dist, speed ); break; case IBE_RPTWARN: G_AddPredictableEvent( ent, EV_MENU, MN_H_RPTWARN ); - Build_Item( ent, buildable, dist ); + G_buildItem( ent, buildable, dist, speed ); break; } } diff --git a/src/game/g_local.h b/src/game/g_local.h index bd77686e..0fcfdc75 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -540,8 +540,8 @@ typedef enum IBE_MAXERRORS } itemBuildError_t; -itemBuildError_t itemFits( gentity_t *ent, buildable_t buildable, int distance ); -gentity_t *Build_Item( gentity_t *ent, buildable_t buildable, int distance ); +itemBuildError_t G_itemFits( gentity_t *ent, buildable_t buildable, int distance ); +gentity_t *G_buildItem( gentity_t *ent, buildable_t buildable, int distance, float speed ); void G_setBuildableAnim( gentity_t *ent, buildableAnimNumber_t anim ); void G_setIdleBuildableAnim( gentity_t *ent, buildableAnimNumber_t anim ); |