diff options
Diffstat (limited to 'src/cgame')
-rw-r--r-- | src/cgame/cg_buildable.c | 70 | ||||
-rw-r--r-- | src/cgame/cg_local.h | 13 | ||||
-rw-r--r-- | src/cgame/cg_main.c | 5 | ||||
-rw-r--r-- | src/cgame/cg_weapons.c | 3 |
4 files changed, 81 insertions, 10 deletions
diff --git a/src/cgame/cg_buildable.c b/src/cgame/cg_buildable.c index 9e2a6d07..5de77173 100644 --- a/src/cgame/cg_buildable.c +++ b/src/cgame/cg_buildable.c @@ -130,7 +130,11 @@ void CG_InitBuildables( ) { char filename[MAX_QPATH]; char *buildableName; + char *modelFile; int i; + int j; + + memset( cg_buildables, 0, sizeof( cg_buildables ) ); for( i = BA_NONE + 1; i < BA_NUM_BUILDABLES; i++ ) { @@ -139,6 +143,12 @@ void CG_InitBuildables( ) Com_sprintf( filename, sizeof( filename ), "models/buildables/%s/animation.cfg", buildableName ); if ( !CG_ParseBuildableAnimationFile( filename, i ) ) Com_Printf( "Failed to load animation file %s\n", filename ); + + for( j = 0; j <= 3; j++ ) + { + if( modelFile = BG_FindModelsForBuildable( i, j ) ) + cg_buildables[ i ].models[ j ] = trap_R_RegisterModel( modelFile ); + } } } @@ -184,7 +194,7 @@ static void CG_RunBuildableLerpFrame( centity_t *cent ) { int f, numFrames; animation_t *anim; - buildable_t buildable = cent->currentState.clientNum; + buildable_t buildable = cent->currentState.modelindex; lerpFrame_t *lf = ¢->lerpFrame; buildableAnimNumber_t newAnimation = cent->buildableAnim; @@ -285,6 +295,56 @@ static void CG_BuildableAnimation( centity_t *cent, int *old, int *now, float *b *backLerp = cent->lerpFrame.backlerp; } +/* +================== +CG_GhostBuildable +================== +*/ +void CG_GhostBuildable( buildable_t buildable ) +{ + refEntity_t ent; + playerState_t *ps; + vec3_t angles, forward, player_origin, entity_origin, target_origin; + vec3_t mins, maxs; + float distance; + trace_t tr; + + ps = &cg.predictedPlayerState; + + memset ( &ent, 0, sizeof( ent ) ); + + VectorCopy( cg.predictedPlayerState.viewangles, angles ); + angles[ PITCH ] = 0; // always forward + + AngleVectors( angles, forward, NULL, NULL ); + VectorCopy( ps->origin, player_origin ); + + distance = BG_FindBuildDistForClass( ps->stats[ STAT_PCLASS ] ); + VectorMA( player_origin, distance, forward, entity_origin ); + + VectorCopy( entity_origin, target_origin ); + entity_origin[ 2 ] += 32; + target_origin[ 2 ] -= 4096; + + BG_FindBBoxForBuildable( buildable, mins, maxs ); + + CG_Trace( &tr, entity_origin, mins, maxs, target_origin, ps->clientNum, MASK_PLAYERSOLID ); + VectorCopy( tr.endpos, entity_origin ); + entity_origin[ 2 ] += 0.1f; + + VectorCopy( entity_origin, ent.origin ); + VectorCopy( entity_origin, ent.oldorigin ); + + AnglesToAxis( angles, ent.axis ); + ent.hModel = cg_buildables[ buildable ].models[ 0 ]; + ent.customShader = cgs.media.quadShader; + ent.nonNormalizedAxes = qfalse; + + // add to refresh list + trap_R_AddRefEntityToScene( &ent ); +} + + #define TRACE_DEPTH 128.0f /* @@ -318,7 +378,7 @@ void CG_Buildable( centity_t *cent ) VectorCopy( cent->lerpOrigin, ent.oldorigin ); VectorCopy( es->origin2, surfNormal ); - BG_FindBBoxForBuildable( es->clientNum, mins, maxs ); + BG_FindBBoxForBuildable( es->modelindex, mins, maxs ); if( surfNormal[ 2 ] != 1.0f ) { @@ -347,7 +407,7 @@ void CG_Buildable( centity_t *cent ) else AnglesToAxis( es->angles, ent.axis ); - ent.hModel = cg_items[es->modelindex].models[0]; + ent.hModel = cg_buildables[ es->modelindex ].models[ 0 ]; ent.nonNormalizedAxes = qfalse; @@ -355,7 +415,7 @@ void CG_Buildable( centity_t *cent ) CG_BuildableAnimation( cent, &ent.oldframe, &ent.frame, &ent.backlerp ); //turret barrel bit - if( cg_items[ es->modelindex ].models[ 1 ] != 0 ) + if( cg_buildables[ es->modelindex ].models[ 1 ] != 0 ) { vec3_t turretOrigin; @@ -363,7 +423,7 @@ void CG_Buildable( centity_t *cent ) AnglesToAxis( es->angles2, ent2.axis ); - ent2.hModel = cg_items[ es->modelindex ].models[ 1 ]; + ent2.hModel = cg_buildables[ es->modelindex ].models[ 1 ]; VectorCopy( cent->lerpOrigin, turretOrigin ); turretOrigin[ 2 ] += 5; diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index adec761b..33dfea74 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -436,6 +436,10 @@ typedef struct { qhandle_t icon; } itemInfo_t; +typedef struct +{ + qhandle_t models[MAX_ITEM_MODELS]; +} buildableInfo_t; typedef struct { int itemNum; @@ -1098,11 +1102,13 @@ extern centity_t cg_entities[MAX_GENTITIES]; //TA: weapon limit expanded: //extern weaponInfo_t cg_weapons[MAX_WEAPONS]; -extern weaponInfo_t cg_weapons[32]; +extern weaponInfo_t cg_weapons[32]; //TA: upgrade infos: -extern upgradeInfo_t cg_upgrades[32]; +extern upgradeInfo_t cg_upgrades[32]; +extern itemInfo_t cg_items[MAX_ITEMS]; +//TA: buildable infos: +extern buildableInfo_t cg_buildables[ BA_NUM_BUILDABLES ]; -extern itemInfo_t cg_items[MAX_ITEMS]; extern markPoly_t cg_markPolys[MAX_MARK_POLYS]; //TA: @@ -1352,6 +1358,7 @@ sfxHandle_t CG_CustomSound( int clientNum, const char *soundName ); // // cg_buildable.c // +void CG_GhostBuildable( buildable_t buildable ); void CG_Buildable( centity_t *cent ); void CG_InitBuildables( ); diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c index f49568bf..3bf26193 100644 --- a/src/cgame/cg_main.c +++ b/src/cgame/cg_main.c @@ -82,9 +82,10 @@ centity_t cg_entities[MAX_GENTITIES]; //TA: weapons limit expanded: //weaponInfo_t cg_weapons[MAX_WEAPONS]; weaponInfo_t cg_weapons[32]; -upgradeInfo_t cg_upgrades[32]; +upgradeInfo_t cg_upgrades[32]; itemInfo_t cg_items[MAX_ITEMS]; +buildableInfo_t cg_buildables[ BA_NUM_BUILDABLES ]; //TA: cgItemPos_t cgIP; @@ -227,7 +228,7 @@ static cvarTable_t cvarTable[] = { { &cg_simpleItems, "cg_simpleItems", "0", CVAR_ARCHIVE }, { &cg_addMarks, "cg_marks", "1", CVAR_ARCHIVE }, { &cg_lagometer, "cg_lagometer", "1", CVAR_ARCHIVE }, - { &cg_teslaTrailTime, "cg_teslaTrailTime", "400", CVAR_ARCHIVE }, + { &cg_teslaTrailTime, "cg_teslaTrailTime", "600", CVAR_ARCHIVE }, { &cg_railTrailTime, "cg_railTrailTime", "400", CVAR_ARCHIVE }, { &cg_gun_x, "cg_gunX", "0", CVAR_CHEAT }, { &cg_gun_y, "cg_gunY", "0", CVAR_CHEAT }, diff --git a/src/cgame/cg_weapons.c b/src/cgame/cg_weapons.c index eaafe655..efde2187 100644 --- a/src/cgame/cg_weapons.c +++ b/src/cgame/cg_weapons.c @@ -1353,6 +1353,9 @@ void CG_AddViewWeapon( playerState_t *ps ) { return; } + /*if( ps->stats[ STAT_BUILDABLE ] & SB_ACTIVE_TOGGLEBIT )*/ + CG_GhostBuildable( BA_H_SPAWN ); + // no gun if in third person view if ( cg.renderingThirdPerson ) { return; |