diff options
author | enneract <trem.redman@gmail.com> | 2014-12-13 16:06:15 +0100 |
---|---|---|
committer | enneract <trem.redman@gmail.com> | 2014-12-13 16:06:15 +0100 |
commit | d1853e239ae258e394a516f0eeda80f430a1a328 (patch) | |
tree | c32016d8a27b10d09d2331ea5314f0ccf63346e0 /src/cgame | |
parent | 2fde9f3481239b2b2226ee812dd34ed4d8d5d6d6 (diff) |
View quake, improved Rocket Launcher assets.
(FIXME: Rocket explosion doesn't fade out)
Diffstat (limited to 'src/cgame')
-rw-r--r-- | src/cgame/cg_local.h | 8 | ||||
-rw-r--r-- | src/cgame/cg_main.c | 10 | ||||
-rw-r--r-- | src/cgame/cg_view.c | 34 | ||||
-rw-r--r-- | src/cgame/cg_weapons.c | 42 |
4 files changed, 91 insertions, 3 deletions
diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index d979046..97a21d9 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -787,6 +787,7 @@ typedef struct weaponInfoMode_s vec3_t flashDlightColor; sfxHandle_t flashSound[ 4 ]; // fast firing weapons randomly choose qboolean continuousFlash; + float flashQuake; qhandle_t missileModel; sfxHandle_t missileSound; @@ -816,6 +817,7 @@ typedef struct weaponInfoMode_s qhandle_t impactMarkSize; sfxHandle_t impactSound[ 4 ]; //random impact sound sfxHandle_t impactFleshSound[ 4 ]; //random impact sound + float impactQuake; } weaponInfoMode_t; // each WP_* weapon enum has an associated weaponInfo_t @@ -1159,6 +1161,8 @@ typedef struct int nearUsableBuildable; int nextWeaponClickTime; + + float viewQuake; } cg_t; @@ -1586,6 +1590,9 @@ extern vmCvar_t cg_chatTeamPrefix; extern vmCvar_t cg_drawBubble; extern vmCvar_t cg_BubbleZoom; +extern vmCvar_t cg_viewQuake; +extern vmCvar_t cg_viewQuakeLambda; + // // cg_main.c // @@ -1627,6 +1634,7 @@ void CG_TestModelNextSkin_f( void ); void CG_TestModelPrevSkin_f( void ); void CG_AddBufferedSound( sfxHandle_t sfx ); void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demoPlayback ); +void CG_InduceViewQuake( vec3_t src, float mag ); void CG_OffsetFirstPersonView( void ); void CG_OffsetThirdPersonView( void ); void CG_OffsetShoulderView( void ); diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c index 6be1d50..c5ad444 100644 --- a/src/cgame/cg_main.c +++ b/src/cgame/cg_main.c @@ -226,7 +226,10 @@ vmCvar_t cg_chatTeamPrefix; vmCvar_t cg_drawBubble; vmCvar_t cg_BubbleZoom; -vmCvar_t cg_EDGEFPSFIX; +vmCvar_t cg_EDGEFPSFIX; + +vmCvar_t cg_viewQuake; +vmCvar_t cg_viewQuakeLambda; typedef struct { @@ -371,7 +374,10 @@ static cvarTable_t cvarTable[ ] = // { &cg_chatTeamPrefix, "cg_chatTeamPrefix", "1", CVAR_ARCHIVE} { &cg_chatTeamPrefix, "cg_chatTeamPrefix", "1", CVAR_ARCHIVE}, - { &cg_EDGEFPSFIX, "cg_EDGEFPSFIX", "0", CVAR_ARCHIVE|CVAR_USERINFO } + { &cg_EDGEFPSFIX, "cg_EDGEFPSFIX", "0", CVAR_ARCHIVE|CVAR_USERINFO }, + + { &cg_viewQuake, "cg_viewQuake", "1", CVAR_ARCHIVE }, + { &cg_viewQuakeLambda, "cg_viewQuakeLambda", "-10", CVAR_ARCHIVE } }; static int cvarTableSize = sizeof( cvarTable ) / sizeof( cvarTable[0] ); diff --git a/src/cgame/cg_view.c b/src/cgame/cg_view.c index a0142d0..68f9287 100644 --- a/src/cgame/cg_view.c +++ b/src/cgame/cg_view.c @@ -537,6 +537,26 @@ static void CG_StepOffset( void ) #define PCLOUD_ZOOM_FREQUENCY 0.625f // 2.5s / 4 #define PCLOUD_DISORIENT_DURATION 2500 +/* +=============== +CG_InduceViewQuake +=============== +*/ + +void CG_InduceViewQuake( vec3_t src, float mag ) +{ + if( !src ) + { + cg.viewQuake += mag; + } + else + { + float dist; + + dist = Distance( src, cg.refdef.vieworg ); + cg.viewQuake += mag / dist / dist * 1000.0f; + } +} /* =============== @@ -838,6 +858,20 @@ void CG_OffsetFirstPersonView( void ) // add step offset CG_StepOffset( ); + + + // view quake + if( cg.thisFrameTeleport ) + { + cg.viewQuake = 0; + } + else + { + angles[ PITCH ] += crandom( ) * cg.viewQuake * cg_viewQuake.value; + angles[ YAW ] += crandom( ) * cg.viewQuake * cg_viewQuake.value; + + cg.viewQuake *= pow( 2, (float)cg.frametime * 1.0e-3 * cg_viewQuakeLambda.value ); + } } //====================================================================== diff --git a/src/cgame/cg_weapons.c b/src/cgame/cg_weapons.c index 21d0352..8e3b438 100644 --- a/src/cgame/cg_weapons.c +++ b/src/cgame/cg_weapons.c @@ -416,6 +416,26 @@ static qboolean CG_ParseWeaponModeSection( weaponInfoMode_t *wim, char **text_p continue; } + else if( !Q_stricmp( token, "impactQuake" ) ) + { + token = COM_Parse( text_p ); + if( !token ) + break; + + wim->impactQuake = atof( token ); + + continue; + } + else if( !Q_stricmp( token, "flashQuake" ) ) + { + token = COM_Parse( text_p ); + if( !token ) + break; + + wim->flashQuake = atof( token ); + + continue; + } else if( !Q_stricmp( token, "}" ) ) return qtrue; //reached the end of this weapon section else @@ -1827,6 +1847,14 @@ void CG_FireWeapon( centity_t *cent, weaponMode_t weaponMode ) if( wi->wim[ weaponMode ].flashSound[ c ] ) trap_S_StartSound( NULL, es->number, CHAN_WEAPON, wi->wim[ weaponMode ].flashSound[ c ] ); } + + if( cent == &cg.predictedPlayerEntity ) + { + float quake; + + quake = wi->wim[ weaponMode ].flashQuake; + CG_InduceViewQuake( NULL, quake ); + } } @@ -1843,7 +1871,7 @@ void CG_MissileHitWall( weapon_t weaponNum, weaponMode_t weaponMode, int clientN qhandle_t mark = 0; qhandle_t ps = 0; int c; - float radius = 1.0f; + float radius = 1.0f, quake; weaponInfo_t *weapon = &cg_weapons[ weaponNum ]; if( weaponMode <= WPM_NONE || weaponMode >= WPM_NUM_WEAPONMODES ) @@ -1852,6 +1880,7 @@ void CG_MissileHitWall( weapon_t weaponNum, weaponMode_t weaponMode, int clientN mark = weapon->wim[ weaponMode ].impactMark; radius = weapon->wim[ weaponMode ].impactMarkSize; ps = weapon->wim[ weaponMode ].impactParticleSystem; + quake = weapon->wim[ weaponMode ].impactQuake; if( soundType == IMPACTSOUND_FLESH ) { @@ -1905,6 +1934,11 @@ void CG_MissileHitWall( weapon_t weaponNum, weaponMode_t weaponMode, int clientN // if( radius > 0.0f ) CG_ImpactMark( mark, origin, dir, random( ) * 360, 1, 1, 1, 1, qfalse, radius, qfalse ); + + if( weaponNum == WP_LUCIFER_CANNON ) + quake *= charge; + + CG_InduceViewQuake( origin, quake ); } @@ -1918,6 +1952,7 @@ void CG_MissileHitEntity( weapon_t weaponNum, weaponMode_t weaponMode, { vec3_t normal; weaponInfo_t *weapon = &cg_weapons[ weaponNum ]; + float quake = weapon->wim[ weaponMode ].impactQuake; VectorCopy( dir, normal ); VectorInverse( normal ); @@ -1947,6 +1982,11 @@ void CG_MissileHitEntity( weapon_t weaponNum, weaponMode_t weaponMode, CG_MissileHitWall( weaponNum, weaponMode, 0, origin, dir, sound, charge ); } + + if( weaponNum == WP_LUCIFER_CANNON ) + quake *= charge; + + CG_InduceViewQuake( origin, quake ); } |