diff --git a/code/cgame/cg_ents.c b/code/cgame/cg_ents.c index 0f7e1067..9d8b2544 100644 --- a/code/cgame/cg_ents.c +++ b/code/cgame/cg_ents.c @@ -294,6 +294,11 @@ static void CG_Item( centity_t *cent ) { cent->lerpOrigin[2] += 8; // an extra height boost } + + if( item->giType == IT_WEAPON && item->giTag == WP_RAILGUN ) { + clientInfo_t *ci = &cgs.clientinfo[cg.snap->ps.clientNum]; + Byte4Copy( ci->c1RGBA, ent.shaderRGBA ); + } ent.hModel = cg_items[es->modelindex].models[0]; diff --git a/code/cgame/cg_local.h b/code/cgame/cg_local.h index ea331bff..a6df88a8 100644 --- a/code/cgame/cg_local.h +++ b/code/cgame/cg_local.h @@ -154,6 +154,8 @@ typedef struct { vec3_t railgunImpact; qboolean railgunFlash; + int railFireTime; + // machinegun spinning float barrelAngle; int barrelTime; @@ -320,6 +322,9 @@ typedef struct { vec3_t color1; vec3_t color2; + + byte c1RGBA[4]; + byte c2RGBA[4]; int score; // updated by score servercmds int location; // location index for team mode diff --git a/code/cgame/cg_players.c b/code/cgame/cg_players.c index 5e4409ca..262bce38 100644 --- a/code/cgame/cg_players.c +++ b/code/cgame/cg_players.c @@ -900,9 +900,19 @@ void CG_NewClientInfo( int clientNum ) { v = Info_ValueForKey( configstring, "c1" ); CG_ColorFromString( v, newInfo.color1 ); + newInfo.c1RGBA[0] = 255 * newInfo.color1[0]; + newInfo.c1RGBA[1] = 255 * newInfo.color1[1]; + newInfo.c1RGBA[2] = 255 * newInfo.color1[2]; + newInfo.c1RGBA[3] = 255; + v = Info_ValueForKey( configstring, "c2" ); CG_ColorFromString( v, newInfo.color2 ); + newInfo.c2RGBA[0] = 255 * newInfo.color2[0]; + newInfo.c2RGBA[1] = 255 * newInfo.color2[1]; + newInfo.c2RGBA[2] = 255 * newInfo.color2[2]; + newInfo.c2RGBA[3] = 255; + // bot skill v = Info_ValueForKey( configstring, "skill" ); newInfo.botSkill = atoi( v ); diff --git a/code/cgame/cg_weapons.c b/code/cgame/cg_weapons.c index 3b7738a9..66d2634c 100644 --- a/code/cgame/cg_weapons.c +++ b/code/cgame/cg_weapons.c @@ -1253,21 +1253,18 @@ void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent gun.renderfx = parent->renderfx; // set custom shading for railgun refire rate - if ( ps || cent->currentState.clientNum == cg.predictedPlayerState.clientNum ) { - if ( cg.predictedPlayerState.weapon == WP_RAILGUN - && cg.predictedPlayerState.weaponstate == WEAPON_FIRING ) { - float f; - - f = (float)cg.predictedPlayerState.weaponTime / 1500; - gun.shaderRGBA[1] = 0; - gun.shaderRGBA[0] = - gun.shaderRGBA[2] = 255 * ( 1.0 - f ); - } else { - gun.shaderRGBA[0] = 255; - gun.shaderRGBA[1] = 255; - gun.shaderRGBA[2] = 255; + if( weaponNum == WP_RAILGUN ) { + clientInfo_t *ci = &cgs.clientinfo[cent->currentState.clientNum]; + if( cent->pe.railFireTime + 1500 > cg.time ) { + int scale = 255 * ( cg.time - cent->pe.railFireTime ) / 1500; + gun.shaderRGBA[0] = ( ci->c1RGBA[0] * scale ) >> 8; + gun.shaderRGBA[1] = ( ci->c1RGBA[1] * scale ) >> 8; + gun.shaderRGBA[2] = ( ci->c1RGBA[2] * scale ) >> 8; gun.shaderRGBA[3] = 255; } + else { + Byte4Copy( ci->c1RGBA, gun.shaderRGBA ); + } } gun.hModel = weapon->weaponModel; @@ -1743,6 +1740,10 @@ void CG_FireWeapon( centity_t *cent ) { } } + if( ent->weapon == WP_RAILGUN ) { + cent->pe.railFireTime = cg.time; + } + // play quad sound if needed if ( cent->currentState.powerups & ( 1 << PW_QUAD ) ) { trap_S_StartSound (NULL, cent->currentState.number, CHAN_ITEM, cgs.media.quadSound ); @@ -1978,7 +1979,7 @@ void CG_MissileHitWall( int weapon, int clientNum, vec3_t origin, vec3_t dir, im float *color; // colorize with client color - color = cgs.clientinfo[clientNum].color2; + color = cgs.clientinfo[clientNum].color1; CG_ImpactMark( mark, origin, dir, random()*360, color[0],color[1], color[2],1, alphaFade, radius, qfalse ); } else { CG_ImpactMark( mark, origin, dir, random()*360, 1,1,1,1, alphaFade, radius, qfalse ); diff --git a/code/qcommon/q_shared.h b/code/qcommon/q_shared.h index 7c1af62d..542eff5f 100644 --- a/code/qcommon/q_shared.h +++ b/code/qcommon/q_shared.h @@ -545,6 +545,8 @@ typedef struct { #define VectorSet(v, x, y, z) ((v)[0]=(x), (v)[1]=(y), (v)[2]=(z)) #define Vector4Copy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3]) +#define Byte4Copy(a,b) ((b)[0]=(a)[0],(b)[1]=(a)[1],(b)[2]=(a)[2],(b)[3]=(a)[3]) + #define SnapVector(v) {v[0]=((int)(v[0]));v[1]=((int)(v[1]));v[2]=((int)(v[2]));} // just in case you do't want to use the macros vec_t _DotProduct( const vec3_t v1, const vec3_t v2 );