int Pickup_Weapon( gentity_t *ent, gentity_t *other ) { int quantity; qboolean alreadyHave = qfalse; // JPW NERVE -- magic ammo for any two-handed weapon if( ent->item->giTag == WP_AMMO ) { AddMagicAmmo( other, ent->count ); // if LT isn't giving ammo to self or another LT or the enemy, give him some props if( other->client->ps.stats[STAT_PLAYER_CLASS] != PC_FIELDOPS ) { if ( ent->parent && ent->parent->client && other->client->sess.sessionTeam == ent->parent->client->sess.sessionTeam ) { if (!(ent->parent->client->PCSpecialPickedUpCount % LT_SPECIAL_PICKUP_MOD)) { AddScore(ent->parent, WOLF_AMMO_UP); if(ent->parent && ent->parent->client) { G_LogPrintf("Ammo_Pack: %d %d\n", ent->parent - g_entities, other - g_entities); // OSP } } ent->parent->client->PCSpecialPickedUpCount++; G_AddSkillPoints( ent->parent, SK_SIGNALS, 1.f ); G_DebugAddSkillPoints( ent->parent, SK_SIGNALS, 1.f, "ammo pack picked up" ); // extracted code originally here into AddMagicAmmo -xkan, 9/18/2002 // add 1 clip of magic ammo for any two-handed weapon } return RESPAWN_SP; } } quantity = ent->count; // check if player already had the weapon alreadyHave = COM_BitCheck( other->client->ps.weapons, ent->item->giTag ); // JPW NERVE prevents drop/pickup weapon "quick reload" exploit if( alreadyHave ) { Add_Ammo( other, ent->item->giTag, quantity, qfalse ); // Gordon: secondary weapon ammo if( ent->delay ) { Add_Ammo( other, weapAlts[ ent->item->giTag ], ent->delay, qfalse ); } } else { if( level.time - other->client->dropWeaponTime < 1000 ) { return 0; } if( other->client->ps.weapon == WP_MORTAR_SET || other->client->ps.weapon == WP_MOBILE_MG42_SET ) { return 0; } // See if we can pick it up if( G_CanPickupWeapon( ent->item->giTag, other ) ) { weapon_t primaryWeapon = G_GetPrimaryWeaponForClient( other->client ); // rain - added parens around ambiguous && if( primaryWeapon || (other->client->sess.playerType == PC_SOLDIER && other->client->sess.skill[SK_HEAVY_WEAPONS] >= 4) ) { if( primaryWeapon ) { // drop our primary weapon G_DropWeapon( other, primaryWeapon ); } // now pickup the other one other->client->dropWeaponTime = level.time; // add the weapon COM_BitSet( other->client->ps.weapons, ent->item->giTag ); // DHM - Fixup mauser/sniper issues if( ent->item->giTag == WP_FG42 ) { COM_BitSet( other->client->ps.weapons, WP_FG42SCOPE); } else if(ent->item->giTag == WP_GARAND) { COM_BitSet( other->client->ps.weapons, WP_GARAND_SCOPE); } else if( ent->item->giTag == WP_K43 ) { COM_BitSet( other->client->ps.weapons, WP_K43_SCOPE ); } else if( ent->item->giTag == WP_MORTAR ) { COM_BitSet( other->client->ps.weapons, WP_MORTAR_SET ); } else if( ent->item->giTag == WP_MOBILE_MG42 ) { COM_BitSet( other->client->ps.weapons, WP_MOBILE_MG42_SET ); } else if( ent->item->giTag == WP_CARBINE ) { COM_BitSet( other->client->ps.weapons, WP_M7 ); } else if( ent->item->giTag == WP_KAR98 ) { COM_BitSet( other->client->ps.weapons, WP_GPG40 ); } other->client->ps.ammoclip[BG_FindClipForWeapon(ent->item->giTag)] = 0; other->client->ps.ammo[BG_FindAmmoForWeapon(ent->item->giTag)] = 0; if( ent->item->giTag == WP_MORTAR ) { other->client->ps.ammo[BG_FindClipForWeapon(ent->item->giTag)] = quantity; // Gordon: secondary weapon ammo if( ent->delay ) { Add_Ammo( other, weapAlts[ ent->item->giTag ], ent->delay, qfalse ); } } else { other->client->ps.ammoclip[BG_FindClipForWeapon(ent->item->giTag)] = quantity; // Gordon: secondary weapon ammo if( ent->delay ) { other->client->ps.ammo[ weapAlts[ ent->item->giTag ] ] = ent->delay; } } } } else { return 0; } } // TAT 1/6/2003 - If we are a bot, call the pickup function if( other->r.svFlags & SVF_BOT ) BotPickupWeapon( other->s.number, ent->item->giTag, alreadyHave ); return -1; }
int Pickup_Weapon( gentity_t *ent, gentity_t *other ) { int quantity; qboolean alreadyHave = qfalse; // JPW NERVE -- magic ammo for any two-handed weapon if( ent->item->giTag == WP_AMMO ) { AddMagicAmmo( other, ent->count ); // tjw: added for g_shortcuts if(ent->parent && ent->parent->client) other->client->pers.lastammo_client = ent->parent->s.clientNum; // if LT isn't giving ammo to self or another LT or the enemy, give him some props if( other->client->ps.stats[STAT_PLAYER_CLASS] != PC_FIELDOPS ) { if ( ent->parent && ent->parent->client && other->client->sess.sessionTeam == ent->parent->client->sess.sessionTeam ) { if (!(ent->parent->client->PCSpecialPickedUpCount % LT_SPECIAL_PICKUP_MOD)) { AddScore(ent->parent, WOLF_AMMO_UP); if(ent->parent && ent->parent->client) { G_LogPrintf("Ammo_Pack: %d %d\n", ent->parent - g_entities, other - g_entities); // OSP } } ent->parent->client->PCSpecialPickedUpCount++; // forty - #474 - don't give xp if we're picking up our own ammo packs. if(other != ent->parent) { G_AddSkillPoints( ent->parent, SK_SIGNALS, 1.f ); G_DebugAddSkillPoints( ent->parent, SK_SIGNALS, 1.f, "ammo pack picked up" ); } //omni-bot event if ( ent->parent ) Bot_Event_RecievedAmmo(other-g_entities, ent->parent); // extracted code originally here into AddMagicAmmo -xkan, 9/18/2002 // add 1 clip of magic ammo for any two-handed weapon } return RESPAWN_SP; } } if( ent->item->giTag == WP_BINOCULARS && (g_weapons.integer & WPF_DROP_BINOCS) ) { COM_BitSet( other->client->ps.weapons, WP_BINOCULARS ); other->client->ps.ammo[BG_FindAmmoForWeapon(WP_BINOCULARS)] = 1; other->client->ps.stats[STAT_KEYS] |= ( 1 << INV_BINOCS ); other->client->sess.numBinocs++; } quantity = ent->count; // check if player already had the weapon alreadyHave = COM_BitCheck( other->client->ps.weapons, ent->item->giTag ); // JPW NERVE prevents drop/pickup weapon "quick reload" exploit if( alreadyHave ) { Add_Ammo( other, ent->item->giTag, quantity, qfalse ); // Gordon: secondary weapon ammo if( ent->delay ) { Add_Ammo( other, weapAlts[ ent->item->giTag ], ent->delay, qfalse ); } } else { if( level.time - other->client->dropWeaponTime < 1000 ) { return 0; } if( other->client->ps.weapon == WP_MORTAR_SET || other->client->ps.weapon == WP_MOBILE_MG42_SET ) { return 0; } // See if we can pick it up if( G_CanPickupWeapon( ent->item->giTag, other ) ) { weapon_t primaryWeapon = G_GetPrimaryWeaponForClient( other->client ); // rain - added parens around ambiguous && if( 1 || // Terifire, for dropweapon (other->client->sess.playerType == PC_SOLDIER && other->client->sess.skill[SK_HEAVY_WEAPONS] >= 4) ) { // gabriel: If a lvl 4 soldier is picking un a mp40/thompson, // don't allow the soldier to have both an mp40 and a thompson if ((ent->item->giTag == WP_MP40) && COM_BitCheck( other->client->ps.weapons, WP_THOMPSON)) { G_DropWeapon( other, WP_THOMPSON); } else if ((ent->item->giTag == WP_THOMPSON) && COM_BitCheck( other->client->ps.weapons, WP_MP40)) { G_DropWeapon( other, WP_MP40); } else if( primaryWeapon ) { // Otherwise, function normally // drop our primary weapon G_DropWeapon( other, primaryWeapon ); } // now pickup the other one other->client->dropWeaponTime = level.time; // add the weapon COM_BitSet( other->client->ps.weapons, ent->item->giTag ); // DHM - Fixup mauser/sniper issues if( ent->item->giTag == WP_FG42 ) { COM_BitSet( other->client->ps.weapons, WP_FG42SCOPE); } else if(ent->item->giTag == WP_GARAND) { COM_BitSet( other->client->ps.weapons, WP_GARAND_SCOPE); } else if( ent->item->giTag == WP_K43 ) { COM_BitSet( other->client->ps.weapons, WP_K43_SCOPE ); } else if( ent->item->giTag == WP_MORTAR ) { COM_BitSet( other->client->ps.weapons, WP_MORTAR_SET ); } else if( ent->item->giTag == WP_MOBILE_MG42 ) { COM_BitSet( other->client->ps.weapons, WP_MOBILE_MG42_SET ); } else if( ent->item->giTag == WP_CARBINE ) { COM_BitSet( other->client->ps.weapons, WP_M7 ); } else if( ent->item->giTag == WP_KAR98 ) { COM_BitSet( other->client->ps.weapons, WP_GPG40 ); } other->client->ps.ammoclip[BG_FindClipForWeapon(ent->item->giTag)] = 0; other->client->ps.ammo[BG_FindAmmoForWeapon(ent->item->giTag)] = 0; if( ent->item->giTag == WP_MORTAR ) { other->client->ps.ammo[BG_FindClipForWeapon(ent->item->giTag)] = quantity; // Gordon: secondary weapon ammo if( ent->delay ) { Add_Ammo( other, weapAlts[ ent->item->giTag ], ent->delay, qfalse ); } /* quad: maybe make a g_weapons flag for this? } else if ((ent->item->giTag == WP_THOMPSON || ent->item->giTag == WP_MP40)) { // TODO: ???? (quad) // redeye - NQ style weapon switching with full ammo // note: I wrote this code before source of NQ was available, so this is less // good than NQ's implementation but still better than original ETPub int weap = BG_FindClipForWeapon(ent->item->giTag); int ammoweap = BG_FindAmmoForWeapon(ent->item->giTag); int max_ammo_per_clip = GetAmmoTableData(ammoweap)->maxclip; int ammo_in_clips = quantity - max_ammo_per_clip; if (quantity <= max_ammo_per_clip) { other->client->ps.ammoclip[weap] = quantity; other->client->ps.ammo[weap] = 0; } else { other->client->ps.ammoclip[weap] = max_ammo_per_clip; other->client->ps.ammo[weap] = ammo_in_clips; } */ } else { other->client->ps.ammoclip[BG_FindClipForWeapon(ent->item->giTag)] = quantity; // Gordon: secondary weapon ammo if( ent->delay ) { other->client->ps.ammo[ weapAlts[ ent->item->giTag ] ] = ent->delay; } } } } else { return 0; } } // TAT 1/6/2003 - If we are a bot, call the pickup function #ifndef NO_BOT_SUPPORT if( other->r.svFlags & SVF_BOT ) BotPickupWeapon( other->s.number, ent->item->giTag, alreadyHave ); #endif Bot_Event_AddWeapon(other->client->ps.clientNum, Bot_WeaponGameToBot(ent->item->giTag)); return -1; }