Limiting velocity
-
- Posts: 65
- Joined: Fri Feb 25, 2005 5:03 pm
Limiting velocity
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?
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.
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![Big Grin :D](./images/smilies/icon_biggrin.gif)
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
![Big Grin :D](./images/smilies/icon_biggrin.gif)
-
- Posts: 65
- Joined: Fri Feb 25, 2005 5:03 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?
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?
-
- Posts: 65
- Joined: Fri Feb 25, 2005 5:03 pm
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.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?
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. :)
-
- Posts: 65
- Joined: Fri Feb 25, 2005 5:03 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.
![Sad :(](./images/smilies/icon_sad.gif)
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.
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
}
stuffcmd("alias +speed /"impulse 998\n");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 999\n");
then parse the impulse in player_postthink
and use above code to +/- the velocity
-
- Posts: 65
- Joined: Fri Feb 25, 2005 5:03 pm
I'd not thought of this. That's pretty fantastic; I can now kill my mod's dependency on Darkplaces just for the physics.stuffcmd("alias +speed /"impulse 998\n");
stuffcmd("alias -speed /"impulse 999\n");
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!
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_prethinku can use variable in the 2.7 part to customizeCode: 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 }
stuffcmd("alias +speed /"impulse 998\n");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 999\n");
then parse the impulse in player_postthink
and use above code to +/- the velocity
what do you mean parse the impulse?