diff options
author | Tim Angus <tim@ngus.net> | 2005-06-28 01:51:28 +0000 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2005-06-28 01:51:28 +0000 |
commit | 0e56723b5c2e42c67bb12eca353caccc7a1a3886 (patch) | |
tree | c0069380a077d32675bc94893b5b4ed8684e2bcd /src | |
parent | 84dcdd0676075ff5f6a0da59376258a6de9522dc (diff) |
* Added ent->client->campingAtTheArmoury for the lamers
Diffstat (limited to 'src')
-rw-r--r-- | src/game/g_active.c | 31 | ||||
-rw-r--r-- | src/game/g_cmds.c | 51 | ||||
-rw-r--r-- | src/game/g_local.h | 3 | ||||
-rw-r--r-- | src/game/tremulous.h | 3 |
4 files changed, 68 insertions, 20 deletions
diff --git a/src/game/g_active.c b/src/game/g_active.c index b12f1e41..93360a12 100644 --- a/src/game/g_active.c +++ b/src/game/g_active.c @@ -657,6 +657,37 @@ void ClientTimerActions( gentity_t *ent, int msec ) damage, 0, MOD_POISON ); } + if( client->campingAtTheArmoury ) + { + if( client->lastBoughtAmmoTime + HUMAN_ARMOURY_CAMP_TIME < level.time ) + client->campingAtTheArmoury = qfalse; + else + { + //check if there are no armouries in range + int entityList[ MAX_GENTITIES ]; + vec3_t range = { HUMAN_ARMOURY_CAMP_DISTANCE, + HUMAN_ARMOURY_CAMP_DISTANCE, HUMAN_ARMOURY_CAMP_DISTANCE }; + vec3_t mins, maxs; + int i, num; + gentity_t *armoury; + + VectorAdd( client->ps.origin, range, maxs ); + VectorSubtract( client->ps.origin, range, mins ); + + num = trap_EntitiesInBox( mins, maxs, entityList, MAX_GENTITIES ); + for( i = 0; i < num; i++ ) + { + armoury = &g_entities[ entityList[ i ] ]; + + if( armoury->s.eType == ET_BUILDABLE && armoury->s.modelindex == BA_H_ARMOURY ) + break; + } + + if( i == num ) + client->campingAtTheArmoury = qfalse; + } + } + //replenish alien health if( client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS ) { 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 diff --git a/src/game/g_local.h b/src/game/g_local.h index 4a12e3c0..00b38bbe 100644 --- a/src/game/g_local.h +++ b/src/game/g_local.h @@ -415,6 +415,9 @@ struct gclient_s #define RAM_FRAMES 1 //TA: number of frames to wait before retriggering int retriggerArmouryMenu; //TA: frame number to retrigger the armoury menu + + int lastBoughtAmmoTime; + qboolean campingAtTheArmoury; }; diff --git a/src/game/tremulous.h b/src/game/tremulous.h index 0f1da479..f444fc5d 100644 --- a/src/game/tremulous.h +++ b/src/game/tremulous.h @@ -540,6 +540,9 @@ #define HUMAN_SPAWN_REPEAT_TIME 10000 +#define HUMAN_ARMOURY_CAMP_TIME 45000 +#define HUMAN_ARMOURY_CAMP_DISTANCE 256.0f + /* * Misc */ |