mirror of
https://github.com/nzp-team/quakec.git
synced 2024-11-22 11:51:11 +00:00
Server: Streamline weapon projectile determination
Use new #defines for firetypes and a new utility function Util_WeaponIsSemiAutomatic to make W_Fire far more legible in the section where firing a projectile or trace is done.
This commit is contained in:
parent
5086304b51
commit
1f64c0239a
2 changed files with 41 additions and 24 deletions
|
@ -646,6 +646,23 @@ float(entity person, float comparison, float include_pap) Util_PlayerHasWeapon =
|
|||
return 0;
|
||||
};
|
||||
|
||||
//
|
||||
// Util_WeaponIsSemiAutomatic(float weapon)
|
||||
// Checks weapon firetypes and returns true if intended
|
||||
// to be semi-automatic.
|
||||
//
|
||||
float(float weapon) Util_WeaponIsSemiAutomatic =
|
||||
{
|
||||
float firetype = GetFiretype(weapon);
|
||||
|
||||
// Valid firetypes
|
||||
if (firetype == FIRETYPE_SEMIAUTO || firetype == FIRETYPE_GRENADE ||
|
||||
firetype == FIRETYPE_RAYBEAM || firetype == FIRETYPE_TESLA)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// Util_WeaponFiresTraceshot(weapon)
|
||||
// Simply returns true if given weapon's firetype requires a
|
||||
|
@ -656,7 +673,7 @@ float(float weapon) Util_WeaponFiresTraceshot =
|
|||
float firetype = GetFiretype(weapon);
|
||||
|
||||
// Valid firetypes
|
||||
if (firetype == 0 || firetype == 1)
|
||||
if (firetype == FIRETYPE_FULLAUTO || firetype == FIRETYPE_SEMIAUTO)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
|
|
@ -1507,38 +1507,38 @@ void(float side) W_Fire =
|
|||
if (self.downed)
|
||||
playdownfire();
|
||||
|
||||
// MOTO - should probably reorganize this whole firetype chunk in the future..
|
||||
|
||||
//Fire weapons
|
||||
if (firetype == 1 || firetype == 3)
|
||||
{
|
||||
// Check if weapon is semi-automatic and if it is, if it's ready to be fired.
|
||||
if (Util_WeaponIsSemiAutomatic(self.weapon)) {
|
||||
if (side == S_RIGHT) {
|
||||
if (self.semi) {
|
||||
return;
|
||||
}
|
||||
self.semi = TRUE;
|
||||
if (self.semi) return;
|
||||
self.semi = true;
|
||||
} else if (side == S_LEFT) {
|
||||
if (self.semi2) {
|
||||
return;
|
||||
}
|
||||
self.semi2 = TRUE;
|
||||
if (self.semi2) return;
|
||||
self.semi2 == true;
|
||||
}
|
||||
|
||||
if (firetype == 3) {
|
||||
W_FireGrenade(side);
|
||||
}
|
||||
} else if (firetype == 4) {
|
||||
W_FireRay();
|
||||
} else if (firetype == 5) {
|
||||
W_FireTesla();
|
||||
} else if (firetype == 6) {
|
||||
W_FireM2();
|
||||
}
|
||||
|
||||
// Weapon Projectile/Trace Logic.
|
||||
if (Util_WeaponFiresTraceshot(self.weapon)) {
|
||||
FireTrace(shotcount, spread, damage, side);
|
||||
}
|
||||
|
||||
switch(firetype) {
|
||||
case FIRETYPE_GRENADE:
|
||||
W_FireGrenade(side);
|
||||
break;
|
||||
case FIRETYPE_RAYBEAM:
|
||||
W_FireRay();
|
||||
break;
|
||||
case FIRETYPE_TESLA:
|
||||
W_FireTesla();
|
||||
break;
|
||||
case FIRETYPE_FLAME:
|
||||
W_FireM2();
|
||||
break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
//Play weapon animation and sound
|
||||
startframe = GetFrame(self.weapon,FIRE_START);
|
||||
endframe = GetFrame(self.weapon,FIRE_END);
|
||||
|
|
Loading…
Reference in a new issue