summaryrefslogtreecommitdiff
path: root/src/game/g_buildable.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/g_buildable.c')
-rw-r--r--src/game/g_buildable.c138
1 files changed, 70 insertions, 68 deletions
diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c
index 1e575a93..c4b1f120 100644
--- a/src/game/g_buildable.c
+++ b/src/game/g_buildable.c
@@ -73,7 +73,7 @@ gentity_t *G_CheckSpawnPoint( int spawnNum, vec3_t origin, vec3_t normal,
vec3_t localOrigin;
trace_t tr;
- BG_FindBBoxForBuildable( spawn, mins, maxs );
+ BG_BuildableBoundingBox( spawn, mins, maxs );
if( spawn == BA_A_SPAWN )
{
@@ -102,7 +102,7 @@ gentity_t *G_CheckSpawnPoint( int spawnNum, vec3_t origin, vec3_t normal,
}
else if( spawn == BA_H_SPAWN )
{
- BG_FindBBoxForClass( PCL_HUMAN, cmins, cmaxs, NULL, NULL, NULL );
+ BG_ClassBoundingBox( PCL_HUMAN, cmins, cmaxs, NULL, NULL, NULL );
VectorCopy( origin, localOrigin );
localOrigin[ 2 ] += maxs[ 2 ] + fabs( cmins[ 2 ] ) + 1.0f;
@@ -472,7 +472,7 @@ static void G_CreepSlow( gentity_t *self )
int i, num;
gentity_t *enemy;
buildable_t buildable = self->s.modelindex;
- float creepSize = (float)BG_FindCreepSizeForBuildable( buildable );
+ float creepSize = (float)BG_Buildable( buildable )->creepSize;
VectorSet( range, creepSize, creepSize, creepSize );
@@ -541,7 +541,7 @@ void AGeneric_CreepRecede( gentity_t *self )
self->s.time = -( level.time -
(int)( (float)CREEP_SCALEDOWN_TIME *
( 1.0f - ( (float)( level.time - self->buildTime ) /
- (float)BG_FindBuildTimeForBuildable( self->s.modelindex ) ) ) ) );
+ (float)BG_Buildable( self->s.modelindex )->buildTime ) ) ) );
}
//creep is still receeding
@@ -609,12 +609,12 @@ void AGeneric_Die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, i
!self->deconstruct )
G_TeamCommand( TEAM_ALIENS,
va( "print \"%s ^3DESTROYED^7 by teammate %s^7\n\"",
- BG_FindHumanNameForBuildable( self->s.modelindex ),
+ BG_Buildable( self->s.modelindex )->humanName,
attacker->client->pers.netname ) );
G_LogPrintf( "Decon: %i %i %i: %s destroyed %s by %s\n",
attacker->client->ps.clientNum, self->s.modelindex, mod,
attacker->client->pers.netname,
- BG_FindNameForBuildable( self->s.modelindex ),
+ BG_Buildable( self->s.modelindex )->name,
modNames[ mod ] );
}
}
@@ -653,7 +653,7 @@ A generic think function for Alien buildables
void AGeneric_Think( gentity_t *self )
{
self->powered = G_IsOvermindBuilt( );
- self->nextthink = level.time + BG_FindNextThinkForBuildable( self->s.modelindex );
+ self->nextthink = level.time + BG_Buildable( self->s.modelindex )->nextthink;
AGeneric_CreepCheck( self );
}
@@ -741,7 +741,7 @@ void ASpawn_Think( gentity_t *self )
G_CreepSlow( self );
- self->nextthink = level.time + BG_FindNextThinkForBuildable( self->s.modelindex );
+ self->nextthink = level.time + BG_Buildable( self->s.modelindex )->nextthink;
}
@@ -839,7 +839,7 @@ void AOvermind_Think( gentity_t *self )
G_CreepSlow( self );
- self->nextthink = level.time + BG_FindNextThinkForBuildable( self->s.modelindex );
+ self->nextthink = level.time + BG_Buildable( self->s.modelindex )->nextthink;
}
@@ -897,11 +897,13 @@ void ABarricade_Shrink( gentity_t *self, qboolean shrink )
}
return;
}
- if ( !shrink &&
- ( !self->shrunkTime ||
- level.time < self->shrunkTime + BARRICADE_SHRINKTIMEOUT ) )
+
+ if ( !shrink && ( !self->shrunkTime ||
+ level.time < self->shrunkTime + BARRICADE_SHRINKTIMEOUT ) )
return;
- BG_FindBBoxForBuildable( BA_A_BARRICADE, self->r.mins, self->r.maxs );
+
+ BG_BuildableBoundingBox( BA_A_BARRICADE, self->r.mins, self->r.maxs );
+
if ( shrink )
{
self->r.maxs[ 2 ] = (int)( self->r.maxs[ 2 ] * BARRICADE_SHRINKPROP );
@@ -933,7 +935,7 @@ void ABarricade_Shrink( gentity_t *self, qboolean shrink )
if ( self->spawned && self->health > 0 &&
anim != BANIM_CONSTRUCT1 && anim != BANIM_CONSTRUCT2 )
{
- G_SetIdleBuildableAnim( self, BG_FindAnimForBuildable( BA_A_BARRICADE ) );
+ G_SetIdleBuildableAnim( self, BG_Buildable( BA_A_BARRICADE )->idleAnim );
G_SetBuildableAnim( self, BANIM_ATTACK2, qtrue );
}
}
@@ -1017,7 +1019,7 @@ void AAcidTube_Think( gentity_t *self )
gentity_t *enemy;
self->powered = G_IsOvermindBuilt( );
- self->nextthink = level.time + BG_FindNextThinkForBuildable( self->s.modelindex );
+ self->nextthink = level.time + BG_Buildable( self->s.modelindex )->nextthink;
VectorAdd( self->s.origin, range, maxs );
VectorSubtract( self->s.origin, range, mins );
@@ -1108,7 +1110,7 @@ Think function for Alien Hive
void AHive_Think( gentity_t *self )
{
self->powered = G_IsOvermindBuilt( );
- self->nextthink = level.time + BG_FindNextThinkForBuildable( self->s.modelindex );
+ self->nextthink = level.time + BG_Buildable( self->s.modelindex )->nextthink;
AGeneric_CreepCheck( self );
@@ -1204,8 +1206,8 @@ qboolean AHovel_Blocked( gentity_t *hovel, gentity_t *player, qboolean provideEx
float displacement;
trace_t tr;
- BG_FindBBoxForBuildable( BA_A_HOVEL, NULL, hovelMaxs );
- BG_FindBBoxForClass( player->client->ps.stats[ STAT_CLASS ],
+ BG_BuildableBoundingBox( BA_A_HOVEL, NULL, hovelMaxs );
+ BG_ClassBoundingBox( player->client->ps.stats[ STAT_CLASS ],
mins, maxs, NULL, NULL, NULL );
VectorCopy( hovel->s.origin2, normal );
@@ -1439,11 +1441,11 @@ void ATrapper_FireOnEnemy( gentity_t *self, int firespeed, float range )
gentity_t *enemy = self->enemy;
vec3_t dirToTarget;
vec3_t halfAcceleration, thirdJerk;
- float distanceToTarget = BG_FindRangeForBuildable( self->s.modelindex );
+ float distanceToTarget = BG_Buildable( self->s.modelindex )->turretRange;
int lowMsec = 0;
int highMsec = (int)( (
( ( distanceToTarget * LOCKBLOB_SPEED ) +
- ( distanceToTarget * BG_FindSpeedForClass( enemy->client->ps.stats[ STAT_CLASS ] ) ) ) /
+ ( distanceToTarget * BG_Class( enemy->client->ps.stats[ STAT_CLASS ] )->speed ) ) /
( LOCKBLOB_SPEED * LOCKBLOB_SPEED ) ) * 1000.0f );
VectorScale( enemy->acceleration, 1.0f / 2.0f, halfAcceleration );
@@ -1561,11 +1563,11 @@ think function for Alien Defense
*/
void ATrapper_Think( gentity_t *self )
{
- int range = BG_FindRangeForBuildable( self->s.modelindex );
- int firespeed = BG_FindFireSpeedForBuildable( self->s.modelindex );
+ int range = BG_Buildable( self->s.modelindex )->turretRange;
+ int firespeed = BG_Buildable( self->s.modelindex )->turretFireSpeed;
self->powered = G_IsOvermindBuilt( );
- self->nextthink = level.time + BG_FindNextThinkForBuildable( self->s.modelindex );
+ self->nextthink = level.time + BG_Buildable( self->s.modelindex )->nextthink;
AGeneric_CreepCheck( self );
@@ -1829,7 +1831,7 @@ void HMedistat_Think( gentity_t *self )
gentity_t *player;
qboolean occupied = qfalse;
- self->nextthink = level.time + BG_FindNextThinkForBuildable( self->s.modelindex );
+ self->nextthink = level.time + BG_Buildable( self->s.modelindex )->nextthink;
//clear target's healing flag
if( self->enemy && self->enemy->client )
@@ -2093,7 +2095,7 @@ Think function for MG turret
void HMGTurret_Think( gentity_t *self )
{
self->nextthink = level.time +
- BG_FindNextThinkForBuildable( self->s.modelindex );
+ BG_Buildable( self->s.modelindex )->nextthink;
// Turn off client side muzzle flashes
self->s.eFlags &= ~EF_FIRING;
@@ -2144,7 +2146,7 @@ void HMGTurret_Think( gentity_t *self )
FireWeapon( self );
self->s.eFlags |= EF_FIRING;
- self->count = level.time + BG_FindFireSpeedForBuildable( self->s.modelindex );
+ self->count = level.time + BG_Buildable( self->s.modelindex )->turretFireSpeed;
G_AddEvent( self, EV_FIRE_WEAPON, 0 );
G_SetBuildableAnim( self, BANIM_ATTACK1, qfalse );
}
@@ -2166,7 +2168,7 @@ Think function for Tesla Generator
*/
void HTeslaGen_Think( gentity_t *self )
{
- self->nextthink = level.time + BG_FindNextThinkForBuildable( self->s.modelindex );
+ self->nextthink = level.time + BG_Buildable( self->s.modelindex )->nextthink;
//if not powered don't do anything and check again for power next think
if( !( self->powered = G_FindPower( self ) ) )
@@ -2314,12 +2316,12 @@ void HSpawn_Die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int
!self->deconstruct )
G_TeamCommand( TEAM_HUMANS,
va( "print \"%s ^3DESTROYED^7 by teammate %s^7\n\"",
- BG_FindHumanNameForBuildable( self->s.modelindex ),
+ BG_Buildable( self->s.modelindex )->humanName,
attacker->client->pers.netname ) );
G_LogPrintf( "Decon: %i %i %i: %s destroyed %s by %s\n",
attacker->client->ps.clientNum, self->s.modelindex, mod,
attacker->client->pers.netname,
- BG_FindNameForBuildable( self->s.modelindex ),
+ BG_Buildable( self->s.modelindex )->name,
modNames[ mod ] );
}
}
@@ -2359,7 +2361,7 @@ void HSpawn_Think( gentity_t *self )
}
}
- self->nextthink = level.time + BG_FindNextThinkForBuildable( self->s.modelindex );
+ self->nextthink = level.time + BG_Buildable( self->s.modelindex )->nextthink;
}
@@ -2389,7 +2391,7 @@ void G_BuildableTouchTriggers( gentity_t *ent )
if( ent->health <= 0 )
return;
- BG_FindBBoxForBuildable( ent->s.modelindex, bmins, bmaxs );
+ BG_BuildableBoundingBox( ent->s.modelindex, bmins, bmaxs );
VectorAdd( ent->s.origin, bmins, mins );
VectorAdd( ent->s.origin, bmaxs, maxs );
@@ -2436,9 +2438,9 @@ General think function for buildables
*/
void G_BuildableThink( gentity_t *ent, int msec )
{
- int bHealth = BG_FindHealthForBuildable( ent->s.modelindex );
- int bRegen = BG_FindRegenRateForBuildable( ent->s.modelindex );
- int bTime = BG_FindBuildTimeForBuildable( ent->s.modelindex );
+ int bHealth = BG_Buildable( ent->s.modelindex )->health;
+ int bRegen = BG_Buildable( ent->s.modelindex )->regenRate;
+ int bTime = BG_Buildable( ent->s.modelindex )->buildTime;
//toggle spawned flag for buildables
if( !ent->spawned && ent->health > 0 )
@@ -2585,11 +2587,11 @@ static qboolean G_BuildablesIntersect( buildable_t a, vec3_t originA,
vec3_t minsA, maxsA;
vec3_t minsB, maxsB;
- BG_FindBBoxForBuildable( a, minsA, maxsA );
+ BG_BuildableBoundingBox( a, minsA, maxsA );
VectorAdd( minsA, originA, minsA );
VectorAdd( maxsA, originA, maxsA );
- BG_FindBBoxForBuildable( b, minsB, maxsB );
+ BG_BuildableBoundingBox( b, minsB, maxsB );
VectorAdd( minsB, originB, minsB );
VectorAdd( maxsB, originB, maxsB );
@@ -2725,8 +2727,8 @@ static itemBuildError_t G_SufficientBPAvailable( buildable_t buildable,
int numBuildables = 0;
int pointsYielded = 0;
gentity_t *ent;
- team_t team = BG_FindTeamForBuildable( buildable );
- int buildPoints = BG_FindBuildPointsForBuildable( buildable );
+ team_t team = BG_Buildable( buildable )->team;
+ int buildPoints = BG_Buildable( buildable )->buildPoints;
int remainingBP, remainingSpawns;
qboolean collision = qfalse;
int collisionCount = 0;
@@ -2853,14 +2855,14 @@ static itemBuildError_t G_SufficientBPAvailable( buildable_t buildable,
if( repeaterInRange )
repeaterInRangeCount--;
- pointsYielded += BG_FindBuildPointsForBuildable( ent->s.modelindex );
+ pointsYielded += BG_Buildable( ent->s.modelindex )->buildPoints;
level.numBuildablesForRemoval++;
}
- else if( BG_FindUniqueTestForBuildable( ent->s.modelindex ) &&
+ else if( BG_Buildable( ent->s.modelindex )->uniqueTest &&
ent->s.modelindex == buildable )
{
// If it's a unique buildable, it must be replaced by the same type
- pointsYielded += BG_FindBuildPointsForBuildable( ent->s.modelindex );
+ pointsYielded += BG_Buildable( ent->s.modelindex )->buildPoints;
level.numBuildablesForRemoval++;
}
}
@@ -2889,7 +2891,7 @@ static itemBuildError_t G_SufficientBPAvailable( buildable_t buildable,
level.numBuildablesForRemoval++ )
{
ent = level.markedBuildables[ level.numBuildablesForRemoval ];
- pointsYielded += BG_FindBuildPointsForBuildable( ent->s.modelindex );
+ pointsYielded += BG_Buildable( ent->s.modelindex )->buildPoints;
}
for( i = 0; i < level.numBuildablesForRemoval; i++ )
@@ -2957,7 +2959,7 @@ itemBuildError_t G_CanBuild( gentity_t *ent, buildable_t buildable, int distance
// Stop all buildables from interacting with traces
G_SetBuildableLinkState( qfalse );
- BG_FindBBoxForBuildable( buildable, mins, maxs );
+ BG_BuildableBoundingBox( buildable, mins, maxs );
BG_PositionBuildableRelativeToPlayer( ps, mins, maxs, trap_Trace, entity_origin, angles, &tr1 );
trap_Trace( &tr2, entity_origin, mins, maxs, entity_origin, ent->s.number, MASK_PLAYERSOLID );
@@ -2966,8 +2968,8 @@ itemBuildError_t G_CanBuild( gentity_t *ent, buildable_t buildable, int distance
VectorCopy( entity_origin, origin );
VectorCopy( tr1.plane.normal, normal );
- minNormal = BG_FindMinNormalForBuildable( buildable );
- invert = BG_FindInvertNormalForBuildable( buildable );
+ minNormal = BG_Buildable( buildable )->minNormal;
+ invert = BG_Buildable( buildable )->invertNormal;
//can we build at this angle?
if( !( normal[ 2 ] >= minNormal || ( invert && normal[ 2 ] <= -minNormal ) ) )
@@ -2981,7 +2983,7 @@ itemBuildError_t G_CanBuild( gentity_t *ent, buildable_t buildable, int distance
reason = IBE_NORMAL;
contents = trap_PointContents( entity_origin, -1 );
- buildPoints = BG_FindBuildPointsForBuildable( buildable );
+ buildPoints = BG_Buildable( buildable )->buildPoints;
if( ent->client->ps.stats[ STAT_TEAM ] == TEAM_ALIENS )
{
@@ -2997,7 +2999,7 @@ itemBuildError_t G_CanBuild( gentity_t *ent, buildable_t buildable, int distance
}
//check there is creep near by for building on
- if( BG_FindCreepTestForBuildable( buildable ) )
+ if( BG_Buildable( buildable )->creepTest )
{
if( !G_IsCreepHere( entity_origin ) )
reason = IBE_NOCREEP;
@@ -3008,7 +3010,7 @@ itemBuildError_t G_CanBuild( gentity_t *ent, buildable_t buildable, int distance
vec3_t builderMins, builderMaxs;
//this assumes the adv builder is the biggest thing that'll use the hovel
- BG_FindBBoxForClass( PCL_ALIEN_BUILDER0_UPG, builderMins, builderMaxs, NULL, NULL, NULL );
+ BG_ClassBoundingBox( PCL_ALIEN_BUILDER0_UPG, builderMins, builderMaxs, NULL, NULL, NULL );
if( APropHovel_Blocked( angles, origin, normal, ent ) )
reason = IBE_HOVELEXIT;
@@ -3031,7 +3033,7 @@ itemBuildError_t G_CanBuild( gentity_t *ent, buildable_t buildable, int distance
}
//this buildable requires a DCC
- if( BG_FindDCCTestForBuildable( buildable ) && !G_IsDCCBuilt( ) )
+ if( BG_Buildable( buildable )->dccTest && !G_IsDCCBuilt( ) )
reason = IBE_NODCC;
//check that there is a parent reactor when building a repeater
@@ -3057,7 +3059,7 @@ itemBuildError_t G_CanBuild( gentity_t *ent, buildable_t buildable, int distance
reason = IBE_PERMISSION;
// Can we only have one of these?
- if( BG_FindUniqueTestForBuildable( buildable ) )
+ if( BG_Buildable( buildable )->uniqueTest )
{
tempent = G_FindBuildable( buildable );
if( tempent && !tempent->deconstruct )
@@ -3119,10 +3121,10 @@ static gentity_t *G_Build( gentity_t *builder, buildable_t buildable, vec3_t ori
built = G_Spawn();
built->s.eType = ET_BUILDABLE;
built->killedBy = ENTITYNUM_NONE;
- built->classname = BG_FindEntityNameForBuildable( buildable );
+ built->classname = BG_Buildable( buildable )->entityName;
built->s.modelindex = buildable;
- built->buildableTeam = built->s.modelindex2 = BG_FindTeamForBuildable( buildable );
- BG_FindBBoxForBuildable( buildable, built->r.mins, built->r.maxs );
+ built->buildableTeam = built->s.modelindex2 = BG_Buildable( buildable )->team;
+ BG_BuildableBoundingBox( buildable, built->r.mins, built->r.maxs );
// detect the buildable's normal vector
if( !builder->client )
@@ -3135,7 +3137,7 @@ static gentity_t *G_Build( gentity_t *builder, buildable_t buildable, vec3_t ori
{
VectorCopy( builder->s.origin2, normal );
}
- else if( BG_FindTrajectoryForBuildable( buildable ) == TR_BUOYANCY )
+ else if( BG_Buildable( buildable )->traj == TR_BUOYANCY )
VectorSet( normal, 0.0f, 0.0f, -1.0f );
else
VectorSet( normal, 0.0f, 0.0f, 1.0f );
@@ -3153,11 +3155,11 @@ static gentity_t *G_Build( gentity_t *builder, buildable_t buildable, vec3_t ori
built->health = 1;
- built->splashDamage = BG_FindSplashDamageForBuildable( buildable );
- built->splashRadius = BG_FindSplashRadiusForBuildable( buildable );
- built->splashMethodOfDeath = BG_FindMODForBuildable( buildable );
+ built->splashDamage = BG_Buildable( buildable )->splashDamage;
+ built->splashRadius = BG_Buildable( buildable )->splashRadius;
+ built->splashMethodOfDeath = BG_Buildable( buildable )->meansOfDeath;
- built->nextthink = BG_FindNextThinkForBuildable( buildable );
+ built->nextthink = BG_Buildable( buildable )->nextthink;
built->takedamage = qtrue;
built->spawned = qfalse;
@@ -3166,9 +3168,9 @@ static gentity_t *G_Build( gentity_t *builder, buildable_t buildable, vec3_t ori
// build instantly in cheat mode
if( builder->client && g_cheats.integer )
{
- built->health = BG_FindHealthForBuildable( buildable );
+ built->health = BG_Buildable( buildable )->health;
built->buildTime = built->s.time =
- level.time - BG_FindBuildTimeForBuildable( buildable );
+ level.time - BG_Buildable( buildable )->buildTime;
}
//things that vary for each buildable that aren't in the dbase
@@ -3281,7 +3283,7 @@ static gentity_t *G_Build( gentity_t *builder, buildable_t buildable, vec3_t ori
built->r.contents = CONTENTS_BODY;
built->clipmask = MASK_PLAYERSOLID;
built->enemy = NULL;
- built->s.weapon = BG_FindProjTypeForBuildable( buildable );
+ built->s.weapon = BG_Buildable( buildable )->turretProjType;
if( builder->client )
built->builtBy = builder->client->ps.clientNum;
@@ -3299,18 +3301,18 @@ static gentity_t *G_Build( gentity_t *builder, buildable_t buildable, vec3_t ori
VectorCopy( angles, built->s.angles );
built->s.angles[ PITCH ] = 0.0f;
built->s.angles2[ YAW ] = angles[ YAW ];
- built->s.pos.trType = BG_FindTrajectoryForBuildable( buildable );
+ built->s.pos.trType = BG_Buildable( buildable )->traj;
built->s.pos.trTime = level.time;
- built->physicsBounce = BG_FindBounceForBuildable( buildable );
+ built->physicsBounce = BG_Buildable( buildable )->bounce;
built->s.groundEntityNum = -1;
built->s.generic1 = (int)( ( (float)built->health /
- (float)BG_FindHealthForBuildable( buildable ) ) * B_HEALTH_MASK );
+ (float)BG_Buildable( buildable )->health ) * B_HEALTH_MASK );
if( built->s.generic1 < 0 )
built->s.generic1 = 0;
- if( BG_FindTeamForBuildable( built->s.modelindex ) == TEAM_ALIENS )
+ if( BG_Buildable( buildable )->team == TEAM_ALIENS )
{
built->powered = qtrue;
built->s.eFlags |= EF_B_POWERED;
@@ -3324,7 +3326,7 @@ static gentity_t *G_Build( gentity_t *builder, buildable_t buildable, vec3_t ori
G_AddEvent( built, EV_BUILD_CONSTRUCT, 0 );
- G_SetIdleBuildableAnim( built, BG_FindAnimForBuildable( buildable ) );
+ G_SetIdleBuildableAnim( built, BG_Buildable( buildable )->idleAnim );
if( built->builtBy >= 0 )
G_SetBuildableAnim( built, BANIM_CONSTRUCT1, qtrue );
@@ -3344,7 +3346,7 @@ qboolean G_BuildIfValid( gentity_t *ent, buildable_t buildable )
float dist;
vec3_t origin;
- dist = BG_FindBuildDistForClass( ent->client->ps.stats[ STAT_CLASS ] );
+ dist = BG_Class( ent->client->ps.stats[ STAT_CLASS ] )->buildDist;
switch( G_CanBuild( ent, buildable, dist, origin ) )
{
@@ -3439,7 +3441,7 @@ static void G_FinishSpawningBuildable( gentity_t *ent )
built->takedamage = qtrue;
built->spawned = qtrue; //map entities are already spawned
- built->health = BG_FindHealthForBuildable( buildable );
+ built->health = BG_Buildable( buildable )->health;
built->s.eFlags |= EF_B_SPAWNED;
// drop towards normal surface