summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game/bg_pmove.c2
-rw-r--r--src/game/g_buildable.c57
-rw-r--r--src/game/g_client.c12
-rw-r--r--src/game/g_local.h8
-rw-r--r--src/game/g_main.c28
-rw-r--r--src/game/g_weapon.c4
6 files changed, 80 insertions, 31 deletions
diff --git a/src/game/bg_pmove.c b/src/game/bg_pmove.c
index b5bae3cc..7e0c9106 100644
--- a/src/game/bg_pmove.c
+++ b/src/game/bg_pmove.c
@@ -2341,7 +2341,7 @@ static void PM_Weapon( void ) {
addTime = 400;
break;
case WP_VENOM:
- addTime = 200;
+ addTime = 500;
break;
case WP_ABUILD:
addTime = 1000;
diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c
index 6441a130..c4db0d34 100644
--- a/src/game/g_buildable.c
+++ b/src/game/g_buildable.c
@@ -350,6 +350,7 @@ void HMCU_Think( gentity_t *self )
#define HDEF1_FIRINGSPEED 200
#define HDEF1_ACCURACYTOLERANCE HDEF1_ANGULARSPEED - 5
#define HDEF1_VERTICALCAP 20
+#define HDEF1_PROJSPEED 2000.0f
/*
================
@@ -362,55 +363,75 @@ qboolean hdef1_trackenemy( gentity_t *self )
{
vec3_t dirToTarget, angleToTarget, angularDiff;
float temp;
- float distanceToTarget;
+ float distanceToTarget = HDEF1_RANGE;
float timeTilImpact;
+ vec3_t halfAcceleration;
+ vec3_t thirdJounce;
+ int i;
VectorSubtract( self->enemy->s.pos.trBase, self->s.pos.trBase, dirToTarget );
//lead targets
-#if 1
+#if 0
distanceToTarget = VectorLength( dirToTarget );
timeTilImpact = distanceToTarget / 2000.0f;
VectorMA( self->enemy->s.pos.trBase, timeTilImpact, self->enemy->s.pos.trDelta, dirToTarget );
VectorSubtract( dirToTarget, self->s.pos.trBase, dirToTarget );
#endif
+
+ VectorScale( self->enemy->acceleration, 0.5f, halfAcceleration );
+ VectorScale( self->enemy->jounce, 0.33333f, thirdJounce );
+
+ //O( time ) - worst case O( time ) = 250 iterations
+ for( i = 0; ( i * HDEF1_PROJSPEED ) / 1000.0f < distanceToTarget; i++ )
+ {
+ float time = (float)i / 1000.0f;
+
+ VectorMA( self->enemy->s.pos.trBase, time, self->enemy->s.pos.trDelta, dirToTarget );
+ VectorMA( dirToTarget, time * time, halfAcceleration, dirToTarget );
+ VectorMA( dirToTarget, time * time * time, thirdJounce, dirToTarget );
+ VectorSubtract( dirToTarget, self->s.pos.trBase, dirToTarget );
+ distanceToTarget = VectorLength( dirToTarget );
+
+ distanceToTarget -= ( self->r.maxs[ 0 ] + self->enemy->r.maxs[ 0 ] );
+ }
VectorNormalize( dirToTarget );
vectoangles( dirToTarget, angleToTarget );
- angularDiff[ PITCH ] = AngleSubtract( self->turloc[ PITCH ], angleToTarget[ PITCH ] );
- angularDiff[ YAW ] = AngleSubtract( self->turloc[ YAW ], angleToTarget[ YAW ] );
+ angularDiff[ PITCH ] = AngleSubtract( self->s.angles2[ PITCH ], angleToTarget[ PITCH ] );
+ angularDiff[ YAW ] = AngleSubtract( self->s.angles2[ YAW ], angleToTarget[ YAW ] );
if( angularDiff[ PITCH ] < -HDEF1_ACCURACYTOLERANCE )
- self->turloc[ PITCH ] += HDEF1_ANGULARSPEED;
+ self->s.angles2[ PITCH ] += HDEF1_ANGULARSPEED;
else if( angularDiff[ PITCH ] > HDEF1_ACCURACYTOLERANCE )
- self->turloc[ PITCH ] -= HDEF1_ANGULARSPEED;
+ self->s.angles2[ PITCH ] -= HDEF1_ANGULARSPEED;
else
- self->turloc[ PITCH ] = angleToTarget[ PITCH ];
+ self->s.angles2[ PITCH ] = angleToTarget[ PITCH ];
- temp = fabs( self->turloc[ PITCH ] );
+ temp = fabs( self->s.angles2[ PITCH ] );
if( temp > 180 )
temp -= 360;
if( temp < -HDEF1_VERTICALCAP )
- self->turloc[ PITCH ] = (-360)+HDEF1_VERTICALCAP;
+ self->s.angles2[ PITCH ] = (-360)+HDEF1_VERTICALCAP;
else if( temp > HDEF1_VERTICALCAP )
- self->turloc[ PITCH ] = -HDEF1_VERTICALCAP;
+ self->s.angles2[ PITCH ] = -HDEF1_VERTICALCAP;
if( angularDiff[ YAW ] < -HDEF1_ACCURACYTOLERANCE )
- self->turloc[ YAW ] += HDEF1_ANGULARSPEED;
+ self->s.angles2[ YAW ] += HDEF1_ANGULARSPEED;
else if( angularDiff[ YAW ] > HDEF1_ACCURACYTOLERANCE )
- self->turloc[ YAW ] -= HDEF1_ANGULARSPEED;
+ self->s.angles2[ YAW ] -= HDEF1_ANGULARSPEED;
else
- self->turloc[ YAW ] = angleToTarget[ YAW ];
+ self->s.angles2[ YAW ] = angleToTarget[ YAW ];
- VectorCopy( self->turloc, self->s.angles2 );
+ VectorCopy( self->s.angles2, self->s.angles2 );
trap_LinkEntity( self );
- if( abs( angleToTarget[ YAW ] - self->turloc[ YAW ] ) <= HDEF1_ACCURACYTOLERANCE &&
- abs( angleToTarget[ PITCH ] - self->turloc[ PITCH ] ) <= HDEF1_ACCURACYTOLERANCE )
+ if( abs( angleToTarget[ YAW ] - self->s.angles2[ YAW ] ) <= HDEF1_ACCURACYTOLERANCE &&
+ abs( angleToTarget[ PITCH ] - self->s.angles2[ PITCH ] ) <= HDEF1_ACCURACYTOLERANCE )
return qtrue;
return qfalse;
@@ -427,7 +448,7 @@ void hdef1_fireonenemy( gentity_t *self )
{
vec3_t aimVector;
- AngleVectors( self->turloc, aimVector, NULL, NULL );
+ AngleVectors( self->s.angles2, aimVector, NULL, NULL );
fire_plasma( self, self->s.pos.trBase, aimVector );
self->count = level.time + HDEF1_FIRINGSPEED;
}
@@ -829,7 +850,7 @@ gentity_t *Build_Item( gentity_t *ent, buildable_t buildable, int distance ) {
G_SetOrigin( built, origin );
VectorCopy( angles, built->s.angles );
- built->turloc[ YAW ] = built->s.angles2[ YAW ] = angles[ YAW ];
+ built->s.angles2[ YAW ] = angles[ YAW ];
VectorCopy( origin, built->s.origin );
built->s.pos.trType = TR_GRAVITY;
built->s.pos.trTime = level.time;
diff --git a/src/game/g_client.c b/src/game/g_client.c
index 42e1f9b4..6aa6b855 100644
--- a/src/game/g_client.c
+++ b/src/game/g_client.c
@@ -661,14 +661,7 @@ void SpawnCorpse( gentity_t *ent ) {
break;
}
- //body->die = body_die;
-
- // don't take more damage if already gibbed
- if ( ent->health <= GIB_HEALTH ) {
- body->takedamage = qfalse;
- } else {
- body->takedamage = qtrue;
- }
+ body->takedamage = qfalse;
//make the make player entity disappear
ent->takedamage = qfalse;
@@ -1358,6 +1351,9 @@ void ClientSpawn( gentity_t *ent, gentity_t *spawn ) {
ent->watertype = 0;
ent->flags = 0;
+ //TA: calculate each client's acceleration
+ ent->evaluateAcceleration = qtrue;
+
client->ps.stats[ STAT_WEAPONS ] = 0;
client->ps.stats[ STAT_WEAPONS2 ] = 0;
client->ps.stats[ STAT_SLOTS ] = 0;
diff --git a/src/game/g_local.h b/src/game/g_local.h
index a7b96e18..0e971899 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -132,6 +132,13 @@ struct gentity_s {
float speed;
vec3_t movedir;
+ //TA: acceleration evaluation
+ qboolean evaluateAcceleration;
+ vec3_t oldVelocity;
+ vec3_t acceleration;
+ vec3_t oldAccel;
+ vec3_t jounce;
+
int nextthink;
void (*think)(gentity_t *self);
void (*reached)(gentity_t *self); // movers call this when hitting endpoint
@@ -176,7 +183,6 @@ struct gentity_s {
int biteam; //TA: buildable item team
gentity_t *parentNode; //TA: for creep and defence/spawn dependencies
- vec3_t turloc; //TA: direction human defense turrets are pointing
qboolean active; //TA: for power repeater, but could be useful elsewhere
qboolean powered; //TA: for human buildables
diff --git a/src/game/g_main.c b/src/game/g_main.c
index 74e2d575..9fb51eb1 100644
--- a/src/game/g_main.c
+++ b/src/game/g_main.c
@@ -1801,6 +1801,28 @@ void G_RunThink (gentity_t *ent) {
}
/*
+=============
+G_EvaluateAcceleration
+
+Calculates the acceleration for an entity
+=============
+*/
+void G_EvaluateAcceleration( gentity_t *ent, int msec )
+{
+ vec3_t deltaVelocity;
+ vec3_t deltaAccel;
+
+ VectorSubtract( ent->s.pos.trDelta, ent->oldVelocity, deltaVelocity );
+ VectorScale( deltaVelocity, 1.0f / (float)msec, ent->acceleration );
+
+ VectorSubtract( ent->acceleration, ent->oldAccel, deltaAccel );
+ VectorScale( deltaAccel, 1.0f / (float)msec, ent->jounce );
+
+ VectorCopy( ent->s.pos.trDelta, ent->oldVelocity );
+ VectorCopy( ent->acceleration, ent->oldAccel );
+}
+
+/*
================
G_RunFrame
@@ -1862,6 +1884,10 @@ start = trap_Milliseconds();
continue;
}
+ //TA: calculate the acceleration of this entity
+ if( ent->evaluateAcceleration )
+ G_EvaluateAcceleration( ent, msec );
+
if ( !ent->r.linked && ent->neverFree ) {
continue;
}
@@ -1881,7 +1907,7 @@ start = trap_Milliseconds();
G_RunMover( ent );
continue;
}
-
+
if ( i < MAX_CLIENTS ) {
G_RunClient( ent );
continue;
diff --git a/src/game/g_weapon.c b/src/game/g_weapon.c
index 9e6db0ab..0f06a19b 100644
--- a/src/game/g_weapon.c
+++ b/src/game/g_weapon.c
@@ -644,9 +644,9 @@ qboolean CheckVenomAttack( gentity_t *ent ) {
if( !traceEnt->takedamage)
return qfalse;
- if( traceEnt->biteam == PTE_DROIDS )
+ if( !traceEnt->client )
return qfalse;
- if( traceEnt->client && traceEnt->client->ps.stats[ STAT_PTEAM ] == PTE_DROIDS )
+ if( traceEnt->client->ps.stats[ STAT_PTEAM ] == PTE_DROIDS )
return qfalse;
G_Damage( traceEnt, ent, ent, forward, tr.endpos, 5, 0, MOD_VENOM );