From 7af551c7381af876b44cdcce8ceca8714e479ae7 Mon Sep 17 00:00:00 2001 From: Victor Chow Date: Tue, 12 Jun 2001 19:29:46 +0000 Subject: [PATCH] Elder: Added/fixed the weapon ammo problem on a dropped weapon (note: mimics AQ2 behaviour, which is not "real" ammo in the gun =) --- reaction/game/g_active.c | 11 +++++++---- reaction/game/g_client.c | 13 +++++++++++++ reaction/game/g_cmds.c | 7 +++++++ reaction/game/g_combat.c | 7 +++++++ reaction/game/g_items.c | 10 +++++++++- reaction/game/g_local.h | 5 +++-- 6 files changed, 46 insertions(+), 7 deletions(-) diff --git a/reaction/game/g_active.c b/reaction/game/g_active.c index 6bc346cb..3b8554de 100644 --- a/reaction/game/g_active.c +++ b/reaction/game/g_active.c @@ -876,8 +876,10 @@ void ThrowWeapon( gentity_t *ent ) //if( client->ps.weapon == WP_KNIFE || client->ps.weapon == WP_PISTOL || client->ps.weapon == WP_GRENADE || ( ucmd->buttons & BUTTON_ATTACK )) // return; + //Elder: TODO: have to add a reloading case: + //weaponTime > 0 or weaponState == weapon_dropping? Or both? //Still firing - if (ucmd->buttons & BUTTON_ATTACK) { + if (ucmd->buttons & BUTTON_ATTACK || client->ps.weaponTime > 0) { return; } //Elder: Bandaging case @@ -886,8 +888,7 @@ void ThrowWeapon( gentity_t *ent ) return; } - //Elder: have to add a reloading case - + weap = 0; if (client->ps.stats[STAT_UNIQUEWEAPONS] > 0) { @@ -907,7 +908,9 @@ void ThrowWeapon( gentity_t *ent ) //Elder: Send a server command instead of force-setting //client->ps.weapon = WP_PISTOL; - client->ps.ammo[ weap ] = 0; + //Elder: Don't reset the weapon ammo + //client->ps.ammo[ weap ] = 0; + client->hadUniqueWeapon[weap] = qtrue; trap_SendServerCommand( ent-g_entities, va("selectpistol")); client->ps.stats[STAT_WEAPONS] &= ~( 1 << weap); diff --git a/reaction/game/g_client.c b/reaction/game/g_client.c index a4cb491d..0bccbb83 100644 --- a/reaction/game/g_client.c +++ b/reaction/game/g_client.c @@ -1040,6 +1040,9 @@ void ClientSpawn(gentity_t *ent) { int eventSequence; char userinfo[MAX_INFO_STRING]; + //To save the ammo stuff + qboolean hadUniqueWeapon[MAX_WEAPONS]; + index = ent - g_entities; client = ent->client; @@ -1101,6 +1104,11 @@ void ClientSpawn(gentity_t *ent) { accuracy_hits = client->accuracy_hits; accuracy_shots = client->accuracy_shots; + //Elder: save unique weapon info + for ( i = 0 ; i < MAX_WEAPONS ; i++ ) { + hadUniqueWeapon[i] = client->hadUniqueWeapon[i]; + } + for ( i = 0 ; i < MAX_PERSISTANT ; i++ ) { persistant[i] = client->ps.persistant[i]; } @@ -1120,6 +1128,11 @@ void ClientSpawn(gentity_t *ent) { client->accuracy_shots = accuracy_shots; client->lastkilled_client = -1; + //Elder: restore unique weapon info + for ( i = 0 ; i < MAX_WEAPONS ; i++ ) { + client->hadUniqueWeapon[i] = hadUniqueWeapon[i]; + } + for ( i = 0 ; i < MAX_PERSISTANT ; i++ ) { client->ps.persistant[i] = persistant[i]; } diff --git a/reaction/game/g_cmds.c b/reaction/game/g_cmds.c index 1cea22b1..7cef1daf 100644 --- a/reaction/game/g_cmds.c +++ b/reaction/game/g_cmds.c @@ -1601,6 +1601,13 @@ void Cmd_Bandage (gentity_t *ent) //Elder: can't use events //G_AddEvent(ent,EV_ZOOM,0); //} + + //Elder: added so you can't "rebandage" + if (ent->client->isBandaging == qtrue) { + trap_SendServerCommand( ent-g_entities, va("print \"You are already bandaging!\n\"")); + return; + } + if (ent->client->bleeding || (ent->client->ps.stats[STAT_RQ3] & RQ3_LEGDAMAGE) == RQ3_LEGDAMAGE) { ent->client->ps.weaponstate = WEAPON_DROPPING; diff --git a/reaction/game/g_combat.c b/reaction/game/g_combat.c index 9849e9e2..5fd54438 100644 --- a/reaction/game/g_combat.c +++ b/reaction/game/g_combat.c @@ -101,29 +101,36 @@ void TossClientItems( gentity_t *self ) { //BTW, that means no cheating to get all weapons or it'll spawn mad!! weaponInventory = self->client->ps.stats[STAT_WEAPONS]; + //Elder: added hadUniqueWeapons check - returns to qfalse if died with the gun + //as opposed to dropping it, then died if ( (weaponInventory & (1 << WP_M3) ) == (1 << WP_M3) ) { item = BG_FindItemForWeapon( WP_M3 ); Drop_Item( self, item, 0); + self->client->hadUniqueWeapon[ WP_M3 ] = qfalse; } if ( (weaponInventory & (1 << WP_M4) ) == (1 << WP_M4) ) { item = BG_FindItemForWeapon( WP_M4 ); Drop_Item( self, item, 0); + self->client->hadUniqueWeapon[ WP_M4 ] = qfalse; } if ( (weaponInventory & (1 << WP_MP5) ) == (1 << WP_MP5) ) { item = BG_FindItemForWeapon( WP_MP5 ); Drop_Item( self, item, 0); + self->client->hadUniqueWeapon[ WP_MP5 ] = qfalse; } if ( (weaponInventory & (1 << WP_HANDCANNON) ) == (1 << WP_HANDCANNON) ) { item = BG_FindItemForWeapon( WP_HANDCANNON ); Drop_Item( self, item, 0); + self->client->hadUniqueWeapon[ WP_HANDCANNON ] = qfalse; } if ( (weaponInventory & (1 << WP_SSG3000) ) == (1 << WP_SSG3000) ) { item = BG_FindItemForWeapon( WP_SSG3000 ); Drop_Item( self, item, 0); + self->client->hadUniqueWeapon[ WP_SSG3000 ] = qfalse; } //Elder: Always drop the pistol diff --git a/reaction/game/g_items.c b/reaction/game/g_items.c index f138f9e5..5a2d8dc7 100644 --- a/reaction/game/g_items.c +++ b/reaction/game/g_items.c @@ -388,8 +388,12 @@ int Pickup_Weapon (gentity_t *ent, gentity_t *other) { ammotoadd=30; break; } + //Elder: conditional added to "restore" weapons + if ( other->client->hadUniqueWeapon[ent->item->giTag] == qfalse || + !((ent->flags & FL_THROWN_ITEM) == FL_THROWN_ITEM) ) { + other->client->ps.ammo[ent->item->giTag]= ammotoadd; + } - other->client->ps.ammo[ent->item->giTag]= ammotoadd; // End Duffman @@ -899,6 +903,10 @@ gentity_t *LaunchItem( gitem_t *item, vec3_t origin, vec3_t velocity, int xr_fla dropped->physicsBounce= 0; } + //Elder: suspend thrown knives so it doesn't jitter + //if (item->giTag == WP_KNIFE) + //dropped->spawnflags |= 1; //suspended + trap_LinkEntity (dropped); return dropped; diff --git a/reaction/game/g_local.h b/reaction/game/g_local.h index 482dd873..cb57378d 100644 --- a/reaction/game/g_local.h +++ b/reaction/game/g_local.h @@ -60,7 +60,7 @@ typedef enum { #define SP_PODIUM_MODEL "models/mapobjects/podium/podium4.md3" -#define RQ3_RESPAWNTIME_DEFAULT 30000 // Elder: time for weapons to respawn +#define RQ3_RESPAWNTIME_DEFAULT 60000 // Elder: time for weapons to respawn - up to 60s #define SP_AUTOOPEN 128 // Elder: revert to Q3 behaviour #define SP_NODOORTOGGLE 256 // Elder: added to disable mover toggling @@ -354,7 +354,8 @@ struct gclient_s { // end Homer //Elder: prep for "ammo" in last gun - int lastGunAmmo[MAX_WEAPONS]; + //Only the server needs to know this + qboolean hadUniqueWeapon[MAX_WEAPONS]; #ifdef MISSIONPACK gentity_t *persistantPowerup;