summaryrefslogtreecommitdiff
path: root/src/cgame
diff options
context:
space:
mode:
Diffstat (limited to 'src/cgame')
-rw-r--r--src/cgame/cg_animation.c101
-rw-r--r--src/cgame/cg_buildable.c4
-rw-r--r--src/cgame/cg_draw.c37
-rw-r--r--src/cgame/cg_local.h1
-rw-r--r--src/cgame/cg_main.c8
-rw-r--r--src/cgame/cg_servercmds.c12
-rw-r--r--src/cgame/cg_view.c2
7 files changed, 141 insertions, 24 deletions
diff --git a/src/cgame/cg_animation.c b/src/cgame/cg_animation.c
new file mode 100644
index 00000000..5295998e
--- /dev/null
+++ b/src/cgame/cg_animation.c
@@ -0,0 +1,101 @@
+/*
+ * Portions Copyright (C) 2000-2001 Tim Angus
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the OSML - Open Source Modification License v1.0 as
+ * described in the file COPYING which is distributed with this source
+ * code.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#include "cg_local.h"
+
+/*
+===============
+CG_RunLerpFrame
+
+Sets cg.snap, cg.oldFrame, and cg.backlerp
+cg.time should be between oldFrameTime and frameTime after exit
+===============
+*/
+void CG_RunLerpFrame( lerpFrame_t *lf )
+{
+ int f, numFrames;
+ animation_t *anim;
+
+ // debugging tool to get no animations
+ if( cg_animSpeed.integer == 0 )
+ {
+ lf->oldFrame = lf->frame = lf->backlerp = 0;
+ return;
+ }
+
+ // if we have passed the current frame, move it to
+ // oldFrame and calculate a new frame
+ if( cg.time >= lf->frameTime )
+ {
+ lf->oldFrame = lf->frame;
+ lf->oldFrameTime = lf->frameTime;
+
+ // get the next frame based on the animation
+ anim = lf->animation;
+ if( !anim->frameLerp )
+ return; // shouldn't happen
+
+ if( cg.time < lf->animationTime )
+ lf->frameTime = lf->animationTime; // initial lerp
+ else
+ lf->frameTime = lf->oldFrameTime + anim->frameLerp;
+
+ f = ( lf->frameTime - lf->animationTime ) / anim->frameLerp;
+ numFrames = anim->numFrames;
+ if( anim->flipflop )
+ numFrames *= 2;
+
+ if( f >= numFrames )
+ {
+ f -= numFrames;
+ if( anim->loopFrames )
+ {
+ f %= anim->loopFrames;
+ f += anim->numFrames - anim->loopFrames;
+ }
+ else
+ {
+ f = numFrames - 1;
+ // the animation is stuck at the end, so it
+ // can immediately transition to another sequence
+ lf->frameTime = cg.time;
+ }
+ }
+
+ if( anim->reversed )
+ lf->frame = anim->firstFrame + anim->numFrames - 1 - f;
+ else if( anim->flipflop && f >= anim->numFrames )
+ lf->frame = anim->firstFrame + anim->numFrames - 1 - ( f % anim->numFrames );
+ else
+ lf->frame = anim->firstFrame + f;
+
+ if( cg.time > lf->frameTime )
+ {
+ lf->frameTime = cg.time;
+ if( cg_debugAnim.integer )
+ CG_Printf( "Clamp lf->frameTime\n" );
+ }
+ }
+
+ if( lf->frameTime > cg.time + 200 )
+ lf->frameTime = cg.time;
+
+ if( lf->oldFrameTime > cg.time )
+ lf->oldFrameTime = cg.time;
+
+ // calculate current lerp value
+ if( lf->frameTime == lf->oldFrameTime )
+ lf->backlerp = 0;
+ else
+ lf->backlerp = 1.0 - (float)( cg.time - lf->oldFrameTime ) / ( lf->frameTime - lf->oldFrameTime );
+}
diff --git a/src/cgame/cg_buildable.c b/src/cgame/cg_buildable.c
index 954b1aa3..39b6d959 100644
--- a/src/cgame/cg_buildable.c
+++ b/src/cgame/cg_buildable.c
@@ -610,12 +610,12 @@ static void CG_PositionAndOrientateBuildable( const vec3_t angles, const vec3_t
VectorMA( inOrigin, -TRACE_DEPTH, normal, end );
VectorMA( inOrigin, 1.0f, normal, start );
- CG_CapTrace( &tr, start, mins, maxs, end, skipNumber, MASK_PLAYERSOLID );
+ CG_CapTrace( &tr, start, mins, maxs, end, skipNumber, MASK_SOLID );
if( tr.fraction == 1.0f )
{
//erm we missed completely - try again with a box trace
- CG_Trace( &tr, start, mins, maxs, end, skipNumber, MASK_PLAYERSOLID );
+ CG_Trace( &tr, start, mins, maxs, end, skipNumber, MASK_SOLID );
}
VectorMA( inOrigin, tr.fraction * -TRACE_DEPTH, normal, outOrigin );
diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c
index 40a49358..38af5c76 100644
--- a/src/cgame/cg_draw.c
+++ b/src/cgame/cg_draw.c
@@ -3222,8 +3222,9 @@ static void CG_Draw2D( void )
CG_DrawCenterString( );
}
-#define PAINBLEND_BORDER_W 128.0f
-#define PAINBLEND_BORDER_H 96.0f
+#define PAINBLEND_BORDER_W 0.15f
+#define PAINBLEND_BORDER_H 0.07f
+
/*
===============
CG_PainBlend
@@ -3234,7 +3235,7 @@ static void CG_PainBlend( void )
vec4_t color;
int damage;
float damageAsFracOfMax;
- qhandle_t shader = cgs.media.whiteShader;
+ qhandle_t shader = cgs.media.viewBloodShader;
float x, y, w, h;
damage = cg.lastHealth - cg.snap->ps.stats[ STAT_HEALTH ];
@@ -3283,38 +3284,38 @@ static void CG_PainBlend( void )
//left
x = 0.0f; y = 0.0f;
- w = PAINBLEND_BORDER_W; h = 480.0f;
+ w = PAINBLEND_BORDER_W * 640.0f; h = 480.0f;
CG_AdjustFrom640( &x, &y, &w, &h );
trap_R_DrawStretchPic( x, y, w, h,
- 0.0f, 0.0f,
- PAINBLEND_BORDER_W / 640.0f, 1.0f,
+ cg_painBlendZoom.value, cg_painBlendZoom.value,
+ cg_painBlendZoom.value + PAINBLEND_BORDER_W, 1.0f - cg_painBlendZoom.value,
shader );
//right
- x = 640.0f - PAINBLEND_BORDER_W; y = 0.0f;
- w = PAINBLEND_BORDER_W; h = 480.0f;
+ x = 640.0f - ( PAINBLEND_BORDER_W * 640.0f ); y = 0.0f;
+ w = PAINBLEND_BORDER_W * 640.0f; h = 480.0f;
CG_AdjustFrom640( &x, &y, &w, &h );
trap_R_DrawStretchPic( x, y, w, h,
- ( 640.0f - PAINBLEND_BORDER_W ) / 640.0f, 0.0f,
- 1.0f, 1.0f,
+ 1.0f - cg_painBlendZoom.value - PAINBLEND_BORDER_W, cg_painBlendZoom.value,
+ 1.0f - cg_painBlendZoom.value, 1.0f - cg_painBlendZoom.value,
shader );
//top
- x = PAINBLEND_BORDER_W; y = 0.0f;
- w = 640.0f - 2 * PAINBLEND_BORDER_W; h = PAINBLEND_BORDER_H;
+ x = PAINBLEND_BORDER_W * 640.0f; y = 0.0f;
+ w = 640.0f - ( 2 * PAINBLEND_BORDER_W * 640.0f ); h = PAINBLEND_BORDER_H * 480.0f;
CG_AdjustFrom640( &x, &y, &w, &h );
trap_R_DrawStretchPic( x, y, w, h,
- PAINBLEND_BORDER_W / 640.0f, 0.0f,
- ( 640.0f - PAINBLEND_BORDER_W ) / 640.0f, PAINBLEND_BORDER_H / 480.0f,
+ cg_painBlendZoom.value + PAINBLEND_BORDER_W, cg_painBlendZoom.value,
+ 1.0f - cg_painBlendZoom.value - PAINBLEND_BORDER_W, cg_painBlendZoom.value + PAINBLEND_BORDER_H,
shader );
//bottom
- x = PAINBLEND_BORDER_W; y = 480.0f - PAINBLEND_BORDER_H;
- w = 640.0f - 2 * PAINBLEND_BORDER_W; h = PAINBLEND_BORDER_H;
+ x = PAINBLEND_BORDER_W * 640.0f; y = 480.0f - ( PAINBLEND_BORDER_H * 480.0f );
+ w = 640.0f - ( 2 * PAINBLEND_BORDER_W * 640.0f ); h = PAINBLEND_BORDER_H * 480.0f;
CG_AdjustFrom640( &x, &y, &w, &h );
trap_R_DrawStretchPic( x, y, w, h,
- PAINBLEND_BORDER_W / 640.0f, ( 480.0f - PAINBLEND_BORDER_H ) / 480.0f,
- ( 640.0f - PAINBLEND_BORDER_W ) / 640.0f, 1.0f,
+ cg_painBlendZoom.value + PAINBLEND_BORDER_W, 1.0f - cg_painBlendZoom.value - PAINBLEND_BORDER_H,
+ 1.0f - cg_painBlendZoom.value - PAINBLEND_BORDER_W, 1.0f - cg_painBlendZoom.value,
shader );
trap_R_SetColor( NULL );
diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h
index c42e1efa..7ee70554 100644
--- a/src/cgame/cg_local.h
+++ b/src/cgame/cg_local.h
@@ -1475,6 +1475,7 @@ extern vmCvar_t cg_painBlendUpRate;
extern vmCvar_t cg_painBlendDownRate;
extern vmCvar_t cg_painBlendMax;
extern vmCvar_t cg_painBlendScale;
+extern vmCvar_t cg_painBlendZoom;
//TA: hack to get class an carriage through to UI module
extern vmCvar_t ui_currentClass;
diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c
index ebc5c1e8..767aabef 100644
--- a/src/cgame/cg_main.c
+++ b/src/cgame/cg_main.c
@@ -208,6 +208,7 @@ vmCvar_t cg_painBlendUpRate;
vmCvar_t cg_painBlendDownRate;
vmCvar_t cg_painBlendMax;
vmCvar_t cg_painBlendScale;
+vmCvar_t cg_painBlendZoom;
//TA: hack to get class and carriage through to UI module
vmCvar_t ui_currentClass;
@@ -317,9 +318,10 @@ static cvarTable_t cvarTable[ ] =
{ &cg_hudFiles, "cg_hudFiles", "ui/hud.txt", CVAR_ARCHIVE},
{ &cg_painBlendUpRate, "cg_painBlendUpRate", "10.0", 0 },
- { &cg_painBlendDownRate, "cg_painBlendDownRate", "1.0", 0 },
- { &cg_painBlendMax, "cg_painBlendMax", "0.5", 0 },
+ { &cg_painBlendDownRate, "cg_painBlendDownRate", "0.5", 0 },
+ { &cg_painBlendMax, "cg_painBlendMax", "0.7", 0 },
{ &cg_painBlendScale, "cg_painBlendScale", "7.0", 0 },
+ { &cg_painBlendZoom, "cg_painBlendZoom", "0.18", 0 },
{ &ui_currentClass, "ui_currentClass", "0", 0 },
{ &ui_carriage, "ui_carriage", "", 0 },
@@ -757,7 +759,7 @@ static void CG_RegisterGraphics( void )
for( i = 0; i < 11; i++ )
cgs.media.numberShaders[ i ] = trap_R_RegisterShader( sb_nums[ i ] );
- cgs.media.viewBloodShader = trap_R_RegisterShader( "viewBloodBlend" ); //FIXME
+ cgs.media.viewBloodShader = trap_R_RegisterShader( "gfx/damage/fullscreen_painblend" ); //FIXME
cgs.media.connectionShader = trap_R_RegisterShader( "disconnected" ); //FIXME?
diff --git a/src/cgame/cg_servercmds.c b/src/cgame/cg_servercmds.c
index 24a869a0..71fbaac9 100644
--- a/src/cgame/cg_servercmds.c
+++ b/src/cgame/cg_servercmds.c
@@ -800,6 +800,18 @@ void CG_Menu( int menu )
break;
+ case MN_A_HOVEL:
+ if( !cg_disableWarningDialogs.integer )
+ {
+ trap_Cvar_Set( "ui_dialog", "There can only be one Hovel. Destroy the existing one if you "
+ "wish to move it." );
+ trap_SendConsoleCommand( "menu tremulous_alien_dialog\n" );
+ }
+ else
+ CG_Printf( "There can only be one Hovel\n" );
+
+ break;
+
case MN_A_NOASSERT:
if( !cg_disableWarningDialogs.integer )
{
diff --git a/src/cgame/cg_view.c b/src/cgame/cg_view.c
index ec296c04..324646c9 100644
--- a/src/cgame/cg_view.c
+++ b/src/cgame/cg_view.c
@@ -532,7 +532,7 @@ static void CG_OffsetFirstPersonView( void )
AngleVectors( angles, forward, NULL, NULL );
VectorNormalize( forward );
- fraction1 = (float)( cg.time - cg.weapon2Time ) / (float)LEVEL3_POUNCE_TIME;
+ fraction1 = (float)( cg.time - cg.weapon2Time ) / (float)LEVEL3_POUNCE_CHARGE_TIME;
if( fraction1 > 1.0f )
fraction1 = 1.0f;