summaryrefslogtreecommitdiff
path: root/src/cgame
diff options
context:
space:
mode:
authorRoman Tetelman <kevlarman@gmail.com>2009-10-03 12:38:09 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:16:07 +0000
commit5ac8f1a7907d7c4d9ddd5ae30ddaff872ff32edd (patch)
tree4d76d153295a4bbb670a081ce207cedc3d404209 /src/cgame
parent919e7694290b4ac307034a9e0bfd4e8ab41c4663 (diff)
* New zap (fixes #40)
FIXME: currently limited to 3 targets due to netcode restrictions FIXME: this code could probably use some general cleanup as well
Diffstat (limited to 'src/cgame')
-rw-r--r--src/cgame/cg_draw.c1
-rw-r--r--src/cgame/cg_ents.c105
2 files changed, 75 insertions, 31 deletions
diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c
index 9469410f..82d0aff2 100644
--- a/src/cgame/cg_draw.c
+++ b/src/cgame/cg_draw.c
@@ -1905,7 +1905,6 @@ static void CG_DrawLagometer( rectDef_t *rect, float text_x, float text_y,
int color;
vec4_t adjustedColor;
float vscale;
- vec4_t white = { 1.0f, 1.0f, 1.0f, 1.0f };
char *ping;
if( cg.snap->ps.pm_type == PM_INTERMISSION )
diff --git a/src/cgame/cg_ents.c b/src/cgame/cg_ents.c
index 54409aee..1cdcfde7 100644
--- a/src/cgame/cg_ents.c
+++ b/src/cgame/cg_ents.c
@@ -216,8 +216,6 @@ Add continuous entity effects, like local entity emission and lighting
*/
static void CG_EntityEffects( centity_t *cent )
{
- int i;
-
// update sound origins
CG_SetEntitySoundPosition( cent );
@@ -253,7 +251,7 @@ static void CG_EntityEffects( centity_t *cent )
if( CG_IsTrailSystemValid( &cent->muzzleTS ) )
{
- //FIXME hack to prevent tesla trails reaching too far
+ //FIXME hack to prevent tesla trails reaching too far
if( cent->currentState.eType == ET_BUILDABLE )
{
vec3_t front, back;
@@ -268,33 +266,6 @@ static void CG_EntityEffects( centity_t *cent )
if( cg.time > cent->muzzleTSDeathTime && CG_IsTrailSystemValid( &cent->muzzleTS ) )
CG_DestroyTrailSystem( &cent->muzzleTS );
}
-
-
- if( cent->currentState.eType == ET_PLAYER )
- {
- centity_t *pcent = cent;;
-
- // predicted entity doesn't have local cgame vars
- if( cent == &cg.predictedPlayerEntity )
- pcent = &cg_entities[ cg.clientNum ];
-
- for( i = 0; i <= 2; i++ )
- {
- if( CG_IsTrailSystemValid( &pcent->level2ZapTS[ i ] ) )
- {
- vec3_t front, back;
-
- CG_AttachmentPoint( &pcent->level2ZapTS[ i ]->frontAttachment, front );
- CG_AttachmentPoint( &pcent->level2ZapTS[ i ]->backAttachment, back );
-
- if( cg.time - pcent->level2ZapTime > 100 ||
- Distance( front, back ) > LEVEL2_AREAZAP_CUTOFF )
- {
- CG_DestroyTrailSystem( &pcent->level2ZapTS[ i ] );
- }
- }
- }
- }
}
@@ -831,6 +802,63 @@ void CG_LinkLocation( centity_t *cent )
/*
=========================
+CG_Lev2ZapChain
+=========================
+*/
+static void CG_Lev2ZapChain( centity_t *cent )
+{
+ int i;
+ entityState_t *es;
+ centity_t *source = NULL, *target = NULL;
+
+ es = &cent->currentState;
+
+ //FIXME: find a better way to send zap targets
+ for( i = 0; i <= 2; i++ )
+ {
+ switch( i )
+ {
+ case 0:
+ if( es->time <= 0 )
+ continue;
+
+ source = &cg_entities[ es->misc ];
+ target = &cg_entities[ es->time ];
+ break;
+
+ case 1:
+ if( es->time2 <= 0 )
+ continue;
+
+ source = &cg_entities[ es->time ];
+ target = &cg_entities[ es->time2 ];
+ break;
+
+ case 2:
+ if( es->constantLight <= 0 )
+ continue;
+
+ source = &cg_entities[ es->time ];
+ target = &cg_entities[ es->constantLight ];
+ break;
+
+ }
+
+ if( !CG_IsTrailSystemValid( &cent->level2ZapTS[ i ] ) )
+ cent->level2ZapTS[ i ] = CG_SpawnNewTrailSystem( cgs.media.level2ZapTS );
+
+ if( CG_IsTrailSystemValid( &cent->level2ZapTS[ i ] ) )
+ {
+ CG_SetAttachmentCent( &cent->level2ZapTS[ i ]->frontAttachment, source );
+ CG_SetAttachmentCent( &cent->level2ZapTS[ i ]->backAttachment, target );
+ CG_AttachToCent( &cent->level2ZapTS[ i ]->frontAttachment );
+ CG_AttachToCent( &cent->level2ZapTS[ i ]->backAttachment );
+ }
+ }
+}
+
+/*
+=========================
CG_AdjustPositionForMover
Also called by client movement prediction code
@@ -1025,8 +1053,21 @@ CG_CEntityPVSLeave
*/
static void CG_CEntityPVSLeave( centity_t *cent )
{
+ int i;
+ entityState_t *es = &cent->currentState;
+
if( cg_debugPVS.integer )
CG_Printf( "Entity %d left PVS\n", cent->currentState.number );
+ switch( es->eType )
+ {
+ case ET_LEV2_ZAP_CHAIN:
+ for( i = 0; i <= 2; i++ )
+ {
+ if( CG_IsTrailSystemValid( &cent->level2ZapTS[ i ] ) )
+ CG_DestroyTrailSystem( &cent->level2ZapTS[ i ] );
+ }
+ break;
+ }
}
@@ -1111,6 +1152,10 @@ static void CG_AddCEntity( centity_t *cent )
CG_LightFlare( cent );
break;
+ case ET_LEV2_ZAP_CHAIN:
+ CG_Lev2ZapChain( cent );
+ break;
+
case ET_LOCATION:
CG_LinkLocation( cent );
break;