Announcement

Collapse
No announcement yet.

A proper way to crouch in DP but...

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • A proper way to crouch in DP but...

    Hi im trying to implement in QC a more easy way to crouch using sv_playerphysics but there is a bug i cant solve, when the player is in the ground starts to bunny hopping
    I included a script to see if there is a solution
    Attached Files
    Last edited by RaymanTheHedgehog; 03-15-2019, 08:56 PM. Reason: same as the last line

  • #2
    Your attached file contains one letter. A bit small, assuming the rest is crouched.
    A simple way to aproach it would be to change the bouncing box.
    This can't be done in qc as it is straight from the base model.
    Another way would be to attach your file again with more than "I".

    Comment


    • #3
      Originally posted by Madfox View Post
      Your attached file contains one letter. A bit small, assuming the rest is crouched.
      A simple way to aproach it would be to change the bouncing box.
      This can't be done in qc as it is straight from the base model.
      Another way would be to attach your file again with more than "I".
      float lastclientthink;
      float sv_accelerate;
      float sv_maxairspeed;
      float sv_friction;
      float sv_maxspeed;
      float sv_stopspeed;
      float sv_gravity;
      .float ladder_time;
      .entity ladder_entity;
      .float gravity;
      .float crouch, attemptcrouch;
      float (entity targ) crouchcheck =
      {

      makevectors (self.v_angle);
      tracebox (self.origin, VEC_HULL_MIN, VEC_HULL_MAX, self.origin + '0 0 16', FALSE, self);

      /*
      vector VEC_HULL_MIN = '-16 -16 -24';
      vector VEC_HULL_MAX = '16 16 32';
      */


      if (trace_fraction == 1) //hits nothing go ahead
      return TRUE;

      if (!trace_ent.takedamage) //hits world or nondamagable object
      return FALSE;

      return FALSE;

      };

      void() player_crouch;
      void() player_run;

      void() SV_PlayerPhysics =
      {
      local vector wishvel, wishdir, v;
      local float wishspeed, f;

      if (self.movetype == MOVETYPE_NONE)
      return;

      if (time != lastclientthink)
      {
      lastclientthink = time;
      sv_maxairspeed = cvar("sv_maxairspeed");
      sv_maxspeed = cvar("sv_maxspeed");
      sv_friction = cvar("sv_friction");
      sv_accelerate = cvar("sv_accelerate");
      sv_stopspeed = cvar("sv_stopspeed");
      sv_gravity = cvar("sv_gravity");
      }

      if (self.punchangle != '0 0 0')
      {
      f = vlen(self.punchangle) - 10 * frametime;
      if (f > 0)
      self.punchangle = normalize(self.punchangle) * f;
      else
      self.punchangle = '0 0 0';
      }

      if (self.punchvector != '0 0 0')
      {
      f = vlen(self.punchvector) - 30 * frametime;
      if (f > 0)
      self.punchvector = normalize(self.punchvector) * f;
      else
      self.punchvector = '0 0 0';
      }

      // if dead, behave differently
      if (self.deadflag)
      return;

      if (!self.fixangle)
      {
      // show 1/3 the pitch angle and all the roll angle
      // LordHavoc: no real interest in porting V_CalcRoll
      //self.angles_z = V_CalcRoll (self.angles, self.velocity)*4;
      self.angles_x = 0;
      self.angles_y = self.v_angle_y + self.punchangle_y;
      self.angles_z = 0;
      }

      if (self.flags & FL_WATERJUMP )
      {
      self.velocity_x = self.movedir_x;
      self.velocity_y = self.movedir_y;
      if (time > self.teleport_time || self.waterlevel == 0)
      {
      self.flags = self.flags - (self.flags & FL_WATERJUMP);
      self.teleport_time = 0;
      }
      }
      else if (self.movetype == MOVETYPE_NOCLIP || self.movetype == MOVETYPE_FLY)
      {
      // noclipping or flying
      self.velocity = self.velocity * (1 - frametime * sv_friction);
      makevectors(self.v_angle);
      //wishvel = v_forward * self.movement_x + v_right * self.movement_y + v_up * self.movement_z;
      wishvel = v_forward * self.movement_x + v_right * self.movement_y + '0 0 1' * self.movement_z;
      // acceleration
      wishdir = normalize(wishvel);
      wishspeed = vlen(wishvel);
      if (wishspeed > sv_maxspeed)
      wishspeed = sv_maxspeed;
      if (time >= self.teleport_time)
      {
      f = wishspeed - (self.velocity * wishdir);
      if (f > 0)
      self.velocity = self.velocity + wishdir * min(f, sv_accelerate * frametime * wishspeed);
      }
      }
      else if (self.waterlevel >= 2)
      {
      // swimming
      makevectors(self.v_angle);
      //wishvel = v_forward * self.movement_x + v_right * self.movement_y;
      wishvel = v_forward * self.movement_x + v_right * self.movement_y;
      if (wishvel == '0 0 0')
      wishvel = '0 0 -60'; // drift towards bottom

      wishdir = normalize(wishvel);
      wishspeed = vlen(wishvel);
      if (wishspeed > sv_maxspeed)
      wishspeed = sv_maxspeed;
      wishspeed = wishspeed * 0.7;

      // water friction
      self.velocity = self.velocity * (1 - frametime * sv_friction);

      // water acceleration
      f = wishspeed - (self.velocity * wishdir);
      if (f > 0)
      self.velocity = self.velocity + wishdir * min(f, sv_accelerate * frametime * wishspeed);
      }
      else if (time < self.ladder_time)
      {
      // on a func_ladder or swimming in func_water
      self.velocity = self.velocity * (1 - frametime * sv_friction);
      makevectors(self.v_angle);
      //wishvel = v_forward * self.movement_x + v_right * self.movement_y;
      wishvel = v_forward * self.movement_x + v_right * self.movement_y + '0 0 1' * self.movement_z;
      if (self.gravity)
      self.velocity_z = self.velocity_z + self.gravity * sv_gravity * frametime;
      else
      self.velocity_z = self.velocity_z + sv_gravity * frametime;
      if (self.ladder_entity.classname == "func_water")
      {
      f = vlen(wishvel);
      if (f > self.ladder_entity.speed)
      wishvel = wishvel * (self.ladder_entity.speed / f);

      self.watertype = self.ladder_entity.skin;
      f = self.ladder_entity.origin_z + self.ladder_entity.maxs_z;
      if ((self.origin_z + self.view_ofs_z) < f)
      self.waterlevel = 3;
      else if ((self.origin_z + (self.mins_z + self.maxs_z) * 0.5) < f)
      self.waterlevel = 2;
      else if ((self.origin_z + self.mins_z + 1) < f)
      self.waterlevel = 1;
      else
      {
      self.waterlevel = 0;
      self.watertype = CONTENT_EMPTY;
      }
      }
      // acceleration
      wishdir = normalize(wishvel);
      wishspeed = vlen(wishvel);
      if (wishspeed > sv_maxspeed)
      wishspeed = sv_maxspeed;
      if (time >= self.teleport_time)
      {
      f = wishspeed - (self.velocity * wishdir);
      if (f > 0)
      self.velocity = self.velocity + wishdir * min(f, sv_accelerate * frametime * wishspeed);
      }
      }
      else if (self.flags & FL_ONGROUND)
      {
      // walking
      makevectors(self.v_angle_y * '0 1 0');
      wishvel = v_forward * self.movement_x + v_right * self.movement_y;
      // friction
      if (self.velocity_x || self.velocity_y)
      {
      v = self.velocity;
      v_z = 0;
      f = vlen(v);
      if (f < sv_stopspeed)
      f = 1 - frametime * (sv_stopspeed / f) * sv_friction;
      else
      f = 1 - frametime * sv_friction;
      if (f > 0)
      self.velocity = self.velocity * f;
      else
      self.velocity = '0 0 0';
      }
      // acceleration
      wishdir = normalize(wishvel);
      wishspeed = vlen(wishvel);
      if (wishspeed > sv_maxspeed)
      wishspeed = sv_maxspeed;
      if (time >= self.teleport_time)
      {
      f = wishspeed - (self.velocity * wishdir);
      if (f > 0)
      self.velocity = self.velocity + wishdir * min(f, sv_accelerate * frametime * wishspeed);
      }
      }
      else
      {
      // airborn
      makevectors(self.v_angle_y * '0 1 0');
      wishvel = v_forward * self.movement_x + v_right * self.movement_y;
      // acceleration
      wishdir = normalize(wishvel);
      wishspeed = vlen(wishvel);
      if (wishspeed > sv_maxairspeed)
      wishspeed = sv_maxairspeed;
      if (time >= self.teleport_time)
      {
      f = wishspeed - (self.velocity * wishdir);
      if (f > 0)
      self.velocity = self.velocity + wishdir * min(f, sv_accelerate * frametime * wishspeed);
      }
      // crouching
      if ((self.movetype == MOVETYPE_WALK) && (self.movement_z) && (crouchcheck(self))) //get up
      {
      setsize (self, '-16 -16 -8', '16 16 8');
      //self.crouch = 0;
      self.view_ofs = '0 0 14';
      }
      return;
      }

      if ((!self.movement_z) && (!self.velocity_z)) //crouch down
      {
      setsize (self, VEC_HULL_MIN, VEC_HULL_MAX);
      //self.crouch = 1;
      self.origin_z = self.origin_z;
      self.view_ofs = '0 0 22';
      }
      };

      There's the full code, sorry this forum manage the attachments very buggy

      Comment


      • #4
        So if I get it right this qc file would make the player crouch, but it has a bug.
        Where should I place it, I mean does it go for player.qc or crouch.qc?
        I will take a look at it.

        Meanwhile, here's a modified ai.qc I made for the same purpose.
        It has a ai_crouch line on 580.
        Place it in the usual qcc code and see how it goes.

        http://home.kpn.nl/lo2kf8/quake/crouch_ai.zip


        Comment


        • #5
          Thanks but, now only crouch when the player is in mid-air.
          My code maybe need some tinkering
          Thanks anyway

          Comment


          • #6
            I just overcome a file that can let you crouch in Quake. It's just a one frame addon but it works.
            The file is from Glen Murphy AKA FrenZon and was published in november 1996.
            Mayby there is a workaround for you to play with?

            You move slower, strafe like a pregnant yak
            (with no legs.) and can't shoot. BUT, your model,
            and bounding box are only 22 units high, (about
            1/3 normal,) so, you can hide underwater in those
            normally waist-high water bits. hide behind walls
            or just sit there looking silly.
            http://home.kpn.nl/lo2kf8/quake/crouch2.zip

            Comment


            • #7
              I wish the source was included but likely something easy to do.
              Secret Level - Quake fandom & my custom levels

              Comment


              • #8
                The crouche scene is just one frame added to the mdl.
                There's nothing more than the impulse code to reach it.
                It's the original code.
                I'm adding now a crouch_shoot scene as I'm most impressed by the simplicity of it.

                Or are you referring to Rayman's code?

                Comment


                • #9
                  I must correct myself.
                  But before I start..;
                  -Please respect the wishes and legal rights of the person who created this -
                  Glen Murphy AKA FrenZon
                  Right, to get the player crouch use the player.mdl with the extra crouch.mdl.
                  I could write out the specific code but I'm afraid I'll get off line.
                  So to easy up a bit here are the specific changes made in:
                  defs.qc - subs.qc - client.qc - player.qc -weapons.qc
                  If you change them in your v106qc and compile them you'll get the proper progs.dat.

                  http://home.kpn.nl/lo2kf8/quake/Q1_Player_crouchqc.zip

                  Of course you can use them to study for your own sake in the DP mod.
                  The keyword to search in an editor is "crouch".
                  For some strange reason I needed the subs.qc as it asked for a SUB_CalcMoveEnt
                  although I couldn't find any difference.

                  Well, and now I'm puzzling with a crouch_shoot qc.
                  I made one, but six frames in the player.mdl isn't enough.
                  And so it goes, one good idea after the other.

                  http://home.kpn.nl/lo2kf8/quake/models/crouchshoot.GIF






                  Comment

                  Working...
                  X