diff options
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/bg_misc.c | 46 | ||||
-rw-r--r-- | src/game/bg_public.h | 14 | ||||
-rw-r--r-- | src/game/g_buildable.c | 54 | ||||
-rw-r--r-- | src/game/g_local.h | 7 | ||||
-rw-r--r-- | src/game/g_main.c | 61 |
5 files changed, 149 insertions, 33 deletions
diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index a4b6eda7..a96cc0d9 100644 --- a/src/game/bg_misc.c +++ b/src/game/bg_misc.c @@ -931,6 +931,7 @@ buildableAttributes_t bg_buildableList[ ] = "team_droid_spawn", { -15, -15, -15 }, { 15, 15, 15 }, + 0, 1000, 50, 50, @@ -948,6 +949,7 @@ buildableAttributes_t bg_buildableList[ ] = "team_droid_def1", { -15, -15, -15 }, { 15, 15, 15 }, + 0, 1000, 50, 20, @@ -965,6 +967,7 @@ buildableAttributes_t bg_buildableList[ ] = "team_human_spawn", { -40, -40, -4 }, { 40, 40, 4 }, + 100, 1000, 50, 50, @@ -982,6 +985,7 @@ buildableAttributes_t bg_buildableList[ ] = "team_human_def1", { -24, -24, -11 }, { 24, 24, 11 }, + 80, 1000, 50, 20, @@ -999,6 +1003,7 @@ buildableAttributes_t bg_buildableList[ ] = "team_human_mcu", { -15, -15, -15 }, { 15, 15, 15 }, + 200, 1000, 50, 50, @@ -1016,6 +1021,7 @@ buildableAttributes_t bg_buildableList[ ] = "team_human_reactor", { -15, -15, -15 }, { 15, 15, 15 }, + 0, 1000, 50, 50, @@ -1033,6 +1039,7 @@ buildableAttributes_t bg_buildableList[ ] = "team_human_repeater", { -15, -15, -15 }, { 15, 15, 15 }, + 10, 1000, 50, 50, @@ -1069,6 +1076,25 @@ int BG_FindBuildNumForName( char *name ) /* ============== +BG_FindBuildNumForEntityName +============== +*/ +int BG_FindBuildNumForEntityName( char *name ) +{ + int i; + + for( i = 0; i < bg_numBuildables; i++ ) + { + if( !Q_stricmp( bg_buildableList[ i ].entityName, name ) ) + return bg_buildableList[ i ].buildNum; + } + + //wimp out + return BA_NONE; +} + +/* +============== BG_FindNameForBuildNum ============== */ @@ -1137,6 +1163,26 @@ void BG_FindBBoxForBuildable( int bclass, vec3_t mins, vec3_t maxs ) /* ============== +BG_FindBuildPointsForBuildable +============== +*/ +int BG_FindBuildPointsForBuildable( int bclass ) +{ + int i; + + for( i = 0; i < bg_numBuildables; i++ ) + { + if( bg_buildableList[ i ].buildNum == bclass ) + { + return bg_buildableList[ i ].buildPoints; + } + } + + return 1000; +} + +/* +============== BG_FindHealthForBuildable ============== */ diff --git a/src/game/bg_public.h b/src/game/bg_public.h index 56cd7552..d67d5a90 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -86,10 +86,13 @@ #define CS_ITEMS 27 // string of 0's and 1's that tell which items are present //TA: extra stuff: -#define CS_ABPOINTS 28 -#define CS_HBPOINTS 29 +#define CS_DBPOINTS 28 +#define CS_DTBPOINTS 29 +#define CS_HBPOINTS 30 +#define CS_HTBPOINTS 31 +#define CS_HPBPOINTS 32 -#define CS_MODELS 32 +#define CS_MODELS 33 #define CS_SOUNDS (CS_MODELS+MAX_MODELS) #define CS_PLAYERS (CS_SOUNDS+MAX_SOUNDS) #define MAX_PRECACHES 32 @@ -752,6 +755,8 @@ typedef struct vec3_t mins; vec3_t maxs; + + int buildPoints; int health; @@ -784,10 +789,12 @@ gitem_t *BG_FindItemForHoldable( holdable_t pw ); //TA: int BG_FindBuildNumForName( char *name ); +int BG_FindBuildNumForEntityName( char *name ); char *BG_FindNameForBuildable( int bclass ); char *BG_FindEntityNameForBuildable( int bclass ); void BG_FindBBoxForBuildable( int bclass, vec3_t mins, vec3_t maxs ); int BG_FindHealthForBuildable( int bclass ); +int BG_FindBuildPointsForBuildable( int bclass ); int BG_FindDamageForBuildable( int bclass ); int BG_FindSplashDamageForBuildable( int bclass ); int BG_FindSplashRadiusForBuildable( int bclass ); @@ -796,6 +803,7 @@ int BG_FindTeamForBuildable( int bclass ); int BG_FindEventForBuildable( int bclass ); int BG_FindNextThinkForBuildable( int bclass ); int BG_FindCreepTestForBuildable( int bclass ); +int BG_FindReactorTestForBuildable( int bclass ); int BG_FindClassNumForName( char *name ); char *BG_FindNameForClassNum( int pclass ); diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index e12aee75..286b792a 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -140,9 +140,6 @@ void DSpawn_Melt( gentity_t *self ) } else G_FreeEntity( self ); - - //update spawn counts - CalculateRanks( ); } /* @@ -288,9 +285,9 @@ void HRpt_Think( gentity_t *self ) } if( count && reactor ) - self->active = qtrue; + self->active = self->powered = qtrue; else - self->active = qfalse; + self->active = self->powered = qfalse; self->nextthink = level.time + 10000; } @@ -524,9 +521,6 @@ void HSpawn_Blast( gentity_t *self ) self->splashRadius, self, self->splashMethodOfDeath ); G_FreeEntity( self ); - - //update spawn counts - CalculateRanks( ); } @@ -611,30 +605,40 @@ itemBuildError_t itemFits( gentity_t *ent, buildable_t buildable, int distance ) if( tr1.fraction < 1.0 || tr2.fraction < 1.0 ) reason = IBE_NOROOM; - if( BG_FindCreepTestForBuildable( buildable ) ) + if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_DROIDS ) { - for ( i = 1, tempent = g_entities + i; i < level.num_entities; i++, tempent++ ) + //droid criteria + if( BG_FindCreepTestForBuildable( buildable ) ) { - if( !Q_stricmp( tempent->classname, "team_droid_spawn" ) ) + for ( i = 1, tempent = g_entities + i; i < level.num_entities; i++, tempent++ ) { - VectorSubtract( entity_origin, tempent->s.origin, temp_v ); - if( VectorLength( temp_v ) <= ( CREEP_BASESIZE * 3 ) ) - break; + if( !Q_stricmp( tempent->classname, "team_droid_spawn" ) ) + { + VectorSubtract( entity_origin, tempent->s.origin, temp_v ); + if( VectorLength( temp_v ) <= ( CREEP_BASESIZE * 3 ) ) + break; + } } - } - if( i >= level.num_entities ) - reason = IBE_NOCREEP; + if( i >= level.num_entities ) + reason = IBE_NOCREEP; + } } - - if( BG_FindReactorTestForBuildable( buildable ) ) + else if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) { - for ( i = 1, tempent = g_entities + i; i < level.num_entities; i++, tempent++ ) + //human criteria + if( level.humanBuildPoints - BG_FindBuildPointsForBuildable( buildable ) < 0 ) + reason = IBE_NOPOWER; + + if( BG_FindReactorTestForBuildable( buildable ) ) { - if( !Q_stricmp( tempent->classname, "team_human_reactor" ) ) + for ( i = 1, tempent = g_entities + i; i < level.num_entities; i++, tempent++ ) { - reason = IBE_REACTOR; - break; + if( !Q_stricmp( tempent->classname, "team_human_reactor" ) ) + { + reason = IBE_REACTOR; + break; + } } } } @@ -716,6 +720,7 @@ gentity_t *Build_Item( gentity_t *ent, buildable_t buildable, int distance ) { else if( buildable == BA_H_REACTOR ) { built->die = HSpawn_Die; + built->powered = qtrue; } else if( buildable == BA_H_REPEATER ) { @@ -734,9 +739,6 @@ gentity_t *Build_Item( gentity_t *ent, buildable_t buildable, int distance ) { VectorCopy( origin, built->s.origin ); built->s.pos.trType = TR_GRAVITY; built->s.pos.trTime = level.time; - - //update spawn counts - CalculateRanks( ); trap_LinkEntity (built); diff --git a/src/game/g_local.h b/src/game/g_local.h index dfe70341..2236e0d8 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -415,12 +415,18 @@ typedef struct { //TA: extra stuff: int numDroidSpawns; int numHumanSpawns; + int numDroidClients; int numHumanClients; + int numLiveDroidClients; int numLiveHumanClients; + int droidBuildPoints; + int droidBuildPointsTotal; int humanBuildPoints; + int humanBuildPointsTotal; + int humanBuildPointsPowered; } level_locals_t; @@ -477,6 +483,7 @@ typedef enum IBE_NOROOM, IBE_NOCREEP, IBE_REACTOR, + IBE_NOPOWER, IBE_MAXERRORS } itemBuildError_t; diff --git a/src/game/g_main.c b/src/game/g_main.c index 8a26fba2..4da1a4b1 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -165,6 +165,8 @@ void G_RunFrame( int levelTime ); void G_ShutdownGame( int restart ); void CheckExitRules( void ); +void countSpawns( void ); +void calculateBuildPoints( void ); /* ================ @@ -493,7 +495,11 @@ void G_InitGame( int levelTime, int randomSeed, int restart ) { G_RemapTeamShaders(); //TA: so the server counts the spawns without a client attached - CalculateRanks( ); + countSpawns( ); + + //TA: FIXME: grab these values from a worldspawn variable + level.humanBuildPoints = level.humanBuildPointsTotal = 1000; + level.droidBuildPoints = level.droidBuildPointsTotal = 1000; } @@ -776,6 +782,47 @@ void countSpawns( void ) /* ============ +calculateBuildPoints + +Recalculate the quantity of building points available to the teams +============ +*/ +void calculateBuildPoints( void ) +{ + int i; + int bclass; + gentity_t *ent; + + level.humanBuildPoints = level.humanBuildPointsPowered = level.humanBuildPointsTotal; + level.droidBuildPoints = level.droidBuildPointsTotal; + + for ( i = 1, ent = g_entities + i ; i < level.num_entities ; i++, ent++ ) + { + if (!ent->inuse) + continue; + + bclass = BG_FindBuildNumForEntityName( ent->classname ); + + if( bclass != BA_NONE ) + { + if( BG_FindTeamForBuildable( bclass ) == BIT_HUMANS ) + { + level.humanBuildPoints -= BG_FindBuildPointsForBuildable( bclass ); + + if( ent->powered ) + level.humanBuildPointsPowered -= BG_FindBuildPointsForBuildable( bclass ); + } + else + { + level.droidBuildPoints -= BG_FindBuildPointsForBuildable( bclass ); + } + } + } +} + + +/* +============ CalculateRanks Recalculates the score ranks of all players @@ -805,8 +852,6 @@ void CalculateRanks( void ) { level.numteamVotingClients[i] = 0; } - countSpawns( ); - for ( i = 0 ; i < level.maxclients ; i++ ) { if ( level.clients[i].pers.connected != CON_DISCONNECTED ) @@ -893,8 +938,11 @@ void CalculateRanks( void ) { } } - trap_SetConfigstring( CS_ABPOINTS, va("%i", level.droidBuildPoints ) ); + trap_SetConfigstring( CS_DBPOINTS, va("%i", level.droidBuildPoints ) ); + trap_SetConfigstring( CS_DTBPOINTS, va("%i", level.droidBuildPointsTotal ) ); trap_SetConfigstring( CS_HBPOINTS, va("%i", level.humanBuildPoints ) ); + trap_SetConfigstring( CS_HTBPOINTS, va("%i", level.humanBuildPointsTotal ) ); + trap_SetConfigstring( CS_HPBPOINTS, va("%i", level.humanBuildPointsPowered ) ); // set the CS_SCORES1/2 configstrings, which will be visible to everyone if ( g_gametype.integer >= GT_TEAM ) { @@ -1852,6 +1900,11 @@ end = trap_Milliseconds(); // see if it is time to do a tournement restart CheckTournament(); + + //TA: + countSpawns(); + calculateBuildPoints(); + Com_Printf( "%d %d %d\n", level.humanBuildPointsTotal, level.humanBuildPoints, level.humanBuildPointsPowered ); // see if it is time to end the level CheckExitRules(); |