diff options
Diffstat (limited to 'src/game/g_cmds.c')
-rw-r--r-- | src/game/g_cmds.c | 51 |
1 files changed, 31 insertions, 20 deletions
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index e8bf564f..47e5b3ba 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -1609,33 +1609,44 @@ void Cmd_Buy_f( gentity_t *ent ) if( upgrade == UP_AMMO ) { - qboolean weaponType; - - for( i = WP_NONE; i < WP_NUM_WEAPONS; i++ ) + if( !ent->client->campingAtTheArmoury ) { - if( buyingEnergyAmmo ) - weaponType = BG_FindUsesEnergyForWeapon( i ); - else - weaponType = !BG_FindUsesEnergyForWeapon( i ); - - if( BG_InventoryContainsWeapon( i, ent->client->ps.stats ) && - weaponType && - !BG_FindInfinteAmmoForWeapon( i ) ) + qboolean weaponType; + + for( i = WP_NONE; i < WP_NUM_WEAPONS; i++ ) { - BG_FindAmmoForWeapon( i, &quan, &clips, &maxClips ); - if( buyingEnergyAmmo ) + weaponType = BG_FindUsesEnergyForWeapon( i ); + else + weaponType = !BG_FindUsesEnergyForWeapon( i ); + + if( BG_InventoryContainsWeapon( i, ent->client->ps.stats ) && + weaponType && + !BG_FindInfinteAmmoForWeapon( i ) ) { - G_AddEvent( ent, EV_RPTUSE_SOUND, 0 ); - ent->client->lastRefilTime = level.time; + BG_FindAmmoForWeapon( i, &quan, &clips, &maxClips ); - if( BG_InventoryContainsUpgrade( UP_BATTPACK, ent->client->ps.stats ) ) - quan = (int)( (float)quan * BATTPACK_MODIFIER ); - } + if( buyingEnergyAmmo ) + { + G_AddEvent( ent, EV_RPTUSE_SOUND, 0 ); + ent->client->lastRefilTime = level.time; + + if( BG_InventoryContainsUpgrade( UP_BATTPACK, ent->client->ps.stats ) ) + quan = (int)( (float)quan * BATTPACK_MODIFIER ); + } - BG_PackAmmoArray( i, ent->client->ps.ammo, ent->client->ps.powerups, - quan, clips, maxClips ); + BG_PackAmmoArray( i, ent->client->ps.ammo, ent->client->ps.powerups, + quan, clips, maxClips ); + } } + + ent->client->lastBoughtAmmoTime = level.time; + ent->client->campingAtTheArmoury = qtrue; + } + else + { + trap_SendServerCommand( ent-g_entities, va( "print \"Move away from the armoury\n\"" ) ); + return; } } else |