diff --git a/reaction/cgame/cg_ents.c b/reaction/cgame/cg_ents.c index 47c80840..b3e13caa 100644 --- a/reaction/cgame/cg_ents.c +++ b/reaction/cgame/cg_ents.c @@ -33,6 +33,33 @@ void CG_PositionEntityOnTag( refEntity_t *entity, const refEntity_t *parent, entity->backlerp = parent->backlerp; } +/* [QUARANTINE] - CG_PositionWeaponOnTag +====================== +CG_PositionWeaponOnTag + +Changed from CG_PositionEntityOnTag function to prevent backlerp change in animations +====================== +*/ +void CG_PositionWeaponOnTag( refEntity_t *entity, const refEntity_t *parent, qhandle_t parentModel, char *tagName ) { +int i; +orientation_t lerped; + +// lerp the tag +trap_R_LerpTag( &lerped, parentModel, parent->oldframe, parent->frame, +1.0 - parent->backlerp, tagName ); + +// FIXME: allow origin offsets along tag? +VectorCopy( parent->origin, entity->origin ); +for ( i = 0 ; i < 3 ; i++ ) { +VectorMA( entity->origin, lerped.origin[i], parent->axis[i], entity->origin ); +} + +// had to cast away the const to avoid compiler problems... +MatrixMultiply( lerped.axis, ((refEntity_t *)parent)->axis, entity->axis ); +// entity->backlerp = parent->backlerp; +} + + /* ====================== diff --git a/reaction/cgame/cg_local.h b/reaction/cgame/cg_local.h index ff759fce..c00b6f88 100644 --- a/reaction/cgame/cg_local.h +++ b/reaction/cgame/cg_local.h @@ -144,6 +144,8 @@ typedef struct { float barrelAngle; int barrelTime; qboolean barrelSpinning; + //Blaze: for weapon animations + lerpFrame_t weapon; } playerEntity_t; //================================================= @@ -372,6 +374,10 @@ typedef struct weaponInfo_s { qhandle_t flashModel; //Elder: added third person model to weaponInfo structure qhandle_t firstModel; + //Blaze: for animations + qhandle_t animHandModel; + animation_t animations[MAX_WEAPON_ANIMATIONS]; + vec3_t weaponMidpoint; // so it will rotate centered instead of by tag @@ -1391,7 +1397,8 @@ void CG_PositionEntityOnTag( refEntity_t *entity, const refEntity_t *parent, qhandle_t parentModel, char *tagName ); void CG_PositionRotatedEntityOnTag( refEntity_t *entity, const refEntity_t *parent, qhandle_t parentModel, char *tagName ); - +//Blaze: for weapon animations +void CG_PositionWeaponOnTag( refEntity_t *entity, const refEntity_t *parent, qhandle_t parentModel, char *tagName ); // @@ -1499,6 +1506,11 @@ void CG_DrawInformation( void ); qboolean CG_DrawOldScoreboard( void ); void CG_DrawOldTourneyScoreboard( void ); +// +// cg_players.c +// +void CG_WeaponAnimation( centity_t *cent, int *weaponOld, int *weapon, float *weaponBackLerp ); + // // cg_consolecmds.c // diff --git a/reaction/cgame/cg_main.c b/reaction/cgame/cg_main.c index 9f85bc1c..319c1b02 100644 --- a/reaction/cgame/cg_main.c +++ b/reaction/cgame/cg_main.c @@ -230,6 +230,8 @@ cvarTable_t cvarTable[] = { { &cg_gun_x, "cg_gunX", "0", CVAR_CHEAT }, { &cg_gun_y, "cg_gunY", "0", CVAR_CHEAT }, { &cg_gun_z, "cg_gunZ", "0", CVAR_CHEAT }, + //Blaze: to test the gun frames + { &cg_gun_frame, "cg_gun_frame", "0", CVAR_CHEAT }, { &cg_centertime, "cg_centertime", "3", CVAR_CHEAT }, { &cg_runpitch, "cg_runpitch", "0.002", CVAR_ARCHIVE}, { &cg_runroll, "cg_runroll", "0.005", CVAR_ARCHIVE }, diff --git a/reaction/cgame/cg_players.c b/reaction/cgame/cg_players.c index 283c9413..eed8a4d1 100644 --- a/reaction/cgame/cg_players.c +++ b/reaction/cgame/cg_players.c @@ -866,6 +866,33 @@ PLAYER ANIMATION ============================================================================= */ +/* [QUARANTINE] - Weapon Animations +=============== +CG_SetWeaponLerpFrame + +may include ANIM_TOGGLEBIT +=============== +*/ +static void CG_SetWeaponLerpFrame( clientInfo_t *ci, lerpFrame_t *lf, int newAnimation ) +{ + animation_t *anim; + + lf->animationNumber = newAnimation; + newAnimation &= ~ANIM_TOGGLEBIT; + + if ( newAnimation < 0 || newAnimation >= MAX_WEAPON_ANIMATIONS ) { + CG_Error( "Bad weapon animation number: %i", newAnimation ); + } + + 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 ); + } +} /* @@ -903,7 +930,7 @@ Sets cg.snap, cg.oldFrame, and cg.backlerp cg.time should be between oldFrameTime and frameTime after exit =============== */ -static void CG_RunLerpFrame( clientInfo_t *ci, lerpFrame_t *lf, int newAnimation, float speedScale ) { +static void CG_RunLerpFrame( clientInfo_t *ci, lerpFrame_t *lf, int newAnimation, float speedScale, qboolean weaponAnim ) { int f, numFrames; animation_t *anim; @@ -915,7 +942,11 @@ 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 ) { - CG_SetLerpFrameAnimation( ci, lf, newAnimation ); + if (weaponAnim) { + CG_SetWeaponLerpFrame( ci, lf, newAnimation ); + } else { + CG_SetLerpFrameAnimation( ci, lf, newAnimation ); + } } // if we have passed the current frame, move it to @@ -997,6 +1028,43 @@ static void CG_ClearLerpFrame( clientInfo_t *ci, lerpFrame_t *lf, int animationN lf->oldFrame = lf->frame = lf->animation->firstFrame; } +/* [QUARANTINE] - Weapon Animations +=============== +CG_WeaponAnimation + +This is called from cg_weapons.c +=============== +*/ +void CG_WeaponAnimation( centity_t *cent, int *weaponOld, int *weapon, float *weaponBackLerp ) +{ + clientInfo_t *ci; + int clientNum; + + clientNum = cent->currentState.clientNum; + + if ( cg_noPlayerAnims.integer ) { + *weaponOld = *weapon = 0; + return; + } + + ci = &cgs.clientinfo[ clientNum ]; + + CG_RunLerpFrame( ci, ¢->pe.weapon, cent->currentState.generic1, 1, qtrue ); + + // QUARANTINE - Debug - Animations + #if 0 + 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); + } + #endif + + *weaponOld = cent->pe.weapon.oldFrame; + *weapon = cent->pe.weapon.frame; + *weaponBackLerp = cent->pe.weapon.backlerp; + +} +// END /* =============== @@ -1026,16 +1094,16 @@ static void CG_PlayerAnimation( centity_t *cent, int *legsOld, int *legs, float // do the shuffle turn frames locally if ( cent->pe.legs.yawing && ( cent->currentState.legsAnim & ~ANIM_TOGGLEBIT ) == LEGS_IDLE ) { - CG_RunLerpFrame( ci, ¢->pe.legs, LEGS_TURN, speedScale ); + CG_RunLerpFrame( ci, ¢->pe.legs, LEGS_TURN, speedScale, qfalse ); } else { - CG_RunLerpFrame( ci, ¢->pe.legs, cent->currentState.legsAnim, speedScale ); + CG_RunLerpFrame( ci, ¢->pe.legs, cent->currentState.legsAnim, speedScale, qfalse ); } *legsOld = cent->pe.legs.oldFrame; *legs = cent->pe.legs.frame; *legsBackLerp = cent->pe.legs.backlerp; - CG_RunLerpFrame( ci, ¢->pe.torso, cent->currentState.torsoAnim, speedScale ); + CG_RunLerpFrame( ci, ¢->pe.torso, cent->currentState.torsoAnim, speedScale, qfalse ); *torsoOld = cent->pe.torso.oldFrame; *torso = cent->pe.torso.frame; @@ -1496,7 +1564,7 @@ static void CG_PlayerFlag( centity_t *cent, qhandle_t hSkin, refEntity_t *torso angles[YAW] = cent->pe.flag.yawAngle; // lerp the flag animation frames ci = &cgs.clientinfo[ cent->currentState.clientNum ]; - CG_RunLerpFrame( ci, ¢->pe.flag, flagAnim, 1 ); + CG_RunLerpFrame( ci, ¢->pe.flag, flagAnim, 1, qfalse ); flag.oldframe = cent->pe.flag.oldFrame; flag.frame = cent->pe.flag.frame; flag.backlerp = cent->pe.flag.backlerp; diff --git a/reaction/cgame/cgame.plg b/reaction/cgame/cgame.plg index b0ce55bb..1bf045b6 100644 --- a/reaction/cgame/cgame.plg +++ b/reaction/cgame/cgame.plg @@ -6,13 +6,37 @@ --------------------Configuration: cgame - Win32 Debug--------------------

Command Lines

-Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP3E1.tmp" with contents +Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP10F.tmp" with contents [ /nologo /G5 /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR"Debug/" /Fp"Debug/cgame.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /c +"c:\reaction\game\bg_misc.c" +"c:\reaction\game\bg_pmove.c" +"c:\reaction\game\bg_slidemove.c" +"c:\reaction\cgame\cg_consolecmds.c" +"c:\reaction\cgame\cg_draw.c" +"c:\reaction\cgame\cg_drawtools.c" +"c:\reaction\cgame\cg_effects.c" +"c:\reaction\cgame\cg_ents.c" +"c:\reaction\cgame\cg_event.c" +"c:\reaction\cgame\cg_info.c" +"c:\reaction\cgame\cg_localents.c" +"c:\reaction\cgame\cg_main.c" +"c:\reaction\cgame\cg_marks.c" +"c:\reaction\cgame\cg_players.c" "c:\reaction\cgame\cg_playerstate.c" +"c:\reaction\cgame\cg_predict.c" +"c:\reaction\cgame\cg_scoreboard.c" +"c:\reaction\cgame\cg_servercmds.c" +"c:\reaction\cgame\cg_snapshot.c" +"c:\reaction\cgame\cg_syscalls.c" +"c:\reaction\cgame\cg_view.c" +"c:\reaction\cgame\cg_weapons.c" +"c:\reaction\game\q_math.c" +"c:\reaction\game\q_shared.c" +"c:\reaction\ui\ui_shared.c" ] -Creating command line "cl.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP3E1.tmp" -Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP3E2.tmp" with contents +Creating command line "cl.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP10F.tmp" +Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP110.tmp" with contents [ /nologo /base:"0x30000000" /subsystem:windows /dll /incremental:yes /pdb:"Debug/cgamex86.pdb" /map:"Debug/cgamex86.map" /debug /machine:I386 /def:".\cgame.def" /out:"../Debug/cgamex86.dll" /implib:"Debug/cgamex86.lib" .\Debug\bg_misc.obj @@ -41,19 +65,51 @@ Creating temporary file "C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP3E2.tmp" with con .\Debug\q_shared.obj .\Debug\ui_shared.obj ] -Creating command line "link.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP3E2.tmp" +Creating command line "link.exe @C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\RSP110.tmp"

Output Window

Compiling... +bg_misc.c +bg_pmove.c +bg_slidemove.c +cg_consolecmds.c +cg_draw.c +c:\reaction\cgame\cg_draw.c(506) : warning C4101: 'angles' : unreferenced local variable +c:\reaction\cgame\cg_draw.c(507) : warning C4101: 'origin' : unreferenced local variable +c:\reaction\cgame\cg_draw.c(500) : warning C4101: 'color' : unreferenced local variable +cg_drawtools.c +cg_effects.c +cg_ents.c +cg_event.c +cg_info.c +cg_localents.c +cg_main.c +cg_marks.c +cg_players.c +c:\reaction\cgame\cg_players.c(1056) : error C2198: 'CG_RunLerpFrame' : too few actual parameters +c:\reaction\cgame\cg_players.c(1058) : error C2198: 'CG_RunLerpFrame' : too few actual parameters +c:\reaction\cgame\cg_players.c(1065) : error C2198: 'CG_RunLerpFrame' : too few actual parameters +c:\reaction\cgame\cg_players.c(1526) : error C2198: 'CG_RunLerpFrame' : too few actual parameters cg_playerstate.c -c:\reaction\cgame\cg_playerstate.c(288) : warning C4101: 'sfx' : unreferenced local variable -Linking... -LINK : LNK6004: ../Debug/cgamex86.dll not found or not built by the last incremental link; performing full link - Creating library Debug/cgamex86.lib and object Debug/cgamex86.exp +c:\reaction\cgame\cg_playerstate.c(345) : warning C4101: 'sfx' : unreferenced local variable +cg_predict.c +cg_scoreboard.c +cg_servercmds.c +cg_snapshot.c +cg_syscalls.c +cg_view.c +cg_weapons.c +c:\reaction\cgame\cg_weapons.c(560) : warning C4013: 'CG_ParseWeaponAnimFile' undefined; assuming extern returning int +c:\reaction\cgame\cg_weapons.c(957) : warning C4101: 'frac' : unreferenced local variable +c:\reaction\cgame\cg_weapons.c(1907) : warning C4101: 'i' : unreferenced local variable +q_math.c +q_shared.c +ui_shared.c +Error executing cl.exe.

Results

-cgamex86.dll - 0 error(s), 1 warning(s) +cgamex86.dll - 4 error(s), 7 warning(s) diff --git a/reaction/game/bg_pmove.c b/reaction/game/bg_pmove.c index a7bc430b..c0326877 100644 --- a/reaction/game/bg_pmove.c +++ b/reaction/game/bg_pmove.c @@ -72,6 +72,28 @@ void RXN_RampMunge ( void ) { } } */ +/* [QUARANTINE] - Weapon Animations +=================== +PM_StartWeaponAnim, PM_ContinueWeaponAnim +=================== +*/ +static void PM_StartWeaponAnim( int anim ) { + if ( pm->ps->pm_type >= PM_DEAD ) { + return; + } + + pm->ps->generic1 = ( ( pm->ps->generic1 & ANIM_TOGGLEBIT ) ^ ANIM_TOGGLEBIT ) | anim; +} + +static void PM_ContinueWeaponAnim( int anim ) { + if ( ( pm->ps->generic1 & ~ANIM_TOGGLEBIT ) == anim ) { + return; + } + + PM_StartWeaponAnim( anim ); +} +// END + /* =============== PM_AddEvent @@ -1830,10 +1852,28 @@ static void PM_TorsoAnimation( void ) { } else { PM_ContinueTorsoAnim( TORSO_STAND ); } + // QUARANTINE - Weapon Animation + // Should always draw the weapon when it is just ready +// PM_ContinueWeaponAnim( WP_ANIM_READY ); + return; } } +/* +============== +PM_WeaponAnimation + +============== +*/ +static void PM_WeaponAnimation( void ) { + if (pm->ps->weaponstate == WEAPON_RELOADING) + { + PM_StartWeaponAnim( WP_ANIM_RELOAD ); + pm->ps->weaponstate = WEAPON_READY; + } + return; +} /* ============== @@ -1894,6 +1934,7 @@ static void PM_Weapon( void ) { // check for weapon change // can't change if weapon is firing, but can change // again if lowering or raising + if ( pm->ps->weaponTime <= 0 || pm->ps->weaponstate != WEAPON_FIRING ) { if ( pm->ps->weapon != pm->cmd.weapon ) { //Elder TODO: if switching weapons, fire off the grenade "instantly" @@ -1927,7 +1968,8 @@ static void PM_Weapon( void ) { if ( pm->ps->weaponTime > 0 ) { return; } - + //Com_Printf("Weaponstate (%d)\n", pm->ps->weaponstate); + // change weapon if time if ( pm->ps->weaponstate == WEAPON_DROPPING ) { PM_FinishWeaponChange(); @@ -1941,6 +1983,10 @@ static void PM_Weapon( void ) { } else { PM_StartTorsoAnim( TORSO_STAND ); } + // QUARANTINE - Weapon Animation + // Should always draw the weapon when it is just ready +// PM_StartWeaponAnim( WP_ANIM_READY ); + return; } @@ -1979,6 +2025,7 @@ static void PM_Weapon( void ) { } } + /* if ( ! (pm->cmd.buttons & BUTTON_ATTACK) ) { pm->ps->weaponTime = 0; @@ -2008,6 +2055,9 @@ static void PM_Weapon( void ) { } else { PM_StartTorsoAnim( TORSO_ATTACK ); } + // QUARANTINE - Weapon animations + // This should change pm->ps->generic1 so we can animate + PM_StartWeaponAnim( WP_ANIM_FIRE ); // Elder: the client side portion is in // Homer: if weapon can set to be burst mode, check for burst value @@ -2570,6 +2620,8 @@ void PmoveSingle (pmove_t *pmove) { // weapons PM_Weapon(); + //weapon animations(rq3 specific) + PM_WeaponAnimation(); // torso animation PM_TorsoAnimation(); diff --git a/reaction/game/bg_public.h b/reaction/game/bg_public.h index ab6512a1..7dee0e06 100644 --- a/reaction/game/bg_public.h +++ b/reaction/game/bg_public.h @@ -356,9 +356,16 @@ typedef enum { WEAPON_COCKED, WEAPON_RAISING, WEAPON_DROPPING, - WEAPON_FIRING//, - //WEAPON_RELOADING + WEAPON_FIRING, + WEAPON_RELOADING } weaponstate_t; +//Blaze: for the weapon animation states +typedef enum { + //WP_ANIM_READY, + WP_ANIM_FIRE, + WP_ANIM_RELOAD, + MAX_WEAPON_ANIMATIONS +} wpAnimNumber_t; // pmove->pm_flags #define PMF_DUCKED 1 diff --git a/reaction/game/g_cmds.c b/reaction/game/g_cmds.c index 0bcb5299..f623fa17 100644 --- a/reaction/game/g_cmds.c +++ b/reaction/game/g_cmds.c @@ -1778,7 +1778,7 @@ void Cmd_Reload( gentity_t *ent ) { //Check if it's already reloading //ent->client->ps.weaponstate == WEAPON_RELOADING - if (ent->client->ps.weaponstate == WEAPON_DROPPING && ent->client->numClips[WP_M3] > 0) + if (ent->client->ps.weaponstate == WEAPON_RELOADING && ent->client->numClips[WP_M3] > 0) { /* G_Printf("Time index: %d, FastReload- VirginStart: %d, WindowStart: %d, WindowEnd: %d\n", @@ -1873,7 +1873,7 @@ void Cmd_Reload( gentity_t *ent ) { //Check if it's already reloading //ent->client->ps.weaponstate == WEAPON_RELOADING - if (ent->client->ps.weaponstate == WEAPON_DROPPING && ent->client->numClips[WP_SSG3000] > 0) + if (ent->client->ps.weaponstate == WEAPON_RELOADING && ent->client->numClips[WP_SSG3000] > 0) { /* G_Printf("Time index: %d, FastReload- VirginStart: %d, WindowStart: %d, WindowEnd: %d\n", @@ -1991,9 +1991,9 @@ void Cmd_Reload( gentity_t *ent ) { } //ent->client->ps.weaponstate = WEAPON_RELOADING; - ent->client->ps.weaponstate = WEAPON_DROPPING; - ent->client->ps.torsoAnim = ( ( ent->client->ps.torsoAnim & ANIM_TOGGLEBIT ) - ^ ANIM_TOGGLEBIT ) | TORSO_DROP; + ent->client->ps.weaponstate = WEAPON_RELOADING; + //ent->client->ps.torsoAnim = ( ( ent->client->ps.torsoAnim & ANIM_TOGGLEBIT ) + // ^ ANIM_TOGGLEBIT ) | TORSO_DROP; ent->client->ps.weaponTime += delay; //Elder: at this point there should be sufficient ammo requirements to reload