Index | FAQ | Search | Memberlist | Usergroups | Profile | Log in to check your private messages | Log in | Register

Limiting velocity

| Inside3d Forums Forum Index -> QuakeC Programming

View previous topic :: View next topic
Author | Message
--- | ---
SkinnedAlive Joined: 25 Feb 2005 Posts: 65 |

Posted: Mon Sep 07, 2009 12:27 pm Post subject: 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?
Last edited by SkinnedAlive on Mon Sep 07, 2009 2:16 pm; edited 1 time in total

Back to top |

GiffE Joined: 08 Oct 2006 Posts: 141 Location: USA, CT |

Posted: Mon Sep 07, 2009 1:53 pm Post subject: |

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
_________________
http://www.giffe-bin.net/

Back to top |

Spike Joined: 05 Nov 2004 Posts: 944 Location: UK |

Posted: Mon Sep 07, 2009 4:54 pm Post subject: |

.float maxspeed; Defined that. Change the player's value. In NQ its a scaler (0 = 1). In QW its an absolute speed (0 = immobile). _________________
What's a signature?

Back to top |

SkinnedAlive Joined: 25 Feb 2005 Posts: 65 |

Posted: Sat Sep 12, 2009 8:39 pm Post subject: |

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?

Back to top |

ceriux Joined: 06 Sep 2008 Posts: 969 Location: Florida, USA |

Posted: Sat Sep 12, 2009 10:06 pm Post subject: |

couldnt you just force always run off then set up an impulse for your run? _________________ QuakeDB - Quake ModDB Group

Back to top |

SkinnedAlive Joined: 25 Feb 2005 Posts: 65 |

Posted: Sat Sep 12, 2009 10:36 pm Post subject: |

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...

Back to top |

Supa Joined: 26 Oct 2004 Posts: 122 |

Posted: Tue Sep 15, 2009 9:32 pm Post subject: |

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. :)

Back to top |

SkinnedAlive Joined: 25 Feb 2005 Posts: 65 |

Posted: Tue Sep 15, 2009 10:04 pm Post subject: |

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.

Back to top |

r00k Joined: 13 Nov 2004 Posts: 483 |

Posted: Wed Sep 16, 2009 3:24 am Post subject: |

Quote:
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:
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

Quote:
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

Back to top |

SkinnedAlive Joined: 25 Feb 2005 Posts: 65 |

Posted: Thu Sep 17, 2009 11:14 am Post subject: |

Quote:
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!

Back to top |

Lardarse Joined: 05 Nov 2005 Posts: 243 Location: Bristol, UK |

Posted: Sat Sep 19, 2009 1:23 pm Post subject: |

Impules only go up to 255. 998 becomes 230 and 999 becomes 231. Make sure that you're not clobbering other impulses. _________________ <ekiM> Son, you're writing data structures your CPU can't cache.

Back to top |

r00k Joined: 13 Nov 2004 Posts: 483 |

Posted: Sat Sep 19, 2009 5:43 pm Post subject: |

I originally used the 999 as a pseudo impulse and 998 to differentiate :O sorry bout that

Back to top |

ceriux Joined: 06 Sep 2008 Posts: 969 Location: Florida, USA |

Posted: Tue Oct 20, 2009 2:35 pm Post subject: |

r00k wrote:

Quote:
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:
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

Quote:
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?
_________________
QuakeDB - Quake ModDB Group

Back to top |

Display posts from previous:

| Inside3d Forums Forum Index -> QuakeC Programming | All times are GMT
Page 1 of 1

Jump to:

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpBB © 2004 phpBB Group