mirror of
https://github.com/nzp-team/quakec.git
synced 2024-11-22 03:41:15 +00:00
SERVER: Implement Weapon_PlayerHasWeaponWithFiretype
This commit is contained in:
parent
93ef51f665
commit
f0bbed099f
2 changed files with 22 additions and 4 deletions
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue