CSMultiplayerRules: When players die, they'll always drop their primary weapon if they have one. Thanks /alpha/

This commit is contained in:
Marco Cawthorne 2023-03-01 21:48:18 -08:00
parent 339a003583
commit 125550e4c3
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
2 changed files with 20 additions and 0 deletions

View File

@ -84,6 +84,9 @@ CSMultiplayerRules::PlayerDeath(NSClientPlayer pl)
if (targ.g_items & ITEM_C4BOMB) {
targ.activeweapon = WEAPON_C4BOMB;
Weapon_DropCurrentWeapon(targ);
} else {
targ.activeweapon = Cstrike_WeaponToDropUponDeath(targ);
Weapon_DropCurrentWeapon(targ);
}
/* clear all ammo and inventory... */

View File

@ -45,3 +45,20 @@ weapon_t g_weapons[] = {
w_smokegrenade,
w_c4bomb
};
int
Cstrike_WeaponToDropUponDeath(player pl)
{
int best_weapon = WEAPON_KNIFE; /* this will never drop, so an okay default */
for (int i = 0; i < g_weapons.length; i++) {
if (pl.g_items & g_weapons[i].id) {
if (g_weapons[i].slot == 0)
return i; /* immediately choose this primary weapon */
best_weapon = i;
}
}
return best_weapon;
}