diff options
author | Tim Angus <tim@ngus.net> | 2001-03-31 18:36:08 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2001-03-31 18:36:08 +0000 |
commit | e462d0658ddb7a655c8d1440d6f226d93be8dac3 (patch) | |
tree | ab20c4fca70ef3dbebda8dd05cb13ebccbb6e96d | |
parent | a83af83ef20da0b7d2754079831fb6e90dc2e069 (diff) |
Can't build without power first
-rw-r--r-- | src/game/g_buildable.c | 49 |
1 files changed, 43 insertions, 6 deletions
diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index f41d714a..135fcdb7 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -41,7 +41,7 @@ qboolean findPower( gentity_t *self ) int distance = 0; int minDistance = 10000; vec3_t temp_v; - + if( self->parentNode && self->parentNode->active ) return qtrue; @@ -66,15 +66,13 @@ qboolean findPower( gentity_t *self ) if( ( !Q_stricmp( closestPower->classname, "team_human_reactor" ) && ( minDistance <= REACTOR_BASESIZE ) - ) - || + ) || ( !Q_stricmp( closestPower->classname, "team_human_repeater" ) && !Q_stricmp( self->classname, "team_human_spawn" ) && ( minDistance <= REPEATER_BASESIZE ) && closestPower->powered - ) - || + ) || ( !Q_stricmp( closestPower->classname, "team_human_repeater" ) && ( minDistance <= REPEATER_BASESIZE ) && @@ -84,6 +82,7 @@ qboolean findPower( gentity_t *self ) ) { self->parentNode = closestPower; + return qtrue; } else @@ -581,7 +580,8 @@ itemBuildError_t itemFits( gentity_t *ent, buildable_t buildable, int distance ) trace_t tr1, tr2; int i; itemBuildError_t reason = IBE_NONE; - gentity_t *tempent; + gentity_t *tempent, *closestPower; + int minDistance, templength; VectorCopy( ent->s.apos.trBase, angles ); angles[PITCH] = 0; // always forward @@ -623,6 +623,43 @@ itemBuildError_t itemFits( gentity_t *ent, buildable_t buildable, int distance ) if( level.humanBuildPoints - BG_FindBuildPointsForBuildable( buildable ) < 0 ) reason = IBE_NOPOWER; +/* tempent->classname = BG_FindEntityNameForBuildable( buildable ); + VectorCopy( entity_origin, tempent->s.origin ); + tempent->parentNode = NULL; + + if( !findPower( tempent ) ) + reason = IBE_NOPOWER;*/ + for ( i = 1, tempent = g_entities + i; i < level.num_entities; i++, tempent++ ) + { + if( !Q_stricmp( tempent->classname, "team_human_reactor" ) || + !Q_stricmp( tempent->classname, "team_human_repeater" ) ) + { + VectorSubtract( entity_origin, tempent->s.origin, temp_v ); + templength = VectorLength( temp_v ); + if( templength < minDistance ) + { + closestPower = tempent; + minDistance = templength; + } + } + } + + if( !( + !Q_stricmp( closestPower->classname, "team_human_reactor" ) && + ( minDistance <= REACTOR_BASESIZE ) + ) && + !( + !Q_stricmp( closestPower->classname, "team_human_repeater" ) && + ( minDistance <= REPEATER_BASESIZE ) && + closestPower->active && + closestPower->powered + ) + ) + { + if( buildable != BA_H_SPAWN && buildable != BA_H_REACTOR && buildable != BA_H_REPEATER ) + reason = IBE_NOPOWER; + } + if( BG_FindReactorTestForBuildable( buildable ) ) { for ( i = 1, tempent = g_entities + i; i < level.num_entities; i++, tempent++ ) |