summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBen Millwood <thebenmachine@gmail.com>2009-10-03 12:19:21 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:15:51 +0000
commitc1d729dfbc605c4fa514bce9e1663961ff7ede51 (patch)
treea58cc6ded714ecf89239f23b2a4a71932a4ca683 /src
parent931e88a788c5214bcbb24827bd5574c97abe99cb (diff)
BP Queuing system
* Remove humanBuildPointsPowered as it isn't used nor is it likely to be * Ensure that alien buildables no longer count for BP after they exploded * Don't restore the BP for a destroyed building as soon as it is destroyed - instead, add them to a global queue and restore them slowly, as determined by g_<team>BuildQueueTime * Remove G_IsOvermindBuilt in favour of level.overmindPresent which did pretty much the same thing This resolves issue #6
Diffstat (limited to 'src')
-rw-r--r--src/cgame/cg_servercmds.c10
-rw-r--r--src/game/g_buildable.c82
-rw-r--r--src/game/g_cmds.c1
-rw-r--r--src/game/g_local.h8
-rw-r--r--src/game/g_main.c40
-rw-r--r--src/game/tremulous.h2
6 files changed, 90 insertions, 53 deletions
diff --git a/src/cgame/cg_servercmds.c b/src/cgame/cg_servercmds.c
index ebfeb2de..b9c310eb 100644
--- a/src/cgame/cg_servercmds.c
+++ b/src/cgame/cg_servercmds.c
@@ -161,11 +161,10 @@ Called on load to set the initial values from configure strings
void CG_SetConfigValues( void )
{
sscanf( CG_ConfigString( CS_BUILDPOINTS ),
- "%d %d %d %d %d", &cgs.alienBuildPoints,
+ "%d %d %d %d", &cgs.alienBuildPoints,
&cgs.alienBuildPointsTotal,
&cgs.humanBuildPoints,
- &cgs.humanBuildPointsTotal,
- &cgs.humanBuildPointsPowered );
+ &cgs.humanBuildPointsTotal );
sscanf( CG_ConfigString( CS_STAGES ), "%d %d %d %d %d %d", &cgs.alienStage, &cgs.humanStage,
&cgs.alienCredits, &cgs.humanCredits, &cgs.alienNextStageThreshold, &cgs.humanNextStageThreshold );
@@ -281,11 +280,10 @@ static void CG_ConfigStringModified( void )
else if( num == CS_WARMUP )
CG_ParseWarmup( );
else if( num == CS_BUILDPOINTS )
- sscanf( str, "%d %d %d %d %d", &cgs.alienBuildPoints,
+ sscanf( str, "%d %d %d %d", &cgs.alienBuildPoints,
&cgs.alienBuildPointsTotal,
&cgs.humanBuildPoints,
- &cgs.humanBuildPointsTotal,
- &cgs.humanBuildPointsPowered );
+ &cgs.humanBuildPointsTotal );
else if( num == CS_STAGES )
{
stage_t oldAlienStage = cgs.alienStage;
diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c
index fee03896..5880166c 100644
--- a/src/game/g_buildable.c
+++ b/src/game/g_buildable.c
@@ -558,17 +558,6 @@ static void nullDieFunction( gentity_t *self, gentity_t *inflictor, gentity_t *a
{
}
-/*
-================
-freeBuildable
-================
-*/
-static void freeBuildable( gentity_t *self )
-{
- G_FreeEntity( self );
-}
-
-
//==================================================================================
@@ -577,7 +566,7 @@ static void freeBuildable( gentity_t *self )
================
AGeneric_CreepRecede
-Called when an alien spawn dies
+Called when an alien buildable dies
================
*/
void AGeneric_CreepRecede( gentity_t *self )
@@ -586,6 +575,7 @@ void AGeneric_CreepRecede( gentity_t *self )
if( !( self->s.eFlags & EF_DEAD ) )
{
self->s.eFlags |= EF_DEAD;
+ G_QueueBuildPoints( self );
G_AddEvent( self, EV_BUILD_DESTROY, 0 );
if( self->spawned )
@@ -692,7 +682,7 @@ A generic think function for Alien buildables
*/
void AGeneric_Think( gentity_t *self )
{
- self->powered = G_IsOvermindBuilt( );
+ self->powered = level.overmindPresent;
self->nextthink = level.time + BG_Buildable( self->s.modelindex )->nextthink;
AGeneric_CreepCheck( self );
}
@@ -995,7 +985,7 @@ void ABarricade_Shrink( gentity_t *self, qboolean shrink )
================
ABarricade_Die
-Called when an alien spawn dies
+Called when an alien barricade dies
================
*/
void ABarricade_Die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod )
@@ -1064,7 +1054,7 @@ void AAcidTube_Think( gentity_t *self )
int i, num;
gentity_t *enemy;
- self->powered = G_IsOvermindBuilt( );
+ self->powered = level.overmindPresent;
self->nextthink = level.time + BG_Buildable( self->s.modelindex )->nextthink;
VectorAdd( self->s.origin, range, maxs );
@@ -1155,7 +1145,7 @@ Think function for Alien Hive
*/
void AHive_Think( gentity_t *self )
{
- self->powered = G_IsOvermindBuilt( );
+ self->powered = level.overmindPresent;
self->nextthink = level.time + BG_Buildable( self->s.modelindex )->nextthink;
AGeneric_CreepCheck( self );
@@ -1192,7 +1182,7 @@ pain function for Alien Hive
*/
void AHive_Pain( gentity_t *self, gentity_t *attacker, int damage )
{
- if( self->health <= 0 || !G_IsOvermindBuilt( ) )
+ if( self->health <= 0 || !level.overmindPresent )
return;
if( !self->active )
@@ -1383,7 +1373,7 @@ Think for alien hovel
*/
void AHovel_Think( gentity_t *self )
{
- self->powered = G_IsOvermindBuilt( );
+ self->powered = level.overmindPresent;
self->nextthink = level.time + 200;
AGeneric_CreepCheck( self );
@@ -2292,11 +2282,7 @@ void HSpawn_Disappear( gentity_t *self )
self->s.eFlags |= EF_NODRAW; //don't draw the model once its destroyed
self->timestamp = level.time;
- self->think = freeBuildable;
- self->nextthink = level.time + 100;
-
- self->r.contents = 0; //stop collisions...
- trap_LinkEntity( self ); //...requires a relink
+ G_FreeEntity( self );
}
@@ -2316,19 +2302,18 @@ void HSpawn_Blast( gentity_t *self )
dir[ 0 ] = dir[ 1 ] = 0;
dir[ 2 ] = 1;
- self->s.eFlags |= EF_NODRAW; //don't draw the model once its destroyed
- G_AddEvent( self, EV_HUMAN_BUILDABLE_EXPLOSION, DirToByte( dir ) );
self->timestamp = level.time;
//do some radius damage
G_RadiusDamage( self->s.pos.trBase, self, self->splashDamage,
self->splashRadius, self, self->splashMethodOfDeath );
- self->think = freeBuildable;
- self->nextthink = level.time + 100;
-
- self->r.contents = 0; //stop collisions...
- trap_LinkEntity( self ); //...requires a relink
+ // begin freeing build points
+ G_QueueBuildPoints( self );
+ // turn into an explosion
+ self->s.eType = ET_EVENTS + EV_HUMAN_BUILDABLE_EXPLOSION;
+ self->freeAfterEvent = qtrue;
+ G_AddEvent( self, EV_HUMAN_BUILDABLE_EXPLOSION, DirToByte( dir ) );
}
@@ -2412,6 +2397,37 @@ void HSpawn_Think( gentity_t *self )
//==================================================================================
+/*
+============
+G_QueueBuildPoints
+============
+*/
+void G_QueueBuildPoints( gentity_t *self )
+{
+ G_Printf( "G_QueueBuildPoints( %s )\n", BG_TeamName( self->buildableTeam ) );
+ switch( self->buildableTeam )
+ {
+ default:
+ case TEAM_NONE:
+ return;
+
+ case TEAM_ALIENS:
+ if( !level.alienBuildPointQueue )
+ level.alienNextQueueTime = level.time + g_alienBuildQueueTime.integer;
+
+ level.alienBuildPointQueue +=
+ BG_Buildable( self->s.modelindex )->buildPoints;
+ break;
+
+ case TEAM_HUMANS:
+ if( !level.humanBuildPointQueue )
+ level.humanNextQueueTime = level.time + g_humanBuildQueueTime.integer;
+
+ level.humanBuildPointQueue +=
+ BG_Buildable( self->s.modelindex )->buildPoints;
+ break;
+ }
+}
/*
============
@@ -3037,9 +3053,7 @@ itemBuildError_t G_CanBuild( gentity_t *ent, buildable_t buildable, int distance
// Check there is an Overmind
if( buildable != BA_A_OVERMIND )
{
- tempent = G_FindBuildable( BA_A_OVERMIND );
-
- if( tempent == NULL || !tempent->spawned || tempent->health <= 0 )
+ if( level.overmindPresent )
reason = IBE_NOOVERMIND;
}
@@ -3105,7 +3119,7 @@ itemBuildError_t G_CanBuild( gentity_t *ent, buildable_t buildable, int distance
if( BG_Buildable( buildable )->uniqueTest )
{
tempent = G_FindBuildable( buildable );
- if( tempent && !tempent->deconstruct )
+ if( tempent && !tempent->deconstruct && !( tempent->s.eFlags & EF_DEAD ) )
{
switch( buildable )
{
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index 00302fc1..5bad0553 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -1766,6 +1766,7 @@ void Cmd_Destroy_f( gentity_t *ent )
// Always let the builder prevent the explosion
if( traceEnt->health <= 0 )
{
+ G_QueueBuildPoints( traceEnt );
G_FreeEntity( traceEnt );
return;
}
diff --git a/src/game/g_local.h b/src/game/g_local.h
index d793a9e0..2c43a6ca 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -588,8 +588,11 @@ typedef struct
int numLiveHumanClients;
int alienBuildPoints;
+ int alienBuildPointQueue;
+ int alienNextQueueTime;
int humanBuildPoints;
- int humanBuildPointsPowered;
+ int humanBuildPointQueue;
+ int humanNextQueueTime;
gentity_t *markedBuildables[ MAX_GENTITIES ];
int numBuildablesForRemoval;
@@ -744,6 +747,7 @@ int G_LayoutList( const char *map, char *list, int len );
void G_LayoutSelect( void );
void G_LayoutLoad( void );
void G_BaseSelfDestruct( team_t team );
+void G_QueueBuildPoints( gentity_t *self );
//
// g_utils.c
@@ -1123,6 +1127,8 @@ extern vmCvar_t g_singlePlayer;
extern vmCvar_t g_humanBuildPoints;
extern vmCvar_t g_alienBuildPoints;
+extern vmCvar_t g_humanBuildQueueTime;
+extern vmCvar_t g_alienBuildQueueTime;
extern vmCvar_t g_humanStage;
extern vmCvar_t g_humanCredits;
extern vmCvar_t g_humanMaxStage;
diff --git a/src/game/g_main.c b/src/game/g_main.c
index ebfea1ef..4eebc5a9 100644
--- a/src/game/g_main.c
+++ b/src/game/g_main.c
@@ -89,6 +89,8 @@ vmCvar_t g_maxNameChanges;
vmCvar_t g_humanBuildPoints;
vmCvar_t g_alienBuildPoints;
+vmCvar_t g_humanBuildQueueTime;
+vmCvar_t g_alienBuildQueueTime;
vmCvar_t g_humanStage;
vmCvar_t g_humanCredits;
vmCvar_t g_humanMaxStage;
@@ -218,6 +220,8 @@ static cvarTable_t gameCvarTable[ ] =
{ &g_humanBuildPoints, "g_humanBuildPoints", DEFAULT_HUMAN_BUILDPOINTS, 0, 0, qfalse },
{ &g_alienBuildPoints, "g_alienBuildPoints", DEFAULT_ALIEN_BUILDPOINTS, 0, 0, qfalse },
+ { &g_humanBuildQueueTime, "g_humanBuildQueueTime", DEFAULT_HUMAN_QUEUE_TIME, 0, 0, qfalse },
+ { &g_alienBuildQueueTime, "g_alienBuildQueueTime", DEFAULT_ALIEN_QUEUE_TIME, 0, 0, qfalse },
{ &g_humanStage, "g_humanStage", "0", 0, 0, qfalse },
{ &g_humanCredits, "g_humanCredits", "0", 0, 0, qfalse },
{ &g_humanMaxStage, "g_humanMaxStage", DEFAULT_HUMAN_MAX_STAGE, 0, 0, qfalse },
@@ -1065,8 +1069,22 @@ void G_CalculateBuildPoints( void )
int i;
buildable_t buildable;
gentity_t *ent;
- int localHTP = g_humanBuildPoints.integer,
- localATP = g_alienBuildPoints.integer;
+ int localHTP = level.humanBuildPoints = g_humanBuildPoints.integer,
+ localATP = level.alienBuildPoints = g_alienBuildPoints.integer;
+
+ while( level.alienBuildPointQueue > 0 &&
+ level.alienNextQueueTime < level.time )
+ {
+ level.alienBuildPointQueue--;
+ level.alienNextQueueTime += g_alienBuildQueueTime.integer;
+ }
+
+ while( level.humanBuildPointQueue > 0 &&
+ level.humanNextQueueTime < level.time )
+ {
+ level.humanBuildPointQueue--;
+ level.humanNextQueueTime += g_alienBuildQueueTime.integer;
+ }
if( g_suddenDeathTime.integer && !level.warmupTime )
{
@@ -1099,8 +1117,8 @@ void G_CalculateBuildPoints( void )
localATP = g_alienBuildPoints.integer;
}
- level.humanBuildPoints = level.humanBuildPointsPowered = localHTP;
- level.alienBuildPoints = localATP;
+ level.humanBuildPoints = localHTP - level.humanBuildPointQueue;
+ level.alienBuildPoints = localATP - level.alienBuildPointQueue;
level.reactorPresent = qfalse;
level.overmindPresent = qfalse;
@@ -1113,6 +1131,9 @@ void G_CalculateBuildPoints( void )
if( ent->s.eType != ET_BUILDABLE )
continue;
+ if( ent->s.eFlags & EF_DEAD )
+ continue;
+
buildable = ent->s.modelindex;
if( buildable != BA_NONE )
@@ -1126,11 +1147,8 @@ void G_CalculateBuildPoints( void )
if( BG_Buildable( buildable )->team == TEAM_HUMANS )
{
level.humanBuildPoints -= BG_Buildable( buildable )->buildPoints;
-
- if( ent->powered )
- level.humanBuildPointsPowered -= BG_Buildable( buildable )->buildPoints;
}
- else
+ else if( BG_Buildable( buildable )->team == TEAM_ALIENS )
{
level.alienBuildPoints -= BG_Buildable( buildable )->buildPoints;
}
@@ -1140,7 +1158,6 @@ void G_CalculateBuildPoints( void )
if( level.humanBuildPoints < 0 )
{
localHTP -= level.humanBuildPoints;
- level.humanBuildPointsPowered -= level.humanBuildPoints;
level.humanBuildPoints = 0;
}
@@ -1150,10 +1167,9 @@ void G_CalculateBuildPoints( void )
level.alienBuildPoints = 0;
}
- trap_SetConfigstring( CS_BUILDPOINTS, va( "%d %d %d %d %d",
+ trap_SetConfigstring( CS_BUILDPOINTS, va( "%d %d %d %d",
level.alienBuildPoints, localATP,
- level.humanBuildPoints, localHTP,
- level.humanBuildPointsPowered ) );
+ level.humanBuildPoints, localHTP ) );
//may as well pump the stages here too
{
diff --git a/src/game/tremulous.h b/src/game/tremulous.h
index d54f3e3f..35c651ec 100644
--- a/src/game/tremulous.h
+++ b/src/game/tremulous.h
@@ -655,10 +655,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define FREEKILL_HUMAN LEVEL0_VALUE
#define DEFAULT_ALIEN_BUILDPOINTS "100"
+#define DEFAULT_ALIEN_QUEUE_TIME "1250"
#define DEFAULT_ALIEN_STAGE2_THRESH "8000"
#define DEFAULT_ALIEN_STAGE3_THRESH "16000"
#define DEFAULT_ALIEN_MAX_STAGE "2"
#define DEFAULT_HUMAN_BUILDPOINTS "100"
+#define DEFAULT_HUMAN_QUEUE_TIME "1250"
#define DEFAULT_HUMAN_STAGE2_THRESH "4000"
#define DEFAULT_HUMAN_STAGE3_THRESH "8000"
#define DEFAULT_HUMAN_MAX_STAGE "2"