diff options
Diffstat (limited to 'src/game')
-rw-r--r-- | src/game/bg_misc.c | 22 | ||||
-rw-r--r-- | src/game/bg_public.h | 2 | ||||
-rw-r--r-- | src/game/g_cmds.c | 13 |
3 files changed, 33 insertions, 4 deletions
diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index 54650521..3f30a127 100644 --- a/src/game/bg_misc.c +++ b/src/game/bg_misc.c @@ -5472,6 +5472,28 @@ weapon_t BG_GetPlayerWeapon( playerState_t *ps ) } /* +================= +BG_HasEnergyWeapon + +Returns true if the player has an energy weapon. +================= +*/ +qboolean BG_HasEnergyWeapon( playerState_t *ps ) +{ + int i; + + for( i = WP_NONE + 1; i < WP_NUM_WEAPONS; i++ ) + { + if( !BG_InventoryContainsWeapon( i, ps->stats ) || + !BG_FindUsesEnergyForWeapon( i ) ) + continue; + + return qtrue; + } + return qfalse; +} + +/* =============== atof_neg diff --git a/src/game/bg_public.h b/src/game/bg_public.h index 67899978..5ddcf076 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -623,6 +623,7 @@ typedef enum MN_H_ITEMHELD, MN_H_TEAMCHANGEBUILDTIMER, MN_H_NOARMOURYHERE, + MN_H_NOENERGYAMMOHERE, MN_H_NOROOMBSUITON, MN_H_NOROOMBSUITOFF, MN_H_ARMOURYBUILDTIMER, @@ -1131,6 +1132,7 @@ int BG_GetValueOfPlayer( playerState_t *ps ); qboolean BG_PlayerCanChangeWeapon( playerState_t *ps ); int BG_PlayerPoisonCloudTime( playerState_t *ps ); weapon_t BG_GetPlayerWeapon( playerState_t *ps ); +qboolean BG_HasEnergyWeapon( playerState_t *ps ); int BG_FindValueOfBuildable( int bclass ); int BG_FindBuildNumForName( char *name ); diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 86c48495..fcfebecf 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -1962,12 +1962,17 @@ void Cmd_Buy_f( gentity_t *ent ) // and make sure we only give energy ammo in this case if( G_BuildableRange( ent->client->ps.origin, 100, BA_H_ARMOURY ) ) energyOnly = qfalse; - else if( G_BuildableRange( ent->client->ps.origin, 100, BA_H_REACTOR ) || - G_BuildableRange( ent->client->ps.origin, 100, BA_H_REPEATER ) ) + else if( upgrade == UP_AMMO && BG_HasEnergyWeapon( &ent->client->ps ) && + ( G_BuildableRange( ent->client->ps.origin, 100, BA_H_REACTOR ) || + G_BuildableRange( ent->client->ps.origin, 100, BA_H_REPEATER ) ) ) energyOnly = qtrue; else { - G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOARMOURYHERE ); + if( upgrade == UP_AMMO && + BG_FindUsesEnergyForWeapon( ent->client->ps.weapon ) ) + G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOENERGYAMMOHERE ); + else + G_TriggerMenu( ent->client->ps.clientNum, MN_H_NOARMOURYHERE ); return; } @@ -2083,7 +2088,7 @@ void Cmd_Buy_f( gentity_t *ent ) } if( upgrade == UP_AMMO ) - G_GiveClientMaxAmmo( ent, qfalse ); + G_GiveClientMaxAmmo( ent, energyOnly ); else { if( upgrade == UP_BATTLESUIT ) |