summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
authorTim Angus <tim@ngus.net>2005-11-20 03:55:39 +0000
committerTim Angus <tim@ngus.net>2005-11-20 03:55:39 +0000
commite80ad4bf122eb05a5ed0c920e36cf656f98dc6e5 (patch)
treebdc1dcb2b08ed77abc72880e81989157c6003555 /src/game
parentd6312bd43317816c281150e3baf7e8204a9452d8 (diff)
* Abstract attachment system
* Scriptable trails system * Various other stuff I'm too tired to try and remember now
Diffstat (limited to 'src/game')
-rw-r--r--src/game/bg_misc.c38
-rw-r--r--src/game/bg_public.h3
-rw-r--r--src/game/g_buildable.c83
-rw-r--r--src/game/g_cmds.c1
-rw-r--r--src/game/g_main.c18
-rw-r--r--src/game/g_weapon.c6
-rw-r--r--src/game/q_math.c11
-rw-r--r--src/game/tremulous.h2
8 files changed, 92 insertions, 70 deletions
diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c
index 062ffdaf..10bb419b 100644
--- a/src/game/bg_misc.c
+++ b/src/game/bg_misc.c
@@ -5037,3 +5037,41 @@ int BG_GetValueOfHuman( playerState_t *ps )
return ceil( ALIEN_MAX_SINGLE_KILLS * portion );
}
+
+/*
+===============
+atof_neg
+
+atof with an allowance for negative values
+===============
+*/
+float atof_neg( char *token, qboolean allowNegative )
+{
+ float value;
+
+ value = atof( token );
+
+ if( !allowNegative && value < 0.0f )
+ value = 1.0f;
+
+ return value;
+}
+
+/*
+===============
+atoi_neg
+
+atoi with an allowance for negative values
+===============
+*/
+int atoi_neg( char *token, qboolean allowNegative )
+{
+ int value;
+
+ value = atoi( token );
+
+ if( !allowNegative && value < 0 )
+ value = 1;
+
+ return value;
+}
diff --git a/src/game/bg_public.h b/src/game/bg_public.h
index ea3b7eef..5cc157e4 100644
--- a/src/game/bg_public.h
+++ b/src/game/bg_public.h
@@ -1288,3 +1288,6 @@ float VectorDistance( vec3_t v1, vec3_t v2 );
float VectorMinComponent( vec3_t v );
float VectorMaxComponent( vec3_t v );
float round( float v );
+
+float atof_neg( char *token, qboolean allowNegative );
+int atoi_neg( char *token, qboolean allowNegative );
diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c
index fddbaf13..d83e76b7 100644
--- a/src/game/g_buildable.c
+++ b/src/game/g_buildable.c
@@ -1258,7 +1258,6 @@ Called when an alien touches a booster
*/
void ABooster_Touch( gentity_t *self, gentity_t *other, trace_t *trace )
{
- int maxAmmo, maxClips;
gclient_t *client = other->client;
if( !self->spawned )
@@ -1289,52 +1288,50 @@ void ABooster_Touch( gentity_t *self, gentity_t *other, trace_t *trace )
//==================================================================================
+#define TRAPPER_ACCURACY 10 // lower is better
/*
================
-ADef_fireonemeny
+ATrapper_FireOnEnemy
-Used by ADef2_Think to fire at enemy
+Used by ATrapper_Think to fire at enemy
================
*/
-void ADef_FireOnEnemy( gentity_t *self, int firespeed, float range )
+void ATrapper_FireOnEnemy( gentity_t *self, int firespeed, float range )
{
- vec3_t dirToTarget;
- vec3_t halfAcceleration, thirdJerk;
- float distanceToTarget = BG_FindRangeForBuildable( self->s.modelindex );
- int i;
-
- VectorScale( self->enemy->acceleration, 1.0f / 2.0f, halfAcceleration );
- VectorScale( self->enemy->jerk, 1.0f / 3.0f, thirdJerk );
-
- //O( time ) - worst case O( time ) = ( range * 1000 ) / speed
- for( i = 0; (float)( i * LOCKBLOB_SPEED ) / 1000.0f < distanceToTarget; i++ )
+ gentity_t *enemy = self->enemy;
+ vec3_t dirToTarget;
+ vec3_t halfAcceleration, thirdJerk;
+ float distanceToTarget = BG_FindRangeForBuildable( self->s.modelindex );
+ int lowMsec = 0;
+ int highMsec = (int)( (
+ ( ( distanceToTarget * LOCKBLOB_SPEED ) +
+ ( distanceToTarget * BG_FindSpeedForClass( enemy->client->ps.stats[ STAT_PCLASS ] ) ) ) /
+ ( LOCKBLOB_SPEED * LOCKBLOB_SPEED ) ) * 1000.0f );
+
+ VectorScale( enemy->acceleration, 1.0f / 2.0f, halfAcceleration );
+ VectorScale( enemy->jerk, 1.0f / 3.0f, thirdJerk );
+
+ // highMsec and lowMsec can only move toward
+ // one another, so the loop must terminate
+ while( highMsec - lowMsec > TRAPPER_ACCURACY )
{
- float time = (float)i / 1000.0f;
-
- if( i > ( ( (float)range * 1000.0f ) / LOCKBLOB_SPEED ) )
- {
- VectorSubtract( self->enemy->s.pos.trBase, self->s.pos.trBase, dirToTarget );
- distanceToTarget = VectorLength( dirToTarget );
-
- G_LogPrintf( "ADef_FireOnEnemy failed.\n"
- " %dth iteration\n enemy location: %v\n"
- " enemy accleration: %v\n enemy jerk: %v\n"
- " base location: %v\n distanceToTarget: %f\n",
- i, self->enemy->s.pos.trBase, self->enemy->acceleration,
- self->enemy->jerk, self->s.pos.trBase, distanceToTarget );
-
- return;
- }
+ int partitionMsec = ( highMsec + lowMsec ) / 2;
+ float time = (float)partitionMsec / 1000.0f;
+ float projectileDistance = LOCKBLOB_SPEED * time;
- VectorMA( self->enemy->s.pos.trBase, time, self->enemy->s.pos.trDelta,
- dirToTarget );
+ VectorMA( enemy->s.pos.trBase, time, enemy->s.pos.trDelta, dirToTarget );
VectorMA( dirToTarget, time * time, halfAcceleration, dirToTarget );
VectorMA( dirToTarget, time * time * time, thirdJerk, dirToTarget );
VectorSubtract( dirToTarget, self->s.pos.trBase, dirToTarget );
distanceToTarget = VectorLength( dirToTarget );
- distanceToTarget -= self->enemy->r.maxs[ 0 ];
+ if( projectileDistance < distanceToTarget )
+ lowMsec = partitionMsec;
+ else if( projectileDistance > distanceToTarget )
+ highMsec = partitionMsec;
+ else if( projectileDistance == distanceToTarget )
+ break; // unlikely to happen
}
VectorNormalize( dirToTarget );
@@ -1348,12 +1345,12 @@ void ADef_FireOnEnemy( gentity_t *self, int firespeed, float range )
/*
================
-ADef_checktarget
+ATrapper_CheckTarget
-Used by ADef2_Think to check enemies for validity
+Used by ATrapper_Think to check enemies for validity
================
*/
-qboolean ADef_CheckTarget( gentity_t *self, gentity_t *target, int range )
+qboolean ATrapper_CheckTarget( gentity_t *self, gentity_t *target, int range )
{
vec3_t distance;
trace_t trace;
@@ -1393,12 +1390,12 @@ qboolean ADef_CheckTarget( gentity_t *self, gentity_t *target, int range )
/*
================
-adef_findenemy
+ATrapper_FindEnemy
-Used by DDef2_Think to locate enemy gentities
+Used by ATrapper_Think to locate enemy gentities
================
*/
-void ADef_FindEnemy( gentity_t *ent, int range )
+void ATrapper_FindEnemy( gentity_t *ent, int range )
{
gentity_t *target;
@@ -1406,7 +1403,7 @@ void ADef_FindEnemy( gentity_t *ent, int range )
for( target = g_entities; target < &g_entities[ level.num_entities ]; target++ )
{
//if target is not valid keep searching
- if( !ADef_CheckTarget( ent, target, range ) )
+ if( !ATrapper_CheckTarget( ent, target, range ) )
continue;
//we found a target
@@ -1444,8 +1441,8 @@ void ATrapper_Think( gentity_t *self )
if( self->spawned && findOvermind( self ) )
{
//if the current target is not valid find a new one
- if( !ADef_CheckTarget( self, self->enemy, range ) )
- ADef_FindEnemy( self, range );
+ if( !ATrapper_CheckTarget( self, self->enemy, range ) )
+ ATrapper_FindEnemy( self, range );
//if a new target cannot be found don't do anything
if( !self->enemy )
@@ -1453,7 +1450,7 @@ void ATrapper_Think( gentity_t *self )
//if we are pointing at our target and we can fire shoot it
if( self->count < level.time )
- ADef_FireOnEnemy( self, firespeed, range );
+ ATrapper_FireOnEnemy( self, firespeed, range );
}
}
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index 606d1875..840fc3bb 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -460,6 +460,7 @@ void G_ChangeTeam( gentity_t *ent, pTeam_t newTeam )
level.bankCredits[ ent->client->ps.clientNum ] = 0;
ent->client->ps.persistant[ PERS_CREDIT ] = 0;
+ ent->client->ps.persistant[ PERS_SCORE ] = 0;
ent->client->pers.classSelection = PCL_NONE;
ClientSpawn( ent, NULL, NULL, NULL );
}
diff --git a/src/game/g_main.c b/src/game/g_main.c
index 64715b20..8ae93622 100644
--- a/src/game/g_main.c
+++ b/src/game/g_main.c
@@ -59,8 +59,8 @@ vmCvar_t g_synchronousClients;
vmCvar_t g_warmup;
vmCvar_t g_doWarmup;
vmCvar_t g_restarted;
-vmCvar_t g_log;
-vmCvar_t g_logSync;
+vmCvar_t g_logFile;
+vmCvar_t g_logFileSync;
vmCvar_t g_blood;
vmCvar_t g_podiumDist;
vmCvar_t g_podiumDrop;
@@ -124,8 +124,8 @@ static cvarTable_t gameCvarTable[ ] =
{ &g_warmup, "g_warmup", "20", CVAR_ARCHIVE, 0, qtrue },
{ &g_doWarmup, "g_doWarmup", "0", 0, 0, qtrue },
- { &g_log, "g_log", "games.log", CVAR_ARCHIVE, 0, qfalse },
- { &g_logSync, "g_logSync", "0", CVAR_ARCHIVE, 0, qfalse },
+ { &g_logFile, "g_logFile", "games.log", CVAR_ARCHIVE, 0, qfalse },
+ { &g_logFileSync, "g_logFileSync", "0", CVAR_ARCHIVE, 0, qfalse },
{ &g_password, "g_password", "", CVAR_USERINFO, 0, qfalse },
@@ -477,15 +477,15 @@ void G_InitGame( int levelTime, int randomSeed, int restart )
level.snd_fry = G_SoundIndex( "sound/player/fry.wav" ); // FIXME standing in lava / slime
- if( g_log.string[ 0 ] )
+ if( g_logFile.string[ 0 ] )
{
- if( g_logSync.integer )
- trap_FS_FOpenFile( g_log.string, &level.logFile, FS_APPEND_SYNC );
+ if( g_logFileSync.integer )
+ trap_FS_FOpenFile( g_logFile.string, &level.logFile, FS_APPEND_SYNC );
else
- trap_FS_FOpenFile( g_log.string, &level.logFile, FS_APPEND );
+ trap_FS_FOpenFile( g_logFile.string, &level.logFile, FS_APPEND );
if( !level.logFile )
- G_Printf( "WARNING: Couldn't open logfile: %s\n", g_log.string );
+ G_Printf( "WARNING: Couldn't open logfile: %s\n", g_logFile.string );
else
{
char serverinfo[ MAX_INFO_STRING ];
diff --git a/src/game/g_weapon.c b/src/game/g_weapon.c
index 94a1aabe..a28da78b 100644
--- a/src/game/g_weapon.c
+++ b/src/game/g_weapon.c
@@ -631,12 +631,6 @@ void teslaFire( gentity_t *ent )
// move origin a bit to come closer to the drawn gun muzzle
VectorMA( tent->s.origin2, 28, up, tent->s.origin2 );
-
- // no explosion at end if SURF_NOIMPACT, but still make the trail
- if( tr.surfaceFlags & SURF_NOIMPACT )
- tent->s.eventParm = 255; // don't make the explosion at the end
- else
- tent->s.eventParm = DirToByte( tr.plane.normal );
}
diff --git a/src/game/q_math.c b/src/game/q_math.c
index 62c5a5a8..78209fd1 100644
--- a/src/game/q_math.c
+++ b/src/game/q_math.c
@@ -1378,8 +1378,6 @@ float pointToLineDistance( const vec3_t p0, const vec3_t p1, const vec3_t p2 )
return c1 / c2;
}
-//TA: wolf trail stuff
-// Ridah
/*
=================
GetPerpendicularViewVector
@@ -1417,15 +1415,6 @@ void ProjectPointOntoVector( vec3_t point, vec3_t vStart, vec3_t vEnd, vec3_t vP
VectorMA( vStart, DotProduct( pVec, vec ), vec, vProj );
}
-float VectorDistance(vec3_t v1, vec3_t v2)
-{
- vec3_t dir;
-
- VectorSubtract(v2, v1, dir);
- return VectorLength(dir);
-}
-// done.
-
/*
================
VectorMaxComponent
diff --git a/src/game/tremulous.h b/src/game/tremulous.h
index 085fabbf..ab9db16c 100644
--- a/src/game/tremulous.h
+++ b/src/game/tremulous.h
@@ -261,7 +261,7 @@
#define TRAPPER_CREEPSIZE 30
#define TRAPPER_RANGE 400
#define TRAPPER_REPEAT 1000
-#define LOCKBLOB_SPEED 500.0f
+#define LOCKBLOB_SPEED 650.0f
#define LOCKBLOB_DOT 0.85f // max angle = acos( LOCKBLOB_DOT )
#define OVERMIND_BP 0