From 729565c1767c3205d814b640e4c9e3ea4bab4b9b Mon Sep 17 00:00:00 2001 From: terencehill Date: Tue, 24 Sep 2024 12:57:26 +0200 Subject: [PATCH] Restore BACKSPACE to change spectator camera mode, make right mouse button switch to previous player --- qcsrc/client/hud/panel/infomessages.qc | 4 ++-- qcsrc/client/view.qc | 4 ++-- qcsrc/server/client.qc | 25 ++++++++++++------------- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/qcsrc/client/hud/panel/infomessages.qc b/qcsrc/client/hud/panel/infomessages.qc index bea111f6e..6c73ddad7 100644 --- a/qcsrc/client/hud/panel/infomessages.qc +++ b/qcsrc/client/hud/panel/infomessages.qc @@ -106,13 +106,13 @@ void HUD_InfoMessages() if(spectatee_status == -1) s = sprintf(_("^1Press ^3%s^1 to spectate"), getcommandkey(_("primary fire"), "+fire")); else - s = sprintf(_("^1Press ^3%s^1 or ^3%s^1 for next or previous player"), getcommandkey(_("next weapon"), "weapnext"), getcommandkey(_("previous weapon"), "weapprev")); + s = sprintf(_("^1Press ^3%s^1 or ^3%s^1 for next or previous player"), getcommandkey(_("primary fire"), "+fire"), getcommandkey(_("secondary fire"), "+fire2")); break; case 1: if(spectatee_status == -1) s = sprintf(_("^1Use ^3%s^1 or ^3%s^1 to change the speed"), getcommandkey(_("next weapon"), "weapnext"), getcommandkey(_("previous weapon"), "weapprev")); else if(!observe_blocked) - s = sprintf(_("^1Press ^3%s^1 to observe, ^3%s^1 to change camera mode"), getcommandkey(_("observe"), "spec"), getcommandkey(_("secondary fire"), "+fire2")); + s = sprintf(_("^1Press ^3%s^1 to observe, ^3%s^1 to change camera mode"), getcommandkey(_("observe"), "spec"), getcommandkey(_("drop weapon"), "dropweapon")); else s = sprintf(_("^1Press ^3%s^1 to change camera mode"), getcommandkey(_("drop weapon"), "dropweapon")); break; diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index 09dc73979..261fd1b01 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -603,7 +603,7 @@ bool View_SpectatorCamera() { if (!waiting_CAMERA_SPECTATOR_update) { - localcmd("\n+attack2; wait; -attack2\n"); // switch to CAMERA_SPECTATOR 2 + Impulse_Send(IMP_weapon_drop); // switch to CAMERA_SPECTATOR 2 waiting_CAMERA_SPECTATOR_update = 1; } } @@ -618,7 +618,7 @@ bool View_SpectatorCamera() { if (waiting_CAMERA_SPECTATOR_update != STAT(CAMERA_SPECTATOR)) { - localcmd("\n+attack2; wait; -attack2\n"); // switch to CAMERA_SPECTATOR (2 and) 0 + Impulse_Send(IMP_weapon_drop); // switch to CAMERA_SPECTATOR (2 and) 0 waiting_CAMERA_SPECTATOR_update = STAT(CAMERA_SPECTATOR); } } diff --git a/qcsrc/server/client.qc b/qcsrc/server/client.qc index b3d3dc8a7..5de427a78 100644 --- a/qcsrc/server/client.qc +++ b/qcsrc/server/client.qc @@ -2429,7 +2429,9 @@ bool PlayerThink(entity this) return true; } -.int new_CAMERA_SPECTATOR; +#define IS_WEAPNEXT_IMPULSE(imp) (imp == 10 || imp == 15 || imp == 18 || (imp >= 200 && imp <= 209)) +#define IS_WEAPPREV_IMPULSE(imp) (imp == 12 || imp == 16 || imp == 19 || (imp >= 220 && imp <= 229)) + // merged SpectatorThink and ObserverThink (old names are here so you can grep for them) void ObserverOrSpectatorThink(entity this) { @@ -2440,17 +2442,12 @@ void ObserverOrSpectatorThink(entity this) int r = MinigameImpulse(this, CS(this).impulse); if (!is_spec || r) CS(this).impulse = 0; - } - - if (is_spec) - { - if (PHYS_INPUT_BUTTON_ATCK2(this)) + if (is_spec && CS(this).impulse == IMP_weapon_drop.impulse) { - if (this.new_CAMERA_SPECTATOR == STAT(CAMERA_SPECTATOR, this)) - this.new_CAMERA_SPECTATOR = (STAT(CAMERA_SPECTATOR, this) + 1) % 3; + STAT(CAMERA_SPECTATOR, this) = (STAT(CAMERA_SPECTATOR, this) + 1) % 3; + CS(this).impulse = 0; + return; } - else if (STAT(CAMERA_SPECTATOR, this) != this.new_CAMERA_SPECTATOR) - STAT(CAMERA_SPECTATOR, this) = this.new_CAMERA_SPECTATOR; } if (frametime && autocvar_sv_show_entnum) show_entnum(this); @@ -2472,7 +2469,7 @@ void ObserverOrSpectatorThink(entity this) if (PHYS_INPUT_BUTTON_JUMP(this) && (joinAllowed(this, this.wants_join) || time < CS(this).jointime + MIN_SPEC_TIME)) { this.flags &= ~FL_JUMPRELEASED; this.flags |= FL_SPAWNING; - } else if((is_spec && (PHYS_INPUT_BUTTON_ATCK(this) || CS(this).impulse == 10 || CS(this).impulse == 15 || CS(this).impulse == 18 || (CS(this).impulse >= 200 && CS(this).impulse <= 209))) + } else if((is_spec && (PHYS_INPUT_BUTTON_ATCK(this) || IS_WEAPNEXT_IMPULSE(CS(this).impulse))) || (!is_spec && ((PHYS_INPUT_BUTTON_ATCK(this) && !CS(this).version_mismatch) || this.would_spectate))) { this.flags &= ~FL_JUMPRELEASED; if(SpectateNext(this)) { @@ -2486,7 +2483,7 @@ void ObserverOrSpectatorThink(entity this) if (is_spec) CS(this).impulse = 0; } else if (is_spec) { - if(CS(this).impulse == 12 || CS(this).impulse == 16 || CS(this).impulse == 19 || (CS(this).impulse >= 220 && CS(this).impulse <= 229)) { + if(PHYS_INPUT_BUTTON_ATCK2(this) || IS_WEAPPREV_IMPULSE(CS(this).impulse)) { this.flags &= ~FL_JUMPRELEASED; if(SpectatePrev(this)) { TRANSMUTE(Spectator, this); @@ -2508,7 +2505,7 @@ void ObserverOrSpectatorThink(entity this) set_movetype(this, preferred_movetype); } } else { // jump pressed - if ((is_spec && !(PHYS_INPUT_BUTTON_ATCK(this))) + if ((is_spec && !(PHYS_INPUT_BUTTON_ATCK(this) || PHYS_INPUT_BUTTON_ATCK2(this))) || (!is_spec && !(PHYS_INPUT_BUTTON_ATCK(this) || PHYS_INPUT_BUTTON_JUMP(this)))) { this.flags |= FL_JUMPRELEASED; // primary attack pressed @@ -2528,6 +2525,8 @@ void ObserverOrSpectatorThink(entity this) if (is_spec) this.flags |= FL_CLIENT | FL_NOTARGET; } +#undef IS_WEAPNEXT_IMPULSE +#undef IS_WEAPPREV_IMPULSE void PlayerUseKey(entity this) { -- 2.39.2