summaryrefslogtreecommitdiff
path: root/src/game/g_cmds.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/game/g_cmds.c')
-rw-r--r--src/game/g_cmds.c147
1 files changed, 106 insertions, 41 deletions
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index ea7ed83f..afd21ca7 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -755,8 +755,10 @@ void Cmd_Team_f( gentity_t *ent )
BG_InventoryContainsWeapon( WP_HBUILD2, ent->client->ps.stats ) ) &&
ent->client->ps.stats[ STAT_MISC ] > 0 )
{
- trap_SendServerCommand( ent-g_entities,
- va( "print \"You cannot change teams until build timer expires\n\"" ) );
+ if( ent->client->pers.teamSelection == PTE_ALIENS )
+ G_TriggerMenu( ent->client->ps.clientNum, MN_A_TEAMCHANGEBUILDTIMER );
+ else
+ G_TriggerMenu( ent->client->ps.clientNum, MN_H_TEAMCHANGEBUILDTIMER );
return;
}
@@ -1561,9 +1563,60 @@ void Cmd_SetViewpos_f( gentity_t *ent )
TeleportPlayer( ent, origin, angles );
}
-#define EVOLVE_TRACE_HEIGHT 128.0f
#define AS_OVER_RT3 ((ALIENSENSE_RANGE*0.5f)/M_ROOT3)
+static qboolean G_RoomForClassChange( gentity_t *ent, pClass_t class,
+ vec3_t newOrigin )
+{
+ vec3_t fromMins, fromMaxs;
+ vec3_t toMins, toMaxs;
+ vec3_t temp;
+ trace_t tr, tr2;
+ float nudgeHeight;
+ pClass_t oldClass = ent->client->ps.stats[ STAT_PCLASS ];
+
+ BG_FindBBoxForClass( oldClass, fromMins, fromMaxs, NULL, NULL, NULL );
+ BG_FindBBoxForClass( class, toMins, toMaxs, NULL, NULL, NULL );
+
+ VectorCopy( ent->s.pos.trBase, newOrigin );
+
+ // test by moving the player up the max required on a 60 degree slope
+ if( fabs( toMins[ 0 ] ) > fabs( toMins[ 1 ] ) )
+ nudgeHeight = ( fabs( toMins[ 0 ] ) * 2.0f ) + 1.0f;
+ else
+ nudgeHeight = ( fabs( toMins[ 1 ] ) * 2.0f ) + 1.0f;
+
+ newOrigin[ 2 ] += fabs( toMins[ 2 ] ) - fabs( fromMins[ 2 ] )
+ + BG_FindZOffsetForClass( class ) - BG_FindZOffsetForClass( oldClass )
+ + 1.0f;
+ VectorCopy( newOrigin, temp );
+ temp[ 2 ] += nudgeHeight;
+
+ toMins[ 0 ] += 1.0f;
+ toMins[ 1 ] += 1.0f;
+ toMaxs[ 0 ] -= 1.0f;
+ toMaxs[ 1 ] -= 1.0f;
+
+ //compute a place up in the air to start the real trace
+ trap_Trace( &tr, newOrigin, toMins, toMaxs, temp, ent->s.number, MASK_SHOT );
+ VectorCopy( newOrigin, temp );
+ temp[ 2 ] += ( nudgeHeight * tr.fraction ) - 1.0f;
+
+ //trace down to the ground so that we can evolve on slopes
+ trap_Trace( &tr, temp, toMins, toMaxs, newOrigin, ent->s.number, MASK_SHOT );
+ VectorCopy( tr.endpos, newOrigin );
+
+ //make REALLY sure
+ trap_Trace( &tr2, newOrigin, toMins, toMaxs, newOrigin,
+ ent->s.number, MASK_SHOT );
+
+ //check there is room to evolve
+ if( !tr.startsolid && tr2.fraction == 1.0f )
+ return qtrue;
+ else
+ return qfalse;
+}
+
/*
=================
Cmd_Class_f
@@ -1574,17 +1627,12 @@ void Cmd_Class_f( gentity_t *ent )
char s[ MAX_TOKEN_CHARS ];
int clientNum;
int i;
- trace_t tr, tr2;
vec3_t infestOrigin;
int allowedClasses[ PCL_NUM_CLASSES ];
int numClasses = 0;
pClass_t currentClass = ent->client->ps.stats[ STAT_PCLASS ];
pClass_t newClass;
-
int numLevels;
- vec3_t fromMins, fromMaxs, toMins, toMaxs;
- vec3_t temp;
-
int entityList[ MAX_GENTITIES ];
vec3_t range = { AS_OVER_RT3, AS_OVER_RT3, AS_OVER_RT3 };
vec3_t mins, maxs;
@@ -1656,8 +1704,7 @@ void Cmd_Class_f( gentity_t *ent )
currentClass == PCL_ALIEN_BUILDER0_UPG ) &&
ent->client->ps.stats[ STAT_MISC ] > 0 )
{
- trap_SendServerCommand( ent-g_entities,
- va( "print \"You cannot evolve until build timer expires\n\"" ) );
+ G_TriggerMenu( ent->client->ps.clientNum, MN_A_EVOLVEBUILDTIMER );
return;
}
@@ -1665,31 +1712,7 @@ void Cmd_Class_f( gentity_t *ent )
newClass,
(short)ent->client->ps.persistant[ PERS_CREDIT ], 0 );
- BG_FindBBoxForClass( currentClass,
- fromMins, fromMaxs, NULL, NULL, NULL );
- BG_FindBBoxForClass( newClass,
- toMins, toMaxs, NULL, NULL, NULL );
-
- VectorCopy( ent->s.pos.trBase, infestOrigin );
-
- infestOrigin[ 2 ] += ( fabs( toMins[ 2 ] ) - fabs( fromMins[ 2 ] ) ) + 1.0f;
- VectorCopy( infestOrigin, temp );
- temp[ 2 ] += EVOLVE_TRACE_HEIGHT;
-
- //compute a place up in the air to start the real trace
- trap_Trace( &tr, infestOrigin, toMins, toMaxs, temp, ent->s.number, MASK_SHOT );
- VectorCopy( infestOrigin, temp );
- temp[ 2 ] += ( EVOLVE_TRACE_HEIGHT * tr.fraction ) - 1.0f;
-
- //trace down to the ground so that we can evolve on slopes
- trap_Trace( &tr, temp, toMins, toMaxs, infestOrigin, ent->s.number, MASK_SHOT );
- VectorCopy( tr.endpos, infestOrigin );
-
- //make REALLY sure
- trap_Trace( &tr2, ent->s.pos.trBase, NULL, NULL, infestOrigin, ent->s.number, MASK_SHOT );
-
- //check there is room to evolve
- if( !tr.startsolid && tr2.fraction == 1.0f )
+ if( G_RoomForClassChange( ent, newClass, infestOrigin ) )
{
//...check we can evolve to that class
if( numLevels >= 0 &&
@@ -2062,8 +2085,7 @@ void Cmd_Buy_f( gentity_t *ent )
!G_BuildableRange( ent->client->ps.origin, 100, BA_H_REPEATER ) &&
!G_BuildableRange( ent->client->ps.origin, 100, BA_H_ARMOURY ) )
{
- trap_SendServerCommand( ent-g_entities, va(
- "print \"You must be near a reactor, repeater or armoury\n\"" ) );
+ G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOENERGYAMMOHERE );
return;
}
}
@@ -2072,7 +2094,7 @@ void Cmd_Buy_f( gentity_t *ent )
//no armoury nearby
if( !G_BuildableRange( ent->client->ps.origin, 100, BA_H_ARMOURY ) )
{
- trap_SendServerCommand( ent-g_entities, va( "print \"You must be near a powered armoury\n\"" ) );
+ G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOARMOURYHERE );
return;
}
}
@@ -2188,6 +2210,19 @@ void Cmd_Buy_f( gentity_t *ent )
G_GiveClientMaxAmmo( ent, buyingEnergyAmmo );
else
{
+ if( upgrade == UP_BATTLESUIT )
+ {
+ vec3_t newOrigin;
+
+ if( !G_RoomForClassChange( ent, PCL_HUMAN_BSUIT, newOrigin ) )
+ {
+ G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOROOMBSUITON );
+ return;
+ }
+ VectorCopy( newOrigin, ent->s.pos.trBase );
+ ent->client->ps.stats[ STAT_PCLASS ] = PCL_HUMAN_BSUIT;
+ }
+
//add to inventory
BG_AddUpgradeToInventory( upgrade, ent->client->ps.stats );
}
@@ -2237,7 +2272,7 @@ void Cmd_Sell_f( gentity_t *ent )
//no armoury nearby
if( !G_BuildableRange( ent->client->ps.origin, 100, BA_H_ARMOURY ) )
{
- trap_SendServerCommand( ent-g_entities, va( "print \"You must be near a powered armoury\n\"" ) );
+ G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOARMOURYHERE );
return;
}
@@ -2260,7 +2295,7 @@ void Cmd_Sell_f( gentity_t *ent )
if( ( weapon == WP_HBUILD || weapon == WP_HBUILD2 ) &&
ent->client->ps.stats[ STAT_MISC ] > 0 )
{
- trap_SendServerCommand( ent-g_entities, va( "print \"Cannot sell until build timer expires\n\"" ) );
+ G_TriggerMenu( ent->client->ps.clientNum, MN_H_ARMOURYBUILDTIMER );
return;
}
@@ -2285,6 +2320,21 @@ void Cmd_Sell_f( gentity_t *ent )
//remove upgrade if carried
if( BG_InventoryContainsUpgrade( upgrade, ent->client->ps.stats ) )
{
+ // shouldn't really need to test for this, but just to be safe
+ if( upgrade == UP_BATTLESUIT )
+ {
+ vec3_t newOrigin;
+
+ if( !G_RoomForClassChange( ent, PCL_HUMAN, newOrigin ) )
+ {
+ G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOROOMBSUITOFF );
+ return;
+ }
+ VectorCopy( newOrigin, ent->s.pos.trBase );
+ ent->client->ps.stats[ STAT_PCLASS ] = PCL_HUMAN;
+ }
+
+ //add to inventory
BG_RemoveUpgradeFromInventory( upgrade, ent->client->ps.stats );
if( upgrade == UP_BATTPACK )
@@ -2302,7 +2352,7 @@ void Cmd_Sell_f( gentity_t *ent )
if( ( i == WP_HBUILD || i == WP_HBUILD2 ) &&
ent->client->ps.stats[ STAT_MISC ] > 0 )
{
- trap_SendServerCommand( ent-g_entities, va( "print \"Cannot sell until build timer expires\n\"" ) );
+ G_TriggerMenu( ent->client->ps.clientNum, MN_H_ARMOURYBUILDTIMER );
continue;
}
@@ -2328,6 +2378,21 @@ void Cmd_Sell_f( gentity_t *ent )
if( BG_InventoryContainsUpgrade( i, ent->client->ps.stats ) &&
BG_FindPurchasableForUpgrade( i ) )
{
+
+ // shouldn't really need to test for this, but just to be safe
+ if( i == UP_BATTLESUIT )
+ {
+ vec3_t newOrigin;
+
+ if( !G_RoomForClassChange( ent, PCL_HUMAN, newOrigin ) )
+ {
+ G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOROOMBSUITOFF );
+ continue;
+ }
+ VectorCopy( newOrigin, ent->s.pos.trBase );
+ ent->client->ps.stats[ STAT_PCLASS ] = PCL_HUMAN;
+ }
+
BG_RemoveUpgradeFromInventory( i, ent->client->ps.stats );
if( i == UP_BATTPACK )