summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cgame/cg_ents.c12
-rw-r--r--src/game/bg_misc.c43
-rw-r--r--src/game/bg_public.h4
-rw-r--r--src/game/g_weapon.c49
4 files changed, 44 insertions, 64 deletions
diff --git a/src/cgame/cg_ents.c b/src/cgame/cg_ents.c
index f2c4d8a0..8f872f31 100644
--- a/src/cgame/cg_ents.c
+++ b/src/cgame/cg_ents.c
@@ -810,19 +810,19 @@ static void CG_Lev2ZapChain( centity_t *cent )
int i;
entityState_t *es;
centity_t *source = NULL, *target = NULL, *attacker = NULL;
- int targets[ LEVEL2_AREAZAP_MAX_TARGETS + 1 ];
+ int targets[ LEVEL2_AREAZAP_MAX_TARGETS ], creator;
es = &cent->currentState;
- BG_UnpackZapTargets( es, targets, LEVEL2_AREAZAP_MAX_TARGETS + 1 );
- attacker = &cg_entities[ targets[ 0 ] ];
+ BG_UnpackZapTargets( es, &creator, targets, LEVEL2_AREAZAP_MAX_TARGETS + 1 );
+ attacker = &cg_entities[ creator ];
- for( i = 1; i < LEVEL2_AREAZAP_MAX_TARGETS + 1; i++ )
+ for( i = 0; i < LEVEL2_AREAZAP_MAX_TARGETS; i++ )
{
- if( i == 1 )
+ if( i == 0 )
source = attacker;
else
- source = &cg_entities[ targets[ 1 ] ];
+ source = &cg_entities[ targets[ 0 ] ];
if( targets[ i ] == ENTITYNUM_NONE )
continue;
diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c
index d969fea1..79bdb09f 100644
--- a/src/game/bg_misc.c
+++ b/src/game/bg_misc.c
@@ -3466,10 +3466,11 @@ int atoi_neg( char *token, qboolean allowNegative )
===============
BG_PackZapTargets
-pack up to 12 entityNums into an entityState_t
+pack up to 12 targets into an entityState_t
===============
*/
-void BG_PackZapTargets( entityState_t *es, int *entityNums, int count )
+//FIXME: magic - 1 and count makes no sense
+void BG_PackZapTargets( entityState_t *es, int creator, const int *targets, int count )
{
int i;
es->misc = es->time = es->time2 = es->constantLight = 0;
@@ -3477,13 +3478,20 @@ void BG_PackZapTargets( entityState_t *es, int *entityNums, int count )
{
int entityNum = ENTITYNUM_NONE;
if( i < count )
- entityNum = entityNums[i];
+ {
+ if( i == 0 )
+ entityNum = creator;
+ else
+ entityNum = targets[ i - 1 ];
+ }
+
if( entityNum & ~(GENTITYNUM_MASK) )
{
- Com_Printf("Warning: BG_PackZapTargets: entityNums[%d] (%d) doesn't fit in %d bits, using ENTITYNUM_NONE",
- i, entityNums[i], GENTITYNUM_BITS);
+ Com_Printf("Warning: BG_PackZapTargets: targets[%d] (%d) doesn't fit in %d bits, using ENTITYNUM_NONE\n",
+ i, targets[i], GENTITYNUM_BITS);
entityNum = ENTITYNUM_NONE;
}
+
switch( i )
{
case 0:
@@ -3523,10 +3531,10 @@ void BG_PackZapTargets( entityState_t *es, int *entityNums, int count )
===============
BG_UnpackZapTargets
-unpacks the 12 entityNums in an entityState_t
+unpacks the 12 targets in an entityState_t
===============
*/
-void BG_UnpackZapTargets( entityState_t *es, int *entityNums, int count )
+void BG_UnpackZapTargets( entityState_t *es, int *creator, int *targets, int count )
{
int i;
for( i = 0; i < count; i++ )
@@ -3534,34 +3542,35 @@ void BG_UnpackZapTargets( entityState_t *es, int *entityNums, int count )
switch( i )
{
case 0:
- entityNums[i] = es->misc & GENTITYNUM_MASK;
+ if(creator)
+ *creator = es->misc & GENTITYNUM_MASK;
break;
case 1:
- entityNums[i] = es->time & GENTITYNUM_MASK;
+ targets[ i - 1 ] = es->time & GENTITYNUM_MASK;
break;
case 2:
- entityNums[i] = (es->time >> GENTITYNUM_BITS) & GENTITYNUM_MASK;
+ targets[ i - 1 ] = (es->time >> GENTITYNUM_BITS) & GENTITYNUM_MASK;
break;
case 3:
- entityNums[i] = (es->time >> (GENTITYNUM_BITS * 2)) & GENTITYNUM_MASK;
+ targets[ i - 1 ] = (es->time >> (GENTITYNUM_BITS * 2)) & GENTITYNUM_MASK;
break;
case 4:
- entityNums[i] = es->time2 & GENTITYNUM_MASK;
+ targets[ i - 1 ] = es->time2 & GENTITYNUM_MASK;
break;
case 5:
- entityNums[i] = (es->time2 >> GENTITYNUM_BITS) & GENTITYNUM_MASK;
+ targets[ i - 1 ] = (es->time2 >> GENTITYNUM_BITS) & GENTITYNUM_MASK;
break;
case 6:
- entityNums[i] = (es->time2 >> (GENTITYNUM_BITS * 2)) & GENTITYNUM_MASK;
+ targets[ i - 1 ] = (es->time2 >> (GENTITYNUM_BITS * 2)) & GENTITYNUM_MASK;
break;
case 7:
- entityNums[i] = es->constantLight & GENTITYNUM_MASK;
+ targets[ i - 1 ] = es->constantLight & GENTITYNUM_MASK;
break;
case 8:
- entityNums[i] = (es->constantLight >> GENTITYNUM_BITS) & GENTITYNUM_MASK;
+ targets[ i - 1 ] = (es->constantLight >> GENTITYNUM_BITS) & GENTITYNUM_MASK;
break;
case 9:
- entityNums[i] = (es->constantLight >> (GENTITYNUM_BITS * 2)) & GENTITYNUM_MASK;
+ targets[ i - 1 ] = (es->constantLight >> (GENTITYNUM_BITS * 2)) & GENTITYNUM_MASK;
break;
}
}
diff --git a/src/game/bg_public.h b/src/game/bg_public.h
index 2ec0435d..cfe456c5 100644
--- a/src/game/bg_public.h
+++ b/src/game/bg_public.h
@@ -1114,8 +1114,8 @@ int BG_PlayerPoisonCloudTime( playerState_t *ps );
weapon_t BG_GetPlayerWeapon( playerState_t *ps );
qboolean BG_HasEnergyWeapon( playerState_t *ps );
-void BG_PackZapTargets( entityState_t *es, int *entityNums, int count );
-void BG_UnpackZapTargets( entityState_t *es, int *entityNums, int count );
+void BG_PackZapTargets( entityState_t *es, int creator, const int *entityNums, int count );
+void BG_UnpackZapTargets( entityState_t *es, int *creator, int *entityNums, int count );
const buildableAttributes_t *BG_BuildableByName( const char *name );
const buildableAttributes_t *BG_BuildableByEntityName( const char *name );
diff --git a/src/game/g_weapon.c b/src/game/g_weapon.c
index a9849572..b150d65f 100644
--- a/src/game/g_weapon.c
+++ b/src/game/g_weapon.c
@@ -1161,20 +1161,19 @@ static void G_UpdateZapEffect( zap_t *zap )
{
int j;
gentity_t *effect = zap->effectChannel;
- int targets[MAX_ZAP_TARGETS + 1];
+ int targets[MAX_ZAP_TARGETS];
effect->s.eType = ET_LEV2_ZAP_CHAIN;
effect->classname = "lev2zapchain";
G_SetOrigin( effect, zap->creator->s.origin );
- targets[ 0 ] = zap->creator->s.number;
for( j = 0; j < zap->numTargets; j++ )
{
int number = zap->targets[ j ]->s.number;
- targets[ j + 1 ] = number;
+ targets[ j ] = number;
}
- BG_PackZapTargets( &effect->s, targets, zap->numTargets );
+ BG_PackZapTargets( &effect->s, zap->creator->s.number, targets, zap->numTargets);
trap_LinkEntity( effect );
}
@@ -1203,13 +1202,18 @@ static void G_CreateNewZap( gentity_t *creator, gentity_t *target )
zap->targets[ 0 ] = target;
zap->numTargets = 1;
-
- for( j = 1; j < MAX_ZAP_TARGETS && zap->targets[ j - 1 ]; j++ )
+ G_Damage( target, creator , zap->creator, forward, target->s.origin,
+ LEVEL2_AREAZAP_DMG, DAMAGE_NO_KNOCKBACK | DAMAGE_NO_LOCDAMAGE, MOD_LEVEL2_ZAP );
+ for( j = 1; j < MAX_ZAP_TARGETS; j++ )
{
zap->targets[ j ] = G_FindNewZapTarget( zap->targets[ 0 ] );
if( zap->targets[ j ] )
+ {
zap->numTargets++;
+ G_Damage( zap->targets[ j ], zap->targets[ 0 ] , zap->creator, forward, target->s.origin,
+ LEVEL2_AREAZAP_DMG, DAMAGE_NO_KNOCKBACK | DAMAGE_NO_LOCDAMAGE, MOD_LEVEL2_ZAP );
+ }
}
zap->effectChannel = G_Spawn( );
@@ -1230,7 +1234,6 @@ void G_UpdateZaps( int msec )
{
int i, j;
zap_t *zap;
- int damage;
for( i = 0; i < MAX_ZAPS; i++ )
{
@@ -1256,38 +1259,6 @@ void G_UpdateZaps( int msec )
}
}
- if( zap->numTargets )
- {
- damage = ceil( ( (float)msec / LEVEL2_AREAZAP_TIME ) *
- LEVEL2_AREAZAP_DMG );
-
- // don't let a high msec value inflate the total damage
- if( damage + zap->damageUsed > LEVEL2_AREAZAP_DMG )
- damage = LEVEL2_AREAZAP_DMG - zap->damageUsed;
-
- for( j = 0; j < zap->numTargets; j++ )
- {
- gentity_t *source;
- gentity_t *target = zap->targets[ j ];
- vec3_t forward;
-
- if( j == 0 )
- source = zap->creator;
- else
- source = zap->targets[ 0 ];
-
- VectorSubtract( target->s.origin, source->s.origin, forward );
- VectorNormalize( forward );
-
- //do the damage
- if( damage )
- {
- G_Damage( target, source, zap->creator, forward, target->s.origin,
- damage, DAMAGE_NO_KNOCKBACK | DAMAGE_NO_LOCDAMAGE, MOD_LEVEL2_ZAP );
- }
- }
- }
-
G_UpdateZapEffect( zap );
zap->timeToLive -= msec;