diff options
author | Tim Angus <tim@ngus.net> | 2002-01-02 01:29:19 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2002-01-02 01:29:19 +0000 |
commit | 52c89557d3619e31891a76d8751444dd9990f12c (patch) | |
tree | 93363120efe62a817147c422f9323df4e56e9bfc /src | |
parent | e3270868dabe772ff15c612bdb660f9bfe281033 (diff) |
Rudimentary staging code. Simplified building rules - they were over complex
Diffstat (limited to 'src')
-rw-r--r-- | src/cgame/cg_consolecmds.c | 65 | ||||
-rw-r--r-- | src/cgame/cg_draw.c | 14 | ||||
-rw-r--r-- | src/cgame/cg_event.c | 34 | ||||
-rw-r--r-- | src/cgame/cg_local.h | 14 | ||||
-rw-r--r-- | src/cgame/cg_main.c | 2 | ||||
-rw-r--r-- | src/cgame/cg_servercmds.c | 24 | ||||
-rw-r--r-- | src/game/bg_misc.c | 177 | ||||
-rw-r--r-- | src/game/bg_public.h | 19 | ||||
-rw-r--r-- | src/game/g_buildable.c | 125 | ||||
-rw-r--r-- | src/game/g_cmds.c | 48 | ||||
-rw-r--r-- | src/game/g_local.h | 3 | ||||
-rw-r--r-- | src/game/g_main.c | 8 | ||||
-rw-r--r-- | src/ui/ui_main.c | 131 |
13 files changed, 470 insertions, 194 deletions
diff --git a/src/cgame/cg_consolecmds.c b/src/cgame/cg_consolecmds.c index 0d22015d..697796de 100644 --- a/src/cgame/cg_consolecmds.c +++ b/src/cgame/cg_consolecmds.c @@ -186,68 +186,6 @@ static void CG_StartOrbit_f( void ) { /* ================== -CG_ClientMenu -================== -*/ -static void CG_ClientMenu( const char *menuname ) -{ - char menuDef[ MAX_STRING_CHARS ]; - int i, j = 0; - - if( !Q_stricmp( menuname, "dinfest" ) ) - { - strcpy( menuDef, "5,5|Infest|0.976,0.957,0.0,1.0|0.933,0.612,0.0,1.0|0.976,0.957,0.0,1.0|1|16|" ); - for( i = PCL_NONE + 1; i < PCL_NUM_CLASSES; i++ ) - { - if( BG_ClassCanEvolveFromTo( cg.snap->ps.stats[ STAT_PCLASS ], i ) ) - { - strcat( menuDef, va( "%s, class %s|", BG_FindNameForClassNum( i ), BG_FindNameForClassNum( i ) ) ); - j++; - } - } - strcat( menuDef, "|Choose a class|to evolve to" ); - - if( j ) - { - trap_SendConsoleCommand( va( "defmenu infest \"%s\"\n", menuDef ) ); - trap_SendConsoleCommand( "menu infest\n" ); - trap_SendConsoleCommand( "undefmenu infest\n" ); - } - } - else if( !Q_stricmp( menuname, "hmcusell" ) ) - { - strcpy( menuDef, "5,5|Sell|1,1,1,1|0.000,0.412,0.702,1|1,1,1,1|2|32|" ); - for( i = WP_NONE +1; i < WP_NUM_WEAPONS; i++ ) - { - if( BG_gotWeapon( i, cg.snap->ps.stats ) ) - strcat( menuDef, va( "%s, sell %s|", BG_FindHumanNameForWeapon( i ), BG_FindNameForWeapon( i ) ) ); - } - for( i = UP_NONE +1; i < UP_NUM_UPGRADES; i++ ) - { - if( BG_gotItem( i, cg.snap->ps.stats ) ) - strcat( menuDef, va( "%s, sell %s|", BG_FindHumanNameForUpgrade( i ), BG_FindNameForUpgrade( i ) ) ); - } - strcat( menuDef, "Previous, menu hmcumenu||Choose an item|to sell" ); - - trap_SendConsoleCommand( va( "defmenu mcusell \"%s\"\n", menuDef ) ); - trap_SendConsoleCommand( "menu mcusell\n" ); - trap_SendConsoleCommand( "undefmenu mcusell\n" ); - } - else if( !Q_stricmp( menuname, "hbankstat" ) ) - { - //FIXME: implement this - strcpy( menuDef, "5,5|Statement|1,1,1,1|0.000,0.412,0.702,1|1,1,1,1|2|32|You have something in this bank|OK,!" ); - - trap_SendConsoleCommand( va( "defmenu bankstat \"%s\"\n", menuDef ) ); - trap_SendConsoleCommand( "menu bankstat\n" ); - trap_SendConsoleCommand( "undefmenu bankstat\n" ); - } - else - trap_SendConsoleCommand( va( "%s not defined", menuname ) ); -} - -/* -================== CG_DecodeMP3_f ================== */ @@ -320,7 +258,6 @@ qboolean CG_ConsoleCommand( void ) { if( !Q_stricmp( cmd, "ui_menu" ) ) { arg1 = CG_Argv( 1 ); - /*CG_ClientMenu( arg1 );*/ trap_SendConsoleCommand( va( "menu %s\n", arg1 ) ); return qtrue; } @@ -393,8 +330,6 @@ void CG_InitConsoleCommands( void ) { trap_AddCommand ("destroy"); trap_AddCommand ("torch"); trap_AddCommand ("menu"); - trap_AddCommand ("defmenu"); - trap_AddCommand ("undefmenu"); trap_AddCommand ("ui_menu"); trap_AddCommand ("loaddefered"); // spelled wrong, but not changing for demo } diff --git a/src/cgame/cg_draw.c b/src/cgame/cg_draw.c index e0c8d768..069ea844 100644 --- a/src/cgame/cg_draw.c +++ b/src/cgame/cg_draw.c @@ -528,9 +528,9 @@ static void CG_DrawStatusBar( void ) { #define PWR_Y 20 if( ps->stats[ STAT_PTEAM ] == PTE_HUMANS ) { - float total = cgs.hBuildPointsTotal; - float allocated = total - cgs.hBuildPoints; - float powered = total - cgs.hBuildPointsPowered; + float total = cgs.humanBuildPointsTotal; + float allocated = total - cgs.humanBuildPoints; + float powered = total - cgs.humanBuildPointsPowered; int awidth = (int)( ( allocated / total ) * PWR_WIDTH ); int pwidth = (int)( ( powered / total ) * PWR_WIDTH ); @@ -566,8 +566,8 @@ static void CG_DrawStatusBar( void ) { #define HV_Y 20 if( ps->stats[ STAT_PTEAM ] == PTE_ALIENS ) { - float total = cgs.dBuildPointsTotal; - float allocated = total - cgs.dBuildPoints; + float total = cgs.alienBuildPointsTotal; + float allocated = total - cgs.alienBuildPoints; int awidth = (int)( ( allocated / total ) * HV_WIDTH ); vec4_t bcolor = { 0.5, 0.5, 0.5, 0.5 }; @@ -1015,9 +1015,9 @@ static float CG_DrawPoints( float y ) team = cg.snap->ps.stats[ STAT_PTEAM ]; if( team == PTE_ALIENS ) - buildpoints = cgs.dBuildPoints; + buildpoints = cgs.alienBuildPoints; else if( team == PTE_HUMANS ) - buildpoints = cgs.hBuildPoints; + buildpoints = cgs.humanBuildPoints; spectator = ( team == PTE_NONE ); diff --git a/src/cgame/cg_event.c b/src/cgame/cg_event.c index 14ea9a74..20725c36 100644 --- a/src/cgame/cg_event.c +++ b/src/cgame/cg_event.c @@ -408,6 +408,23 @@ void CG_Menu( int eventParm ) *carriageCvar = 0; + //determine what the player is carrying + for( i = WP_NONE +1; i < WP_NUM_WEAPONS; i++ ) + { + if( BG_gotWeapon( i, cg.snap->ps.stats ) ) + strcat( carriageCvar, va( "W%d ", i ) ); + } + for( i = UP_NONE +1; i < UP_NUM_UPGRADES; i++ ) + { + if( BG_gotItem( i, cg.snap->ps.stats ) ) + strcat( carriageCvar, va( "U%d ", i ) ); + } + strcat( carriageCvar, "$" ); + + trap_Cvar_Set( "ui_carriage", carriageCvar ); + + trap_Cvar_Set( "ui_stages", va( "%d %d", cgs.alienStage, cgs.humanStage ) ); + switch( eventParm ) { case MN_TEAM: trap_SendConsoleCommand( "menu tremulous_teamselect\n" ); break; @@ -415,22 +432,7 @@ void CG_Menu( int eventParm ) case MN_H_SPAWN: trap_SendConsoleCommand( "menu tremulous_humanitem\n" ); break; case MN_A_BUILD: trap_SendConsoleCommand( "menu tremulous_alienbuild\n" ); break; case MN_H_BUILD: trap_SendConsoleCommand( "menu tremulous_humanbuild\n" ); break; - case MN_H_MCU: - for( i = WP_NONE +1; i < WP_NUM_WEAPONS; i++ ) - { - if( BG_gotWeapon( i, cg.snap->ps.stats ) ) - strcat( carriageCvar, va( "W%d ", i ) ); - } - for( i = UP_NONE +1; i < UP_NUM_UPGRADES; i++ ) - { - if( BG_gotItem( i, cg.snap->ps.stats ) ) - strcat( carriageCvar, va( "U%d ", i ) ); - } - strcat( carriageCvar, "$" ); - - trap_Cvar_Set( "ui_carriage", carriageCvar ); - trap_SendConsoleCommand( "menu tremulous_humanmcu\n" ); - break; + case MN_H_MCU: trap_SendConsoleCommand( "menu tremulous_humanmcu\n" ); break; case MN_H_BANK: trap_SendConsoleCommand( "menu tremulous_humanbank\n" ); break; case MN_H_NOROOM: trap_SendConsoleCommand( "menu tremulous_human_no_room\n" ); break; case MN_H_NOPOWER: trap_SendConsoleCommand( "menu tremulous_human_no_power\n" ); break; diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index 514cc3c5..5ffedbd6 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -1030,11 +1030,14 @@ typedef struct { qboolean newHud; - int dBuildPoints; - int dBuildPointsTotal; - int hBuildPoints; - int hBuildPointsTotal; - int hBuildPointsPowered; + int alienBuildPoints; + int alienBuildPointsTotal; + int humanBuildPoints; + int humanBuildPointsTotal; + int humanBuildPointsPowered; + + int alienStage; + int humanStage; // // locally derived information from gamestate @@ -1219,6 +1222,7 @@ extern vmCvar_t cg_smoothTime; //TA: hack to get class an carriage through to UI module extern vmCvar_t ui_currentClass; extern vmCvar_t ui_carriage; +extern vmCvar_t ui_stages; // // cg_main.c diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c index 0052b426..1e923b5b 100644 --- a/src/cgame/cg_main.c +++ b/src/cgame/cg_main.c @@ -182,6 +182,7 @@ vmCvar_t cg_smoothTime; //TA: hack to get class an carriage through to UI module vmCvar_t ui_currentClass; vmCvar_t ui_carriage; +vmCvar_t ui_stages; typedef struct { @@ -267,6 +268,7 @@ static cvarTable_t cvarTable[] = { { &ui_currentClass, "ui_currentClass", "0", 0 }, { &ui_carriage, "ui_carriage", "", 0 }, + { &ui_stages, "ui_stages", "0 0", 0 }, // the following variables are created in other parts of the system, // but we also reference them here diff --git a/src/cgame/cg_servercmds.c b/src/cgame/cg_servercmds.c index 8877b389..09b7704e 100644 --- a/src/cgame/cg_servercmds.c +++ b/src/cgame/cg_servercmds.c @@ -179,11 +179,13 @@ void CG_SetConfigValues( void ) { cgs.scores2 = atoi( CG_ConfigString( CS_SCORES2 ) ); sscanf( CG_ConfigString( CS_BUILDPOINTS ), - "%d %d %d %d %d", &cgs.dBuildPoints, - &cgs.dBuildPointsTotal, - &cgs.hBuildPoints, - &cgs.hBuildPointsTotal, - &cgs.hBuildPointsPowered ); + "%d %d %d %d %d", &cgs.alienBuildPoints, + &cgs.alienBuildPointsTotal, + &cgs.humanBuildPoints, + &cgs.humanBuildPointsTotal, + &cgs.humanBuildPointsPowered ); + + sscanf( CG_ConfigString( CS_STAGES ), "%d %d", &cgs.alienStage, &cgs.humanStage ); cgs.levelStartTime = atoi( CG_ConfigString( CS_LEVEL_START_TIME ) ); if( cgs.gametype == GT_CTF ) { @@ -267,11 +269,13 @@ static void CG_ConfigStringModified( void ) { } else if ( num == CS_SCORES2 ) { cgs.scores2 = atoi( str ); } else if( num == CS_BUILDPOINTS ) { - sscanf( str, "%d %d %d %d %d", &cgs.dBuildPoints, - &cgs.dBuildPointsTotal, - &cgs.hBuildPoints, - &cgs.hBuildPointsTotal, - &cgs.hBuildPointsPowered ); + sscanf( str, "%d %d %d %d %d", &cgs.alienBuildPoints, + &cgs.alienBuildPointsTotal, + &cgs.humanBuildPoints, + &cgs.humanBuildPointsTotal, + &cgs.humanBuildPointsPowered ); + } else if( num == CS_STAGES ) { + sscanf( str, "%d %d", &cgs.alienStage, &cgs.humanStage ); } else if ( num == CS_LEVEL_START_TIME ) { cgs.levelStartTime = atoi( str ); } else if ( num == CS_VOTE_TIME ) { diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index f2b132a8..71df0fe3 100644 --- a/src/game/bg_misc.c +++ b/src/game/bg_misc.c @@ -31,6 +31,7 @@ buildableAttributes_t bg_buildableList[ ] = TR_GRAVITY, //trType_t traj; 0.0, //float bounce; 100, //int buildPoints; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages 1000, //int health; 50, //int damage; 50, //int splashDamage; @@ -60,6 +61,7 @@ buildableAttributes_t bg_buildableList[ ] = TR_GRAVITY, //trType_t traj; 0.0, //float bounce; 80, //int buildPoints; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages 1000, //int health; 50, //int damage; 20, //int splashDamage; @@ -89,6 +91,7 @@ buildableAttributes_t bg_buildableList[ ] = TR_GRAVITY, //trType_t traj; 0.0, //float bounce; 80, //int buildPoints; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages 1000, //int health; 50, //int damage; 20, //int splashDamage; @@ -118,6 +121,7 @@ buildableAttributes_t bg_buildableList[ ] = TR_GRAVITY, //trType_t traj; 0.0, //float bounce; 80, //int buildPoints; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages 1000, //int health; 50, //int damage; 20, //int splashDamage; @@ -147,6 +151,7 @@ buildableAttributes_t bg_buildableList[ ] = TR_GRAVITY, //trType_t traj; 0.0, //float bounce; 80, //int buildPoints; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages 1000, //int health; 50, //int damage; 20, //int splashDamage; @@ -176,6 +181,7 @@ buildableAttributes_t bg_buildableList[ ] = TR_GRAVITY, //trType_t traj; 0.0, //float bounce; 0, //int buildPoints; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages 1000, //int health; 50, //int damage; 20, //int splashDamage; @@ -205,6 +211,7 @@ buildableAttributes_t bg_buildableList[ ] = TR_GRAVITY, //trType_t traj; 0.0, //float bounce; 80, //int buildPoints; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages 1000, //int health; 50, //int damage; 20, //int splashDamage; @@ -234,6 +241,7 @@ buildableAttributes_t bg_buildableList[ ] = TR_GRAVITY, //trType_t traj; 0.0, //float bounce; 100, //int buildPoints; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages 1000, //int health; 50, //int damage; 50, //int splashDamage; @@ -263,6 +271,37 @@ buildableAttributes_t bg_buildableList[ ] = TR_GRAVITY, //trType_t traj; 0.0, //float bounce; 100, //int buildPoints; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages + 1000, //int health; + 50, //int damage; + 50, //int splashDamage; + 150, //int splashRadius; + MOD_HSPAWN, //int meansOfDeath; + BIT_HUMANS, //int team; + ( 1 << WP_HBUILD )|( 1 << WP_HBUILD2 ), //weapon_t buildWeapon; + BANIM_IDLE1, //int idleAnim; + 100, //int nextthink; + 0, //int turretFireSpeed; + 0, //int turretRange; + WP_NONE, //weapon_t turretProjType; + 0.707f, //float minNormal; + qfalse, //qboolean invertNormal; + qfalse, //qboolean creepTest; + 0, //int creepSize; + qfalse //qboolean reactorTest; + }, + { + BA_H_ADVMEDISTAT, //int buildNum; + "advmedistat", //char *buildName; + "Adv Medistation", //char *humanName; + "team_human_advmedistat",//char *entityName; + { "models/buildables/medistat/medistat.md3", 0, 0, 0 }, + { -65, -65, -7 }, //vec3_t mins; + { 65, 65, 7 }, //vec3_t maxs; + TR_GRAVITY, //trType_t traj; + 0.0, //float bounce; + 100, //int buildPoints; + ( 1 << S3 ), //int stages 1000, //int health; 50, //int damage; 50, //int splashDamage; @@ -292,6 +331,7 @@ buildableAttributes_t bg_buildableList[ ] = TR_GRAVITY, //trType_t traj; 0.0, //float bounce; 80, //int buildPoints; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages 1000, //int health; 50, //int damage; 20, //int splashDamage; @@ -323,6 +363,7 @@ buildableAttributes_t bg_buildableList[ ] = TR_GRAVITY, //trType_t traj; 0.0, //float bounce; 80, //int buildPoints; + ( 1 << S2 )|( 1 << S3 ), //int stages 1000, //int health; 50, //int damage; 20, //int splashDamage; @@ -352,6 +393,7 @@ buildableAttributes_t bg_buildableList[ ] = TR_GRAVITY, //trType_t traj; 0.0, //float bounce; 80, //int buildPoints; + ( 1 << S3 ), //int stages 1000, //int health; 50, //int damage; 20, //int splashDamage; @@ -381,6 +423,7 @@ buildableAttributes_t bg_buildableList[ ] = TR_GRAVITY, //trType_t traj; 0.0, //float bounce; 200, //int buildPoints; + ( 1 << S3 ), //int stages 1000, //int health; 50, //int damage; 50, //int splashDamage; @@ -410,6 +453,7 @@ buildableAttributes_t bg_buildableList[ ] = TR_GRAVITY, //trType_t traj; 0.0, //float bounce; 200, //int buildPoints; + ( 1 << S2 )|( 1 << S3 ), //int stages 1000, //int health; 50, //int damage; 50, //int splashDamage; @@ -439,6 +483,7 @@ buildableAttributes_t bg_buildableList[ ] = TR_GRAVITY, //trType_t traj; 0.0, //float bounce; 200, //int buildPoints; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages 1000, //int health; 50, //int damage; 50, //int splashDamage; @@ -468,6 +513,7 @@ buildableAttributes_t bg_buildableList[ ] = TR_GRAVITY, //trType_t traj; 0.0, //float bounce; 0, //int buildPoints; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages 1000, //int health; 50, //int damage; 50, //int splashDamage; @@ -497,6 +543,7 @@ buildableAttributes_t bg_buildableList[ ] = TR_GRAVITY, //trType_t traj; 0.0, //float bounce; 10, //int buildPoints; + ( 1 << S2 )|( 1 << S3 ), //int stages 1000, //int health; 50, //int damage; 50, //int splashDamage; @@ -526,6 +573,7 @@ buildableAttributes_t bg_buildableList[ ] = TR_BUOYANCY, //trType_t traj; 0.2, //float bounce; 10, //int buildPoints; + ( 1 << S2 )|( 1 << S3 ), //int stages 100, //int health; 50, //int damage; 50, //int splashDamage; @@ -754,6 +802,29 @@ int BG_FindBuildPointsForBuildable( int bclass ) /* ============== +BG_FindStagesForBuildable +============== +*/ +qboolean BG_FindStagesForBuildable( int bclass, stage_t stage ) +{ + int i; + + for( i = 0; i < bg_numBuildables; i++ ) + { + if( bg_buildableList[ i ].buildNum == bclass ) + { + if( bg_buildableList[ i ].stages & ( 1 << stage ) ) + return qtrue; + else + return qfalse; + } + } + + return qfalse; +} + +/* +============== BG_FindHealthForBuildable ============== */ @@ -1102,6 +1173,7 @@ classAttributes_t bg_classList[ ] = "Builder", //char *humanName; "lucy", //char *modelname; "default", //char *skinname; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages { -15, -15, -20 }, //vec3_t mins; { 15, 15, 20 }, //vec3_t maxs; { 15, 15, 20 }, //vec3_t crouchmaxs; @@ -1127,6 +1199,7 @@ classAttributes_t bg_classList[ ] = "Advanced Builder", //char *humanname; "lucy", //char *modelname; "angel", //char *skinname; + ( 1 << S2 )|( 1 << S3 ), //int stages { -20, -20, -20 }, //vec3_t mins; { 20, 20, 20 }, //vec3_t maxs; { 20, 20, 20 }, //vec3_t crouchmaxs; @@ -1152,6 +1225,7 @@ classAttributes_t bg_classList[ ] = "Offensive", //char *humanname; "klesk", //char *modelname; "default", //char *skinname; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages { -15, -15, -15 }, //vec3_t mins; { 15, 15, 15 }, //vec3_t maxs; { 15, 15, 15 }, //vec3_t crouchmaxs; @@ -1177,6 +1251,7 @@ classAttributes_t bg_classList[ ] = "Offensive Level 1", //char *humanname; "anarki", //char *modelname; "default", //char *skinname; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages { -24, -24, -24 }, //vec3_t mins; { 24, 24, 24 }, //vec3_t maxs; { 24, 24, 24 }, //vec3_t crouchmaxs; @@ -1202,6 +1277,7 @@ classAttributes_t bg_classList[ ] = "Offensive Level 1 Upgrade", //char *humanname; "anarki", //char *modelname; "default", //char *skinname; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages { -24, -24, -24 }, //vec3_t mins; { 24, 24, 24 }, //vec3_t maxs; { 24, 24, 24 }, //vec3_t crouchmaxs; @@ -1227,6 +1303,7 @@ classAttributes_t bg_classList[ ] = "Offensive Level 2", //char *humanname; "bones", //char *modelname; "default", //char *skinname; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages { -24, -24, -24 }, //vec3_t mins; { 24, 24, 24 }, //vec3_t maxs; { 24, 24, 24 }, //vec3_t crouchmaxs; @@ -1252,6 +1329,7 @@ classAttributes_t bg_classList[ ] = "Offensive Level 2 Upgrade", //char *humanname; "bones", //char *modelname; "default", //char *skinname; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages { -24, -24, -24 }, //vec3_t mins; { 24, 24, 24 }, //vec3_t maxs; { 24, 24, 24 }, //vec3_t crouchmaxs; @@ -1277,6 +1355,7 @@ classAttributes_t bg_classList[ ] = "Offensive Level 3", //char *humanname; "orbb", //char *modelname; "default", //char *skinname; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages { -15, -15, -15 }, //vec3_t mins; { 15, 15, 15 }, //vec3_t maxs; { 15, 15, 15 }, //vec3_t crouchmaxs; @@ -1302,6 +1381,7 @@ classAttributes_t bg_classList[ ] = "Offensive Level 3 Upgrade", //char *humanname; "orbb", //char *modelname; "default", //char *skinname; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages { -15, -15, -15 }, //vec3_t mins; { 15, 15, 15 }, //vec3_t maxs; { 15, 15, 15 }, //vec3_t crouchmaxs; @@ -1327,6 +1407,7 @@ classAttributes_t bg_classList[ ] = "Offensive Level 4", //char *humanname; "xaero", //char *modelname; "default", //char *skinname; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages { -15, -15, -15 }, //vec3_t mins; { 15, 15, 15 }, //vec3_t maxs; { 15, 15, 15 }, //vec3_t crouchmaxs; @@ -1352,6 +1433,7 @@ classAttributes_t bg_classList[ ] = "Human", //char *humanname; "sarge", //char *modelname; "default", //char *skinname; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages { -15, -15, -24 }, //vec3_t mins; { 15, 15, 32 }, //vec3_t maxs; { 15, 15, 16 }, //vec3_t crouchmaxs; @@ -1361,7 +1443,7 @@ classAttributes_t bg_classList[ ] = 100, //int health; 0, //int armor; SCA_TAKESFALLDAMAGE|SCA_CANJUMP, //int abilities; - 80.0f, //float buildDist; + 110.0f, //float buildDist; 90, //int fov; 0.002f, //float bob; 200, //int steptime; @@ -1453,6 +1535,29 @@ char *BG_FindModelNameForClass( int pclass ) /* ============== +BG_FindStagesForClass +============== +*/ +qboolean BG_FindStagesForClass( int pclass, stage_t stage ) +{ + int i; + + for( i = 0; i < bg_numPclasses; i++ ) + { + if( bg_classList[ i ].classNum == pclass ) + { + if( bg_classList[ i ].stages & ( 1 << stage ) ) + return qtrue; + else + return qfalse; + } + } + + return qfalse; +} + +/* +============== BG_FindBBoxForClass ============== */ @@ -1786,6 +1891,7 @@ weaponAttributes_t bg_weapons[ ] = { WP_MACHINEGUN, //int weaponNum; 100, //int price; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; "rifle", //char *weaponName; "Rifle", //char *weaponHumanName; @@ -1804,6 +1910,7 @@ weaponAttributes_t bg_weapons[ ] = { WP_FLAMER, //int weaponNum; 100, //int price; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; "flamer", //char *weaponName; "Flame Thrower", //char *weaponHumanName; @@ -1822,6 +1929,7 @@ weaponAttributes_t bg_weapons[ ] = { WP_CHAINGUN, //int weaponNum; 100, //int price; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; "chaingun", //char *weaponName; "Chaingun", //char *weaponHumanName; @@ -1840,6 +1948,7 @@ weaponAttributes_t bg_weapons[ ] = { WP_MASS_DRIVER, //int weaponNum; 100, //int price; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; "mdriver", //char *weaponName; "Mass Driver", //char *weaponHumanName; @@ -1858,6 +1967,7 @@ weaponAttributes_t bg_weapons[ ] = { WP_PULSE_RIFLE, //int weaponNum; 100, //int price; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; "prifle", //char *weaponName; "Pulse Rifle", //char *weaponHumanName; @@ -1876,6 +1986,7 @@ weaponAttributes_t bg_weapons[ ] = { WP_HBUILD, //int weaponNum; 100, //int price; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; "ckit", //char *weaponName; "Construction Kit", //char *weaponHumanName; @@ -1894,6 +2005,7 @@ weaponAttributes_t bg_weapons[ ] = { WP_HBUILD2, //int weaponNum; 100, //int price; + ( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; "ackit", //char *weaponName; "Adv Construction Kit",//char *weaponHumanName; @@ -1912,6 +2024,7 @@ weaponAttributes_t bg_weapons[ ] = { WP_ABUILD, //int weaponNum; 100, //int price; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; "dbuild", //char *weaponName; "Alien build weapon", //char *weaponHumanName; @@ -1930,6 +2043,7 @@ weaponAttributes_t bg_weapons[ ] = { WP_ABUILD2, //int weaponNum; 100, //int price; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; "dbuild2", //char *weaponName; "Alien build weapon2",//char *weaponHumanName; @@ -1948,6 +2062,7 @@ weaponAttributes_t bg_weapons[ ] = { WP_VENOM, //int weaponNum; 100, //int price; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; "venom", //char *weaponName; "Venom", //char *weaponHumanName; @@ -1966,6 +2081,7 @@ weaponAttributes_t bg_weapons[ ] = { WP_GRABANDCSAW, //int weaponNum; 100, //int price; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; "grabandcsaw", //char *weaponName; "Circular Saw", //char *weaponHumanName; @@ -1984,6 +2100,7 @@ weaponAttributes_t bg_weapons[ ] = { WP_POUNCE, //int weaponNum; 100, //int price; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; "pounce", //char *weaponName; "Claw and pounce", //char *weaponHumanName; @@ -2002,6 +2119,7 @@ weaponAttributes_t bg_weapons[ ] = { WP_LOCKBLOB_LAUNCHER, //int weaponNum; 100, //int price; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; "lockblob", //char *weaponName; "Lock Blob", //char *weaponHumanName; @@ -2020,6 +2138,7 @@ weaponAttributes_t bg_weapons[ ] = { WP_TESLAGEN, //int weaponNum; 100, //int price; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; "teslagen", //char *weaponName; "Tesla Generator", //char *weaponHumanName; @@ -2038,6 +2157,7 @@ weaponAttributes_t bg_weapons[ ] = { WP_PLASMAGUN, //int weaponNum; 100, //int price; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_WEAPON, //int slots; "plasmagun", //char *weaponName; "Plasma Gun", //char *weaponHumanName; @@ -2079,6 +2199,29 @@ int BG_FindPriceForWeapon( int weapon ) /* ============== +BG_FindStagesForWeapon +============== +*/ +qboolean BG_FindStagesForWeapon( int weapon, stage_t stage ) +{ + int i; + + for( i = 0; i < bg_numWeapons; i++ ) + { + if( bg_weapons[ i ].weaponNum == weapon ) + { + if( bg_weapons[ i ].stages & ( 1 << stage ) ) + return qtrue; + else + return qfalse; + } + } + + return qfalse; +} + +/* +============== BG_FindSlotsForWeapon ============== */ @@ -2345,6 +2488,7 @@ upgradeAttributes_t bg_upgrades[ ] = { UP_TORCH, //int upgradeNum; 100, //int price; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_NONE, //int slots; "torch", //char *upgradeName; "Torch", //char *upgradeHumanName; @@ -2354,6 +2498,7 @@ upgradeAttributes_t bg_upgrades[ ] = { UP_NVG, //int upgradeNum; 100, //int price; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_HEAD, //int slots; "nvg", //char *upgradeName; "NVG", //char *upgradeHumanName; @@ -2363,6 +2508,7 @@ upgradeAttributes_t bg_upgrades[ ] = { UP_CHESTARMOUR, //int upgradeNum; 100, //int price; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_TORSO, //int slots; "carmour", //char *upgradeName; "Chest Armour", //char *upgradeHumanName; @@ -2372,6 +2518,7 @@ upgradeAttributes_t bg_upgrades[ ] = { UP_LIMBARMOUR, //int upgradeNum; 100, //int price; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_ARMS|SLOT_LEGS, //int slots; "larmour", //char *upgradeName; "Limb Armour", //char *upgradeHumanName; @@ -2381,6 +2528,7 @@ upgradeAttributes_t bg_upgrades[ ] = { UP_HELMET, //int upgradeNum; 100, //int price; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_HEAD, //int slots; "helmet", //char *upgradeName; "Helmet", //char *upgradeHumanName; @@ -2390,6 +2538,7 @@ upgradeAttributes_t bg_upgrades[ ] = { UP_ANTITOXIN, //int upgradeNum; 100, //int price; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_NONE, //int slots; "atoxin", //char *upgradeName; "Anti-toxin", //char *upgradeHumanName; @@ -2399,6 +2548,7 @@ upgradeAttributes_t bg_upgrades[ ] = { UP_BATTPACK, //int upgradeNum; 100, //int price; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_BACKPACK, //int slots; "battpack", //char *upgradeName; "Battery Pack", //char *upgradeHumanName; @@ -2408,6 +2558,7 @@ upgradeAttributes_t bg_upgrades[ ] = { UP_JETPACK, //int upgradeNum; 100, //int price; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_BACKPACK, //int slots; "jetpack", //char *upgradeName; "Jet Pack", //char *upgradeHumanName; @@ -2417,6 +2568,7 @@ upgradeAttributes_t bg_upgrades[ ] = { UP_BATTLESUIT, //int upgradeNum; 100, //int price; + ( 1 << S1 )|( 1 << S2 )|( 1 << S3 ), //int stages SLOT_HEAD|SLOT_TORSO|SLOT_ARMS|SLOT_LEGS, //int slots; "bsuit", //char *upgradeName; "Battlesuit", //char *upgradeHumanName; @@ -2449,6 +2601,29 @@ int BG_FindPriceForUpgrade( int upgrade ) /* ============== +BG_FindStagesForUpgrade +============== +*/ +qboolean BG_FindStagesForUpgrade( int upgrade, stage_t stage ) +{ + int i; + + for( i = 0; i < bg_numUpgrades; i++ ) + { + if( bg_upgrades[ i ].upgradeNum == upgrade ) + { + if( bg_upgrades[ i ].stages & ( 1 << stage ) ) + return qtrue; + else + return qfalse; + } + } + + return qfalse; +} + +/* +============== BG_FindSlotsForUpgrade ============== */ diff --git a/src/game/bg_public.h b/src/game/bg_public.h index 03b13f95..551b6bbd 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -80,6 +80,7 @@ //TA: extra stuff: #define CS_BUILDPOINTS 28 +#define CS_STAGES 29 #define CS_MODELS 33 #define CS_SOUNDS (CS_MODELS+MAX_MODELS) @@ -409,6 +410,7 @@ typedef enum BA_H_MCU, BA_H_DCC, BA_H_MEDISTAT, + BA_H_ADVMEDISTAT, BA_H_BANK, BA_H_REACTOR, @@ -822,6 +824,8 @@ typedef struct char *modelName; char *skinName; + int stages; + vec3_t mins; vec3_t maxs; vec3_t crouchMaxs; @@ -849,6 +853,14 @@ typedef struct int value; } classAttributes_t; +//stages +typedef enum +{ + S1, + S2, + S3 +} stage_t; + //TA: buildable item record typedef struct { @@ -867,6 +879,7 @@ typedef struct float bounce; int buildPoints; + int stages; int health; @@ -902,6 +915,7 @@ typedef struct int weaponNum; int price; + int stages; int slots; @@ -932,6 +946,7 @@ typedef struct int upgradeNum; int price; + int stages; int slots; @@ -955,6 +970,7 @@ int BG_FindHealthForBuildable( int bclass ); trType_t BG_FindTrajectoryForBuildable( int bclass ); float BG_FindBounceForBuildable( int bclass ); int BG_FindBuildPointsForBuildable( int bclass ); +qboolean BG_FindStagesForBuildable( int bclass, stage_t stage ); int BG_FindDamageForBuildable( int bclass ); int BG_FindSplashDamageForBuildable( int bclass ); int BG_FindSplashRadiusForBuildable( int bclass ); @@ -976,6 +992,7 @@ int BG_FindClassNumForName( char *name ); char *BG_FindNameForClassNum( int pclass ); char *BG_FindHumanNameForClassNum( int pclass ); char *BG_FindModelNameForClass( int pclass ); +qboolean BG_FindStagesForClass( int pclass, stage_t stage ); void BG_FindBBoxForClass( int pclass, vec3_t mins, vec3_t maxs, vec3_t cmaxs, vec3_t dmins, vec3_t dmaxs ); void BG_FindViewheightForClass( int pclass, int *viewheight, int *cViewheight ); int BG_FindHealthForClass( int pclass ); @@ -992,6 +1009,7 @@ int BG_FindEvolveTimeForClass( int pclass ); int BG_FindValueOfClass( int pclass ); int BG_FindPriceForWeapon( int weapon ); +qboolean BG_FindStagesForWeapon( int weapon, stage_t stage ); int BG_FindSlotsForWeapon( int weapon ); char *BG_FindNameForWeapon( int weapon ); int BG_FindWeaponNumForName( char *name ); @@ -1007,6 +1025,7 @@ qboolean BG_FindPurchasableForWeapon( int weapon ); WUTeam_t BG_FindTeamForWeapon( int weapon ); int BG_FindPriceForUpgrade( int upgrade ); +qboolean BG_FindStagesForUpgrade( int upgrade, stage_t stage ); int BG_FindSlotsForUpgrade( int upgrade ); char *BG_FindNameForUpgrade( int upgrade ); int BG_FindUpgradeNumForName( char *name ); diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index a0ded01d..0a8557ae 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -51,7 +51,7 @@ findPower attempt to find power for self, return qtrue if successful ================ */ -qboolean findPower( gentity_t *self ) +static qboolean findPower( gentity_t *self ) { int i; gentity_t *ent; @@ -62,7 +62,7 @@ qboolean findPower( gentity_t *self ) qboolean foundPower = qfalse; //if this already has power then stop now - if( self->parentNode && self->parentNode->active ) + if( self->parentNode && self->parentNode->powered ) return qtrue; //reset parent @@ -79,7 +79,7 @@ qboolean findPower( gentity_t *self ) { VectorSubtract( self->s.origin, ent->s.origin, temp_v ); distance = VectorLength( temp_v ); - if( distance < minDistance && ( ent->active || self->s.modelindex == BA_H_SPAWN ) ) + if( distance < minDistance && ent->powered ) { closestPower = ent; minDistance = distance; @@ -94,11 +94,8 @@ qboolean findPower( gentity_t *self ) //bleh 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.modelindex == BA_H_REPEATER && ( minDistance <= REPEATER_BASESIZE ) && - closestPower->active && closestPower->powered ) - ) + closestPower->powered ) ) { self->parentNode = closestPower; @@ -110,12 +107,29 @@ qboolean findPower( gentity_t *self ) /* ================ +isPower + +simple wrapper to findPower to check if a location has power +================ +*/ +static qboolean isPower( vec3_t origin ) +{ + gentity_t dummy; + + dummy.parentNode = NULL; + VectorCopy( origin, dummy.s.origin ); + + return findPower( &dummy ); +} + +/* +================ findDCC attempt to find a controlling DCC for self, return qtrue if successful ================ */ -qboolean findDCC( gentity_t *self ) +static qboolean findDCC( gentity_t *self ) { int i; gentity_t *ent; @@ -168,7 +182,7 @@ findCreep attempt to find creep for self, return qtrue if successful ================ */ -qboolean findCreep( gentity_t *self ) +static qboolean findCreep( gentity_t *self ) { int i; gentity_t *ent; @@ -191,7 +205,6 @@ qboolean findCreep( gentity_t *self ) if( ent->s.modelindex == BA_A_SPAWN || ent->s.modelindex == BA_A_HIVEMIND ) { - /*VectorSubtract( self->s.origin, ent->s.origin, temp_v );*/ VectorSubtract( self->s.origin, ent->s.origin, temp_v ); distance = VectorLength( temp_v ); if( distance < minDistance ) @@ -217,6 +230,23 @@ qboolean findCreep( gentity_t *self ) /* ================ +isCreep + +simple wrapper to findCreep to check if a location has creep +================ +*/ +static qboolean isCreep( vec3_t origin ) +{ + gentity_t dummy; + + dummy.parentNode = NULL; + VectorCopy( origin, dummy.s.origin ); + + return findCreep( &dummy ); +} + +/* +================ nullDieFunction hack to prevent compilers complaining about function pointer -> NULL conversion @@ -895,7 +925,6 @@ Think for human power repeater void HRpt_Think( gentity_t *self ) { int i; - int count = 0; qboolean reactor = qfalse; gentity_t *ent; @@ -905,19 +934,10 @@ void HRpt_Think( gentity_t *self ) if( !ent->classname || ent->s.eType != ET_BUILDABLE ) continue; - if( ent->s.modelindex == BA_H_SPAWN && ent->parentNode == self ) - count++; - if( ent->s.modelindex == BA_H_REACTOR ) reactor = qtrue; } - //if repeater has children and there is a reactor then this is active - if( count && reactor ) - self->active = qtrue; - else - self->active = qfalse; - self->powered = reactor; self->nextthink = level.time + REFRESH_TIME; @@ -1033,15 +1053,14 @@ void HDCC_Think( gentity_t *self ) //================================================================================== - - -#define MAX_HEAL_CLIENTS 1 +#define MAX_MEDISTAT_CLIENTS 1 +#define MAX_ADVMEDISTAT_CLIENTS 3 /* ================ HMedistat_Think -think function for Alien Acid Tube +think function for Human Medistation ================ */ void HMedistat_Think( gentity_t *self ) @@ -1051,7 +1070,8 @@ void HMedistat_Think( gentity_t *self ) int i, num; gentity_t *player; int healCount = 0; - + int maxclients; + VectorAdd( self->s.origin, self->r.maxs, maxs ); VectorAdd( self->s.origin, self->r.mins, mins ); @@ -1065,6 +1085,11 @@ void HMedistat_Think( gentity_t *self ) if( self->active ) G_setIdleBuildableAnim( self, BANIM_IDLE2 ); + if( self->s.modelindex == BA_H_ADVMEDISTAT ) + maxclients = MAX_ADVMEDISTAT_CLIENTS; + else + maxclients = MAX_MEDISTAT_CLIENTS; + //do some healage num = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES ); for( i = 0; i < num; i++ ) @@ -1073,7 +1098,8 @@ void HMedistat_Think( gentity_t *self ) if( player->client && player->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) { - if( player->health < player->client->ps.stats[ STAT_MAX_HEALTH ] && healCount < MAX_HEAL_CLIENTS ) + if( player->health < player->client->ps.stats[ STAT_MAX_HEALTH ] && + healCount < maxclients ) { healCount++; player->health++; @@ -1711,6 +1737,14 @@ itemBuildError_t G_itemFits( gentity_t *ent, buildable_t buildable, int distance if( !( normal[ 2 ] >= minNormal || ( invert && normal[ 2 ] <= -minNormal ) ) ) return IBE_NORMAL; + //check there is creep near by for building on + + if( BG_FindCreepTestForBuildable( buildable ) ) + { + if( !isCreep( entity_origin ) ) + reason = IBE_NOCREEP; + } + //look for a hivemind for ( i = 1, tempent = g_entities + i; i < level.num_entities; i++, tempent++ ) { @@ -1751,39 +1785,7 @@ itemBuildError_t G_itemFits( gentity_t *ent, buildable_t buildable, int distance else if( ent->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS ) { //human criteria - - closestPower = g_entities + 1; //FIXME - - //find the nearest power entity - for ( i = 1, tempent = g_entities + i; i < level.num_entities; i++, tempent++ ) - { - if( !tempent->classname || tempent->s.eType != ET_BUILDABLE ) - continue; - - 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 ); - if( templength < minDistance && ( tempent->active || buildable == BA_H_SPAWN ) ) - { - closestPower = tempent; - minDistance = templength; - } - } - } - - //if this power entity satisfies expression - if( !( - ( closestPower->s.modelindex == BA_H_REACTOR && minDistance <= REACTOR_BASESIZE ) || - ( - closestPower->s.modelindex == BA_H_REPEATER && minDistance <= REPEATER_BASESIZE && - ( - ( buildable == BA_H_SPAWN && closestPower->powered ) || - ( closestPower->powered && closestPower->active ) - ) - ) - ) - ) + if( !isPower( entity_origin ) ) { //tell player to build a repeater to provide power if( buildable != BA_H_REACTOR && buildable != BA_H_REPEATER ) @@ -1948,6 +1950,11 @@ gentity_t *G_buildItem( gentity_t *builder, buildable_t buildable, vec3_t origin built->die = HSpawn_Die; break; + case BA_H_ADVMEDISTAT: + built->think = HMedistat_Think; + built->die = HSpawn_Die; + break; + case BA_H_REACTOR: built->die = HSpawn_Die; built->powered = built->active = qtrue; diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index d8239549..e61fa353 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -1573,7 +1573,7 @@ void Cmd_Class_f( gentity_t *ent ) !( ent->client->ps.stats[ STAT_STATE ] & SS_HOVELING ) ) { //if we are not currently spectating, we are attempting evolution - if( ent->client->pers.pclass != PCL_NONE ) + if( ent->client->ps.stats[ STAT_PCLASS ] != PCL_NONE ) { for ( i = 1, body = g_entities + i; i < level.num_entities; i++, body++ ) { @@ -1593,15 +1593,16 @@ void Cmd_Class_f( gentity_t *ent ) { ent->client->pers.pclass = BG_FindClassNumForName( s ); - //...check we can evolve to that class - if( !BG_ClassCanEvolveFromTo( ent->client->ps.stats[ STAT_PCLASS ], - ent->client->pers.pclass ) ) + if( ent->client->pers.pclass == PCL_NONE ) { - trap_SendServerCommand( ent-g_entities, va("print \"You cannot evolve from your current class\n\"" ) ); + trap_SendServerCommand( ent-g_entities, va("print \"Unknown class\n\"" ) ); return; } - - if( ent->client->pers.pclass != PCL_NONE ) + + //...check we can evolve to that class + if( BG_ClassCanEvolveFromTo( ent->client->ps.stats[ STAT_PCLASS ], + ent->client->pers.pclass ) || + BG_FindStagesForClass( ent->client->pers.pclass, g_alienStage.integer ) ) { //prevent lerping ent->client->ps.eFlags ^= EF_TELEPORT_BIT; @@ -1627,7 +1628,8 @@ void Cmd_Class_f( gentity_t *ent ) } else { - trap_SendServerCommand( ent-g_entities, va("print \"Unknown class\n\"" ) ); + ent->client->pers.pclass = PCL_NONE; + trap_SendServerCommand( ent-g_entities, va("print \"You cannot evolve from your current class\n\"" ) ); return; } } @@ -1641,7 +1643,8 @@ void Cmd_Class_f( gentity_t *ent ) { for( i = 0; i < NUM_AC; i++ ) { - if( allowedClasses[ i ] == ent->client->pers.pclass ) + if( allowedClasses[ i ] == ent->client->pers.pclass && + BG_FindStagesForClass( ent->client->pers.pclass, g_alienStage.integer ) ) { ent->client->sess.sessionTeam = TEAM_FREE; ClientUserinfoChanged( clientNum ); @@ -1663,7 +1666,7 @@ void Cmd_Class_f( gentity_t *ent ) else if( ent->client->pers.pteam == PTE_HUMANS ) { //humans cannot use this command whilst alive - if( ent->client->pers.pclass != PCL_NONE ) + if( ent->client->ps.stats[ STAT_PCLASS ] != PCL_NONE ) { trap_SendServerCommand( ent-g_entities, va("print \"You must be dead to use the class command\n\"" ) ); return; @@ -1678,6 +1681,7 @@ void Cmd_Class_f( gentity_t *ent ) ent->client->pers.pitem = WP_HBUILD; else { + ent->client->pers.pclass = PCL_NONE; trap_SendServerCommand( ent-g_entities, va("print \"Unknown starting item\n\"" ) ); return; } @@ -1888,6 +1892,13 @@ void Cmd_Buy_f( gentity_t *ent ) return; } + //are we /allowed/ to buy this? + if( !BG_FindStagesForWeapon( weapon, g_humanStage.integer ) ) + { + trap_SendServerCommand( ent-g_entities, va("print \"You can't buy this item\n\"" ) ); + return; + } + //add to inventory BG_packWeapon( weapon, ent->client->ps.stats ); BG_FindAmmoForWeapon( weapon, &quan, &clips, &maxClips ); @@ -1921,6 +1932,20 @@ void Cmd_Buy_f( gentity_t *ent ) return; } + if( BG_FindTeamForUpgrade( upgrade ) != WUT_HUMANS ) + { + //shouldn't need a fancy dialog + trap_SendServerCommand( ent-g_entities, va("print \"You can't buy alien items\n\"" ) ); + return; + } + + //are we /allowed/ to buy this? + if( !BG_FindStagesForUpgrade( upgrade, g_humanStage.integer ) ) + { + trap_SendServerCommand( ent-g_entities, va("print \"You can't buy this item\n\"" ) ); + return; + } + //add to inventory BG_packItem( upgrade, ent->client->ps.stats ); @@ -2139,7 +2164,8 @@ void Cmd_Build_f( gentity_t *ent ) if( buildable != BA_NONE && ( 1 << ent->client->ps.weapon ) & BG_FindBuildWeaponForBuildable( buildable ) && !( ent->client->ps.stats[ STAT_STATE ] & SS_INFESTING ) && - !( ent->client->ps.stats[ STAT_STATE ] & SS_HOVELING ) ) + !( ent->client->ps.stats[ STAT_STATE ] & SS_HOVELING ) && + BG_FindStagesForBuildable( buildable, g_humanStage.integer ) ) { dist = BG_FindBuildDistForClass( ent->client->ps.stats[ STAT_PCLASS ] ); diff --git a/src/game/g_local.h b/src/game/g_local.h index e9d35984..b4d71604 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -543,6 +543,7 @@ typedef enum IBE_RPTWARN, IBE_NOPOWER, IBE_NORMAL, + IBE_NOCREEP, IBE_MAXERRORS } itemBuildError_t; @@ -853,6 +854,8 @@ extern vmCvar_t g_singlePlayer; extern vmCvar_t g_humanBuildPoints; extern vmCvar_t g_alienBuildPoints; +extern vmCvar_t g_humanStage; +extern vmCvar_t g_alienStage; void trap_Printf( const char *fmt ); void trap_Error( const char *fmt ); diff --git a/src/game/g_main.c b/src/game/g_main.c index c8f5d3b4..8d9a46b0 100644 --- a/src/game/g_main.c +++ b/src/game/g_main.c @@ -78,6 +78,8 @@ vmCvar_t g_listEntity; //TA vmCvar_t g_humanBuildPoints; vmCvar_t g_alienBuildPoints; +vmCvar_t g_humanStage; +vmCvar_t g_alienStage; static cvarTable_t gameCvarTable[] = { // don't override the cheat state set by the system @@ -149,6 +151,8 @@ static cvarTable_t gameCvarTable[] = { { &g_humanBuildPoints, "g_humanBuildPoints", "1000", 0, 0, qfalse }, { &g_alienBuildPoints, "g_alienBuildPoints", "1000", 0, 0, qfalse }, + { &g_humanStage, "g_humanStage", "0", 0, 0, qfalse }, + { &g_alienStage, "g_alienStage", "0", 0, 0, qfalse }, { &g_rankings, "g_rankings", "0", 0, 0, qfalse} }; @@ -835,6 +839,10 @@ void calculateBuildPoints( void ) level.humanBuildPoints, localHTP, level.humanBuildPointsPowered ) ); + + //may as well pump the stages here too + trap_SetConfigstring( CS_STAGES, va( "%d %d", + g_alienStage.integer, g_humanStage.integer ) ); } diff --git a/src/ui/ui_main.c b/src/ui/ui_main.c index b16ec3a7..6d6816c9 100644 --- a/src/ui/ui_main.c +++ b/src/ui/ui_main.c @@ -2813,6 +2813,38 @@ static void UI_StartSinglePlayer() { /* =============== +UI_GetCurrentAlienStage +=============== +*/ +static stage_t UI_GetCurrentAlienStage( ) +{ + char buffer[ MAX_TOKEN_CHARS ]; + stage_t stage, dummy; + + trap_Cvar_VariableStringBuffer( "ui_stages", buffer, sizeof( buffer ) ); + sscanf( buffer, "%d %d", &stage, &dummy ); + + return stage; +} + +/* +=============== +UI_GetCurrentHumanStage +=============== +*/ +static stage_t UI_GetCurrentHumanStage( ) +{ + char buffer[ MAX_TOKEN_CHARS ]; + stage_t stage, dummy; + + trap_Cvar_VariableStringBuffer( "ui_stages", buffer, sizeof( buffer ) ); + sscanf( buffer, "%d %d", &dummy, &stage ); + + return stage; +} + +/* +=============== UI_LoadTremTeams =============== */ @@ -2882,12 +2914,15 @@ UI_LoadTremHumanMCUBuys static void UI_LoadTremHumanMCUBuys( ) { int i, j = 0; + stage_t stage = UI_GetCurrentHumanStage( ); uiInfo.tremHumanMCUBuyCount = 0; for( i = WP_NONE +1; i < WP_NUM_WEAPONS; i++ ) { - if( BG_FindTeamForWeapon( i ) == WUT_HUMANS && BG_FindPurchasableForWeapon( i ) ) + if( BG_FindTeamForWeapon( i ) == WUT_HUMANS && + BG_FindPurchasableForWeapon( i ) && + BG_FindStagesForWeapon( i, stage ) ) { uiInfo.tremHumanMCUBuyList[ j ].text = String_Alloc( BG_FindHumanNameForWeapon( i ) ); @@ -2900,7 +2935,8 @@ static void UI_LoadTremHumanMCUBuys( ) for( i = UP_NONE +1; i < UP_NUM_UPGRADES; i++ ) { - if( BG_FindTeamForUpgrade( i ) == WUT_HUMANS ) + if( BG_FindTeamForUpgrade( i ) == WUT_HUMANS && + BG_FindStagesForUpgrade( i, stage ) ) { uiInfo.tremHumanMCUBuyList[ j ].text = String_Alloc( BG_FindHumanNameForUpgrade( i ) ); @@ -2914,21 +2950,26 @@ static void UI_LoadTremHumanMCUBuys( ) /* =============== -UI_LoadTremHumanMCUSells +UI_ParseCarriageList =============== */ -static void UI_LoadTremHumanMCUSells( ) +static void UI_ParseCarriageList( int *weapons, int *upgrades ) { - int i, j = 0; + int i; char carriageCvar[ MAX_TOKEN_CHARS ]; char *iterator; char buffer[ MAX_TOKEN_CHARS ]; char *bufPointer; - uiInfo.tremHumanMCUSellCount = 0; trap_Cvar_VariableStringBuffer( "ui_carriage", carriageCvar, sizeof( carriageCvar ) ); iterator = carriageCvar; + if( weapons ) + *weapons = 0; + + if( upgrades ) + *upgrades = 0; + //simple parser to give rise to weapon/upgrade list while( iterator && iterator[ 0 ] != '$' ) { @@ -2944,11 +2985,9 @@ static void UI_LoadTremHumanMCUSells( ) *bufPointer++ = '\n'; i = atoi( buffer ); - uiInfo.tremHumanMCUSellList[ j ].text = String_Alloc( BG_FindHumanNameForWeapon( i ) ); - uiInfo.tremHumanMCUSellList[ j++ ].cmd = - String_Alloc( va( "cmd sell %s", BG_FindNameForWeapon( i ) ) ); - uiInfo.tremHumanMCUSellCount++; + if( weapons ) + *weapons |= ( 1 << i ); } else if( iterator[ 0 ] == 'U' ) { @@ -2960,14 +2999,50 @@ static void UI_LoadTremHumanMCUSells( ) *bufPointer++ = '\n'; i = atoi( buffer ); + + if( upgrades ) + *upgrades |= ( 1 << i ); + } + + iterator++; + } +} + +/* +=============== +UI_LoadTremHumanMCUSells +=============== +*/ +static void UI_LoadTremHumanMCUSells( ) +{ + int weapons, upgrades; + int i, j = 0; + + uiInfo.tremHumanMCUSellCount = 0; + UI_ParseCarriageList( &weapons, &upgrades ); + + for( i = WP_NONE + 1; i < WP_NUM_WEAPONS; i++ ) + { + if( weapons & ( 1 << i ) ) + { + uiInfo.tremHumanMCUSellList[ j ].text = String_Alloc( BG_FindHumanNameForWeapon( i ) ); + uiInfo.tremHumanMCUSellList[ j++ ].cmd = + String_Alloc( va( "cmd sell %s", BG_FindNameForWeapon( i ) ) ); + + uiInfo.tremHumanMCUSellCount++; + } + } + + for( i = UP_NONE + 1; i < UP_NUM_UPGRADES; i++ ) + { + if( upgrades & ( 1 << i ) ) + { uiInfo.tremHumanMCUSellList[ j ].text = String_Alloc( BG_FindHumanNameForUpgrade( i ) ); uiInfo.tremHumanMCUSellList[ j++ ].cmd = String_Alloc( va( "cmd sell %s", BG_FindNameForUpgrade( i ) ) ); uiInfo.tremHumanMCUSellCount++; } - - iterator++; } } @@ -2978,14 +3053,16 @@ UI_LoadTremAlienUpgrades( ) */ static void UI_LoadTremAlienUpgrades( ) { - int i, j = 0; - int class = trap_Cvar_VariableValue( "ui_currentClass" ); + int i, j = 0; + int class = trap_Cvar_VariableValue( "ui_currentClass" ); + stage_t stage = UI_GetCurrentAlienStage( ); uiInfo.tremAlienUpgradeCount = 0; for( i = PCL_NONE + 1; i < PCL_NUM_CLASSES; i++ ) { - if( BG_ClassCanEvolveFromTo( class, i ) ) + if( BG_ClassCanEvolveFromTo( class, i ) && + BG_FindStagesForClass( i, stage ) ) { uiInfo.tremAlienUpgradeList[ j ].text = String_Alloc( BG_FindNameForClassNum( i ) ); uiInfo.tremAlienUpgradeList[ j++ ].cmd = @@ -3003,13 +3080,20 @@ UI_LoadTremAlienBuilds */ static void UI_LoadTremAlienBuilds( ) { - int i, j = 0; - + int weapons; + int i, j = 0; + stage_t stage; + + UI_ParseCarriageList( &weapons, NULL ); + stage = UI_GetCurrentAlienStage( ); + uiInfo.tremAlienBuildCount = 0; for( i = BA_NONE +1; i < BA_NUM_BUILDABLES; i++ ) { - if( BG_FindTeamForBuildable( i ) == BIT_ALIENS ) + if( BG_FindTeamForBuildable( i ) == BIT_ALIENS && + BG_FindBuildWeaponForBuildable( i ) & weapons && + BG_FindStagesForBuildable( i, stage ) ) { uiInfo.tremAlienBuildList[ j ].text = String_Alloc( BG_FindHumanNameForBuildable( i ) ); @@ -3028,13 +3112,20 @@ UI_LoadTremHumanBuilds */ static void UI_LoadTremHumanBuilds( ) { - int i, j = 0; + int weapons; + int i, j = 0; + stage_t stage; + + UI_ParseCarriageList( &weapons, NULL ); + stage = UI_GetCurrentHumanStage( ); uiInfo.tremHumanBuildCount = 0; for( i = BA_NONE +1; i < BA_NUM_BUILDABLES; i++ ) { - if( BG_FindTeamForBuildable( i ) == BIT_HUMANS ) + if( BG_FindTeamForBuildable( i ) == BIT_HUMANS && + BG_FindBuildWeaponForBuildable( i ) & weapons && + BG_FindStagesForBuildable( i, stage ) ) { uiInfo.tremHumanBuildList[ j ].text = String_Alloc( BG_FindHumanNameForBuildable( i ) ); |