diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cgame/cg_local.h | 5 | ||||
-rw-r--r-- | src/cgame/cg_main.c | 10 | ||||
-rw-r--r-- | src/cgame/cg_view.c | 103 | ||||
-rw-r--r-- | src/game/bg_misc.c | 73 | ||||
-rw-r--r-- | src/game/bg_public.h | 1 |
5 files changed, 68 insertions, 124 deletions
diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index c1e5dada..68895d72 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -1475,13 +1475,10 @@ extern vmCvar_t cg_tracerWidth; extern vmCvar_t cg_tracerLength; extern vmCvar_t cg_autoswitch; extern vmCvar_t cg_thirdPerson; +extern vmCvar_t cg_thirdPersonAngle; extern vmCvar_t cg_thirdPersonShoulderViewMode; extern vmCvar_t cg_thirdPersonPitchFollow; extern vmCvar_t cg_thirdPersonRange; -extern vmCvar_t cg_shoulderViewOverride; -extern vmCvar_t cg_shoulderViewUp; -extern vmCvar_t cg_shoulderViewRight; -extern vmCvar_t cg_shoulderViewForward; extern vmCvar_t cg_stereoSeparation; extern vmCvar_t cg_lagometer; extern vmCvar_t cg_synchronousClients; diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c index 44edf153..3fa458d1 100644 --- a/src/cgame/cg_main.c +++ b/src/cgame/cg_main.c @@ -141,13 +141,10 @@ vmCvar_t cg_tracerWidth; vmCvar_t cg_tracerLength; vmCvar_t cg_autoswitch; vmCvar_t cg_thirdPerson; +vmCvar_t cg_thirdPersonAngle; vmCvar_t cg_thirdPersonShoulderViewMode; vmCvar_t cg_thirdPersonPitchFollow; vmCvar_t cg_thirdPersonRange; -vmCvar_t cg_shoulderViewOverride; -vmCvar_t cg_shoulderViewUp; -vmCvar_t cg_shoulderViewRight; -vmCvar_t cg_shoulderViewForward; vmCvar_t cg_stereoSeparation; vmCvar_t cg_lagometer; vmCvar_t cg_synchronousClients; @@ -268,12 +265,9 @@ static cvarTable_t cvarTable[ ] = { &cg_tracerLength, "cg_tracerlength", "100", CVAR_CHEAT }, { &cg_thirdPersonRange, "cg_thirdPersonRange", "75", CVAR_ARCHIVE }, { &cg_thirdPerson, "cg_thirdPerson", "0", CVAR_CHEAT }, + { &cg_thirdPersonAngle, "cg_thirdPersonAngle", "0", CVAR_CHEAT }, { &cg_thirdPersonPitchFollow, "cg_thirdPersonPitchFollow", "0", 0 }, { &cg_thirdPersonShoulderViewMode, "cg_thirdPersonShoulderViewMode", "1", CVAR_ARCHIVE }, - { &cg_shoulderViewOverride, "cg_shoulderViewOverride", "0", 0 }, - { &cg_shoulderViewUp, "cg_shoulderViewUp", "0", 0 }, - { &cg_shoulderViewRight, "cg_shoulderViewRight", "0", 0 }, - { &cg_shoulderViewForward, "cg_shoulderViewForward", "0", 0 }, { &cg_stats, "cg_stats", "0", 0 }, { &cg_drawFriend, "cg_drawFriend", "1", CVAR_ARCHIVE }, { &cg_teamChatsOnly, "cg_teamChatsOnly", "0", CVAR_ARCHIVE }, diff --git a/src/cgame/cg_view.c b/src/cgame/cg_view.c index 964fa705..06f621f5 100644 --- a/src/cgame/cg_view.c +++ b/src/cgame/cg_view.c @@ -402,6 +402,8 @@ void CG_OffsetThirdPersonView( void ) } } + rotationAngles[ YAW ] -= cg_thirdPersonAngle.value; + // Move the camera range distance back. AngleVectors( rotationAngles, forward, right, up ); VectorCopy( cg.refdef.vieworg, view ); @@ -449,87 +451,26 @@ CG_OffsetShoulderView */ void CG_OffsetShoulderView( void ) { - int i; - int cmdNum; - usercmd_t cmd, oldCmd; - vec3_t rotationAngles; - vec3_t axis[ 3 ], rotaxis[ 3 ]; - float deltaMousePitch; - static float mousePitch; - vec3_t forward, right, up; - float classFwdOffset = 0.0f, classUpOffset = 0.0f, classRightOffset = 0.0f; + int i; + int cmdNum; + usercmd_t cmd, oldCmd; + vec3_t rotationAngles; + vec3_t axis[ 3 ], rotaxis[ 3 ]; + float deltaMousePitch; + static float mousePitch; + vec3_t forward, right, up; + classConfig_t* classConfig; + + // Ignore following pitch; it's too jerky otherwise. + if( !cg_thirdPersonPitchFollow.integer ) + cg.refdefViewAngles[ PITCH ] = 0.0f; AngleVectors( cg.refdefViewAngles, forward, right, up ); - // Set a nice view by offsetting from vieworigin to get to the "shoulder" - // for each class. - // FIXME: These need to not be hard-coded so hackishly - switch( cg.snap->ps.stats[ STAT_CLASS ] ) - { - case PCL_ALIEN_BUILDER0: - case PCL_ALIEN_BUILDER0_UPG: - classFwdOffset = -8.0f; - classRightOffset = 15.0f; - classUpOffset = 13.0f; - break; - case PCL_ALIEN_LEVEL0: - classFwdOffset = -5.0f; - classRightOffset = 0.0f; - classUpOffset = 17.0f; - break; - case PCL_ALIEN_LEVEL1: - case PCL_ALIEN_LEVEL1_UPG: - classFwdOffset = -10.0f; - classRightOffset = 0.0f; - classUpOffset = 18.0f; - break; - case PCL_ALIEN_LEVEL2: - case PCL_ALIEN_LEVEL2_UPG: - classFwdOffset = 0.0f; - classRightOffset = 12.0f; - classUpOffset = 5.0f; - break; - case PCL_ALIEN_LEVEL3: - classFwdOffset = -10.0f; - classRightOffset = 15.0f; - classUpOffset = 8.0f; - break; - case PCL_ALIEN_LEVEL3_UPG: - classFwdOffset = -10.0f; - classRightOffset = 17.0f; - classUpOffset = 12.0f; - break; - case PCL_ALIEN_LEVEL4: - classFwdOffset = -20.0f; - classRightOffset = -25.0f; - classUpOffset = 30.0f; - break; - case PCL_HUMAN: - classFwdOffset = -10.0f; - classRightOffset = 15.0f; - classUpOffset = 0.0f; - break; - case PCL_HUMAN_BSUIT: - classFwdOffset = -30.0f; - classRightOffset = 25.0f; - classUpOffset = -2.0f; - break; - } - - // The override is temporary so that people can help find good offset positions for me. - // It will not remain in final code. - if( !cg_shoulderViewOverride.integer ) - { - VectorMA( cg.refdef.vieworg, classFwdOffset, forward, cg.refdef.vieworg ); - VectorMA( cg.refdef.vieworg, classUpOffset, up, cg.refdef.vieworg ); - VectorMA( cg.refdef.vieworg, classRightOffset, right, cg.refdef.vieworg ); - } - else - { - VectorMA( cg.refdef.vieworg, cg_shoulderViewForward.value, forward, cg.refdef.vieworg ); - VectorMA( cg.refdef.vieworg, cg_shoulderViewUp.value, up, cg.refdef.vieworg ); - VectorMA( cg.refdef.vieworg, cg_shoulderViewRight.value, right, cg.refdef.vieworg ); - } + classConfig = BG_ClassConfig( cg.snap->ps.stats[ STAT_CLASS ] ); + VectorMA( cg.refdef.vieworg, classConfig->shoulderOffsets[ 0 ], forward, cg.refdef.vieworg ); + VectorMA( cg.refdef.vieworg, classConfig->shoulderOffsets[ 1 ], right, cg.refdef.vieworg ); + VectorMA( cg.refdef.vieworg, classConfig->shoulderOffsets[ 2 ], up, cg.refdef.vieworg ); // If someone is playing like this, the rest is already taken care of // so just get the firstperson effects and leave. @@ -554,11 +495,7 @@ void CG_OffsetShoulderView( void ) // Handle pitch. rotationAngles[ PITCH ] = mousePitch; - // Ignore following pitch; it's too jerky otherwise. - if( cg_thirdPersonPitchFollow.integer ) - mousePitch += cg.refdefViewAngles[ PITCH ]; - - rotationAngles[ PITCH ] = AngleNormalize180( rotationAngles[ PITCH ] ); + rotationAngles[ PITCH ] = AngleNormalize180( rotationAngles[ PITCH ] + AngleNormalize180( cg.refdefViewAngles[ PITCH ] ) ); if( rotationAngles [ PITCH ] < -90.0f ) rotationAngles [ PITCH ] = -90.0f; if( rotationAngles [ PITCH ] > 90.0f ) rotationAngles [ PITCH ] = 90.0f; diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index 5adbcd33..f41e07b5 100644 --- a/src/game/bg_misc.c +++ b/src/game/bg_misc.c @@ -1440,20 +1440,21 @@ static qboolean BG_ParseClassFile( const char *filename, classConfig_t *cc ) int defined = 0; enum { - MODEL = 1 << 0, - SKIN = 1 << 1, - HUD = 1 << 2, - MODELSCALE = 1 << 3, - SHADOWSCALE = 1 << 4, - MINS = 1 << 5, - MAXS = 1 << 6, - DEADMINS = 1 << 7, - DEADMAXS = 1 << 8, - CROUCHMAXS = 1 << 9, - VIEWHEIGHT = 1 << 10, - CVIEWHEIGHT = 1 << 11, - ZOFFSET = 1 << 12, - NAME = 1 << 13 + MODEL = 1 << 0, + SKIN = 1 << 1, + HUD = 1 << 2, + MODELSCALE = 1 << 3, + SHADOWSCALE = 1 << 4, + MINS = 1 << 5, + MAXS = 1 << 6, + DEADMINS = 1 << 7, + DEADMAXS = 1 << 8, + CROUCHMAXS = 1 << 9, + VIEWHEIGHT = 1 << 10, + CVIEWHEIGHT = 1 << 11, + ZOFFSET = 1 << 12, + NAME = 1 << 13, + SHOULDEROFFSETS = 1 << 14 }; // load the file @@ -1662,27 +1663,41 @@ static qboolean BG_ParseClassFile( const char *filename, classConfig_t *cc ) defined |= NAME; continue; } + else if( !Q_stricmp( token, "shoulderOffsets" ) ) + { + for( i = 0; i <= 2; i++ ) + { + token = COM_Parse( &text_p ); + if( !token ) + break; + + cc->shoulderOffsets[ i ] = atof( token ); + } + defined |= SHOULDEROFFSETS; + continue; + } Com_Printf( S_COLOR_RED "ERROR: unknown token '%s'\n", token ); return qfalse; } - if( !( defined & MODEL ) ) token = "model"; - else if( !( defined & SKIN ) ) token = "skin"; - else if( !( defined & HUD ) ) token = "hud"; - else if( !( defined & MODELSCALE ) ) token = "modelScale"; - else if( !( defined & SHADOWSCALE ) ) token = "shadowScale"; - else if( !( defined & MINS ) ) token = "mins"; - else if( !( defined & MAXS ) ) token = "maxs"; - else if( !( defined & DEADMINS ) ) token = "deadMins"; - else if( !( defined & DEADMAXS ) ) token = "deadMaxs"; - else if( !( defined & CROUCHMAXS ) ) token = "crouchMaxs"; - else if( !( defined & VIEWHEIGHT ) ) token = "viewheight"; - else if( !( defined & CVIEWHEIGHT ) ) token = "crouchViewheight"; - else if( !( defined & ZOFFSET ) ) token = "zOffset"; - else if( !( defined & NAME ) ) token = "name"; - else token = ""; + if( !( defined & MODEL ) ) token = "model"; + else if( !( defined & SKIN ) ) token = "skin"; + else if( !( defined & HUD ) ) token = "hud"; + else if( !( defined & MODELSCALE ) ) token = "modelScale"; + else if( !( defined & SHADOWSCALE ) ) token = "shadowScale"; + else if( !( defined & MINS ) ) token = "mins"; + else if( !( defined & MAXS ) ) token = "maxs"; + else if( !( defined & DEADMINS ) ) token = "deadMins"; + else if( !( defined & DEADMAXS ) ) token = "deadMaxs"; + else if( !( defined & CROUCHMAXS ) ) token = "crouchMaxs"; + else if( !( defined & VIEWHEIGHT ) ) token = "viewheight"; + else if( !( defined & CVIEWHEIGHT ) ) token = "crouchViewheight"; + else if( !( defined & ZOFFSET ) ) token = "zOffset"; + else if( !( defined & NAME ) ) token = "name"; + else if( !( defined & SHOULDEROFFSETS ) ) token = "shoulderOffsets"; + else token = ""; if( strlen( token ) > 0 ) { diff --git a/src/game/bg_public.h b/src/game/bg_public.h index e1654ef8..1b9c3e2f 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -965,6 +965,7 @@ typedef struct int viewheight; int crouchViewheight; float zOffset; + vec3_t shoulderOffsets; } classConfig_t; //stages |