From 7b3547e2b5409873de49d4e81f5480ec03b59c05 Mon Sep 17 00:00:00 2001 From: Victor Chow Date: Fri, 17 Aug 2001 20:38:54 +0000 Subject: [PATCH] Elder: New code for upcoming VM 0-09-00 Client-side --- reaction/cgame/cg_event.c | 21 +++++++++++++++ reaction/cgame/cg_local.h | 6 ++++- reaction/cgame/cg_main.c | 9 +++++++ reaction/cgame/cg_players.c | 52 ++++++++++++++++++++++--------------- reaction/cgame/cg_weapons.c | 11 +++++--- 5 files changed, 74 insertions(+), 25 deletions(-) diff --git a/reaction/cgame/cg_event.c b/reaction/cgame/cg_event.c index b1745e06..d5f1387e 100644 --- a/reaction/cgame/cg_event.c +++ b/reaction/cgame/cg_event.c @@ -1460,6 +1460,27 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) { cgs.media.footsteps[ FOOTSTEP_GRASS ][rand()&3] ); } break; + case EV_FOOTSTEP_WOOD: + DEBUGNAME("EV_FOOTSTEP_WOOD"); + if (cg_footsteps.integer) { + trap_S_StartSound (NULL, es->number, CHAN_BODY, + cgs.media.footsteps[ FOOTSTEP_WOOD ][rand()&3] ); + } + break; + case EV_FOOTSTEP_CARPET: + DEBUGNAME("EV_FOOTSTEP_CARPET"); + if (cg_footsteps.integer) { + trap_S_StartSound (NULL, es->number, CHAN_BODY, + cgs.media.footsteps[ FOOTSTEP_CARPET ][rand()&3] ); + } + break; + case EV_FOOTSTEP_METAL2: + DEBUGNAME("EV_FOOTSTEP_METAL2"); + if (cg_footsteps.integer) { + trap_S_StartSound (NULL, es->number, CHAN_BODY, + cgs.media.footsteps[ FOOTSTEP_METAL2 ][rand()&3] ); + } + break; case EV_FOOTSPLASH: DEBUGNAME("EV_FOOTSPLASH"); if (cg_footsteps.integer) { diff --git a/reaction/cgame/cg_local.h b/reaction/cgame/cg_local.h index cf7c6574..9a690759 100644 --- a/reaction/cgame/cg_local.h +++ b/reaction/cgame/cg_local.h @@ -92,7 +92,11 @@ typedef enum { FOOTSTEP_ENERGY, FOOTSTEP_METAL, FOOTSTEP_SPLASH, - FOOTSTEP_GRASS, // Elder: new surface sounds + // Elder: new surface sounds + FOOTSTEP_GRASS, + FOOTSTEP_WOOD, + FOOTSTEP_CARPET, + FOOTSTEP_METAL2, FOOTSTEP_TOTAL } footstep_t; diff --git a/reaction/cgame/cg_main.c b/reaction/cgame/cg_main.c index 1a0a3b3c..94ebd980 100644 --- a/reaction/cgame/cg_main.c +++ b/reaction/cgame/cg_main.c @@ -747,6 +747,15 @@ static void CG_RegisterSounds( void ) { //Elder: new footsteps Com_sprintf (name, sizeof(name), "sound/player/footsteps/grass%i.wav", i+1); cgs.media.footsteps[FOOTSTEP_GRASS][i] = trap_S_RegisterSound (name, qfalse); + + Com_sprintf (name, sizeof(name), "sound/player/footsteps/wood%i.wav", i+1); + cgs.media.footsteps[FOOTSTEP_WOOD][i] = trap_S_RegisterSound (name, qfalse); + + Com_sprintf (name, sizeof(name), "sound/player/footsteps/carpet%i.wav", i+1); + cgs.media.footsteps[FOOTSTEP_CARPET][i] = trap_S_RegisterSound (name, qfalse); + + Com_sprintf (name, sizeof(name), "sound/player/footsteps/metal%i.wav", i+1); + cgs.media.footsteps[FOOTSTEP_METAL2][i] = trap_S_RegisterSound (name, qfalse); } // only register the items that the server says we need diff --git a/reaction/cgame/cg_players.c b/reaction/cgame/cg_players.c index 20cb41f5..db97c1f9 100644 --- a/reaction/cgame/cg_players.c +++ b/reaction/cgame/cg_players.c @@ -1087,23 +1087,24 @@ static void CG_SetWeaponLerpFrame( clientInfo_t *ci, lerpFrame_t *lf, int newAni CG_Error( "Bad weapon animation number: %i", newAnimation ); } - anim = &cg_weapons[cg.snap->ps.weapon].animations[ newAnimation ]; + // Elder: selecting the right weapon animation + if (newAnimation == WP_ANIM_ACTIVATE) + anim = &cg_weapons[cg.weaponSelect].animations[ newAnimation ]; + else + anim = &cg_weapons[cg.snap->ps.weapon].animations[ newAnimation ]; lf->animation = anim; lf->animationTime = lf->frameTime + anim->initialLerp; if ( cg_debugAnim.integer ) { CG_Printf( "Weapon Anim: %i\n", newAnimation ); + // Elder: more info + CG_Printf( "Snap Weapon: %i\n", cg.snap->ps.weapon); + CG_Printf( "Desired Weapon: %i\n", cg.weaponSelect); } - //Elder: reset frame? - if ( cg_debugAnim.integer ) { - CG_Printf("Anim: %d, Old lf->frame %d, New lf->frame: %d\n", - newAnimation, lf->frame, anim->firstFrame); - } - - lf->oldFrame = lf->frame; - lf->frame = anim->firstFrame; + //Elder: reset frame so there is no lerping between new animations + lf->oldFrame = lf->frame = lf->animation->firstFrame; } @@ -1157,20 +1158,22 @@ static void CG_RunLerpFrame( clientInfo_t *ci, lerpFrame_t *lf, int newAnimation // see if the animation sequence is switching if ( newAnimation != lf->animationNumber || !lf->animation ) { if (weaponAnim) { + lf->frameTime = lf->oldFrameTime = cg.time; CG_SetWeaponLerpFrame( ci, lf, newAnimation ); - resetAnim = qtrue; + //resetAnim = qtrue; } else { CG_SetLerpFrameAnimation( ci, lf, newAnimation ); } } // Elder's chunk of debug code + /* if (weaponAnim && cg_debugAnim.integer) { CG_Printf("(%d)==================\n", cg.time); CG_Printf("lf->frame (%d), lf->frameTime (%d),\n", lf->frame, lf->frameTime); CG_Printf("lf->oldFrame (%d), lf->oldFrameTime (%d),\n", lf->oldFrame, lf->oldFrameTime); - } + }*/ // if we have passed the current frame, move it to // oldFrame and calculate a new frame @@ -1195,6 +1198,7 @@ static void CG_RunLerpFrame( clientInfo_t *ci, lerpFrame_t *lf, int newAnimation if (anim->flipflop) { numFrames *= 2; } + if ( f >= numFrames ) { f -= numFrames; if ( anim->loopFrames ) { @@ -1215,9 +1219,9 @@ static void CG_RunLerpFrame( clientInfo_t *ci, lerpFrame_t *lf, int newAnimation } else { //Elder's stuff - if (resetAnim) - lf->frame = anim->firstFrame; - else + //if (resetAnim) + //lf->frame = anim->firstFrame; + //else lf->frame = anim->firstFrame + f; } if ( cg.time > lf->frameTime ) { @@ -1256,6 +1260,7 @@ static void CG_ClearLerpFrame( clientInfo_t *ci, lerpFrame_t *lf, int animationN lf->oldFrame = lf->frame = lf->animation->firstFrame; } + /* [QUARANTINE] - Weapon Animations =============== CG_WeaponAnimation @@ -1280,7 +1285,8 @@ void CG_WeaponAnimation( centity_t *cent, int *weaponOld, int *weapon, float *we CG_RunLerpFrame( ci, ¢->pe.weapon, cent->currentState.generic1, 1, qtrue ); // QUARANTINE - Debug - Animations - #if 0 + #if 1 + if (cg_debugAnim.integer) if(cent->pe.weapon.oldFrame || cent->pe.weapon.frame || cent->pe.weapon.backlerp) { CG_Printf("weaponOld: %i weaponFrame: %i weaponBack: %i\n", cent->pe.weapon.oldFrame, cent->pe.weapon.frame, cent->pe.weapon.backlerp); @@ -2226,6 +2232,7 @@ void CG_AddRefEntityWithPowerups( refEntity_t *ent, entityState_t *state, int te trap_R_AddRefEntityToScene( ent ); //} + if ( state->powerups & ( 1 << PW_QUAD ) ) { if (team == TEAM_RED) @@ -2245,13 +2252,16 @@ void CG_AddRefEntityWithPowerups( refEntity_t *ent, entityState_t *state, int te trap_R_AddRefEntityToScene( ent ); } - //Elder: IR Vision - if (bg_itemlist[cg.snap->ps.stats[STAT_HOLDABLE_ITEM]].giTag == HI_BANDOLIER && - cg.rq3_irvision && !(state->eFlags & EF_DEAD)) + //Elder: IR Vision -- only on players + if (state->eType == ET_PLAYER) { - //Temporary heh - ent->customShader = cgs.media.quadShader; - trap_R_AddRefEntityToScene( ent ); + if (bg_itemlist[cg.snap->ps.stats[STAT_HOLDABLE_ITEM]].giTag == HI_BANDOLIER && + cg.rq3_irvision && !(state->eFlags & EF_DEAD)) + { + //Temporary heh + ent->customShader = cgs.media.quadShader; + trap_R_AddRefEntityToScene( ent ); + } } } diff --git a/reaction/cgame/cg_weapons.c b/reaction/cgame/cg_weapons.c index acfce104..8e7d4e1f 100644 --- a/reaction/cgame/cg_weapons.c +++ b/reaction/cgame/cg_weapons.c @@ -811,6 +811,7 @@ void CG_RegisterWeapon( int weaponNum ) { weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/handcannon/hcfire.wav", qfalse ); weaponInfo->ejectBrassFunc = CG_ShotgunEjectBrass; cgs.media.bulletExplosionShader = trap_R_RegisterShader( "bulletExplosion" ); + Com_sprintf( filename, sizeof(filename), "models/weapons2/handcannon/animation.cfg" ); if ( !CG_ParseWeaponAnimFile(filename, weaponInfo) ) { Com_Printf("Failed to load weapon animation file %s\n", filename); @@ -1422,7 +1423,8 @@ void CG_AddViewWeapon( playerState_t *ps ) { // allow the gun to be completely removed - if ( !cg_drawGun.integer ) { + // Elder: don't draw if throwing + if ( !cg_drawGun.integer || (cg.snap->ps.stats[STAT_RQ3] & RQ3_THROWWEAPON) == RQ3_THROWWEAPON) { //Blaze: Removed these // vec3_t origin; @@ -1503,7 +1505,10 @@ void CG_AddViewWeapon( playerState_t *ps ) { //if ( ps->weapon != WP_PISTOL && ps->weapon != WP_M3) //{ // map torso animations to weapon animations - if ( cg_gun_frame.integer || ps->weapon == WP_PISTOL || ps->weapon == WP_M3 || ps->weapon == WP_HANDCANNON) { + if ( cg_gun_frame.integer || + ps->weapon == WP_PISTOL || + ps->weapon == WP_M3 || + ps->weapon == WP_HANDCANNON) { // development tool hand.frame = hand.oldframe = cg_gun_frame.integer; hand.backlerp = 0; @@ -2912,7 +2917,7 @@ static void CG_LocalLaser () if (tr.fraction != 1) VectorMA(tr.endpos,-4, forward, tr.endpos); - + VectorCopy(re->origin, re->oldorigin); VectorCopy(tr.endpos, re->origin); //VectorCopy(tr.endpos, cg.laserEnt->pos.trBase); //BG_EvaluateTrajectory(&cg.laserEnt->pos, cg.time, re->origin);