diff options
| author | Tim Angus <tim@ngus.net> | 2001-10-17 22:08:15 +0000 | 
|---|---|---|
| committer | Tim Angus <tim@ngus.net> | 2001-10-17 22:08:15 +0000 | 
| commit | 40aca014bafee22f1e6e9f07673da14a295f8889 (patch) | |
| tree | 2ded9f15ee2f21a569501a2f7c7ff752c1756d39 | |
| parent | 816950d5a2114c26c69ec874a5a4fe09a495e4e8 (diff) | |
Starcraft style building inprogress
| -rw-r--r-- | src/cgame/cg_buildable.c | 70 | ||||
| -rw-r--r-- | src/cgame/cg_local.h | 13 | ||||
| -rw-r--r-- | src/cgame/cg_main.c | 5 | ||||
| -rw-r--r-- | src/cgame/cg_weapons.c | 3 | ||||
| -rw-r--r-- | src/game/bg_misc.c | 36 | ||||
| -rw-r--r-- | src/game/bg_public.h | 12 | ||||
| -rw-r--r-- | src/game/g_buildable.c | 69 | 
7 files changed, 160 insertions, 48 deletions
diff --git a/src/cgame/cg_buildable.c b/src/cgame/cg_buildable.c index 9e2a6d07..5de77173 100644 --- a/src/cgame/cg_buildable.c +++ b/src/cgame/cg_buildable.c @@ -130,7 +130,11 @@ void CG_InitBuildables( )  {    char  filename[MAX_QPATH];    char  *buildableName; +  char  *modelFile;    int   i; +  int   j; + +  memset( cg_buildables, 0, sizeof( cg_buildables ) );    for( i = BA_NONE + 1; i < BA_NUM_BUILDABLES; i++ )    { @@ -139,6 +143,12 @@ void CG_InitBuildables( )      Com_sprintf( filename, sizeof( filename ), "models/buildables/%s/animation.cfg", buildableName );      if ( !CG_ParseBuildableAnimationFile( filename, i ) )        Com_Printf( "Failed to load animation file %s\n", filename ); + +    for( j = 0; j <= 3; j++ ) +    { +      if( modelFile = BG_FindModelsForBuildable( i, j ) ) +        cg_buildables[ i ].models[ j ] = trap_R_RegisterModel( modelFile ); +    }    }  } @@ -184,7 +194,7 @@ static void CG_RunBuildableLerpFrame( centity_t *cent )  {    int                   f, numFrames;    animation_t           *anim; -  buildable_t           buildable = cent->currentState.clientNum; +  buildable_t           buildable = cent->currentState.modelindex;    lerpFrame_t           *lf = ¢->lerpFrame;    buildableAnimNumber_t newAnimation = cent->buildableAnim; @@ -285,6 +295,56 @@ static void CG_BuildableAnimation( centity_t *cent, int *old, int *now, float *b    *backLerp = cent->lerpFrame.backlerp;  } +/* +================== +CG_GhostBuildable +================== +*/ +void CG_GhostBuildable( buildable_t buildable ) +{ +  refEntity_t     ent; +  playerState_t   *ps; +  vec3_t          angles, forward, player_origin, entity_origin, target_origin; +  vec3_t          mins, maxs; +  float           distance; +  trace_t         tr; +   +  ps = &cg.predictedPlayerState; +   +  memset ( &ent, 0, sizeof( ent ) ); + +  VectorCopy( cg.predictedPlayerState.viewangles, angles ); +  angles[ PITCH ] = 0;  // always forward + +  AngleVectors( angles, forward, NULL, NULL ); +  VectorCopy( ps->origin, player_origin ); + +  distance = BG_FindBuildDistForClass( ps->stats[ STAT_PCLASS ] ); +  VectorMA( player_origin, distance, forward, entity_origin ); +   +  VectorCopy( entity_origin, target_origin ); +  entity_origin[ 2 ] += 32; +  target_origin[ 2 ] -= 4096; + +  BG_FindBBoxForBuildable( buildable, mins, maxs ); +   +  CG_Trace( &tr, entity_origin, mins, maxs, target_origin, ps->clientNum, MASK_PLAYERSOLID ); +  VectorCopy( tr.endpos, entity_origin ); +  entity_origin[ 2 ] += 0.1f; + +  VectorCopy( entity_origin, ent.origin ); +  VectorCopy( entity_origin, ent.oldorigin ); + +  AnglesToAxis( angles, ent.axis ); +  ent.hModel = cg_buildables[ buildable ].models[ 0 ]; +  ent.customShader = cgs.media.quadShader; +  ent.nonNormalizedAxes = qfalse; + +  // add to refresh list +  trap_R_AddRefEntityToScene( &ent ); +} + +  #define TRACE_DEPTH 128.0f  /* @@ -318,7 +378,7 @@ void CG_Buildable( centity_t *cent )    VectorCopy( cent->lerpOrigin, ent.oldorigin );    VectorCopy( es->origin2, surfNormal ); -  BG_FindBBoxForBuildable( es->clientNum, mins, maxs ); +  BG_FindBBoxForBuildable( es->modelindex, mins, maxs );    if( surfNormal[ 2 ] != 1.0f )    { @@ -347,7 +407,7 @@ void CG_Buildable( centity_t *cent )    else      AnglesToAxis( es->angles, ent.axis ); -  ent.hModel = cg_items[es->modelindex].models[0]; +  ent.hModel = cg_buildables[ es->modelindex ].models[ 0 ];    ent.nonNormalizedAxes = qfalse; @@ -355,7 +415,7 @@ void CG_Buildable( centity_t *cent )    CG_BuildableAnimation( cent, &ent.oldframe, &ent.frame, &ent.backlerp );    //turret barrel bit -  if( cg_items[ es->modelindex ].models[ 1 ] != 0 ) +  if( cg_buildables[ es->modelindex ].models[ 1 ] != 0 )    {      vec3_t turretOrigin; @@ -363,7 +423,7 @@ void CG_Buildable( centity_t *cent )      AnglesToAxis( es->angles2, ent2.axis ); -    ent2.hModel = cg_items[ es->modelindex ].models[ 1 ]; +    ent2.hModel = cg_buildables[ es->modelindex ].models[ 1 ];      VectorCopy( cent->lerpOrigin, turretOrigin );      turretOrigin[ 2 ] += 5; diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index adec761b..33dfea74 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -436,6 +436,10 @@ typedef struct {    qhandle_t   icon;  } itemInfo_t; +typedef struct +{ +  qhandle_t   models[MAX_ITEM_MODELS]; +} buildableInfo_t;  typedef struct {    int       itemNum; @@ -1098,11 +1102,13 @@ extern  centity_t   cg_entities[MAX_GENTITIES];  //TA: weapon limit expanded:  //extern  weaponInfo_t  cg_weapons[MAX_WEAPONS]; -extern  weaponInfo_t  cg_weapons[32]; +extern  weaponInfo_t    cg_weapons[32];  //TA: upgrade infos: -extern  upgradeInfo_t  cg_upgrades[32]; +extern  upgradeInfo_t   cg_upgrades[32]; +extern  itemInfo_t      cg_items[MAX_ITEMS]; +//TA: buildable infos: +extern  buildableInfo_t cg_buildables[ BA_NUM_BUILDABLES ]; -extern  itemInfo_t    cg_items[MAX_ITEMS];  extern  markPoly_t    cg_markPolys[MAX_MARK_POLYS];  //TA: @@ -1352,6 +1358,7 @@ sfxHandle_t CG_CustomSound( int clientNum, const char *soundName );  //  // cg_buildable.c  // +void CG_GhostBuildable( buildable_t buildable );  void CG_Buildable( centity_t *cent );  void CG_InitBuildables( ); diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c index f49568bf..3bf26193 100644 --- a/src/cgame/cg_main.c +++ b/src/cgame/cg_main.c @@ -82,9 +82,10 @@ centity_t     cg_entities[MAX_GENTITIES];  //TA: weapons limit expanded:  //weaponInfo_t    cg_weapons[MAX_WEAPONS];  weaponInfo_t    cg_weapons[32]; -upgradeInfo_t    cg_upgrades[32]; +upgradeInfo_t   cg_upgrades[32];  itemInfo_t      cg_items[MAX_ITEMS]; +buildableInfo_t cg_buildables[ BA_NUM_BUILDABLES ];  //TA:  cgItemPos_t      cgIP; @@ -227,7 +228,7 @@ static cvarTable_t   cvarTable[] = {    { &cg_simpleItems, "cg_simpleItems", "0", CVAR_ARCHIVE },    { &cg_addMarks, "cg_marks", "1", CVAR_ARCHIVE },    { &cg_lagometer, "cg_lagometer", "1", CVAR_ARCHIVE }, -  { &cg_teslaTrailTime, "cg_teslaTrailTime", "400", CVAR_ARCHIVE  }, +  { &cg_teslaTrailTime, "cg_teslaTrailTime", "600", CVAR_ARCHIVE  },    { &cg_railTrailTime, "cg_railTrailTime", "400", CVAR_ARCHIVE  },    { &cg_gun_x, "cg_gunX", "0", CVAR_CHEAT },    { &cg_gun_y, "cg_gunY", "0", CVAR_CHEAT }, diff --git a/src/cgame/cg_weapons.c b/src/cgame/cg_weapons.c index eaafe655..efde2187 100644 --- a/src/cgame/cg_weapons.c +++ b/src/cgame/cg_weapons.c @@ -1353,6 +1353,9 @@ void CG_AddViewWeapon( playerState_t *ps ) {      return;    } +  /*if( ps->stats[ STAT_BUILDABLE ] & SB_ACTIVE_TOGGLEBIT )*/ +    CG_GhostBuildable( BA_H_SPAWN ); +    // no gun if in third person view    if ( cg.renderingThirdPerson ) {      return; diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index fdc371e0..03472b08 100644 --- a/src/game/bg_misc.c +++ b/src/game/bg_misc.c @@ -1241,6 +1241,7 @@ buildableAttributes_t bg_buildableList[ ] =      BA_D_SPAWN,            //int       buildNum;           "bioegg",              //char      *buildName;      "team_droid_spawn",    //char      *entityName; +    { "models/buildables/bioegg/bioegg.md3", 0, 0, 0 },      { -15, -15, -15 },     //vec3_t    mins;      { 15, 15, 15 },        //vec3_t    maxs;      TR_GRAVITY,            //trType_t traj; @@ -1268,6 +1269,7 @@ buildableAttributes_t bg_buildableList[ ] =      BA_D_BARRICADE,        //int       buildNum;      "barricade",           //char      *buildName;      "team_droid_barricade",//char      *entityName; +    { "models/buildables/barricade/barricade.md3", 0, 0, 0 },      { -15, -15, -15 },     //vec3_t    mins;      { 15, 15, 15 },        //vec3_t    maxs;      TR_GRAVITY,            //trType_t traj; @@ -1295,6 +1297,7 @@ buildableAttributes_t bg_buildableList[ ] =      BA_D_BOOSTER,          //int       buildNum;      "booster",             //char      *buildName;      "team_droid_booster",  //char      *entityName; +    { "models/buildables/booster/booster.md3", 0, 0, 0 },      { -15, -15, -15 },     //vec3_t    mins;      { 15, 15, 15 },        //vec3_t    maxs;      TR_GRAVITY,            //trType_t traj; @@ -1322,6 +1325,7 @@ buildableAttributes_t bg_buildableList[ ] =      BA_D_ACIDTUBE,         //int       buildNum;      "acid_tube",           //char      *buildName;      "team_droid_acid_tube",//char      *entityName; +    { "models/buildables/acid_tube/acid_tube.md3", 0, 0, 0 },      { -15, -15, -15 },     //vec3_t    mins;      { 15, 15, 15 },        //vec3_t    maxs;      TR_GRAVITY,            //trType_t traj; @@ -1349,6 +1353,7 @@ buildableAttributes_t bg_buildableList[ ] =      BA_D_TRAPPER,          //int       buildNum;      "trapper",             //char      *buildName;      "team_droid_trapper",  //char      *entityName; +    { "models/buildables/trapper/trapper.md3", 0, 0, 0 },      { -15, -15, -15 },     //vec3_t    mins;      { 15, 15, 15 },        //vec3_t    maxs;      TR_GRAVITY,            //trType_t traj; @@ -1376,6 +1381,7 @@ buildableAttributes_t bg_buildableList[ ] =      BA_D_HIVEMIND,         //int       buildNum;      "hivemind",            //char      *buildName;      "team_droid_hivemind", //char      *entityName; +    { "models/buildables/hivemind/hivemind.md3", 0, 0, 0 },      { -15, -15, -15 },     //vec3_t    mins;      { 15, 15, 15 },        //vec3_t    maxs;      TR_GRAVITY,            //trType_t traj; @@ -1403,6 +1409,7 @@ buildableAttributes_t bg_buildableList[ ] =      BA_H_SPAWN,            //int       buildNum;      "replicator",          //char      *buildName;      "team_human_spawn",    //char      *entityName; +    { "models/buildables/replicator/replicator.md3", 0, 0, 0 },      { -40, -40, -4 },      //vec3_t    mins;      { 40, 40, 4 },         //vec3_t    maxs;      TR_GRAVITY,            //trType_t traj; @@ -1430,6 +1437,7 @@ buildableAttributes_t bg_buildableList[ ] =      BA_H_MEDISTAT,         //int       buildNum;      "medistat",            //char      *buildName;      "team_human_medistat", //char      *entityName; +    { "models/buildables/medistat/medistat.md3", 0, 0, 0 },      { -40, -40, -4 },      //vec3_t    mins;      { 40, 40, 4 },         //vec3_t    maxs;      TR_GRAVITY,            //trType_t traj; @@ -1457,6 +1465,7 @@ buildableAttributes_t bg_buildableList[ ] =      BA_H_DEF1,             //int       buildNum;      "plasmaturret",        //char      *buildName;      "team_human_def1",     //char      *entityName; +    { "models/buildables/plasmaturret/pturret_base.md3", "models/buildables/plasmaturret/pturret_top.md3", 0, 0 },      { -24, -24, -11 },     //vec3_t    mins;      { 24, 24, 11 },        //vec3_t    maxs;      TR_GRAVITY,            //trType_t traj; @@ -1484,6 +1493,7 @@ buildableAttributes_t bg_buildableList[ ] =      BA_H_DEF2,             //int       buildNum;      "mgturret",            //char      *buildName;      "team_human_def2",     //char      *entityName; +    { "models/buildables/plasmaturret/pturret_base.md3", "models/weapons2/machinegun/machinegun.md3", 0, 0 },      { -24, -24, -11 },     //vec3_t    mins;      { 24, 24, 11 },        //vec3_t    maxs;      TR_GRAVITY,            //trType_t traj; @@ -1511,6 +1521,7 @@ buildableAttributes_t bg_buildableList[ ] =      BA_H_DEF3,             //int       buildNum;      "tesla",               //char      *buildName;      "team_human_tesla",    //char      *entityName; +    { "models/buildables/tesla/tesla.md3", 0, 0, 0 },      { -22, -22, -40 },     //vec3_t    mins;      { 22, 22, 40 },        //vec3_t    maxs;      TR_GRAVITY,            //trType_t traj; @@ -1538,6 +1549,7 @@ buildableAttributes_t bg_buildableList[ ] =      BA_H_DCC,              //int       buildNum;      "dcc",                 //char      *buildName;      "team_human_dcc",      //char      *entityName; +    { "models/buildables/dcc/dcc.md3", 0, 0, 0 },      { -15, -15, -15 },     //vec3_t    mins;      { 15, 15, 15 },        //vec3_t    maxs;      TR_GRAVITY,            //trType_t traj; @@ -1565,6 +1577,7 @@ buildableAttributes_t bg_buildableList[ ] =      BA_H_BANK,             //int       buildNum;      "bank",                //char      *buildName;      "team_human_bank",     //char      *entityName; +    { "models/buildables/bank/bank.md3", 0, 0, 0 },      { -15, -15, -15 },     //vec3_t    mins;      { 15, 15, 15 },        //vec3_t    maxs;      TR_GRAVITY,            //trType_t traj; @@ -1592,6 +1605,7 @@ buildableAttributes_t bg_buildableList[ ] =      BA_H_MCU,              //int       buildNum;      "mcu",                 //char      *buildName;      "team_human_mcu",      //char      *entityName; +    { "models/buildables/mcu/mcu.md3", 0, 0, 0 },      { -15, -15, -15 },     //vec3_t    mins;      { 15, 15, 15 },        //vec3_t    maxs;      TR_GRAVITY,            //trType_t traj; @@ -1619,6 +1633,7 @@ buildableAttributes_t bg_buildableList[ ] =      BA_H_REACTOR,          //int       buildNum;      "reactor",             //char      *buildName;      "team_human_reactor",  //char      *entityName; +    { "models/buildables/reactor/reactor.md3", 0, 0, 0 },      { -15, -15, -15 },     //vec3_t    mins;      { 15, 15, 15 },        //vec3_t    maxs;      TR_GRAVITY,            //trType_t traj; @@ -1646,6 +1661,7 @@ buildableAttributes_t bg_buildableList[ ] =      BA_H_REPEATER,         //int       buildNum;      "repeater",            //char      *buildName;      "team_human_repeater", //char      *entityName; +    { "models/buildables/repeater/repeater.md3", 0, 0, 0 },      { -15, -15, -15 },     //vec3_t    mins;      { 15, 15, 15 },        //vec3_t    maxs;      TR_GRAVITY,            //trType_t traj; @@ -1673,6 +1689,7 @@ buildableAttributes_t bg_buildableList[ ] =      BA_H_FLOATMINE,        //int       buildNum;      "floatmine",           //char      *buildName;      "team_human_floatmine",//char      *entityName; +    { "models/buildables/floatmine/floatmine.md3", 0, 0, 0 },      { -15, -15, -15 },     //vec3_t    mins;      { 15, 15, 15 },        //vec3_t    maxs;      TR_BUOYANCY,           //trType_t traj; @@ -1778,6 +1795,25 @@ char *BG_FindEntityNameForBuildable( int bclass )  /*  ============== +BG_FindModelsForBuildNum +============== +*/ +char *BG_FindModelsForBuildable( int bclass, int modelNum ) +{ +  int i; + +  for( i = 0; i < bg_numBuildables; i++ ) +  { +    if( bg_buildableList[ i ].buildNum == bclass ) +      return bg_buildableList[ i ].models[ modelNum ]; +  } + +  //wimp out +  return ""; +} + +/* +==============  BG_FindBBoxForBuildable  ==============  */ diff --git a/src/game/bg_public.h b/src/game/bg_public.h index c96ef9e2..2aa4e737 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -234,7 +234,8 @@ typedef enum {    STAT_STAMINA,   //TA: stamina (human only)    STAT_STATE,     //TA: client states e.g. wall climbing    STAT_CREDIT,    //TA: human credit -  STAT_MISC       //TA: for uh...misc stuff +  STAT_MISC,      //TA: for uh...misc stuff +  STAT_BUILDABLE  //TA: which ghost model to display for building  } statIndex_t;  #define SCA_WALLCLIMBER         1 @@ -253,6 +254,8 @@ typedef enum {  #define SS_BLOBLOCKED           128  #define SS_POISONED             256 +#define SB_VALID_TOGGLEBIT      8192 +#define SB_ACTIVE_TOGGLEBIT     16384  // player_state->persistant[] indexes  // these fields are the only part of player_state that isn't @@ -856,6 +859,8 @@ typedef struct    char      *buildName;    char      *entityName; +   +  char      *models[ MAX_ITEM_MODELS ];    vec3_t    mins;    vec3_t    maxs; @@ -942,6 +947,7 @@ int           BG_FindBuildNumForName( char *name );  int           BG_FindBuildNumForEntityName( char *name );  char          *BG_FindNameForBuildable( int bclass );  char          *BG_FindEntityNameForBuildable( int bclass ); +char          *BG_FindModelsForBuildable( int bclass, int modelNum );  void          BG_FindBBoxForBuildable( int bclass, vec3_t mins, vec3_t maxs );  int           BG_FindHealthForBuildable( int bclass );  trType_t      BG_FindTrajectoryForBuildable( int bclass ); @@ -1026,8 +1032,8 @@ typedef enum {    ET_PLAYER,    ET_ITEM, -  ET_BUILDABLE, //TA: buildable type -  ET_CREEP, //TA: creep type +  ET_BUILDABLE,       //TA: buildable type +  ET_CREEP,           //TA: creep type    ET_MISSILE,    ET_MOVER, diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index 7ee5e570..cec65380 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -86,11 +86,11 @@ qboolean findPower( gentity_t *self )        continue;      //if entity is a power item calculate the distance to it -    if( ent->s.clientNum == BA_H_REACTOR || ent->s.clientNum == BA_H_REPEATER ) +    if( ent->s.modelindex == BA_H_REACTOR || ent->s.modelindex == BA_H_REPEATER )      {        VectorSubtract( self->s.origin, ent->s.origin, temp_v );        distance = VectorLength( temp_v ); -      if( distance < minDistance && ( ent->active || self->s.clientNum == BA_H_SPAWN ) ) +      if( distance < minDistance && ( ent->active || self->s.modelindex == BA_H_SPAWN ) )        {          closestPower = ent;          minDistance = distance; @@ -104,10 +104,10 @@ qboolean findPower( gentity_t *self )      return qfalse;    //bleh -  if( ( closestPower->s.clientNum == BA_H_REACTOR && ( minDistance <= REACTOR_BASESIZE ) ) ||  -      ( closestPower->s.clientNum == BA_H_REPEATER && self->s.clientNum == BA_H_SPAWN && +  if( ( closestPower->s.modelindex == BA_H_REACTOR && ( minDistance <= REACTOR_BASESIZE ) ) ||  +      ( closestPower->s.modelindex == BA_H_REPEATER && self->s.modelindex == BA_H_SPAWN &&          ( minDistance <= REPEATER_BASESIZE ) && closestPower->powered ) || -      ( closestPower->s.clientNum == BA_H_REPEATER && ( minDistance <= REPEATER_BASESIZE ) && +      ( closestPower->s.modelindex == BA_H_REPEATER && ( minDistance <= REPEATER_BASESIZE ) &&          closestPower->active && closestPower->powered )      )    { @@ -150,7 +150,7 @@ qboolean findDCC( gentity_t *self )        continue;      //if entity is a power item calculate the distance to it -    if( ent->s.clientNum == BA_H_DCC ) +    if( ent->s.modelindex == BA_H_DCC )      {        VectorSubtract( self->s.origin, ent->s.origin, temp_v );        distance = VectorLength( temp_v ); @@ -200,7 +200,7 @@ qboolean findCreep( gentity_t *self )        if( !ent->classname || ent->s.eType != ET_BUILDABLE )          continue; -      if( ent->s.clientNum == BA_D_SPAWN || ent->s.clientNum == BA_D_HIVEMIND ) +      if( ent->s.modelindex == BA_D_SPAWN || ent->s.modelindex == BA_D_HIVEMIND )        {          /*VectorSubtract( self->s.origin, ent->s.origin, temp_v );*/          VectorSubtract( self->s.origin, ent->s.origin, temp_v ); @@ -402,7 +402,7 @@ void DSpawn_Think( gentity_t *self )        G_FreeEntity( ent ); //quietly remove    } -  self->nextthink = level.time + BG_FindNextThinkForBuildable( self->s.clientNum ); +  self->nextthink = level.time + BG_FindNextThinkForBuildable( self->s.modelindex );  }  /* @@ -503,7 +503,7 @@ void DBarricade_Think( gentity_t *self )      return;    } -  self->nextthink = level.time + BG_FindNextThinkForBuildable( self->s.clientNum ); +  self->nextthink = level.time + BG_FindNextThinkForBuildable( self->s.modelindex );  } @@ -543,7 +543,7 @@ void DAcidTube_Damage( gentity_t *self )    G_SelectiveRadiusDamage( self->s.pos.trBase, self->parent, self->splashDamage,      self->splashRadius, self, self->splashMethodOfDeath, PTE_DROIDS ); -  self->nextthink = level.time + BG_FindNextThinkForBuildable( self->s.clientNum ); +  self->nextthink = level.time + BG_FindNextThinkForBuildable( self->s.modelindex );  }  /* @@ -586,7 +586,7 @@ void DAcidTube_Think( gentity_t *self )      }    } -  self->nextthink = level.time + BG_FindNextThinkForBuildable( self->s.clientNum ); +  self->nextthink = level.time + BG_FindNextThinkForBuildable( self->s.modelindex );  } @@ -629,7 +629,7 @@ void ddef_fireonenemy( gentity_t *self, int firespeed )    vec3_t  dirToTarget;    vec3_t  target;    vec3_t  halfAcceleration, thirdJerk; -  float   distanceToTarget = BG_FindRangeForBuildable( self->s.clientNum ); +  float   distanceToTarget = BG_FindRangeForBuildable( self->s.modelindex );    int     i;    VectorScale( self->enemy->acceleration, 1.0f / 2.0f, halfAcceleration ); @@ -740,10 +740,10 @@ think function for Droid Defense  */  void DTrapper_Think( gentity_t *self )  { -  int range =     BG_FindRangeForBuildable( self->s.clientNum ); -  int firespeed = BG_FindFireSpeedForBuildable( self->s.clientNum ); +  int range =     BG_FindRangeForBuildable( self->s.modelindex ); +  int firespeed = BG_FindFireSpeedForBuildable( self->s.modelindex ); -  self->nextthink = level.time + BG_FindNextThinkForBuildable( self->s.clientNum ); +  self->nextthink = level.time + BG_FindNextThinkForBuildable( self->s.modelindex );    //if there is no creep nearby die    if( !findCreep( self ) ) @@ -791,10 +791,10 @@ void HRpt_Think( gentity_t *self )      if( !ent->classname || ent->s.eType != ET_BUILDABLE )        continue; -    if( ent->s.clientNum == BA_H_SPAWN && ent->parentNode == self ) +    if( ent->s.modelindex == BA_H_SPAWN && ent->parentNode == self )        count++; -    if( ent->s.clientNum == BA_H_REACTOR ) +    if( ent->s.modelindex == BA_H_REACTOR )        reactor = qtrue;    } @@ -958,7 +958,7 @@ void HMedistat_Think( gentity_t *self )      }    } -  self->nextthink = level.time + BG_FindNextThinkForBuildable( self->s.clientNum ); +  self->nextthink = level.time + BG_FindNextThinkForBuildable( self->s.modelindex );  } @@ -1062,7 +1062,7 @@ qboolean hdef1_trackenemy( gentity_t *self )  {    vec3_t  dirToTarget, angleToTarget, angularDiff;    float   temp; -  float   distanceToTarget = BG_FindRangeForBuildable( self->s.clientNum ); +  float   distanceToTarget = BG_FindRangeForBuildable( self->s.modelindex );    float   timeTilImpact;    vec3_t  halfAcceleration;    vec3_t  thirdJerk; @@ -1317,10 +1317,10 @@ think function for Human Defense  */  void HDef_Think( gentity_t *self )  { -  int range =     BG_FindRangeForBuildable( self->s.clientNum ); -  int firespeed = BG_FindFireSpeedForBuildable( self->s.clientNum ); +  int range =     BG_FindRangeForBuildable( self->s.modelindex ); +  int firespeed = BG_FindFireSpeedForBuildable( self->s.modelindex ); -  self->nextthink = level.time + BG_FindNextThinkForBuildable( self->s.clientNum ); +  self->nextthink = level.time + BG_FindNextThinkForBuildable( self->s.modelindex );    //find power for self    self->powered = findPower( self ); @@ -1351,7 +1351,7 @@ void HDef_Think( gentity_t *self )    self->enemy->targeted = self;    //if we are pointing at our target and we can fire shoot it -  switch( self->s.clientNum ) +  switch( self->s.modelindex )    {      case BA_H_DEF1:        if( hdef1_trackenemy( self ) && ( self->count < level.time ) ) @@ -1471,7 +1471,7 @@ void HSpawn_Think( gentity_t *self )        G_FreeEntity( ent ); //quietly remove    } -  self->nextthink = level.time + BG_FindNextThinkForBuildable( self->s.clientNum ); +  self->nextthink = level.time + BG_FindNextThinkForBuildable( self->s.modelindex );  } @@ -1540,7 +1540,7 @@ itemBuildError_t G_itemFits( gentity_t *ent, buildable_t buildable, int distance          if( !tempent->classname || tempent->s.eType != ET_BUILDABLE )            continue; -        if( tempent->s.clientNum == BA_D_SPAWN || tempent->s.clientNum == BA_D_HIVEMIND ) +        if( tempent->s.modelindex == BA_D_SPAWN || tempent->s.modelindex == BA_D_HIVEMIND )          {            VectorSubtract( entity_origin, tempent->s.origin, temp_v );            if( VectorLength( temp_v ) <= ( CREEP_BASESIZE * 3 ) ) @@ -1557,7 +1557,7 @@ itemBuildError_t G_itemFits( gentity_t *ent, buildable_t buildable, int distance      {        if( !tempent->classname || tempent->s.eType != ET_BUILDABLE )          continue; -      if( tempent->s.clientNum == BA_D_HIVEMIND ) +      if( tempent->s.modelindex == BA_D_HIVEMIND )          break;      } @@ -1578,7 +1578,7 @@ itemBuildError_t G_itemFits( gentity_t *ent, buildable_t buildable, int distance          if( !tempent->classname || tempent->s.eType != ET_BUILDABLE )            continue; -        if( tempent->s.clientNum == BA_D_HIVEMIND ) +        if( tempent->s.modelindex == BA_D_HIVEMIND )          {            reason = IBE_HIVEMIND;            break; @@ -1601,7 +1601,7 @@ itemBuildError_t G_itemFits( gentity_t *ent, buildable_t buildable, int distance        if( !tempent->classname || tempent->s.eType != ET_BUILDABLE )          continue; -      if( tempent->s.clientNum == BA_H_REACTOR || tempent->s.clientNum == BA_H_REPEATER ) +      if( tempent->s.modelindex == BA_H_REACTOR || tempent->s.modelindex == BA_H_REPEATER )        {          VectorSubtract( entity_origin, tempent->s.origin, temp_v );          templength = VectorLength( temp_v ); @@ -1615,9 +1615,9 @@ itemBuildError_t G_itemFits( gentity_t *ent, buildable_t buildable, int distance      //if this power entity satisfies expression      if( !( -           ( closestPower->s.clientNum == BA_H_REACTOR && minDistance <= REACTOR_BASESIZE ) ||  +           ( closestPower->s.modelindex == BA_H_REACTOR && minDistance <= REACTOR_BASESIZE ) ||              ( -             closestPower->s.clientNum == BA_H_REPEATER && minDistance <= REPEATER_BASESIZE && +             closestPower->s.modelindex == BA_H_REPEATER && minDistance <= REPEATER_BASESIZE &&               (                 ( buildable == BA_H_SPAWN && closestPower->powered ) ||                 ( closestPower->powered && closestPower->active ) @@ -1643,7 +1643,7 @@ itemBuildError_t G_itemFits( gentity_t *ent, buildable_t buildable, int distance          if( !tempent->classname || tempent->s.eType != ET_BUILDABLE )            continue; -        if( tempent->s.clientNum == BA_H_REACTOR )  +        if( tempent->s.modelindex == BA_H_REACTOR )             break;        } @@ -1659,7 +1659,7 @@ itemBuildError_t G_itemFits( gentity_t *ent, buildable_t buildable, int distance          if( !tempent->classname || tempent->s.eType != ET_BUILDABLE )            continue; -        if( tempent->s.clientNum == BA_H_REACTOR )  +        if( tempent->s.modelindex == BA_H_REACTOR )           {            reason = IBE_REACTOR;            break; @@ -1694,11 +1694,10 @@ gentity_t *G_buildItem( gentity_t *builder, buildable_t buildable, vec3_t origin    built->classname = BG_FindEntityNameForBuildable( buildable );    built->item = BG_FindItemForBuildable( buildable ); -  built->s.modelindex = built->item - bg_itemlist; // store item number in modelindex -  built->s.clientNum = buildable; //so we can tell what this is on the client side +  built->s.modelindex = buildable; //so we can tell what this is on the client side +  built->biteam = built->s.modelindex2 = BG_FindTeamForBuildable( buildable );    BG_FindBBoxForBuildable( buildable, built->r.mins, built->r.maxs ); -  built->biteam = built->s.modelindex2 = BG_FindTeamForBuildable( buildable );    built->health = BG_FindHealthForBuildable( buildable );    built->damage = BG_FindDamageForBuildable( buildable );  | 
