Forum

Limiting velocity

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Limiting velocity

Postby SkinnedAlive » Mon Sep 07, 2009 12:27 pm

If I wanted to limit the player's running velocity on the fly, but still allow for them to be fully affected by explosions and such then where would I make this change? Is this possible? Presumably stuffcmding sv_maxvelocity every frame is a very bad idea.

Bonus questions:
Is there a way to offset weapon models through QC or would I have to add new animations to do this?
Is there an easy way to add extra HUD elements via Darkplaces?
Last edited by SkinnedAlive on Mon Sep 07, 2009 2:16 pm, edited 1 time in total.
SkinnedAlive
 
Posts: 65
Joined: Fri Feb 25, 2005 5:03 pm

Postby GiffE » Mon Sep 07, 2009 1:53 pm

Well you cant stuff an sv_ cvar, they are server sided and have no effect on individual players anyway. They change the everyone's max speed.

That said, if your using darkplaces use DP_SV_PLAYERPHYSICS
You can use dpmod's playermovement.qc then you can manipulate individuals speed.

Question B:
You CAN offset viewmodels if you spawn your own viewmodel and use DP_ENT_VIEWMODEL. Then you can change its origin and angle to your hearts content.

Question C:
CSQC is meant for that kind of thing. Learn it :D
GiffE
 
Posts: 170
Joined: Sun Oct 08, 2006 3:39 pm
Location: USA, CT

Postby Spike » Mon Sep 07, 2009 4:54 pm

.float maxspeed;

Defined that. Change the player's value.
In NQ its a scaler (0 = 1).
In QW its an absolute speed (0 = immobile).
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby SkinnedAlive » Sat Sep 12, 2009 8:39 pm

Thank you for your help. I eventually achieved this with LordHavoc's sv_user.qc.

I have another question though; how would I find out whether the player is running (using +speed) or not via the QC. Is there an easy way to do this or am I going to have to go to the trouble of learning CSQC (CSQC_ConsoleCommand?) or making my own run button via impulse commands?
SkinnedAlive
 
Posts: 65
Joined: Fri Feb 25, 2005 5:03 pm

Postby ceriux » Sat Sep 12, 2009 10:06 pm

couldnt you just force always run off then set up an impulse for your run?
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Postby SkinnedAlive » Sat Sep 12, 2009 10:36 pm

I could, but the redundancy of having multiple run commands in place is really awkward and I'd like to avoid having extra commands to bind if at all possible.

I guess I may just have to suck it up and do that though...
SkinnedAlive
 
Posts: 65
Joined: Fri Feb 25, 2005 5:03 pm

Postby Supa » Tue Sep 15, 2009 9:32 pm

SkinnedAlive wrote:I have another question though; how would I find out whether the player is running (using +speed) or not via the QC. Is there an easy way to do this or am I going to have to go to the trouble of learning CSQC (CSQC_ConsoleCommand?) or making my own run button via impulse commands?

Watch the client's .movement vector inside SV_PlayerPhysics - movement_x is +forward and +back, movement_y is +left and +right, and this vector is filled out by the user's defined cl_*speed cvars. For example, if you set cl_forwardspeed to 230 and turn always run off, holding +forward will give you a .movement_x of +230. Remember that +speed will effectively multiply .movement by what cl_movespeedkey is set to, though it'll be capped off by sv_maxspeed if it's too high. So setting sv_maxspeed to 350, your cl_forwardspeed to 400, cl_movespeedkey to 2.0 and holding +speed would give you a .movement_x of 800, which would then be capped by sv_maxspeed to 350.

Since you're using SV_PlayerPhysics, I'll assume you would be comfortable with forcing the cl_*speed and cl_movespeedkey cvars in default.cfg. Basically what you would want to do at this point is force the cl_*speed cvars to what you want your walking speed to be in addition to forcing always run off. From there it's just a matter of watching .movement and seeing if any component exceeds your set walking speed. Don't forget that player physics are run every server frame, so you'll want to put a timer on any thing that walking or running triggers or it'll become framerate dependant.

Naturally, this will all go out the window if the user turns always run back on or tweaks the cl_*speed cvars after loading a map.. But in that case they'll probably just end stuck with whatever effects you want to impose on a running player, so it may as well not be a case you'll need to worry about. :)
User avatar
Supa
 
Posts: 164
Joined: Tue Oct 26, 2004 8:10 am

Postby SkinnedAlive » Tue Sep 15, 2009 10:04 pm

Thanks for the comprehensive explanation, Supa! In the end I had to go for making my own run impulse (yet another key to bind :( ) but it works beautifully now.

On another note (rather than make a new thread about it), Darkplaces seems to be throwing up these warnings a lot of the time when the game is saved: "PRVM_GetString: Invalid temp-string offset (0 >= 0 vm_tempstringsbuf.cursize)"

Anybody have any idea what this is about? I'm pretty sure it's my mod's doing.
SkinnedAlive
 
Posts: 65
Joined: Fri Feb 25, 2005 5:03 pm

Postby r00k » Wed Sep 16, 2009 3:24 am

If I wanted to limit the player's running velocity on the fly, but still allow for them to be fully affected by explosions and such then where would I make this change? Is this possible?



I've used this in the past in player_prethink
Code: Select all
      if ((self.flags) & FL_ONGROUND)
      {
         self.velocity_x = (1 - (2.7) * frametime)) * (self.velocity_x);// slow down ball carrier
         self.velocity_y = (1 - (2.7) * frametime)) * (self.velocity_y);// slow down ball carrier
      }

u can use variable in the 2.7 part to customize

I have another question though; how would I find out whether the player is running (using +speed) or not via the QC


stuffcmd("alias +speed /"impulse 998\n");
stuffcmd("alias -speed /"impulse 999\n");

then parse the impulse in player_postthink

and use above code to +/- the velocity
r00k
 
Posts: 1110
Joined: Sat Nov 13, 2004 10:39 pm

Postby SkinnedAlive » Thu Sep 17, 2009 11:14 am

stuffcmd("alias +speed /"impulse 998\n");
stuffcmd("alias -speed /"impulse 999\n");


I'd not thought of this. That's pretty fantastic; I can now kill my mod's dependency on Darkplaces just for the physics.

Speaking of Darkplaces, I'm still getting these PRVM_GetString warnings although they seem to be otherwise symptomless. Anybody have any idea what in QuakeC might cause this? A local string of something like that maybe?

After that I think I'm pretty much done with the code on this mod (fingers crossed).

EDIT: Nevermind, the warning went away after switching away from sv_user.qc. Everything works great now. The next challenge is mapping. Thanks for your help everybody!
SkinnedAlive
 
Posts: 65
Joined: Fri Feb 25, 2005 5:03 pm

Postby Lardarse » Sat Sep 19, 2009 1:23 pm

Impules only go up to 255. 998 becomes 230 and 999 becomes 231. Make sure that you're not clobbering other impulses.
Roaming status: Testing and documentation
User avatar
Lardarse
 
Posts: 266
Joined: Sat Nov 05, 2005 1:58 pm
Location: Bristol, UK

Postby r00k » Sat Sep 19, 2009 5:43 pm

I originally used the 999 as a pseudo impulse and 998 to differentiate :O
sorry bout that
r00k
 
Posts: 1110
Joined: Sat Nov 13, 2004 10:39 pm

Postby ceriux » Tue Oct 20, 2009 2:35 pm

r00k wrote:
If I wanted to limit the player's running velocity on the fly, but still allow for them to be fully affected by explosions and such then where would I make this change? Is this possible?



I've used this in the past in player_prethink
Code: Select all
      if ((self.flags) & FL_ONGROUND)
      {
         self.velocity_x = (1 - (2.7) * frametime)) * (self.velocity_x);// slow down ball carrier
         self.velocity_y = (1 - (2.7) * frametime)) * (self.velocity_y);// slow down ball carrier
      }

u can use variable in the 2.7 part to customize

I have another question though; how would I find out whether the player is running (using +speed) or not via the QC


stuffcmd("alias +speed /"impulse 998\n");
stuffcmd("alias -speed /"impulse 999\n");

then parse the impulse in player_postthink

and use above code to +/- the velocity



what do you mean parse the impulse?
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest