Forum

Questions on the player controlller

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Questions on the player controlller

Postby JasonX » Mon Mar 28, 2011 12:39 pm

I'm working on a few enhancements to the player controller and i wanted to ask you guys a few things:

1) Is it possible to make the player controller a little different, based on the level he's in? For example, i want to make an icy level, where the floor is a little slippery.
2) Double-jumping. I saw a few threads about it, but it seems a little hackish. Has this been done in a more elegant way? Also, how do i make the player double-jump any time during the jump, not just when the first jump apex is reached?
3) Dashing. How can i make the player run for a few seconds if he double-tapped the forward button?
JasonX
 
Posts: 411
Joined: Tue Apr 21, 2009 2:08 pm

Re: Questions on the player controlller

Postby Baker » Mon Mar 28, 2011 1:37 pm

JasonX wrote:I'm working on a few enhancements to the player controller and i wanted to ask you guys a few things:

1) Is it possible to make the player controller a little different, based on the level he's in? For example, i want to make an icy level, where the floor is a little slippery.


In QuakeC, find in the check for the map "E1M8" that changes the sv_gravity ...

world.qc

Code: Select all
void() worldspawn =
{
   lastspawn = world;
   InitBodyQue ();

// custom map attributes
   if (self.model == "maps/e1m8.bsp")
      cvar_set ("sv_gravity", "100");
   else
      cvar_set ("sv_gravity", "800");


And set some funky movement cvars for your strange movement map.

2) Double-jumping. I saw a few threads about it, but it seems a little hackish. Has this been done in a more elegant way? Also, how do i make the player double-jump any time during the jump, not just when the first jump apex is reached?


Probably store the first jump time, and if say .5 seconds has elapsed and the player isn't on the ground, allow the jump to work. All a jump does as far as I know is give the player some up velocity and checking if FL_ONGROUND (or whatever it is called).

Meaning the player can only jump if on the ground.

I'm not Mr. QuakeC so I could be wrong about this, but I don't think I am since the QMatrix mod had wall jump and the player certainly isn't on the ground when he's not on the ground.

Here is where to look in client.qc

Code: Select all
void() PlayerJump =
{
   local vector start, end;
   
   if (self.flags & FL_WATERJUMP)
      return;
   
   if (self.waterlevel >= 2)
   {
      if (self.watertype == CONTENT_WATER)
         self.velocity_z = 100;
      else if (self.watertype == CONTENT_SLIME)
         self.velocity_z = 80;
      else
         self.velocity_z = 50;

// play swiming sound
      if (self.swim_flag < time)
      {
         self.swim_flag = time + 1;
         if (random() < 0.5)
            sound (self, CHAN_BODY, "misc/water1.wav", 1, ATTN_NORM);
         else
            sound (self, CHAN_BODY, "misc/water2.wav", 1, ATTN_NORM);
      }

      return;
   }

   if (!(self.flags & FL_ONGROUND))
      return;

   if ( !(self.flags & FL_JUMPRELEASED) )
      return;      // don't pogo stick

   self.flags = self.flags - (self.flags & FL_JUMPRELEASED);

   self.flags = self.flags - FL_ONGROUND;   // don't stairwalk
   
   self.button2 = 0;
// player jumping sound
   sound (self, CHAN_BODY, "player/plyrjmp8.wav", 1, ATTN_NORM);
   self.velocity_z = self.velocity_z + 270;
};
The night is young. How else can I annoy the world before sunsrise? 8) Inquisitive minds want to know ! And if they don't -- well like that ever has stopped me before ..
User avatar
Baker
 
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Postby mh » Mon Mar 28, 2011 1:51 pm

For slipperly floors play with the value of sv_friction. Also look at sv_edgefriction.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Re: Questions on the player controlller

Postby Nahuel » Mon Mar 28, 2011 3:00 pm

Corrected below! :oops: :oops:
Last edited by Nahuel on Mon Mar 28, 2011 3:34 pm, edited 1 time in total.
hi, I am nahuel, I love quake and qc.
User avatar
Nahuel
 
Posts: 492
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Re: Questions on the player controlller

Postby Nahuel » Mon Mar 28, 2011 3:33 pm

Nahuel wrote:
JasonX wrote:2) Double-jumping. I saw a few threads about it, but it seems a little hackish. Has this been done in a more elegant way? Also, how do i make the player double-jump any time during the jump, not just when the first jump apex is reached?

very interesting question, I had never wondered something like that.
I created the following code and I hope I hope that you will like.

First in defs.qc put this line near to the end;
.float salto;

later change the code PlayerJump that is in client.qc with this new

void() PlayerJump =
{
local vector start, end;
if (self.flags & FL_WATERJUMP)
return;
if (self.waterlevel >= 2)
{
if (self.watertype == CONTENT_WATER)
self.velocity_z = 100;
else if (self.watertype == CONTENT_SLIME)
self.velocity_z = 80;
else
self.velocity_z = 50;

// play swiming sound
if (self.swim_flag < time)
{
self.swim_flag = time + 1;
if (random() < 0.5)
sound (self, CHAN_BODY, "misc/water1.wav", 1, ATTN_NORM);
else
sound (self, CHAN_BODY, "misc/water2.wav", 1, ATTN_NORM);
}

return;
}


if (self.flags & FL_ONGROUND)
self.salto == 0;

if (self.salto == 0)
{
if ( !(self.flags & FL_JUMPRELEASED) )
return; // don't pogo stick
if ( !(self.flags & FL_ONGROUND) )
return; // don't pogo stick


self.flags = self.flags - (self.flags & FL_JUMPRELEASED);

self.flags = self.flags - FL_ONGROUND; // don't stairwalk

self.button2 = 0;
// player jumping sound
sound (self, CHAN_BODY, "player/plyrjmp8.wav", 1, ATTN_NORM);
if
(self.velocity_z >= 0);

self.velocity_z = self.velocity_z + 280;

self.salto = self.salto + 1;
}
if (self.salto == 1)
{
if ( !(self.flags & FL_JUMPRELEASED) )
return; // don't pogo stick

self.flags = self.flags - (self.flags & FL_JUMPRELEASED);

self.flags = self.flags - FL_ONGROUND; // don't stairwalk
if
(self.velocity_z >= 0);

self.velocity_z = self.velocity_z + 280;
if
(self.velocity_z < 0); // I believe the problem is here

self.velocity_z = 300 + (random() * 20);

self.button2 = 0;
// player jumping sound
sound (self, CHAN_BODY, "player/plyrjmp8.wav", 1, ATTN_NORM);
self.salto = 0;
}

};


this gave me an idea, a species of ladder-wall similar to those of megaman!!!!!!!!! I will try to make it
:D :D :D
hi, I am nahuel, I love quake and qc.
User avatar
Nahuel
 
Posts: 492
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Re: Questions on the player controlller

Postby mankrip » Wed Mar 30, 2011 2:21 am

JasonX wrote:3) Dashing. How can i make the player run for a few seconds if he double-tapped the forward button?

The quick way is to piggyback an impulse into the +forward command, through an alias:
Code: Select all
alias +forward_dash "+forward;impulse 69"
alias -forward_dash "-forward"

And then you can create a new .float in the QC code to track the last time this impulse was pressed, and execute the dash function if the last time this impulse has been pressed is too close to the current time it has been pressed.
Ph'nglui mglw'nafh mankrip Hell's end wgah'nagl fhtagn.
==-=-=-=-=-=-=-=-=-=-==
Dev blog / Twitter / YouTube
User avatar
mankrip
 
Posts: 915
Joined: Fri Jul 04, 2008 3:02 am


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest