]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add possibility of changing camera mode (first person, fixed third person, free third...
authorterencehill <piuntn@gmail.com>
Sun, 17 Jul 2016 19:12:09 +0000 (21:12 +0200)
committerterencehill <piuntn@gmail.com>
Sun, 17 Jul 2016 19:12:09 +0000 (21:12 +0200)
qcsrc/client/hud/panel/infomessages.qc
qcsrc/client/view.qc
qcsrc/common/stats.qh
qcsrc/server/cl_client.qc

index a197963e75492145545a315b9de468585059cdce..30b7fa8a7929bf46a9b618e3e7c2b67d918b8aa6 100644 (file)
@@ -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"));
index 4ca30d4a8de656478a7bc75ebf54ee4b33c9b73b..70d1f02f4ba18f563263d2ca2c646115b5e6a7c7 100644 (file)
@@ -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())))
        {
index 2c471f0db30bb63d39b53966ed92ff6bf2e573ad..4432929a1958ba8970ec6ebd8a1b7945944549d0 100644 (file)
@@ -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
index e0b7e116eae253a3b6f85f3dc43e352b69774f99..2d81f5962dab98ed0ef52d2f1868bed323b957da 100644 (file)
@@ -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)