/** * @brief Pick a weapon up. */ int Pickup_Weapon(gentity_t *ent, gentity_t *other) { int quantity; qboolean alreadyHave = qfalse; // magic ammo for any two-handed weapon if (ent->item->giTag == WP_AMMO) { AddMagicAmmo(other, ent->count); 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", (int)(ent->parent - g_entities), (int)(other - g_entities)); } } ent->parent->client->PCSpecialPickedUpCount++; G_AddSkillPoints(ent->parent, SK_SIGNALS, 1.f); G_DebugAddSkillPoints(ent->parent, SK_SIGNALS, 1.f, "ammo pack picked up"); #ifdef FEATURE_OMNIBOT //omni-bot event if (ent->parent) { Bot_Event_RecievedAmmo(other - g_entities, ent->parent); } #endif // extracted code originally here into AddMagicAmmo // add 1 clip of magic ammo for any two-handed weapon } return RESPAWN_NEVER; } } quantity = ent->count; // check if player already had the weapon alreadyHave = COM_BitCheck(other->client->ps.weapons, ent->item->giTag); // prevents drop/pickup weapon "quick reload" exploit if (alreadyHave) { Add_Ammo(other, ent->item->giTag, quantity, qfalse); // secondary weapon ammo if (ent->delay) { Add_Ammo(other, weaponTable[ent->item->giTag].weapAlts, ent->delay, qfalse); } } else { if (level.time - other->client->dropWeaponTime < 1000) { return 0; } // don't pick up when MG or mortar is set if (IS_MORTAR_WEAPON_SET(other->client->ps.weapon) || IS_MG_WEAPON_SET(other->client->ps.weapon)) { return 0; } // see if we can pick it up if (G_CanPickupWeapon(ent->item->giTag, other)) { weapon_t primaryWeapon; if (other->client->sess.playerType == PC_SOLDIER && other->client->sess.skill[SK_HEAVY_WEAPONS] >= 4) { primaryWeapon = G_GetPrimaryWeaponForClientSoldier(ent->item->giTag, other->client); } else { primaryWeapon = G_GetPrimaryWeaponForClient(other->client); } // added parens around ambiguous && 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); // fixup mauser/sniper issues switch (ent->item->giTag) { case WP_FG42: COM_BitSet(other->client->ps.weapons, WP_FG42SCOPE); break; case WP_GARAND: COM_BitSet(other->client->ps.weapons, WP_GARAND_SCOPE); break; case WP_K43: COM_BitSet(other->client->ps.weapons, WP_K43_SCOPE); break; case WP_MORTAR: COM_BitSet(other->client->ps.weapons, WP_MORTAR_SET); break; case WP_MORTAR2: COM_BitSet(other->client->ps.weapons, WP_MORTAR2_SET); break; case WP_MOBILE_MG42: COM_BitSet(other->client->ps.weapons, WP_MOBILE_MG42_SET); break; case WP_MOBILE_BROWNING: COM_BitSet(other->client->ps.weapons, WP_MOBILE_BROWNING_SET); break; case WP_CARBINE: COM_BitSet(other->client->ps.weapons, WP_M7); break; case WP_KAR98: COM_BitSet(other->client->ps.weapons, WP_GPG40); break; default: break; } 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 || ent->item->giTag == WP_MORTAR2) { other->client->ps.ammo[BG_FindClipForWeapon(ent->item->giTag)] = quantity; // secondary weapon ammo if (ent->delay) { Add_Ammo(other, weaponTable[ent->item->giTag].weapAlts, ent->delay, qfalse); } } else { other->client->ps.ammoclip[BG_FindClipForWeapon(ent->item->giTag)] = quantity; // secondary weapon ammo if (ent->delay) { other->client->ps.ammo[weaponTable[ent->item->giTag].weapAlts] = ent->delay; } } } } else { return 0; } } #ifdef FEATURE_OMNIBOT Bot_Event_AddWeapon(other->client->ps.clientNum, Bot_WeaponGameToBot(ent->item->giTag)); #endif return RESPAWN_NEVER; }
/** * @brief Pick a weapon up. * @param[in,out] ent * @param[in,out] other * @return */ int Pickup_Weapon(gentity_t *ent, gentity_t *other) { int quantity; qboolean alreadyHave = qfalse; // magic ammo for any two-handed weapon if (ent->item->giWeapon == WP_AMMO) { AddMagicAmmo(other, ent->count); if (ent->parent && ent->parent->client) { other->client->pers.lastammo_client = ent->parent->s.clientNum; } // if field ops isn't giving ammo to self or the enemy, give him some props if (ent->parent && (ent->parent->client != other->client)) { if (ent->parent && ent->parent->client && other->client->sess.sessionTeam == ent->parent->client->sess.sessionTeam) { G_AddSkillPoints(ent->parent, SK_SIGNALS, 1.f); G_DebugAddSkillPoints(ent->parent, SK_SIGNALS, 1.f, "ammo pack picked up"); #ifdef FEATURE_OMNIBOT //omni-bot event if (ent->parent) { Bot_Event_RecievedAmmo(other - g_entities, ent->parent); } #endif // extracted code originally here into AddMagicAmmo // add 1 clip of magic ammo for any two-handed weapon } return RESPAWN_NEVER; } } quantity = ent->count; // check if player already had the weapon alreadyHave = COM_BitCheck(other->client->ps.weapons, ent->item->giWeapon); // prevents drop/pickup weapon "quick reload" exploit if (alreadyHave) { Add_Ammo(other, ent->item->giWeapon, quantity, qfalse); // secondary weapon ammo if (ent->delay != 0.f) { Add_Ammo(other, GetWeaponTableData(ent->item->giWeapon)->weapAlts, ent->delay, qfalse); } } else { if (level.time - other->client->dropWeaponTime < 1000) { return 0; } // don't pick up when MG or mortar is set if (GetWeaponTableData(other->client->ps.weapon)->isSetWeapon) { return 0; } // see if we can pick it up if (G_CanPickupWeapon(ent->item->giWeapon, other)) { weapon_t primaryWeapon; if (other->client->sess.playerType == PC_SOLDIER && other->client->sess.skill[SK_HEAVY_WEAPONS] >= 4) { primaryWeapon = G_GetPrimaryWeaponForClientSoldier(ent->item->giWeapon, other->client); } else { primaryWeapon = G_GetPrimaryWeaponForClient(other->client); } // added parens around ambiguous && 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->giWeapon); // fixup mauser/sniper issues if (GetWeaponTableData(ent->item->giWeapon)->weapAlts != WP_NONE) { weapon_t weapAlts = GetWeaponTableData(ent->item->giWeapon)->weapAlts; if (GetWeaponTableData(weapAlts)->isRiflenade || GetWeaponTableData(weapAlts)->isScoped || GetWeaponTableData(weapAlts)->isSetWeapon) { COM_BitSet(other->client->ps.weapons, weapAlts); } } other->client->ps.ammoclip[GetWeaponTableData(ent->item->giWeapon)->clipIndex] = 0; other->client->ps.ammo[GetWeaponTableData(ent->item->giWeapon)->ammoIndex] = 0; if (GetWeaponTableData(ent->item->giWeapon)->isMortar) { other->client->ps.ammo[GetWeaponTableData(ent->item->giWeapon)->clipIndex] = quantity; // secondary weapon ammo if (ent->delay != 0.f) { Add_Ammo(other, GetWeaponTableData(ent->item->giWeapon)->weapAlts, ent->delay, qfalse); } } else { other->client->ps.ammoclip[GetWeaponTableData(ent->item->giWeapon)->clipIndex] = quantity; // secondary weapon ammo if (ent->delay != 0.f) { other->client->ps.ammo[GetWeaponTableData(ent->item->giWeapon)->weapAlts] = ent->delay; } } } } else { return 0; } } #ifdef FEATURE_OMNIBOT Bot_Event_AddWeapon(other->client->ps.clientNum, Bot_WeaponGameToBot(ent->item->giWeapon)); #endif return RESPAWN_NEVER; }