summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
Diffstat (limited to 'src/game')
-rw-r--r--src/game/bg_public.h1
-rw-r--r--src/game/g_buildable.c49
-rw-r--r--src/game/g_client.c8
-rw-r--r--src/game/g_weapon.c71
4 files changed, 96 insertions, 33 deletions
diff --git a/src/game/bg_public.h b/src/game/bg_public.h
index 8cbeb64d..cc789c1f 100644
--- a/src/game/bg_public.h
+++ b/src/game/bg_public.h
@@ -516,6 +516,7 @@ typedef enum
EV_BULLET_HIT_WALL,
EV_SHOTGUN,
+ EV_MASS_DRIVER,
EV_MISSILE_HIT,
EV_MISSILE_MISS,
diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c
index 27168bbb..721e3fae 100644
--- a/src/game/g_buildable.c
+++ b/src/game/g_buildable.c
@@ -1840,35 +1840,38 @@ void HReactor_Think( gentity_t *self )
if( self->spawned && ( self->health > 0 ) )
{
- //do some damage
+ qboolean fired = qfalse;
+
+ // Creates a tesla trail for every target
num = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES );
for( i = 0; i < num; i++ )
{
enemy = &g_entities[ entityList[ i ] ];
+ if( !enemy->client ||
+ enemy->client->ps.stats[ STAT_PTEAM ] != PTE_ALIENS )
+ continue;
- if( enemy->client && enemy->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS )
- {
- self->timestamp = level.time;
- if( self->dcc )
- {
- G_SelectiveRadiusDamage( self->s.pos.trBase, self,
- REACTOR_ATTACK_DCC_DAMAGE, REACTOR_ATTACK_DCC_RANGE, self,
- MOD_REACTOR, PTE_HUMANS );
- }
- else
- {
- G_SelectiveRadiusDamage( self->s.pos.trBase, self,
- REACTOR_ATTACK_DAMAGE, REACTOR_ATTACK_RANGE, self,
- MOD_REACTOR, PTE_HUMANS );
- }
-
- tent = G_TempEntity( enemy->s.pos.trBase, EV_TESLATRAIL );
-
- VectorCopy( self->s.pos.trBase, tent->s.origin2 );
+ tent = G_TempEntity( enemy->s.pos.trBase, EV_TESLATRAIL );
+ tent->s.generic1 = self->s.number; //src
+ tent->s.clientNum = enemy->s.number; //dest
+ VectorCopy( self->s.pos.trBase, tent->s.origin2 );
+ fired = qtrue;
+ }
- tent->s.generic1 = self->s.number; //src
- tent->s.clientNum = enemy->s.number; //dest
- }
+ // Actual damage is done by radius
+ if( fired )
+ {
+ self->timestamp = level.time;
+ if( self->dcc )
+ G_SelectiveRadiusDamage( self->s.pos.trBase, self,
+ REACTOR_ATTACK_DCC_DAMAGE,
+ REACTOR_ATTACK_DCC_RANGE, self,
+ MOD_REACTOR, PTE_HUMANS );
+ else
+ G_SelectiveRadiusDamage( self->s.pos.trBase, self,
+ REACTOR_ATTACK_DAMAGE,
+ REACTOR_ATTACK_RANGE, self,
+ MOD_REACTOR, PTE_HUMANS );
}
}
diff --git a/src/game/g_client.c b/src/game/g_client.c
index 0e657f0a..b1b07df4 100644
--- a/src/game/g_client.c
+++ b/src/game/g_client.c
@@ -1590,6 +1590,14 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn, vec3_t origin, vec3_t angles
BG_PlayerStateToEntityState( &client->ps, &ent->s, qtrue );
VectorCopy( ent->client->ps.origin, ent->r.currentOrigin );
trap_LinkEntity( ent );
+
+ // if this is devmap, give them some credits
+ if( g_cheats.integer && ent != spawn )
+ {
+ int credits = ent->client->pers.teamSelection == PTE_HUMANS ? 1000 : 5;
+
+ G_AddCreditToClient( ent->client, credits, qtrue );
+ }
}
// must do this here so the number of active clients is calculated
diff --git a/src/game/g_weapon.c b/src/game/g_weapon.c
index 7217bb1b..22d4dd74 100644
--- a/src/game/g_weapon.c
+++ b/src/game/g_weapon.c
@@ -438,19 +438,23 @@ MASS DRIVER
*/
#ifdef MDRIVER_SHOOT_THROUGH
+#define MDRIVER_MAX_HITS 16
void massDriverFire( gentity_t *ent )
{
trace_t tr;
- vec3_t end;
- gentity_t *tent, *traceEnt;
- int i, skipent;
+ vec3_t hitPoints[ MDRIVER_MAX_HITS ], hitNormals[ MDRIVER_MAX_HITS ],
+ origin, originToEnd, muzzleToOrigin, end;
+ gentity_t *traceEnts[ MDRIVER_MAX_HITS ], *traceEnt, *tent;
+ float length_offset;
+ int i, hits = 0, skipent;
- VectorMA( muzzle, 8192 * 16, forward, end );
+ // loop through all entities hit by a line trace
G_UnlaggedOn( muzzle, 8192 * 16 );
+ VectorMA( muzzle, 8192 * 16, forward, end );
VectorCopy( muzzle, tr.endpos );
skipent = ent->s.number;
- for( i = 0; i < 64 && skipent != ENTITYNUM_NONE; i++ )
+ for( i = 0; i < MDRIVER_MAX_HITS && skipent != ENTITYNUM_NONE; i++ )
{
trap_Trace( &tr, tr.endpos, NULL, NULL, end, skipent, MASK_SHOT );
if( tr.surfaceFlags & SURF_NOIMPACT )
@@ -473,24 +477,71 @@ void massDriverFire( gentity_t *ent )
!g_friendlyBuildableFire.integer )
skipent = ENTITYNUM_NONE;
- // snap the endpos to integers, but nudged towards the line
- SnapVectorTowards( tr.endpos, muzzle );
+ // save the hit entity, position, and normal
+ VectorCopy( tr.endpos, hitPoints[ hits ] );
+ VectorCopy( tr.plane.normal, hitNormals[ hits ] );
+ SnapVectorTowards( hitPoints[ hits ], muzzle );
+ traceEnts[ hits++ ] = traceEnt;
+ }
+ if( !hits )
+ return;
+
+ // originate trail line from the gun tip, not the head!
+ VectorCopy( muzzle, origin );
+ VectorMA( origin, -8, up, origin );
+ VectorMA( origin, 6, right, origin );
+ VectorMA( origin, 48, forward, origin );
+
+ // save the final position
+ VectorCopy( tr.endpos, end );
+ VectorSubtract( end, origin, originToEnd );
+ VectorNormalize( originToEnd );
+
+ // origin is further in front than muzzle, need to adjust length
+ VectorSubtract( origin, muzzle, muzzleToOrigin );
+ length_offset = VectorLength( muzzleToOrigin );
+
+ // now that the trace is finished, we know where we stopped and can generate
+ // visually correct impact locations
+ for( i = 0; i < hits; i++ )
+ {
+ vec3_t muzzleToPos;
+ float length;
+
+ // restore saved values
+ VectorCopy( hitPoints[ i ], tr.endpos );
+ VectorCopy( hitNormals[ i ], tr.plane.normal );
+ traceEnt = traceEnts[ i ];
+
+ // compute the visually correct impact point
+ VectorSubtract( tr.endpos, muzzle, muzzleToPos );
+ length = VectorLength( muzzleToPos ) - length_offset;
+ VectorMA( origin, length, originToEnd, tr.endpos );
// send impact
if( traceEnt->takedamage && traceEnt->client )
BloodSpurt( ent, traceEnt, &tr );
- else
+ else if( i < hits - 1 )
{
tent = G_TempEntity( tr.endpos, EV_MISSILE_MISS );
tent->s.eventParm = DirToByte( tr.plane.normal );
tent->s.weapon = ent->s.weapon;
- tent->s.generic1 = ent->s.generic1; //weaponMode
+ tent->s.generic1 = ent->s.generic1; // weaponMode
}
-
+
if( traceEnt->takedamage )
G_Damage( traceEnt, ent, ent, forward, tr.endpos,
MDRIVER_DMG, 0, MOD_MDRIVER );
}
+
+ // create an event entity for the trail, doubles as an impact event
+ SnapVectorTowards( end, muzzle );
+ tent = G_TempEntity( end, EV_MASS_DRIVER );
+ tent->s.eventParm = DirToByte( tr.plane.normal );
+ tent->s.weapon = ent->s.weapon;
+ tent->s.generic1 = ent->s.generic1; // weaponMode
+ VectorCopy( origin, tent->s.origin2 );
+
G_UnlaggedOff( );
}