SERVER: Implement Weapon_PlayerHasWeaponWithFiretype

This commit is contained in:
cypress 2024-01-08 14:03:35 -05:00
parent 93ef51f665
commit f0bbed099f
2 changed files with 22 additions and 4 deletions

View file

@ -527,10 +527,9 @@ void() PlayerPreThink =
self.onfire = false;
}
// refuel/cool flamethrowers
// Flamethrower-based weapon cooldown/refuel process.
if (self.ltime < time) {
// FIXME: Weapon hardcode definition.
float weapon_slot = Weapon_PlayerHasWeapon(self, W_M2, true);
float weapon_slot = Weapon_PlayerHasWeaponWithFiretype(self, FIRETYPE_FLAME);
if (weapon_slot == 0)
return;

View file

@ -80,7 +80,7 @@ void(entity person, float slot, float ammo) Weapon_SetPlayerAmmoInSlot =
};
//
// Weapon_PlayerHasWeapon(peron, comparison, include_pap)
// Weapon_PlayerHasWeapon(person, comparison, include_pap)
// Checks to see if the Player is holding a weapon in any
// of their three slots. `include_pap` dictates whether to
// consider Pack-A-Punch'd varients. Returns 1, 2, 3 depending
@ -107,6 +107,25 @@ float(entity person, float comparison, float include_pap) Weapon_PlayerHasWeapon
return 0;
};
//
// Weapon_PlayerHasWeaponWithFiretype(person, comparison)
// Similar check to Weapon_PlayerHasWeapon, but returns
// an index to the first-found firetype instead.
//
float(entity person, float comparison) Weapon_PlayerHasWeaponWithFiretype =
{
for (float i = 0; i < MAX_PLAYER_WEAPONS; i++) {
// Storage.
float weapon_firetype = GetFiretype(person.weapons[i].weapon_id);
// Now do the comparison
if (weapon_firetype == comparison)
return i + 1;
}
return 0;
};
//
// Weapon_IsSemiAutomatic(float weapon)
// Checks weapon firetypes and returns true if intended