diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cgame/cg_servercmds.c | 7 | ||||
-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 |
4 files changed, 40 insertions, 4 deletions
diff --git a/src/cgame/cg_servercmds.c b/src/cgame/cg_servercmds.c index 7b609c90..22be1bff 100644 --- a/src/cgame/cg_servercmds.c +++ b/src/cgame/cg_servercmds.c @@ -693,6 +693,13 @@ void CG_Menu( int menu, int arg ) type = DT_ARMOURYEVOLVE; break; + case MN_H_NOENERGYAMMOHERE: + longMsg = "You must be near a Reactor or a powered Armoury or Repeater " + "in order to purchase energy ammunition."; + shortMsg = "You must be near a Reactor or a powered Armoury or Repeater"; + type = DT_ARMOURYEVOLVE; + break; + case MN_H_NOROOMBSUITON: longMsg = "There is not enough room here to put on a Battle Suit. " "Make sure you have enough head room to climb in."; 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 ) |