]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'terencehill/camera_spectator_2' into 'master'
authorMario <zacjardine@y7mail.com>
Mon, 25 Jul 2016 07:38:33 +0000 (07:38 +0000)
committerMario <zacjardine@y7mail.com>
Mon, 25 Jul 2016 07:38:33 +0000 (07:38 +0000)
Dropweapon to change camera mode while spectating

See merge request !339

1  2 
qcsrc/client/view.qc
qcsrc/common/stats.qh
qcsrc/server/cl_client.qc

diff --combined qcsrc/client/view.qc
index 3b52de90d3c561cecc1af16b996a32d37369cc24,70d1f02f4ba18f563263d2ca2c646115b5e6a7c7..200bcfde715373d44105d516894ad72745de8778
@@@ -942,6 -942,9 +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 +1462,25 @@@ void CSQC_UpdateView(entity this, floa
        // 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;
                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())))
        {
           mousepos = mousepos*0.5 + getmousepos();
         */
  
 -      FOREACH_ENTITY(it.draw, it.draw(it));
 +      FOREACH_ENTITY_FLOAT(pure_data, false,
 +      {
 +              if(it.draw) { it.draw(it); }
 +      });
  
        addentities(MASK_NORMAL | MASK_ENGINE | MASK_ENGINEVIEWMODELS);
        renderscene();
          } else */
  
        // draw 2D entities
 -      FOREACH_ENTITY(it.draw2d, it.draw2d(it));
 +      FOREACH_ENTITY_FLOAT(pure_data, false,
 +      {
 +              if(it.draw2d) { it.draw2d(it); }
 +      });
        Draw_ShowNames_All();
        Debug_Draw();
  
diff --combined qcsrc/common/stats.qh
index 4592d8d20305af151541b5e30bdcf4bf3cb351e5,1e55ad009bf2919f8929c4b2585191833541e755..bbf315183d12cd24c0f4749fdbb72919b31a1ed5
@@@ -174,21 -174,12 +174,21 @@@ REGISTER_STAT(BUGRIGS_SPEED_POW, float
  REGISTER_STAT(BUGRIGS_SPEED_REF, float, g_bugrigs_speed_ref)
  REGISTER_STAT(BUGRIGS_STEER, float, g_bugrigs_steer)
  
 -REGISTER_STAT(GAMEPLAYFIX_DOWNTRACEONGROUND, int, cvar("sv_gameplayfix_downtracesupportsongroundflag"))
 -REGISTER_STAT(GAMEPLAYFIX_EASIERWATERJUMP, int, cvar("sv_gameplayfix_easierwaterjump"))
 -REGISTER_STAT(GAMEPLAYFIX_STEPDOWN, int, cvar("sv_gameplayfix_stepdown"))
 -REGISTER_STAT(GAMEPLAYFIX_STEPMULTIPLETIMES, int, cvar("sv_gameplayfix_stepmultipletimes"))
 -REGISTER_STAT(GAMEPLAYFIX_UNSTICKPLAYERS, int, cvar("sv_gameplayfix_unstickplayers"))
 +#ifdef SVQC
 +int autocvar_sv_gameplayfix_downtracesupportsongroundflag;
 +int autocvar_sv_gameplayfix_easierwaterjump;
 +int autocvar_sv_gameplayfix_stepdown;
 +int autocvar_sv_gameplayfix_stepmultipletimes;
 +int autocvar_sv_gameplayfix_unstickplayers;
 +int autocvar_sv_gameplayfix_fixedcheckwatertransition;
 +#endif
 +REGISTER_STAT(GAMEPLAYFIX_DOWNTRACEONGROUND, int, autocvar_sv_gameplayfix_downtracesupportsongroundflag)
 +REGISTER_STAT(GAMEPLAYFIX_EASIERWATERJUMP, int, autocvar_sv_gameplayfix_easierwaterjump)
 +REGISTER_STAT(GAMEPLAYFIX_STEPDOWN, int, autocvar_sv_gameplayfix_stepdown)
 +REGISTER_STAT(GAMEPLAYFIX_STEPMULTIPLETIMES, int, autocvar_sv_gameplayfix_stepmultipletimes)
 +REGISTER_STAT(GAMEPLAYFIX_UNSTICKPLAYERS, int, autocvar_sv_gameplayfix_unstickplayers)
  REGISTER_STAT(GAMEPLAYFIX_UPVELOCITYCLEARSONGROUND, int, autocvar_sv_gameplayfix_upwardvelocityclearsongroundflag)
 +REGISTER_STAT(GAMEPLAYFIX_WATERTRANSITION, int, autocvar_sv_gameplayfix_fixedcheckwatertransition)
  
  REGISTER_STAT(MOVEVARS_JUMPSTEP, int, cvar("sv_jumpstep"))
  REGISTER_STAT(NOSTEP, int, cvar("sv_nostep"))
@@@ -214,7 -205,6 +214,7 @@@ float autocvar_sv_dodging_horiz_speed_f
  float autocvar_sv_dodging_ramp_time;
  float autocvar_sv_dodging_up_speed;
  bool autocvar_sv_dodging_wall_dodging;
 +bool autocvar_sv_dodging_air_dodging;
  #endif
  
  REGISTER_STAT(DODGING, int, g_dodging)
@@@ -229,8 -219,7 +229,8 @@@ REGISTER_STAT(DODGING_RAMP_TIME, float
  /** cvar loopback */
  REGISTER_STAT(DODGING_TIMEOUT, float)
  REGISTER_STAT(DODGING_UP_SPEED, float, autocvar_sv_dodging_up_speed)
 -REGISTER_STAT(DODGING_WALL, int, autocvar_sv_dodging_wall_dodging)
 +REGISTER_STAT(DODGING_WALL, bool, autocvar_sv_dodging_wall_dodging)
 +REGISTER_STAT(DODGING_AIR, bool, autocvar_sv_dodging_air_dodging)
  
  REGISTER_STAT(JETPACK_ACCEL_SIDE, float, autocvar_g_jetpack_acceleration_side)
  REGISTER_STAT(JETPACK_ACCEL_UP, float, autocvar_g_jetpack_acceleration_up)
@@@ -238,7 -227,6 +238,7 @@@ REGISTER_STAT(JETPACK_ANTIGRAVITY, floa
  REGISTER_STAT(JETPACK_FUEL, float, autocvar_g_jetpack_fuel)
  REGISTER_STAT(JETPACK_MAXSPEED_SIDE, float, autocvar_g_jetpack_maxspeed_side)
  REGISTER_STAT(JETPACK_MAXSPEED_UP, float, autocvar_g_jetpack_maxspeed_up)
 +REGISTER_STAT(JETPACK_REVERSE_THRUST, float, autocvar_g_jetpack_reverse_thrust)
  
  REGISTER_STAT(MOVEVARS_HIGHSPEED, float, autocvar_g_movement_highspeed)
  
@@@ -258,6 -246,8 +258,8 @@@ 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)
  
+ REGISTER_STAT(CAMERA_SPECTATOR, int)
  REGISTER_STAT(SPECTATORSPEED, float)
  
  #ifdef SVQC
index 525006c9cec056f3d634c8c2fea06af9f201cc06,942bc4699d20dc6cb4416969ebfd417f864bff19..60f331bb30570d85ec1ce9e8110e004d6014a751
@@@ -269,7 -269,7 +269,7 @@@ void PutObserverInServer(entity this
        this.health = FRAGS_SPECTATOR;
        this.takedamage = DAMAGE_NO;
        this.solid = SOLID_NOT;
 -      this.movetype = MOVETYPE_FLY_WORLDONLY; // user preference is controlled by playerprethink
 +      set_movetype(this, MOVETYPE_FLY_WORLDONLY); // user preference is controlled by playerprethink
        this.flags = FL_CLIENT | FL_NOTARGET;
        this.armorvalue = 666;
        this.effects = 0;
@@@ -481,7 -481,7 +481,7 @@@ void PutClientInServer(entity this
                this.iscreature = true;
                this.teleportable = TELEPORT_NORMAL;
                this.damagedbycontents = true;
 -              this.movetype = MOVETYPE_WALK;
 +              set_movetype(this, MOVETYPE_WALK);
                this.solid = SOLID_SLIDEBOX;
                this.dphitcontentsmask = DPCONTENTS_BODY | DPCONTENTS_SOLID;
                if (autocvar_g_playerclip_collisions)
@@@ -1289,7 -1289,7 +1289,7 @@@ void respawn(entity this
        {
                this.solid = SOLID_NOT;
                this.takedamage = DAMAGE_NO;
 -              this.movetype = MOVETYPE_FLY;
 +              set_movetype(this, MOVETYPE_FLY);
                this.velocity = '0 0 1' * autocvar_g_respawn_ghosts_speed;
                this.avelocity = randomvec() * autocvar_g_respawn_ghosts_speed * 3 - randomvec() * autocvar_g_respawn_ghosts_speed * 3;
                this.effects |= CSQCMODEL_EF_RESPAWNGHOST;
@@@ -1615,7 -1615,7 +1615,7 @@@ void SpectateCopy(entity this, entity s
        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) && STAT(CAMERA_SPECTATOR, this) != 2)
                this.fixangle = true;
        setorigin(this, spectatee.origin);
        setsize(this, spectatee.mins, spectatee.maxs);
@@@ -1675,7 -1675,7 +1675,7 @@@ bool SpectateSet(entity this
        msg_entity = this;
        WriteByte(MSG_ONE, SVC_SETVIEW);
        WriteEntity(MSG_ONE, this.enemy);
 -      this.movetype = MOVETYPE_NONE;
 +      set_movetype(this, MOVETYPE_NONE);
        accuracy_resend(this);
  
        if(!SpectateUpdate(this))
@@@ -1925,6 -1925,7 +1925,6 @@@ void ObserverThink(entity this
                MinigameImpulse(this, this.impulse);
                this.impulse = 0;
        }
 -      float prefered_movetype;
        if (this.flags & FL_JUMPRELEASED) {
                if (PHYS_INPUT_BUTTON_JUMP(this) && !this.version_mismatch) {
                        this.flags &= ~FL_JUMPRELEASED;
                                TRANSMUTE(Spectator, this);
                        }
                } else {
 -                      prefered_movetype = ((!PHYS_INPUT_BUTTON_USE(this) ? this.cvar_cl_clippedspectating : !this.cvar_cl_clippedspectating) ? MOVETYPE_FLY_WORLDONLY : MOVETYPE_NOCLIP);
 -                      if (this.movetype != prefered_movetype)
 -                              this.movetype = prefered_movetype;
 +                      int preferred_movetype = ((!PHYS_INPUT_BUTTON_USE(this) ? this.cvar_cl_clippedspectating : !this.cvar_cl_clippedspectating) ? MOVETYPE_FLY_WORLDONLY : MOVETYPE_NOCLIP);
 +                      set_movetype(this, preferred_movetype);
                }
        } else {
                if (!(PHYS_INPUT_BUTTON_ATCK(this) || PHYS_INPUT_BUTTON_JUMP(this))) {
@@@ -1957,6 -1959,13 +1957,13 @@@ void SpectatorThink(entity this
        {
                if(MinigameImpulse(this, this.impulse))
                        this.impulse = 0;
+               if (this.impulse == IMP_weapon_drop.impulse)
+               {
+                       STAT(CAMERA_SPECTATOR, this) = (STAT(CAMERA_SPECTATOR, this) + 1) % 3;
+                       this.impulse = 0;
+                       return;
+               }
        }
        if (this.flags & FL_JUMPRELEASED) {
                if (PHYS_INPUT_BUTTON_JUMP(this) && !this.version_mismatch) {
@@@ -2279,8 -2288,6 +2286,8 @@@ void PlayerPreThink (entity this
          .entity weaponentity = weaponentities[0]; // TODO: unhardcode
                if (this.hook.state) {
                        do_crouch = false;
 +              } else if (this.waterlevel >= WATERLEVEL_SWIMMING) {
 +                      do_crouch = false;
                } else if (this.vehicle) {
                        do_crouch = false;
                } else if (STAT(FROZEN, this)) {
@@@ -2418,30 -2425,6 +2425,30 @@@ void DrownPlayer(entity this
        }
  }
  
 +void Player_Physics(entity this)
 +{
 +      this.movetype = ((this.move_qcphysics) ? MOVETYPE_NONE : this.move_movetype);
 +
 +      if(!this.move_qcphysics)
 +              return;
 +
 +      int mt = this.move_movetype;
 +
 +      if(mt == MOVETYPE_PUSH || mt == MOVETYPE_FAKEPUSH || mt == MOVETYPE_PHYSICS)
 +      {
 +              this.move_qcphysics = false;
 +              this.movetype = mt;
 +              return;
 +      }
 +
 +      if(!frametime && !this.pm_frametime)
 +              return;
 +
 +      Movetype_Physics_NoMatchTicrate(this, this.pm_frametime, true);
 +
 +      this.pm_frametime = 0;
 +}
 +
  /*
  =============
  PlayerPostThink
@@@ -2452,8 -2435,6 +2459,8 @@@ Called every frame for each client afte
  .float idlekick_lasttimeleft;
  void PlayerPostThink (entity this)
  {
 +      Player_Physics(this);
 +
        if (sv_maxidle > 0)
        if (frametime) // WORKAROUND: only use dropclient in server frames (frametime set). Never use it in cl_movement frames (frametime zero).
        if (IS_REAL_CLIENT(this))