Server: Improve Button Check logic for Firing/ADS

Moves everything together to improve branching/speed things up a bit.
Also adds a note about PC flipping the fire buttons for akimbo weaponry
and puts akimbo stuff closer together.
This commit is contained in:
Ian 2022-11-17 22:11:52 -05:00
parent 1f64c0239a
commit b74c6cd8c8

View file

@ -1597,7 +1597,6 @@ void(float side) W_Fire =
* W_Knife *
******************************/
// FIXME - knife & nade vmodels change skin on PSP!
void () W_Knife =
{
if (time < self.knife_delay || self.new_anim_stop ||
@ -2370,43 +2369,39 @@ void () Weapon_Logic =
UpdatePunchangle(self);
#endif
//FIXME - cleanup!
if (IsDualWeapon(self.weapon)) {
//
// Fire Button Logic
// NOTE: Since the right weapon is the "normal" side there's some
// flip flop logic on PC so that LMB will fire the left side instead.
//
// Right Trigger/LMB/etc.
if (self.button0) {
#ifdef PC
W_Fire(S_LEFT);
if (IsDualWeapon(self.weapon)) { W_Fire(S_LEFT); } else { W_Fire(S_RIGHT); }
#else
W_Fire(S_RIGHT);
#endif
#endif // PC
} else {
// Check for release for semi automatic weapons.
#ifdef PC
self.semi2 = FALSE;
if (IsDualWeapon(self.weapon)) { self.semi2 = false; } else { self.semi = false; }
#else
self.semi = FALSE;
#endif
self.semi = false;
#endif // PC
}
// Left Trigger/RMB/etc.
if (self.button8) {
if (IsDualWeapon(self.weapon)) {
#ifdef PC
W_Fire(S_RIGHT);
#else
W_Fire(S_LEFT);
#endif
#endif // PC
} else {
#ifdef PC
self.semi = FALSE;
#else
self.semi2 = FALSE;
#endif
}
} else {
if (self.button0) {
W_Fire(S_RIGHT);
} else {
self.semi = FALSE;
}
// Toggle ADS back and forth
if (cvar("cl_adsmode")) {
if (self.button8) {
self.ads_toggle = !self.ads_toggle;
if (self.ads_toggle == false) {
@ -2417,18 +2412,16 @@ void () Weapon_Logic =
self.viewzoom = 1;
UpdateVmodel(self.weaponmodel, GetWepSkin(self.weapon));
UpdateV2model(self.weapon2model, 0);
#endif
#endif // PC
} else {
W_AimIn();
self.zoom = 1;
#ifdef PC
self.viewzoom = 0.9;
#endif
}
#endif // PC
}
} else {
if (self.button8) {
if (!self.zoom) {
W_AimIn();
}
@ -2448,9 +2441,10 @@ void () Weapon_Logic =
self.viewzoom = 0.89999;
}
}
#endif
#endif // PC
}
}
} else if (!self.button8 && self.zoom) {
#ifdef PC
if (self.weapon == W_KAR_SCOPE || self.weapon == W_PTRS ||
self.weapon == W_HEADCRACKER || self.weapon == W_PENETRATOR) {
@ -2476,8 +2470,15 @@ void () Weapon_Logic =
}
#else
W_AimOut();
#endif
}
#endif // PC
} else {
// Check for release for semi automatic weapons.
if (IsDualWeapon(self.weapon)) {
#ifdef PC
self.semi = false;
#else
self.semi2 = false;
#endif // PC
}
}