diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/game/g_buildable.c | 104 | ||||
-rw-r--r-- | src/game/g_cmds.c | 15 | ||||
-rw-r--r-- | src/game/g_local.h | 3 | ||||
-rw-r--r-- | src/game/tremulous.h | 2 |
4 files changed, 78 insertions, 46 deletions
diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index d182db1e..0336f031 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -111,30 +111,6 @@ gentity_t *G_CheckSpawnPoint( int spawnNum, vec3_t origin, vec3_t normal, return NULL; } -/* -================ -G_NumberOfDependants - -Return number of entities that depend on this one -================ -*/ -static int G_NumberOfDependants( gentity_t *self ) -{ - int i, n = 0; - gentity_t *ent; - - for( i = MAX_CLIENTS, ent = g_entities + i; i < level.num_entities; i++, ent++ ) - { - if( ent->s.eType != ET_BUILDABLE ) - continue; - - if( ent->parentNode == self ) - n++; - } - - return n; -} - #define POWER_REFRESH_TIME 2000 /* @@ -144,7 +120,7 @@ G_FindPower attempt to find power for self, return qtrue if successful ================ */ -static qboolean G_FindPower( gentity_t *self ) +qboolean G_FindPower( gentity_t *self ) { int i, j; gentity_t *ent, *ent2; @@ -158,7 +134,27 @@ static qboolean G_FindPower( gentity_t *self ) // Reactor is always powered if( self->s.modelindex == BA_H_REACTOR ) + { + self->parentNode = self; + return qtrue; + } + + // Handle repeaters + if( self->s.modelindex == BA_H_REPEATER ) + { + if( level.reactorPresent ) + { + G_FindReactor( self ); + self->parentNode = self->reactorNode; + + return qtrue; + } + + self->parentNode = NULL; + + return qfalse; + } // Reset parent self->parentNode = NULL; @@ -602,6 +598,45 @@ qboolean G_FindOvermind( gentity_t *self ) /* ================ +G_FindReactor + +Attempt to find a reactor for self +================ +*/ +qboolean G_FindReactor( gentity_t *self ) +{ + int i; + gentity_t *ent; + + if( self->buildableTeam != TEAM_HUMANS ) + return qfalse; + + // If this already has reactor then stop now + if( self->reactorNode && self->reactorNode->health > 0 ) + return qtrue; + + // Reset parent + self->reactorNode = NULL; + + // Iterate through entities + for( i = MAX_CLIENTS, ent = g_entities + i; i < level.num_entities; i++, ent++ ) + { + if( ent->s.eType != ET_BUILDABLE ) + continue; + + // If entity is an overmind calculate the distance to it + if( ent->s.modelindex == BA_H_REACTOR && ent->spawned && ent->health > 0 ) + { + self->reactorNode = ent; + return qtrue; + } + } + + return qfalse; +} + +/* +================ G_FindCreep attempt to find creep for self, return qtrue if successful @@ -1883,19 +1918,6 @@ void HRepeater_Think( gentity_t *self ) } } - if( G_NumberOfDependants( self ) == 0 ) - { - // If no dependants for x seconds then disappear - if( self->count < 0 ) - self->count = level.time; - else if( self->count > 0 && ( ( level.time - self->count ) > REPEATER_INACTIVE_TIME ) ) - G_Damage( self, NULL, NULL, NULL, NULL, self->health, 0, MOD_SUICIDE ); - } - else - { - self->count = -1; - } - if( G_InPowerZone( self ) ) { // if the repeater is inside of another power zone then disappear @@ -3219,11 +3241,11 @@ static itemBuildError_t G_SufficientBPAvailable( buildable_t buildable, if( ent->s.modelindex == core && buildable != core ) continue; - // Don't allow a power source to be replaced by a non-power source + // Don't allow a power source to be replaced by a dependant if( team == TEAM_HUMANS && - buildable != BA_H_REACTOR && + G_PowerEntityForPoint( origin ) != ent && buildable != BA_H_REPEATER && - !( ent->s.modelindex == BA_H_REACTOR || ent->s.modelindex == BA_H_REPEATER ) ) + buildable != core ) continue; if( ent->deconstruct ) diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 4b691a01..35047f86 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -1970,10 +1970,15 @@ void Cmd_Destroy_f( gentity_t *ent ) if( G_TimeTilSuddenDeath( ) <= 0 ) return; - if( !g_markDeconstruct.integer && ent->client->ps.stats[ STAT_MISC ] > 0 ) + if( !g_markDeconstruct.integer || + ( ent->client->pers.teamSelection == TEAM_HUMANS && + !G_FindPower( traceEnt ) ) ) { - G_AddEvent( ent, EV_BUILD_DELAY, ent->client->ps.clientNum ); - return; + if( ent->client->ps.stats[ STAT_MISC ] > 0 ) + { + G_AddEvent( ent, EV_BUILD_DELAY, ent->client->ps.clientNum ); + return; + } } if( traceEnt->health > 0 ) @@ -1983,7 +1988,9 @@ void Cmd_Destroy_f( gentity_t *ent ) G_Damage( traceEnt, ent, ent, forward, tr.endpos, traceEnt->health, 0, MOD_SUICIDE ); } - else if( g_markDeconstruct.integer ) + else if( g_markDeconstruct.integer && + ( ent->client->pers.teamSelection != TEAM_HUMANS || + G_FindPower( traceEnt ) ) ) { traceEnt->deconstruct = qtrue; // Mark buildable for deconstruction traceEnt->deconstructTime = level.time; diff --git a/src/game/g_local.h b/src/game/g_local.h index a99b2341..033b0458 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -200,6 +200,7 @@ struct gentity_s qboolean powered; // for human buildables int builtBy; // clientNum of person that built this gentity_t *overmindNode; // controlling overmind + gentity_t *reactorNode; // reactor int dcc; // number of controlling dccs qboolean spawned; // whether or not this buildable has finished spawning int shrunkTime; // time when a barricade shrunk or zero @@ -750,6 +751,7 @@ buildable_t G_IsPowered( vec3_t origin ); qboolean G_IsDCCBuilt( void ); int G_FindDCC( gentity_t *self ); qboolean G_FindOvermind( gentity_t *self ); +qboolean G_FindReactor( gentity_t *self ); qboolean G_FindCreep( gentity_t *self ); void G_BuildableThink( gentity_t *ent, int msec ); @@ -767,6 +769,7 @@ void G_LayoutLoad( void ); void G_BaseSelfDestruct( team_t team ); void G_QueueBuildPoints( gentity_t *self ); int G_GetBuildPoints( const vec3_t pos, team_t team, int dist ); +qboolean G_FindPower( gentity_t *self ); gentity_t *G_PowerEntityForPoint( const vec3_t origin ); gentity_t *G_PowerEntityForEntity( gentity_t *ent ); gentity_t *G_RepeaterEntityForPoint( vec3_t origin ); diff --git a/src/game/tremulous.h b/src/game/tremulous.h index 9a5647a7..8101442d 100644 --- a/src/game/tremulous.h +++ b/src/game/tremulous.h @@ -609,7 +609,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #define REACTOR_ATTACK_DCC_DAMAGE 40 #define REACTOR_VALUE HBVM(30) -#define REPEATER_BP 2 +#define REPEATER_BP 4 #define REPEATER_BT 10000 #define REPEATER_HEALTH HBHM(250) #define REPEATER_SPLASHDAMAGE 50 |