/** * @brief Add ammo. * @return whether any ammo was added */ int Add_Ammo(gentity_t *ent, int weapon, int count, qboolean fillClip) { int ammoweap = BG_FindAmmoForWeapon(weapon); int maxammo = BG_MaxAmmoForWeapon(ammoweap, ent->client->sess.skill); int originalCount = ent->client->ps.ammo[ammoweap]; // FIXME: do a switch if (ammoweap == WP_GRENADE_LAUNCHER) // make sure if he picks up a grenade that he get's the "launcher" too { COM_BitSet(ent->client->ps.weapons, WP_GRENADE_LAUNCHER); fillClip = qtrue; // grenades always filter into the "clip" } else if (ammoweap == WP_GRENADE_PINEAPPLE) { COM_BitSet(ent->client->ps.weapons, WP_GRENADE_PINEAPPLE); fillClip = qtrue; // grenades always filter into the "clip" } else if (ammoweap == WP_DYNAMITE) { COM_BitSet(ent->client->ps.weapons, WP_DYNAMITE); fillClip = qtrue; } else if (ammoweap == WP_SATCHEL_DET) { COM_BitSet(ent->client->ps.weapons, WP_SATCHEL_DET); fillClip = qtrue; } if (fillClip) { Fill_Clip(&ent->client->ps, weapon); } if (ammoweap == WP_PANZERFAUST || ammoweap == WP_BAZOOKA || ammoweap == WP_FLAMETHROWER) { ent->client->ps.ammoclip[ammoweap] += count; if (ent->client->ps.ammoclip[ammoweap] > maxammo) { ent->client->ps.ammoclip[ammoweap] = maxammo; // - ent->client->ps.ammoclip[BG_FindClipForWeapon(weapon)]; } } else { ent->client->ps.ammo[ammoweap] += count; if (ent->client->ps.ammo[ammoweap] > maxammo) { ent->client->ps.ammo[ammoweap] = maxammo; // - ent->client->ps.ammoclip[BG_FindClipForWeapon(weapon)]; } } if (count >= 999) // 'really, give /all/' { ent->client->ps.ammo[ammoweap] = count; } return (ent->client->ps.ammo[ammoweap] > originalCount); }
void G_UpdateFireteamConfigString(fireteamData_t *ft) { char buffer[128]; int clnts[2] = { 0, 0 }; if (!ft->inuse) { Com_sprintf(buffer, 128, "\\id\\-1"); } else { int i; for (i = 0; i < MAX_CLIENTS; i++) { if (ft->joinOrder[i] != -1) { COM_BitSet(clnts, ft->joinOrder[i]); } } Com_sprintf(buffer, 128, "\\id\\%i\\l\\%i\\p\\%i\\c\\%.8x%.8x", ft->ident - 1, ft->joinOrder[0], ft->priv, clnts[1], clnts[0]); //G_Printf(va("%s\n", buffer)); } trap_SetConfigstring(CS_FIRETEAMS + (ft - level.fireTeams), buffer); }
qboolean AddWeaponToPlayer(gclient_t *client, weapon_t weapon, int ammo, int ammoclip, qboolean setcurrent) { COM_BitSet(client->ps.weapons, weapon); client->ps.ammoclip[BG_FindClipForWeapon(weapon)] = ammoclip; client->ps.ammo[BG_FindAmmoForWeapon(weapon)] = ammo; if (setcurrent) { client->ps.weapon = weapon; } return qtrue; }
//----(SA) modified void Add_Ammo( gentity_t *ent, int weapon, int count, qboolean fillClip ) { int ammoweap = BG_FindAmmoForWeapon( weapon ); int totalcount; ent->client->ps.ammo[ammoweap] += count; if ( ammoweap == WP_GRENADE_LAUNCHER ) { // make sure if he picks up a grenade that he get's the "launcher" too COM_BitSet( ent->client->ps.weapons, WP_GRENADE_LAUNCHER ); fillClip = qtrue; // grenades always filter into the "clip" } else if ( ammoweap == WP_GRENADE_PINEAPPLE ) { COM_BitSet( ent->client->ps.weapons, WP_GRENADE_PINEAPPLE ); fillClip = qtrue; // grenades always filter into the "clip" } else if ( ammoweap == WP_DYNAMITE || ammoweap == WP_DYNAMITE2 ) { COM_BitSet( ent->client->ps.weapons, WP_DYNAMITE ); fillClip = qtrue; } if ( fillClip ) { Fill_Clip( &ent->client->ps, weapon ); } // cap to max ammo if ( g_dmflags.integer & DF_NO_WEAPRELOAD ) { // no clips totalcount = ent->client->ps.ammo[ammoweap]; if ( totalcount > ammoTable[ammoweap].maxammo ) { ent->client->ps.ammo[ammoweap] = ammoTable[ammoweap].maxammo; } } else { // using clips totalcount = ent->client->ps.ammo[ammoweap] + ent->client->ps.ammoclip[BG_FindClipForWeapon( weapon )]; if ( totalcount > ammoTable[ammoweap].maxammo ) { ent->client->ps.ammo[ammoweap] = ammoTable[ammoweap].maxammo - ent->client->ps.ammoclip[BG_FindClipForWeapon( weapon )]; } } if ( count >= 999 ) { // 'really, give /all/' ent->client->ps.ammo[ammoweap] = count; } // JPW NERVE }
/** * @brief Add ammo. * @param ent * @param weapon * @param count * @param fillClip * @return whether any ammo was added */ int Add_Ammo(gentity_t *ent, weapon_t weapon, int count, qboolean fillClip) { weapon_t ammoweap = GetWeaponTableData(weapon)->ammoIndex; int maxammo = BG_MaxAmmoForWeapon(ammoweap, ent->client->sess.skill); int originalCount = ent->client->ps.ammo[ammoweap]; if (GetWeaponTableData(ammoweap)->isGrenade || ammoweap == WP_DYNAMITE || ammoweap == WP_SATCHEL_DET) // make sure if he picks it up that he get's the "launcher" too { COM_BitSet(ent->client->ps.weapons, ammoweap); fillClip = qtrue; // always filter into the "clip" } if (fillClip) { Fill_Clip(&ent->client->ps, weapon); } if (GetWeaponTableData(ammoweap)->isPanzer || ammoweap == WP_FLAMETHROWER) { ent->client->ps.ammoclip[ammoweap] += count; if (ent->client->ps.ammoclip[ammoweap] > maxammo) { ent->client->ps.ammoclip[ammoweap] = maxammo; // - ent->client->ps.ammoclip[BG_FindClipForWeapon(weapon)]; } } else { ent->client->ps.ammo[ammoweap] += count; if (ent->client->ps.ammo[ammoweap] > maxammo) { ent->client->ps.ammo[ammoweap] = maxammo; // - ent->client->ps.ammoclip[BG_FindClipForWeapon(weapon)]; } } if (count >= 999) // 'really, give /all/' { ent->client->ps.ammo[ammoweap] = count; } return (ent->client->ps.ammo[ammoweap] > originalCount); }
int Pickup_Weapon( gentity_t *ent, gentity_t *other ) { int quantity; qboolean alreadyHave = qfalse; int i,weapon; // JPW NERVE // JPW NERVE -- magic ammo for any two-handed weapon if ( ent->item->giTag == WP_AMMO ) { // 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_LT ) { if ( ent->parent ) { if ( other->client->sess.sessionTeam == ent->parent->client->sess.sessionTeam ) { if ( ent->parent->client ) { if ( !( ent->parent->client->PCSpecialPickedUpCount % LT_SPECIAL_PICKUP_MOD ) ) { AddScore( ent->parent, WOLF_AMMO_UP ); } ent->parent->client->PCSpecialPickedUpCount++; } } } } // everybody likes grenades -- abuse weapon var as grenade type and i as max # grenades class can carry switch ( other->client->ps.stats[STAT_PLAYER_CLASS] ) { case PC_LT: // redundant but added for completeness/flexibility case PC_MEDIC: i = 1; break; case PC_SOLDIER: i = 4; break; case PC_ENGINEER: i = 8; break; default: i = 1; break; } if ( other->client->sess.sessionTeam == TEAM_RED ) { weapon = WP_GRENADE_LAUNCHER; } else { weapon = WP_GRENADE_PINEAPPLE; } if ( other->client->ps.ammoclip[BG_FindClipForWeapon( weapon )] < i ) { other->client->ps.ammoclip[BG_FindClipForWeapon( weapon )]++; } COM_BitSet( other->client->ps.weapons,weapon ); // TTimo - add 8 pistol bullets if ( other->client->sess.sessionTeam == TEAM_RED ) { weapon = WP_LUGER; } else { weapon = WP_COLT; } // G_Printf("filling magazine for weapon %d colt/luger (%d rounds)\n", weapon, ammoTable[weapon].maxclip); other->client->ps.ammo[BG_FindAmmoForWeapon( weapon )] += ammoTable[weapon].maxclip; if ( other->client->ps.ammo[BG_FindAmmoForWeapon( weapon )] > ammoTable[weapon].maxclip * 4 ) { other->client->ps.ammo[BG_FindAmmoForWeapon( weapon )] = ammoTable[weapon].maxclip * 4; } // and some two-handed ammo for ( i = 0; i < MAX_WEAPS_IN_BANK_MP; i++ ) { weapon = weapBanksMultiPlayer[3][i]; if ( COM_BitCheck( other->client->ps.weapons, weapon ) ) { // G_Printf("filling magazine for weapon %d (%d rounds)\n",weapon,ammoTable[weapon].maxclip); if ( weapon == WP_FLAMETHROWER ) { // FT doesn't use magazines so refill tank other->client->ps.ammoclip[BG_FindAmmoForWeapon( WP_FLAMETHROWER )] = ammoTable[weapon].maxclip; } else { other->client->ps.ammo[BG_FindAmmoForWeapon( weapon )] += ammoTable[weapon].maxclip; if ( other->client->ps.ammo[BG_FindAmmoForWeapon( weapon )] > ammoTable[weapon].maxclip * 3 ) { other->client->ps.ammo[BG_FindAmmoForWeapon( weapon )] = ammoTable[weapon].maxclip * 3; } } return RESPAWN_SP; } } return RESPAWN_SP; } // jpw if ( ent->count < 0 ) { quantity = 0; // None for you, sir! } else { if ( ent->count ) { quantity = ent->count; } else { //----(SA) modified // JPW NERVE did this so ammocounts work right on dropped weapons if ( g_gametype.integer != GT_SINGLE_PLAYER ) { quantity = ent->item->quantity; } else { // jpw quantity = ( random() * ( ent->item->quantity - 1 ) ) + 1; // giving 1-<item default count> } } } // check if player already had the weapon alreadyHave = COM_BitCheck( other->client->ps.weapons, ent->item->giTag ); // add the weapon COM_BitSet( other->client->ps.weapons, ent->item->giTag ); // DHM - Fixup mauser/sniper issues if ( ent->item->giTag == WP_MAUSER ) { COM_BitSet( other->client->ps.weapons, WP_SNIPERRIFLE ); } if ( ent->item->giTag == WP_SNIPERRIFLE ) { COM_BitSet( other->client->ps.weapons, WP_MAUSER ); } //----(SA) added // snooper == automatic garand mod if ( ent->item->giTag == WP_SNOOPERSCOPE ) { COM_BitSet( other->client->ps.weapons, WP_GARAND ); } // fg42scope == automatic fg42 mod else if ( ent->item->giTag == WP_FG42SCOPE ) { COM_BitSet( other->client->ps.weapons, WP_FG42 ); } else if ( ent->item->giTag == WP_GARAND ) { COM_BitSet( other->client->ps.weapons, WP_SNOOPERSCOPE ); } //----(SA) end // JPW NERVE prevents drop/pickup weapon "quick reload" exploit if ( alreadyHave ) { Add_Ammo( other, ent->item->giTag, quantity, !alreadyHave ); } else { other->client->ps.ammoclip[BG_FindClipForWeapon( ent->item->giTag )] = quantity; } // jpw // single player has no respawns (SA) if ( g_gametype.integer == GT_SINGLE_PLAYER ) { return RESPAWN_SP; } if ( g_gametype.integer == GT_TEAM ) { return g_weaponTeamRespawn.integer; } return g_weaponRespawn.integer; }
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 ); 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; } } return -1; }
/* ================ Bot_ScriptInitBot ================ */ qboolean Bot_ScriptInitBot(int entnum) { gentity_t *ent, *trav; bot_state_t *bs; char userinfo[MAX_INFO_STRING]; bot_script_global_data_t *bsgd; char *token, *p, *pBackup; int i, val = 0; int weapons[2]; gitem_t *item = NULL; char *name; // bs = &botstates[entnum]; if(!bs->inuse) { return qfalse; } if(bs->script.data) { return qtrue; } // set starting defaults bs->script.status.eventIndex = -1; bs->script.data = NULL; // ent = BotGetEntity(bs->entitynum); trap_GetUserinfo(bs->entitynum, userinfo, sizeof(userinfo)); name = Info_ValueForKey(userinfo, "scriptName"); if(!name || !name[0]) { return qfalse; } // find the script data for this bot bsgd = botCharacterScriptData; for(i = 0; i < numScriptCharacters; i++, bsgd++) { if(Q_stricmp(name, bsgd->name) != 0) { continue; } // check params p = bsgd->params; // // eliminate them with each condition not met while(qtrue) { token = COM_ParseExt(&p, qfalse); if(!token || !token[0]) { // we're done, we found a match break; } // if(token[0] != '/') { G_Error("BotScript, line %i: condition identifier expected, '%s' found\n", bsgd->lineNum, token); } // if(!Q_stricmp(token, "/team")) { token = COM_ParseExt(&p, qfalse); if(!token || !token[0] || token[0] == '/') { G_Error("BotScript, line %i: unexpected end of /team parameter", bsgd->lineNum); } // if(!Q_stricmp(token, "axis")) { val = TEAM_AXIS; } else if(!Q_stricmp(token, "allies")) { val = TEAM_ALLIES; } else { G_Error("BotScript, line %i: unknown team \"%s\"", bsgd->lineNum, token); } // eliminate player if(bs->mpTeam != val) { break; } } else // if(!Q_stricmp(token, "/class")) { token = COM_ParseExt(&p, qfalse); if(!token || !token[0] || token[0] == '/') { G_Error("BotScript, line %i: unexpected end of /class parameter", bsgd->lineNum); } // val = Team_ClassForString(token); if(val < 0) { G_Error("BotScript, line %i: unknown class \"%s\"", bsgd->lineNum, token); } if(bs->mpClass != val) { break; } } else // if(!Q_stricmp(token, "/weapon")) { memset(weapons, 0, sizeof(weapons)); // for each weapon while(qtrue) { // read the weapon token = COM_ParseExt(&p, qfalse); if(!token || !token[0] || token[0] == '/') { G_Error("BotScript, line %i: unexpected end of /weapon parameter", bsgd->lineNum); } // if((item = BG_FindItem(token))) { if(!item->giTag) { G_Error("BotScript, line %i: unknown weapon \"%s\"", bsgd->lineNum, token); } COM_BitSet(weapons, item->giTag); } else { G_Error("BotScript, line %i: unknown weapon \"%s\"", bsgd->lineNum, token); } // pBackup = p; token = COM_ParseExt(&p, qfalse); if(Q_stricmp(token, "or") != 0) { // not OR, so drop out of here p = pBackup; break; } } if(!(ent->client->ps.weapons[0] & weapons[0]) && !(ent->client->ps.weapons[1] & weapons[1])) { break; } } else // if(!Q_stricmp(token, "/within_range")) { // targetname token = COM_ParseExt(&p, qfalse); if(!token || !token[0] || token[0] == '/') { G_Error("BotScript, line %i: unexpected end of /within_range parameter", bsgd->lineNum); } trav = G_FindByTargetname(NULL, token); if(!trav) { G_Error("BotScript, line %i: unknown spawn point \"%s\"", bsgd->lineNum, token); } // range token = COM_ParseExt(&p, qfalse); if(!token || !token[0] || token[0] == '/') { G_Error("BotScript, line %i: range expected, not found", bsgd->lineNum); } // // eliminate players if(VectorDistanceSquared(ent->r.currentOrigin, trav->s.origin) > SQR(atof(token))) { break; } } } // // if there is a NOT a valid token waiting, then we passed all checks if(!token[0]) { break; } } // if(i < numScriptCharacters) { // we found a script for this character bs->script.data = bsgd->data; return qtrue; } // return qfalse; }
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; }
/** * @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; }