From 6af24abf02f1d0dedc5dbe655a37d5afc9f0646a Mon Sep 17 00:00:00 2001 From: "Tony J. White" Date: Fri, 17 Nov 2006 20:15:12 +0000 Subject: * (bug 2853) allow energy ammo to be purchased as long as an energy weapon is in the inventory regardless of what weapon is selected * (bug 2827) allow energy ammo to be purchased at an armoury --- src/game/g_cmds.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 9c1dd05b..e99153d6 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -1902,6 +1902,7 @@ void Cmd_Buy_f( gentity_t *ent ) int weapon, upgrade, numItems = 0; int maxAmmo, maxClips; qboolean buyingEnergyAmmo = qfalse; + qboolean hasEnergyWeapon = qfalse; for( i = UP_NONE; i < UP_NUM_UPGRADES; i++ ) { @@ -1912,7 +1913,11 @@ void Cmd_Buy_f( gentity_t *ent ) for( i = WP_NONE; i < WP_NUM_WEAPONS; i++ ) { if( BG_InventoryContainsWeapon( i, ent->client->ps.stats ) ) + { + if( BG_FindUsesEnergyForWeapon( i ) ) + hasEnergyWeapon = qtrue; numItems++; + } } trap_Argv( 1, s, sizeof( s ) ); @@ -1926,15 +1931,19 @@ void Cmd_Buy_f( gentity_t *ent ) //special case to keep norf happy if( weapon == WP_NONE && upgrade == UP_AMMO ) - buyingEnergyAmmo = BG_FindUsesEnergyForWeapon( ent->client->ps.weapon ); + { + buyingEnergyAmmo = hasEnergyWeapon; + } if( buyingEnergyAmmo ) { //no armoury nearby - if( ( !G_BuildableRange( ent->client->ps.origin, 100, BA_H_REACTOR ) && - !G_BuildableRange( ent->client->ps.origin, 100, BA_H_REPEATER ) ) ) + if( !G_BuildableRange( ent->client->ps.origin, 100, BA_H_REACTOR ) && + !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 or repeater\n\"" ) ); + trap_SendServerCommand( ent-g_entities, va( + "print \"You must be near a reactor, repeater or armoury\n\"" ) ); return; } } -- cgit