From d33f2c481cd158883cb7e45d0d44c54cf59a9def Mon Sep 17 00:00:00 2001 From: terencehill Date: Sun, 17 Jul 2016 21:12:09 +0200 Subject: [PATCH] Add possibility of changing camera mode (first person, fixed third person, free third person) with dropweapon while spectating someone --- qcsrc/client/hud/panel/infomessages.qc | 2 +- qcsrc/client/view.qc | 24 ++++++++++++++++++++++++ qcsrc/common/stats.qh | 3 +++ qcsrc/server/cl_client.qc | 12 +++++++++++- 4 files changed, 39 insertions(+), 2 deletions(-) diff --git a/qcsrc/client/hud/panel/infomessages.qc b/qcsrc/client/hud/panel/infomessages.qc index a197963e7..30b7fa8a7 100644 --- a/qcsrc/client/hud/panel/infomessages.qc +++ b/qcsrc/client/hud/panel/infomessages.qc @@ -83,7 +83,7 @@ void HUD_InfoMessages() 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 - s = sprintf(_("^1Press ^3%s^1 to observe"), getcommandkey("secondary fire", "+fire2")); + s = sprintf(_("^1Press ^3%s^1 to observe, ^3%s^1 to change camera mode"), getcommandkey("secondary fire", "+fire2"), getcommandkey("drop weapon", "dropweapon")); drawInfoMessage(s); s = sprintf(_("^1Press ^3%s^1 for gamemode info"), getcommandkey("server info", "+show_info")); diff --git a/qcsrc/client/view.qc b/qcsrc/client/view.qc index 4ca30d4a8..70d1f02f4 100644 --- a/qcsrc/client/view.qc +++ b/qcsrc/client/view.qc @@ -942,6 +942,9 @@ void HUD_Crosshair(entity this) if (!autocvar_crosshair_enabled) // main toggle for crosshair rendering return; + if (spectatee_status > 0 && STAT(CAMERA_SPECTATOR) == 2) + return; + if (hud != HUD_NORMAL) { HUD_Crosshair_Vehicle(this); @@ -1459,6 +1462,25 @@ void CSQC_UpdateView(entity this, float w, float h) // event chase camera if(autocvar_chase_active <= 0) // greater than 0 means it's enabled manually, and this code is skipped { + if(STAT(CAMERA_SPECTATOR)) + { + if(spectatee_status > 0) + { + if(!autocvar_chase_active) + { + cvar_set("chase_active", "-2"); + goto skip_eventchase_death; + } + } + else if(autocvar_chase_active == -2) + cvar_set("chase_active", "0"); + + if(autocvar_chase_active == -2) + goto skip_eventchase_death; + } + else if(autocvar_chase_active == -2) + cvar_set("chase_active", "0"); + float vehicle_chase = (hud != HUD_NORMAL && (autocvar_cl_eventchase_vehicle || spectatee_status > 0)); float ons_roundlost = (gametype == MAPINFO_TYPE_ONSLAUGHT && STAT(ROUNDLOST)); entity gen = NULL; @@ -1569,6 +1591,8 @@ void CSQC_UpdateView(entity this, float w, float h) eventchase_current_distance = 0; } + LABEL(skip_eventchase_death); + // do lockview after event chase camera so that it still applies whenever necessary. if(autocvar_cl_lockview || (!autocvar_hud_cursormode && (autocvar__hud_configure && spectatee_status <= 0 || intermission > 1 || QuickMenu_IsOpened()))) { diff --git a/qcsrc/common/stats.qh b/qcsrc/common/stats.qh index 2c471f0db..4432929a1 100644 --- a/qcsrc/common/stats.qh +++ b/qcsrc/common/stats.qh @@ -246,6 +246,9 @@ REGISTER_STAT(DOM_PPS_PINK, float) REGISTER_STAT(TELEPORT_MAXSPEED, float, autocvar_g_teleport_maxspeed) REGISTER_STAT(TELEPORT_TELEFRAG_AVOID, int, autocvar_g_telefrags_avoid) +.int camera_spectator; +REGISTER_STAT(CAMERA_SPECTATOR, int, this.camera_spectator) + REGISTER_STAT(SPECTATORSPEED, float) #ifdef SVQC diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index e0b7e116e..2d81f5962 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -1615,7 +1615,7 @@ void SpectateCopy(entity this, entity spectatee) this.angles = spectatee.v_angle; STAT(FROZEN, this) = STAT(FROZEN, spectatee); this.revive_progress = spectatee.revive_progress; - if(!PHYS_INPUT_BUTTON_USE(this)) + if(!PHYS_INPUT_BUTTON_USE(this) && this.camera_spectator != 2) this.fixangle = true; setorigin(this, spectatee.origin); setsize(this, spectatee.mins, spectatee.maxs); @@ -1959,6 +1959,13 @@ void SpectatorThink(entity this) { if(MinigameImpulse(this, this.impulse)) this.impulse = 0; + + if (this.impulse == IMP_weapon_drop.impulse) + { + this.camera_spectator = (this.camera_spectator + 1) % 3; + this.impulse = 0; + return; + } } if (this.flags & FL_JUMPRELEASED) { if (PHYS_INPUT_BUTTON_JUMP(this) && !this.version_mismatch) { @@ -2067,6 +2074,7 @@ Called every frame for each client before the physics are run .float usekeypressed; .float last_vehiclecheck; .int items_added; +.float camera_spectator_stat = _STAT(CAMERA_SPECTATOR); void PlayerPreThink (entity this) { WarpZone_PlayerPhysics_FixVAngle(this); @@ -2394,6 +2402,8 @@ void PlayerPreThink (entity this) // if a player goes unarmed after holding a loaded weapon, empty his clip size and remove the crosshair ammo ring if (PS(this).m_weapon == WEP_Null) this.clip_load = this.clip_size = 0; + + this.camera_spectator_stat = this.camera_spectator; } void DrownPlayer(entity this) -- 2.39.2