From e6cee5e1d9d160cf84e963fceda0261bbf563990 Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Tue, 19 Jul 2005 02:41:01 +0000 Subject: * Added a sound to buying ammo * Anticamp doesn't kick in unless you actually receive ammo * Mass driver spawn clips now matches max clips (wtf?) --- src/game/bg_misc.c | 18 ++++++++++++++++++ src/game/bg_public.h | 1 + src/game/g_buildable.c | 3 ++- src/game/g_cmds.c | 17 ++++++++++++----- src/game/tremulous.h | 2 +- 5 files changed, 34 insertions(+), 7 deletions(-) diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index 15361e64..08484549 100644 --- a/src/game/bg_misc.c +++ b/src/game/bg_misc.c @@ -4795,6 +4795,24 @@ void BG_PackAmmoArray( int weapon, int ammo[ ], int ammo2[ ], int quan, int clip ammo2[ weapon - 16 ] = weaponvalue; } +/* +======================== +BG_WeaponIsFull + +Check if a weapon has full ammo +======================== +*/ +qboolean BG_WeaponIsFull( weapon_t weapon, int ammo[ ], int ammo2[ ] ) +{ + int maxAmmo, maxClips; + int quan, clips; + + BG_FindAmmoForWeapon( weapon, &maxAmmo, NULL, &maxClips ); + BG_UnpackAmmoArray( weapon, ammo, ammo2, &quan, &clips, NULL ); + + return ( maxAmmo == quan ) && ( maxClips == clips ); +} + /* ======================== BG_AddWeaponToInventory diff --git a/src/game/bg_public.h b/src/game/bg_public.h index f72f5791..0ac09d26 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -1078,6 +1078,7 @@ typedef struct //TA: void BG_UnpackAmmoArray( int weapon, int ammo[ ], int ammo2[ ], int *quan, int *clips, int *maxclips ); void BG_PackAmmoArray( int weapon, int ammo[ ], int ammo2[ ], int quan, int clips, int maxclips ); +qboolean BG_WeaponIsFull( weapon_t weapon, int ammo[ ], int ammo2[ ] ); void BG_AddWeaponToInventory( int weapon, int stats[ ] ); void BG_RemoveWeaponFromInventory( int weapon, int stats[ ] ); qboolean BG_InventoryContainsWeapon( int weapon, int stats[ ] ); diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index 3d6e58a0..c9079f39 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -1520,7 +1520,8 @@ void HRpt_Use( gentity_t *self, gentity_t *other, gentity_t *activator ) if( !BG_FindUsesEnergyForWeapon( weapon ) ) return; - if( !other->client->campingAtTheArmoury ) + if( !other->client->campingAtTheArmoury && + !BG_WeaponIsFull( weapon, ps->ammo, ps->powerups ) ) { BG_FindAmmoForWeapon( weapon, &maxAmmo, NULL, &maxClips ); diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 3a0c2612..384c9240 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -1453,7 +1453,7 @@ static void G_GiveClientMaxAmmo( gentity_t *ent, qboolean buyingEnergyAmmo ) if( !ent->client->campingAtTheArmoury || !ent->client->firedWeapon ) { - qboolean weaponType; + qboolean weaponType, successfullyBought = qfalse; for( i = WP_NONE; i < WP_NUM_WEAPONS; i++ ) { @@ -1463,8 +1463,8 @@ static void G_GiveClientMaxAmmo( gentity_t *ent, qboolean buyingEnergyAmmo ) weaponType = !BG_FindUsesEnergyForWeapon( i ); if( BG_InventoryContainsWeapon( i, ent->client->ps.stats ) && - weaponType && - !BG_FindInfinteAmmoForWeapon( i ) ) + weaponType && !BG_FindInfinteAmmoForWeapon( i ) && + !BG_WeaponIsFull( i, ent->client->ps.ammo, ent->client->ps.powerups ) ) { BG_FindAmmoForWeapon( i, &quan, &clips, &maxClips ); @@ -1476,14 +1476,21 @@ static void G_GiveClientMaxAmmo( gentity_t *ent, qboolean buyingEnergyAmmo ) if( BG_InventoryContainsUpgrade( UP_BATTPACK, ent->client->ps.stats ) ) quan = (int)( (float)quan * BATTPACK_MODIFIER ); } + else + G_AddEvent( ent, EV_CHANGE_WEAPON, 0 ); BG_PackAmmoArray( i, ent->client->ps.ammo, ent->client->ps.powerups, quan, clips, maxClips ); + + successfullyBought = qtrue; } } - ent->client->lastBoughtAmmoTime = level.time; - ent->client->campingAtTheArmoury = qtrue; + if( successfullyBought ) + { + ent->client->lastBoughtAmmoTime = level.time; + ent->client->campingAtTheArmoury = qtrue; + } } else { diff --git a/src/game/tremulous.h b/src/game/tremulous.h index 0ee771e0..2416dff9 100644 --- a/src/game/tremulous.h +++ b/src/game/tremulous.h @@ -354,7 +354,7 @@ #define MDRIVER_PRICE 350 #define MDRIVER_CLIPSIZE 5 -#define MDRIVER_SPAWNCLIPS 2 +#define MDRIVER_SPAWNCLIPS 3 #define MDRIVER_MAXCLIPS 3 #define MDRIVER_DMG HDM(35) #define MDRIVER_REPEAT 1000 -- cgit