diff options
author | Tim Angus <tim@ngus.net> | 2004-01-13 20:15:24 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2004-01-13 20:15:24 +0000 |
commit | 1a92fbd9fddb8735bee7e22868b50040ca15b601 (patch) | |
tree | 98dc332d0e1b6300b65d7d9711dcb040f334d265 /src/cgame | |
parent | 06970828585e1fda9f4f0a71d6f5e040a8cd4d30 (diff) |
* Changed charge feedback and timing a bit
* First frame of the buildable is now set before the construction animation
* Fixed a secondary buildable animation bug
Diffstat (limited to 'src/cgame')
-rw-r--r-- | src/cgame/cg_buildable.c | 72 | ||||
-rw-r--r-- | src/cgame/cg_ents.c | 3 | ||||
-rw-r--r-- | src/cgame/cg_view.c | 11 |
3 files changed, 51 insertions, 35 deletions
diff --git a/src/cgame/cg_buildable.c b/src/cgame/cg_buildable.c index f44df8e8..dd008dee 100644 --- a/src/cgame/cg_buildable.c +++ b/src/cgame/cg_buildable.c @@ -609,7 +609,7 @@ static void CG_RunBuildableLerpFrame( centity_t *cent ) else lf->frame = anim->firstFrame + f; - if ( cg.time > lf->frameTime ) + if( cg.time > lf->frameTime ) { lf->frameTime = cg.time; if( cg_debugAnim.integer ) @@ -624,7 +624,7 @@ static void CG_RunBuildableLerpFrame( centity_t *cent ) lf->oldFrameTime = cg.time; // calculate current lerp value - if ( lf->frameTime == lf->oldFrameTime ) + if( lf->frameTime == lf->oldFrameTime ) lf->backlerp = 0; else lf->backlerp = 1.0 - (float)( cg.time - lf->oldFrameTime ) / ( lf->frameTime - lf->oldFrameTime ); @@ -642,20 +642,47 @@ static void CG_BuildableAnimation( centity_t *cent, int *old, int *now, float *b //if no animation is set default to idle anim if( cent->buildableAnim == BANIM_NONE ) cent->buildableAnim = es->torsoAnim; - - if( ( cent->oldBuildableAnim ^ es->legsAnim ) & ANIM_TOGGLEBIT ) + + //display the first frame of the construction anim if not yet spawned + if( !( es->generic1 & B_SPAWNED_TOGGLEBIT ) ) { - if( cent->buildableAnim == es->torsoAnim || es->legsAnim & ANIM_FORCEBIT ) - cent->buildableAnim = cent->oldBuildableAnim = es->legsAnim; - else - cent->buildableAnim = cent->oldBuildableAnim = es->torsoAnim; + animation_t *anim = &cg_buildables[ es->modelindex ].animations[ BANIM_CONSTRUCT1 ]; + + //so that when animation starts for real it has sensible numbers + cent->lerpFrame.oldFrameTime = + cent->lerpFrame.frameTime = + cent->lerpFrame.animationTime = + cg.time; + + *old = cent->lerpFrame.oldFrame = anim->firstFrame; + *now = cent->lerpFrame.frame = anim->firstFrame; + *backLerp = cent->lerpFrame.backlerp = 0.0f; + + //ensure that an animation is triggered once the buildable has spawned + cent->oldBuildableAnim = BANIM_NONE; } - - CG_RunBuildableLerpFrame( cent ); + else + { + if( ( cent->oldBuildableAnim ^ es->legsAnim ) & ANIM_TOGGLEBIT ) + { + if( cg_debugAnim.integer ) + CG_Printf( "%d->%d l:%d t:%d %s(%d)\n", + cent->oldBuildableAnim, cent->buildableAnim, + es->legsAnim, es->torsoAnim, + BG_FindHumanNameForBuildable( es->modelindex ), es->number ); - *old = cent->lerpFrame.oldFrame; - *now = cent->lerpFrame.frame; - *backLerp = cent->lerpFrame.backlerp; + if( cent->buildableAnim == es->torsoAnim || es->legsAnim & ANIM_FORCEBIT ) + cent->buildableAnim = cent->oldBuildableAnim = es->legsAnim; + else + cent->buildableAnim = cent->oldBuildableAnim = es->torsoAnim; + } + + CG_RunBuildableLerpFrame( cent ); + + *old = cent->lerpFrame.oldFrame; + *now = cent->lerpFrame.frame; + *backLerp = cent->lerpFrame.backlerp; + } } #define TRACE_DEPTH 128.0f @@ -957,21 +984,10 @@ void CG_Buildable( centity_t *cent ) ent.nonNormalizedAxes = qfalse; - if( team == BIT_ALIENS ) - { - if( es->generic1 & B_SPAWNED_TOGGLEBIT ) - { - //run animations - CG_BuildableAnimation( cent, &ent.oldframe, &ent.frame, &ent.backlerp ); - } - } - else if( team == BIT_HUMANS ) - { - if( !( es->generic1 & B_SPAWNED_TOGGLEBIT ) ) - ent.customShader = cgs.media.humanSpawningShader; - else - CG_BuildableAnimation( cent, &ent.oldframe, &ent.frame, &ent.backlerp ); - } + if( team == BIT_HUMANS && !( es->generic1 & B_SPAWNED_TOGGLEBIT ) ) + ent.customShader = cgs.media.humanSpawningShader; + + CG_BuildableAnimation( cent, &ent.oldframe, &ent.frame, &ent.backlerp ); // add to refresh list trap_R_AddRefEntityToScene( &ent ); diff --git a/src/cgame/cg_ents.c b/src/cgame/cg_ents.c index 1ae81676..b56a1a40 100644 --- a/src/cgame/cg_ents.c +++ b/src/cgame/cg_ents.c @@ -879,9 +879,6 @@ static void CG_CEntityPVSEnter( centity_t *cent ) cent->buildablePS = NULL; cent->entityPS = NULL; - - //make sure entities entering the PVS don't get stale animation data - memset( ¢->lerpFrame, 0, sizeof( lerpFrame_t ) ); } diff --git a/src/cgame/cg_view.c b/src/cgame/cg_view.c index 149188a5..c3e13457 100644 --- a/src/cgame/cg_view.c +++ b/src/cgame/cg_view.c @@ -462,17 +462,20 @@ static void CG_OffsetFirstPersonView( void ) else bob2 = BG_FindBobForClass( cg.predictedPlayerState.stats[ STAT_PCLASS ] ); + +#define BMOFO_FEEDBACK 10.0f + //give a charging player some feedback - if( cg.predictedPlayerState.weapon == WP_BIGMOFO ) + if( ps->weapon == WP_BIGMOFO ) { - if( cg.predictedPlayerState.stats[ STAT_MISC ] > 0 ) + if( ps->stats[ STAT_MISC ] > 0 ) { - float fraction = (float)( cg.time - cg.weapon2Time ) / (float)BMOFO_CHARGE_TIME; + float fraction = (float)ps->stats[ STAT_MISC ] / (float)BMOFO_CHARGE_TIME; if( fraction > 1.0f ) fraction = 1.0f; - bob2 *= ( 1.0f + fraction * 6.0f ); + bob2 *= ( 1.0f + fraction * BMOFO_FEEDBACK ); } } |