diff options
author | Tim Angus <tim@ngus.net> | 2001-08-25 21:38:01 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2001-08-25 21:38:01 +0000 |
commit | 4a45364574eb2df7ed81862c7f2b50f2fd8c792f (patch) | |
tree | eea292d57de9ffa99951fab5de1da517aff842fb /src | |
parent | 999320c83474af63b7357677df7055f0495da328 (diff) |
Generalised building more
Diffstat (limited to 'src')
-rw-r--r-- | src/game/bg_misc.c | 96 | ||||
-rw-r--r-- | src/game/bg_public.h | 9 | ||||
-rw-r--r-- | src/game/g_buildable.c | 6 | ||||
-rw-r--r-- | src/game/g_cmds.c | 153 |
4 files changed, 162 insertions, 102 deletions
diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index bbe1f333..68a00c2e 100644 --- a/src/game/bg_misc.c +++ b/src/game/bg_misc.c @@ -1127,7 +1127,8 @@ buildableAttributes_t bg_buildableList[ ] = 200, //int splashRadius; MOD_DSPAWN, //int meansOfDeath; BIT_DROIDS, //int team; - BANIM_IDLE1, //int constructAnim; + ( 1 << WP_DBUILD ), //weapon_t buildWeapon; + BANIM_IDLE1, //int constructAnim; 100, //int nextthink; 0, //int turretFireSpeed; 0, //int turretRange; @@ -1150,7 +1151,8 @@ buildableAttributes_t bg_buildableList[ ] = 50, //int splashRadius; MOD_DSPAWN, //int meansOfDeath; BIT_DROIDS, //int team; - BANIM_IDLE1, //int constructAnim; + ( 1 << WP_DBUILD ), //weapon_t buildWeapon; + BANIM_IDLE1, //int constructAnim; 100, //int nextthink; 0, //int turretFireSpeed; 0, //int turretRange; @@ -1173,7 +1175,8 @@ buildableAttributes_t bg_buildableList[ ] = 50, //int splashRadius; MOD_DSPAWN, //int meansOfDeath; BIT_DROIDS, //int team; - BANIM_IDLE1, //int constructAnim; + ( 1 << WP_DBUILD ), //weapon_t buildWeapon; + BANIM_IDLE1, //int constructAnim; 100, //int nextthink; 1500, //int turretFireSpeed; 500, //int turretRange; @@ -1196,7 +1199,8 @@ buildableAttributes_t bg_buildableList[ ] = 50, //int splashRadius; MOD_DSPAWN, //int meansOfDeath; BIT_DROIDS, //int team; - BANIM_IDLE1, //int constructAnim; + ( 1 << WP_DBUILD ), //weapon_t buildWeapon; + BANIM_IDLE1, //int constructAnim; -1, //int nextthink; 0, //int turretFireSpeed; 0, //int turretRange; @@ -1219,7 +1223,8 @@ buildableAttributes_t bg_buildableList[ ] = 150, //int splashRadius; MOD_HSPAWN, //int meansOfDeath; BIT_HUMANS, //int team; - BANIM_IDLE1, //int constructAnim; + ( 1 << WP_HBUILD ), //weapon_t buildWeapon; + BANIM_IDLE1, //int constructAnim; 100, //int nextthink; 0, //int turretFireSpeed; 0, //int turretRange; @@ -1242,7 +1247,8 @@ buildableAttributes_t bg_buildableList[ ] = 50, //int splashRadius; MOD_HSPAWN, //int meansOfDeath; BIT_HUMANS, //int team; - BANIM_IDLE1, //int constructAnim; + ( 1 << WP_HBUILD ), //weapon_t buildWeapon; + BANIM_IDLE1, //int constructAnim; 50, //int nextthink; 500, //int turretFireSpeed; 500, //int turretRange; @@ -1265,7 +1271,8 @@ buildableAttributes_t bg_buildableList[ ] = 50, //int splashRadius; MOD_HSPAWN, //int meansOfDeath; BIT_HUMANS, //int team; - BANIM_IDLE1, //int constructAnim; + ( 1 << WP_HBUILD ), //weapon_t buildWeapon; + BANIM_IDLE1, //int constructAnim; 50, //int nextthink; 50, //int turretFireSpeed; 300, //int turretRange; @@ -1288,7 +1295,8 @@ buildableAttributes_t bg_buildableList[ ] = 50, //int splashRadius; MOD_HSPAWN, //int meansOfDeath; BIT_HUMANS, //int team; - BANIM_IDLE1, //int constructAnim; + ( 1 << WP_HBUILD ), //weapon_t buildWeapon; + BANIM_IDLE1, //int constructAnim; 150, //int nextthink; 4000, //int turretFireSpeed; 1500, //int turretRange; @@ -1311,7 +1319,8 @@ buildableAttributes_t bg_buildableList[ ] = 150, //int splashRadius; MOD_HSPAWN, //int meansOfDeath; BIT_HUMANS, //int team; - BANIM_IDLE1, //int constructAnim; + ( 1 << WP_HBUILD ), //weapon_t buildWeapon; + BANIM_IDLE1, //int constructAnim; 100, //int nextthink; 0, //int turretFireSpeed; 0, //int turretRange; @@ -1334,7 +1343,8 @@ buildableAttributes_t bg_buildableList[ ] = 150, //int splashRadius; MOD_HSPAWN, //int meansOfDeath; BIT_HUMANS, //int team; - BANIM_IDLE1, //int constructAnim; + ( 1 << WP_HBUILD ), //weapon_t buildWeapon; + BANIM_IDLE1, //int constructAnim; -1, //int nextthink; 0, //int turretFireSpeed; 0, //int turretRange; @@ -1357,6 +1367,7 @@ buildableAttributes_t bg_buildableList[ ] = 150, //int splashRadius; MOD_HSPAWN, //int meansOfDeath; BIT_HUMANS, //int team; + ( 1 << WP_HBUILD ), //weapon_t buildWeapon; BANIM_IDLE1, //int constructAnim; 100, //int nextthink; 0, //int turretFireSpeed; @@ -1380,6 +1391,7 @@ buildableAttributes_t bg_buildableList[ ] = 150, //int splashRadius; MOD_HSPAWN, //int meansOfDeath; BIT_HUMANS, //int team; + ( 1 << WP_HBUILD ), //weapon_t buildWeapon; BANIM_IDLE1, //int constructAnim; 100, //int nextthink; 0, //int turretFireSpeed; @@ -1680,6 +1692,26 @@ int BG_FindTeamForBuildable( int bclass ) /* ============== +BG_FindBuildWeaponForBuildable +============== +*/ +weapon_t BG_FindBuildWeaponForBuildable( int bclass ) +{ + int i; + + for( i = 0; i < bg_numBuildables; i++ ) + { + if( bg_buildableList[ i ].buildNum == bclass ) + { + return bg_buildableList[ i ].buildWeapon; + } + } + + return BA_NONE; +} + +/* +============== BG_FindAnimForBuildable ============== */ @@ -1834,8 +1866,9 @@ classAttributes_t bg_classList[ ] = { 15, 15, 4 }, //vec3_t deadmaxs; 12, 12, //int viewheight, crouchviewheight; 50, //int health; - 0, //int armor; + 0, //int armor; SCA_TAKESFALLDAMAGE|SCA_FOVWARPS, //int abilities; + 50.0f, //float buildDist; 80, //int fov; 0.015f, //float bob; 350, //int steptime; @@ -1859,6 +1892,7 @@ classAttributes_t bg_classList[ ] = 75, //int health; 10, //int armor; SCA_CANJUMP|SCA_FOVWARPS, //int abilities; + 50.0f, //float buildDist; 110, //int fov; 0.005f, //float bob; 200, //int steptime; @@ -1882,6 +1916,7 @@ classAttributes_t bg_classList[ ] = 100, //int health; 40, //int armor; SCA_TAKESFALLDAMAGE|SCA_FOVWARPS, //int abilities; + 50.0f, //float buildDist; 90, //int fov; 0.015f, //float bob; 350, //int steptime; @@ -1905,6 +1940,7 @@ classAttributes_t bg_classList[ ] = 120, //int health; 40, //int armor; SCA_CANJUMP|SCA_FOVWARPS, //int abilities; + 50.0f, //float buildDist; 120, //int fov; 0.002f, //float bob; 350, //int steptime; @@ -1928,6 +1964,7 @@ classAttributes_t bg_classList[ ] = 100, //int health; 40, //int armor; SCA_CANJUMP|SCA_FOVWARPS, //int abilities; + 50.0f, //float buildDist; 100, //int fov; 0.015f, //float bob; 350, //int steptime; @@ -1951,6 +1988,7 @@ classAttributes_t bg_classList[ ] = 25, //int health; 0, //int armor; SCA_WALLCLIMBER|SCA_CANJUMP|SCA_NOWEAPONDRIFT|SCA_FOVWARPS, //int abilities; + 0.0f, //float buildDist; 140, //int fov; 0.0f, //float bob; 25, //int steptime; @@ -1974,6 +2012,7 @@ classAttributes_t bg_classList[ ] = 50, //int health; 5, //int armor; SCA_CANJUMP|SCA_NOWEAPONDRIFT|SCA_FOVWARPS, //int abilities; + 0.0f, //float buildDist; 120, //int fov; 0.001f, //float bob; 25, //int steptime; @@ -1997,6 +2036,7 @@ classAttributes_t bg_classList[ ] = 50, //int health; 10, //int armor; SCA_CANJUMP|SCA_NOWEAPONDRIFT|SCA_FOVWARPS, //int abilities; + 0.0f, //float buildDist; 120, //int fov; 0.0005f, //float bob; 25, //int steptime; @@ -2020,6 +2060,7 @@ classAttributes_t bg_classList[ ] = 100, //int health; 20, //int armor; SCA_CANJUMP|SCA_NOWEAPONDRIFT|SCA_FOVWARPS, //int abilities; + 0.0f, //float buildDist; 130, //int fov; 0.0f, //float bob; 60, //int steptime; @@ -2043,6 +2084,7 @@ classAttributes_t bg_classList[ ] = 100, //int health; 30, //int armor; SCA_CANJUMP|SCA_NOWEAPONDRIFT|SCA_FOVWARPS, //int abilities; + 0.0f, //float buildDist; 130, //int fov; 0.0f, //float bob; 60, //int steptime; @@ -2066,6 +2108,7 @@ classAttributes_t bg_classList[ ] = 200, //int health; 40, //int armor; SCA_CANJUMP|SCA_NOWEAPONDRIFT|SCA_FOVWARPS, //int abilities; + 0.0f, //float buildDist; 120, //int fov; 0.0f, //float bob; 200, //int steptime; @@ -2089,6 +2132,7 @@ classAttributes_t bg_classList[ ] = 200, //int health; 50, //int armor; SCA_CANJUMP|SCA_NOWEAPONDRIFT|SCA_FOVWARPS, //int abilities; + 0.0f, //float buildDist; 120, //int fov; 0.0f, //float bob; 200, //int steptime; @@ -2112,6 +2156,7 @@ classAttributes_t bg_classList[ ] = 200, //int health; 60, //int armor; SCA_CANJUMP|SCA_NOWEAPONDRIFT|SCA_FOVWARPS, //int abilities; + 0.0f, //float buildDist; 120, //int fov; 0.0f, //float bob; 200, //int steptime; @@ -2135,6 +2180,7 @@ classAttributes_t bg_classList[ ] = 50, //int health; 0, //int armor; SCA_WALLCLIMBER|SCA_CANJUMP|SCA_NOWEAPONDRIFT|SCA_FOVWARPS, //int abilities; + 0.0f, //float buildDist; 90, //int fov; 0.0f, //float bob; 25, //int steptime; @@ -2158,6 +2204,7 @@ classAttributes_t bg_classList[ ] = 50, //int health; 50, //int armor; SCA_CANJUMP|SCA_NOWEAPONDRIFT|SCA_FOVWARPS, //int abilities; + 0.0f, //float buildDist; 100, //int fov; 0.0f, //float bob; 25, //int steptime; @@ -2181,6 +2228,7 @@ classAttributes_t bg_classList[ ] = 50, //int health; 50, //int armor; SCA_CANJUMP|SCA_NOWEAPONDRIFT|SCA_FOVWARPS, //int abilities; + 0.0f, //float buildDist; 100, //int fov; 0.0f, //float bob; 25, //int steptime; @@ -2204,6 +2252,7 @@ classAttributes_t bg_classList[ ] = 150, //int health; 50, //int armor; SCA_CANJUMP|SCA_NOWEAPONDRIFT|SCA_FOVWARPS, //int abilities; + 0.0f, //float buildDist; 110, //int fov; 0.0f, //float bob; 25, //int steptime; @@ -2227,6 +2276,7 @@ classAttributes_t bg_classList[ ] = 150, //int health; 50, //int armor; SCA_CANJUMP|SCA_NOWEAPONDRIFT|SCA_FOVWARPS, //int abilities; + 0.0f, //float buildDist; 110, //int fov; 0.0f, //float bob; 25, //int steptime; @@ -2250,6 +2300,7 @@ classAttributes_t bg_classList[ ] = 250, //int health; 50, //int armor; SCA_CANJUMP|SCA_NOWEAPONDRIFT|SCA_FOVWARPS, //int abilities; + 0.0f, //float buildDist; 130, //int fov; 0.0f, //float bob; 25, //int steptime; @@ -2273,6 +2324,7 @@ classAttributes_t bg_classList[ ] = 250, //int health; 50, //int armor; SCA_CANJUMP|SCA_NOWEAPONDRIFT|SCA_FOVWARPS, //int abilities; + 0.0f, //float buildDist; 130, //int fov; 0.0f, //float bob; 25, //int steptime; @@ -2296,6 +2348,7 @@ classAttributes_t bg_classList[ ] = 250, //int health; 50, //int armor; SCA_CANJUMP|SCA_NOWEAPONDRIFT|SCA_FOVWARPS, //int abilities; + 0.0f, //float buildDist; 130, //int fov; 0.0f, //float bob; 25, //int steptime; @@ -2319,6 +2372,7 @@ classAttributes_t bg_classList[ ] = 100, //int health; 0, //int armor; SCA_TAKESFALLDAMAGE|SCA_CANJUMP, //int abilities; + 80.0f, //float buildDist; 90, //int fov; 0.002f, //float bob; 200, //int steptime; @@ -2633,6 +2687,26 @@ qboolean BG_ClassHasAbility( int pclass, int ability ) /* ============== +BG_FindBuildDistForClass +============== +*/ +float BG_FindBuildDistForClass( int pclass ) +{ + int i; + + for( i = 0; i < bg_numPclasses; i++ ) + { + if( bg_classList[ i ].classNum == pclass ) + { + return bg_classList[ i ].buildDist; + } + } + + return 0.0f; +} + +/* +============== BG_ClassCanEvolveFromTo ============== */ diff --git a/src/game/bg_public.h b/src/game/bg_public.h index 8ebf4a10..72ccafa7 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -345,8 +345,12 @@ typedef enum { WP_VENOM, WP_GRABANDCSAW, WP_POUNCE, + + //build weapons must remain in a block WP_HBUILD, WP_DBUILD, + //ok? + WP_SCANNER, WP_GGRENADE, @@ -825,6 +829,8 @@ typedef struct int abilities; + float buildDist; + int fov; float bob; int steptime; @@ -861,6 +867,7 @@ typedef struct int meansOfDeath; int team; + weapon_t buildWeapon; int constructAnim; @@ -933,6 +940,7 @@ int BG_FindSplashDamageForBuildable( int bclass ); int BG_FindSplashRadiusForBuildable( int bclass ); int BG_FindMODForBuildable( int bclass ); int BG_FindTeamForBuildable( int bclass ); +weapon_t BG_FindBuildWeaponForBuildable( int bclass ); int BG_FindAnimForBuildable( int bclass ); int BG_FindNextThinkForBuildable( int bclass ); int BG_FindFireSpeedForBuildable( int bclass ); @@ -954,6 +962,7 @@ float BG_FindSpeedForClass( int pclass ); float BG_FindStickyForClass( int pclass ); int BG_FindSteptimeForClass( int pclass ); qboolean BG_ClassHasAbility( int pclass, int ability ); +float BG_FindBuildDistForClass( int pclass ); qboolean BG_ClassCanEvolveFromTo( int fclass, int tclass ); int BG_FindEvolveTimeForClass( int pclass ); int BG_FindValueOfClass( int pclass ); diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index e7093ca8..bd1332e2 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -86,7 +86,7 @@ qboolean findPower( gentity_t *self ) { VectorSubtract( self->s.origin, ent->s.origin, temp_v ); distance = VectorLength( temp_v ); - if( distance < minDistance ) + if( distance < minDistance && ( ent->active || !Q_stricmp( self->classname, "team_human_spawn" ) ) ) { closestPower = ent; minDistance = distance; @@ -1215,7 +1215,7 @@ itemBuildError_t itemFits( gentity_t *ent, buildable_t buildable, int distance ) { VectorSubtract( entity_origin, tempent->s.origin, temp_v ); templength = VectorLength( temp_v ); - if( templength < minDistance ) + if( templength < minDistance && ( tempent->active || buildable == BA_H_SPAWN ) ) { closestPower = tempent; minDistance = templength; @@ -1374,7 +1374,7 @@ gentity_t *Build_Item( gentity_t *ent, buildable_t buildable, int distance ) { case BA_H_REACTOR: built->die = HSpawn_Die; - built->powered = qtrue; + built->powered = built->active = qtrue; break; case BA_H_REPEATER: diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index ca4cc109..29b1f27c 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -1705,8 +1705,8 @@ void Cmd_Destroy_f( gentity_t *ent ) if( tr.fraction < 1.0 && ( traceEnt->s.eType == ET_BUILDABLE ) && ( traceEnt->biteam == ent->client->pers.pteam ) && - ( ( ent->client->ps.weapon == WP_DBUILD ) || - ( ent->client->ps.weapon == WP_HBUILD ) ) ) + ( ( ent->client->ps.weapon >= WP_DBUILD ) && + ( ent->client->ps.weapon <= WP_HBUILD ) ) ) G_Damage( traceEnt, ent, ent, forward, tr.endpos, 10000, 0, MOD_SUICIDE ); } @@ -2004,101 +2004,78 @@ Cmd_Build_f void Cmd_Build_f( gentity_t *ent ) { char s[ MAX_TOKEN_CHARS ]; - int buildable; + buildable_t buildable; + weapon_t weapon; + float dist; trap_Argv( 1, s, sizeof( s ) ); - if( ( ent->client->pers.pteam == PTE_DROIDS ) && - BG_gotWeapon( WP_DBUILD, ent->client->ps.stats ) && - ( ent->client->ps.weapon == WP_DBUILD ) ) - { - buildable = BG_FindBuildNumForName( s ); - - if( buildable == BA_NONE ) - trap_SendServerCommand( ent-g_entities, va("print \"Unknown item\n\"" ) ); - else - { - switch( itemFits( ent, buildable, -50 ) ) - { - case IBE_NONE: - Build_Item( ent, buildable, -50 ); - break; - - case IBE_NOCREEP: - G_AddPredictableEvent( ent, EV_MENU, MN_D_NOCREEP ); - break; - - case IBE_NOASSERT: - G_AddPredictableEvent( ent, EV_MENU, MN_D_NOASSERT ); - break; - - case IBE_NOHIVEMIND: - G_AddPredictableEvent( ent, EV_MENU, MN_D_NOHVMND ); - break; - - case IBE_HIVEMIND: - G_AddPredictableEvent( ent, EV_MENU, MN_D_HIVEMIND ); - break; - - case IBE_NOROOM: - G_AddPredictableEvent( ent, EV_MENU, MN_D_NOROOM ); - break; - - case IBE_SPWNWARN: - G_AddPredictableEvent( ent, EV_MENU, MN_D_SPWNWARN ); - Build_Item( ent, buildable, -50 ); - break; - } - } - } - else if( ( ent->client->pers.pteam == PTE_HUMANS ) && - BG_gotWeapon( WP_HBUILD, ent->client->ps.stats ) && - ( ent->client->ps.weapon == WP_HBUILD ) ) + buildable = BG_FindBuildNumForName( s ); + + if( buildable != BA_NONE && + ( 1 << ent->client->ps.weapon ) & BG_FindBuildWeaponForBuildable( buildable ) ) { - buildable = BG_FindBuildNumForName( s ); - - if( buildable == BA_NONE ) - trap_SendServerCommand( ent-g_entities, va("print \"Unknown item\n\"" ) ); - else + dist = BG_FindBuildDistForClass( ent->client->ps.stats[ STAT_PCLASS ] ); + + switch( itemFits( ent, buildable, dist ) ) { - switch( itemFits( ent, buildable, 80 ) ) - { - case IBE_NONE: - Build_Item( ent, buildable, 80 ); - break; - - case IBE_REACTOR: - G_AddPredictableEvent( ent, EV_MENU, MN_H_REACTOR ); - break; - - case IBE_REPEATER: - G_AddPredictableEvent( ent, EV_MENU, MN_H_REPEATER ); - break; - - case IBE_NOROOM: + case IBE_NONE: + Build_Item( ent, buildable, dist ); + break; + + case IBE_NOCREEP: + G_AddPredictableEvent( ent, EV_MENU, MN_D_NOCREEP ); + break; + + case IBE_NOASSERT: + G_AddPredictableEvent( ent, EV_MENU, MN_D_NOASSERT ); + break; + + case IBE_NOHIVEMIND: + G_AddPredictableEvent( ent, EV_MENU, MN_D_NOHVMND ); + break; + + case IBE_HIVEMIND: + G_AddPredictableEvent( ent, EV_MENU, MN_D_HIVEMIND ); + break; + + case IBE_SPWNWARN: + G_AddPredictableEvent( ent, EV_MENU, MN_D_SPWNWARN ); + Build_Item( ent, buildable, dist ); + break; + + case IBE_REACTOR: + G_AddPredictableEvent( ent, EV_MENU, MN_H_REACTOR ); + break; + + case IBE_REPEATER: + G_AddPredictableEvent( ent, EV_MENU, MN_H_REPEATER ); + break; + + case IBE_NOROOM: + if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) G_AddPredictableEvent( ent, EV_MENU, MN_H_NOROOM ); - break; - - case IBE_NOPOWER: - G_AddPredictableEvent( ent, EV_MENU, MN_H_NOPOWER ); - break; - - case IBE_RPLWARN: - G_AddPredictableEvent( ent, EV_MENU, MN_H_RPLWARN ); - Build_Item( ent, buildable, 80 ); - break; - - case IBE_RPTWARN: - G_AddPredictableEvent( ent, EV_MENU, MN_H_RPTWARN ); - Build_Item( ent, buildable, 80 ); - break; - } + else + G_AddPredictableEvent( ent, EV_MENU, MN_D_NOROOM ); + break; + + case IBE_NOPOWER: + G_AddPredictableEvent( ent, EV_MENU, MN_H_NOPOWER ); + break; + + case IBE_RPLWARN: + G_AddPredictableEvent( ent, EV_MENU, MN_H_RPLWARN ); + Build_Item( ent, buildable, dist ); + break; + + case IBE_RPTWARN: + G_AddPredictableEvent( ent, EV_MENU, MN_H_RPTWARN ); + Build_Item( ent, buildable, dist ); + break; } } - else if( ent->client->pers.pteam == PTE_NONE ) - trap_SendServerCommand( ent-g_entities, va("print \"Join a team first\n\"" ) ); else - trap_SendServerCommand( ent-g_entities, va("print \"Class is unable to build\n\"" ) ); + trap_SendServerCommand( ent-g_entities, va("print \"Cannot build this item\n\"" ) ); } |