/** * @brief Drop weapon. */ void G_DropWeapon(gentity_t *ent, weapon_t weapon) { vec3_t angles, velocity, org, offset, mins, maxs; gclient_t *client = ent->client; gentity_t *ent2; gitem_t *item; trace_t tr; if (!IS_VALID_WEAPON(weapon)) { return; } item = BG_FindItemForWeapon(weapon); VectorCopy(client->ps.viewangles, angles); // clamp pitch if (angles[PITCH] < -30) { angles[PITCH] = -30; } else if (angles[PITCH] > 30) { angles[PITCH] = 30; } AngleVectors(angles, velocity, NULL, NULL); VectorScale(velocity, 64, offset); offset[2] += client->ps.viewheight / 2.f; VectorScale(velocity, 75, velocity); velocity[2] += 50 + random() * 35; VectorAdd(client->ps.origin, offset, org); VectorSet(mins, -ITEM_RADIUS, -ITEM_RADIUS, 0); VectorSet(maxs, ITEM_RADIUS, ITEM_RADIUS, 2 * ITEM_RADIUS); trap_Trace(&tr, client->ps.origin, mins, maxs, org, ent->s.number, MASK_SOLID); VectorCopy(tr.endpos, org); ent2 = LaunchItem(item, org, velocity, client->ps.clientNum); COM_BitClear(client->ps.weapons, weapon); switch (weapon) { case WP_KAR98: COM_BitClear(client->ps.weapons, WP_GPG40); break; case WP_CARBINE: COM_BitClear(client->ps.weapons, WP_M7); break; case WP_FG42: COM_BitClear(client->ps.weapons, WP_FG42SCOPE); break; case WP_K43: COM_BitClear(client->ps.weapons, WP_K43_SCOPE); break; case WP_GARAND: COM_BitClear(client->ps.weapons, WP_GARAND_SCOPE); break; case WP_MORTAR: COM_BitClear(client->ps.weapons, WP_MORTAR_SET); break; case WP_MORTAR2: COM_BitClear(client->ps.weapons, WP_MORTAR2_SET); break; case WP_MOBILE_MG42: COM_BitClear(client->ps.weapons, WP_MOBILE_MG42_SET); break; case WP_MOBILE_BROWNING: COM_BitClear(client->ps.weapons, WP_MOBILE_BROWNING_SET); break; default: break; } // Clear out empty weapon, change to next best weapon G_AddEvent(ent, EV_WEAPONSWITCHED, 0); if (weapon == client->ps.weapon) { client->ps.weapon = 0; } if (IS_MORTAR_WEAPON_SET(weapon)) { ent2->count = client->ps.ammo[BG_FindAmmoForWeapon(weapon)] + client->ps.ammoclip[BG_FindClipForWeapon(weapon)]; } else { ent2->count = client->ps.ammoclip[BG_FindClipForWeapon(weapon)]; } if (weapon == WP_KAR98 || weapon == WP_CARBINE) { ent2->delay = client->ps.ammo[BG_FindAmmoForWeapon(weaponTable[weapon].weapAlts)]; } else { ent2->delay = 0; } // ent2->item->quantity = client->ps.ammoclip[BG_FindClipForWeapon(weapon)]; // um, modifying an item is not a good idea client->ps.ammoclip[BG_FindClipForWeapon(weapon)] = 0; #ifdef FEATURE_OMNIBOT Bot_Event_RemoveWeapon(client->ps.clientNum, Bot_WeaponGameToBot(weapon)); #endif }
void G_DropWeapon( gentity_t *ent, weapon_t weapon ) { vec3_t angles, velocity, org, offset, mins, maxs; gclient_t *client = ent->client; gentity_t *ent2; gitem_t *item; trace_t tr; item = BG_FindItemForWeapon( weapon ); VectorCopy( client->ps.viewangles, angles ); // clamp pitch if ( angles[PITCH] < -30 ) angles[PITCH] = -30; else if ( angles[PITCH] > 30 ) angles[PITCH] = 30; AngleVectors( angles, velocity, NULL, NULL ); VectorScale( velocity, 64, offset ); offset[2] += client->ps.viewheight / 2.f; VectorScale( velocity, 75, velocity ); velocity[2] += 50 + random() * 35; VectorAdd( client->ps.origin, offset, org ); VectorSet( mins, -ITEM_RADIUS, -ITEM_RADIUS, 0 ); VectorSet( maxs, ITEM_RADIUS, ITEM_RADIUS, 2*ITEM_RADIUS ); trap_Trace( &tr, client->ps.origin, mins, maxs, org, ent->s.number, MASK_SOLID ); VectorCopy( tr.endpos, org ); ent2 = LaunchItem( item, org, velocity, client->ps.clientNum ); COM_BitClear( client->ps.weapons, weapon ); if( weapon == WP_KAR98 ) { COM_BitClear( client->ps.weapons, WP_GPG40 ); } else if ( weapon == WP_CARBINE ) { COM_BitClear( client->ps.weapons, WP_M7 ); } else if ( weapon == WP_FG42 ) { COM_BitClear( client->ps.weapons, WP_FG42SCOPE ); } else if( weapon == WP_K43 ) { COM_BitClear( client->ps.weapons, WP_K43_SCOPE ); } else if( weapon == WP_GARAND ) { COM_BitClear( client->ps.weapons, WP_GARAND_SCOPE ); } else if( weapon == WP_MORTAR ) { COM_BitClear( client->ps.weapons, WP_MORTAR_SET ); } else if( weapon == WP_MOBILE_MG42 ) { COM_BitClear( client->ps.weapons, WP_MOBILE_MG42_SET ); } if( weapon == WP_GPG40 ) { // etace COM_BitClear( client->ps.weapons, WP_KAR98 ); } else if ( weapon == WP_M7 ) { COM_BitClear( client->ps.weapons, WP_CARBINE ); } else if ( weapon == WP_FG42SCOPE ) { COM_BitClear( client->ps.weapons, WP_FG42 ); } else if( weapon == WP_K43_SCOPE ) { COM_BitClear( client->ps.weapons, WP_K43 ); } else if( weapon == WP_GARAND_SCOPE ) { COM_BitClear( client->ps.weapons, WP_GARAND ); } else if( weapon == WP_MORTAR_SET ) { COM_BitClear( client->ps.weapons, WP_MORTAR ); } else if( weapon == WP_MOBILE_MG42_SET ) { COM_BitClear( client->ps.weapons, WP_MOBILE_MG42 ); } // Clear out empty weapon, change to next best weapon G_AddEvent( ent, EV_WEAPONSWITCHED, 1 ); if( weapon == client->ps.weapon ) client->ps.weapon = 0; if( weapon == WP_MORTAR ) { ent2->count = client->ps.ammo[BG_FindAmmoForWeapon(weapon)] + client->ps.ammoclip[BG_FindClipForWeapon(weapon)]; /* quad: maybe make a g_weapons flag for this?!? } else if (weapon == WP_MP40 || weapon == WP_THOMPSON) { // redeye - NQ style weapon switching with full ammo ent2->count = client->ps.ammo[BG_FindAmmoForWeapon(weapon)] + client->ps.ammoclip[BG_FindClipForWeapon(weapon)]; */ } else { ent2->count = client->ps.ammoclip[BG_FindClipForWeapon(weapon)]; } if( weapon == WP_KAR98 || weapon == WP_CARBINE ) { ent2->delay = client->ps.ammo[BG_FindAmmoForWeapon(weapAlts[weapon])]; } else { ent2->delay = 0; } // ent2->item->quantity = client->ps.ammoclip[BG_FindClipForWeapon(weapon)]; // Gordon: um, modifying an item is not a good idea client->ps.ammoclip[BG_FindClipForWeapon(weapon)] = 0; Bot_Event_RemoveWeapon(client->ps.clientNum, Bot_WeaponGameToBot(weapon)); }
/** * @brief Drop Weapon * @param[in] ent * @param[in] weapon */ void G_DropWeapon(gentity_t *ent, weapon_t weapon) { vec3_t angles, velocity, org, offset, mins, maxs; gclient_t *client = ent->client; gentity_t *ent2; gitem_t *item; trace_t tr; if (!IS_VALID_WEAPON(weapon)) { return; } item = BG_FindItemForWeapon(weapon); VectorCopy(client->ps.viewangles, angles); // clamp pitch if (angles[PITCH] < -30) { angles[PITCH] = -30; } else if (angles[PITCH] > 30) { angles[PITCH] = 30; } AngleVectors(angles, velocity, NULL, NULL); VectorScale(velocity, 64, offset); offset[2] += client->ps.viewheight / 2.f; VectorScale(velocity, 75, velocity); velocity[2] += 50 + random() * 35; VectorAdd(client->ps.origin, offset, org); VectorSet(mins, -ITEM_RADIUS, -ITEM_RADIUS, 0); VectorSet(maxs, ITEM_RADIUS, ITEM_RADIUS, 2 * ITEM_RADIUS); trap_Trace(&tr, client->ps.origin, mins, maxs, org, ent->s.number, MASK_SOLID); VectorCopy(tr.endpos, org); ent2 = LaunchItem(item, org, velocity, client->ps.clientNum); COM_BitClear(client->ps.weapons, weapon); if (GetWeaponTableData(weapon)->weapAlts != WP_NONE) { weapon_t weapAlts = GetWeaponTableData(weapon)->weapAlts; if (GetWeaponTableData(weapAlts)->isRiflenade || GetWeaponTableData(weapAlts)->isScoped || GetWeaponTableData(weapAlts)->isSetWeapon) { COM_BitClear(client->ps.weapons, weapAlts); } } // Clear out empty weapon, change to next best weapon G_AddEvent(ent, EV_WEAPONSWITCHED, 0); if (weapon == client->ps.weapon) { client->ps.weapon = 0; } if (GetWeaponTableData(weapon)->isMortarSet) { ent2->count = client->ps.ammo[GetWeaponTableData(weapon)->ammoIndex] + client->ps.ammoclip[GetWeaponTableData(weapon)->clipIndex]; } else { ent2->count = client->ps.ammoclip[GetWeaponTableData(weapon)->clipIndex]; } if (weapon == WP_KAR98 || weapon == WP_CARBINE) { ent2->delay = client->ps.ammo[GetWeaponTableData(GetWeaponTableData(weapon)->weapAlts)->ammoIndex]; } else { ent2->delay = 0; } // ent2->item->quantity = client->ps.ammoclip[BG_FindClipForWeapon(weapon)]; // um, modifying an item is not a good idea client->ps.ammoclip[GetWeaponTableData(weapon)->clipIndex] = 0; #ifdef FEATURE_OMNIBOT Bot_Event_RemoveWeapon(client->ps.clientNum, Bot_WeaponGameToBot(weapon)); #endif }