Forum

detecting if player is runing

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

detecting if player is runing

Postby Nahuel » Mon Apr 01, 2013 6:15 pm

is there a way to know if the player is pressing the "+speed" button? i know is possible to know if the player is pressing button1 for example
Code: Select all
if (self.button1)

:) thanks in advance
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: detecting if player is runing

Postby mankrip » Mon Apr 01, 2013 7:07 pm

Without some extension like CSQC, probably not.

Maybe you can check the value from self.movement (which only works in some engines), and see if it matches the velocity for the running. This won't work if the running speed cvars have been modified.
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

Re: detecting if player is runing

Postby Nahuel » Mon Apr 01, 2013 7:13 pm

i am using
Code: Select all
vlen (self.velocity)  > ...
but i need to know if the player is pressing the button , do you know what about csqc and button pressed?
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: detecting if player is runing

Postby Spike » Mon Apr 01, 2013 7:32 pm

I'm not really trying to troll... but who out there actually uses +speed (as opposed to always-run)?
does it actually make sense to try to detect it?
ssqc has no way to distinguish between +speed and merely setting cl_forwardspeed to 400 (aka: always-run) or so.

The evil way:
alias +speed +button5
alias -speed -button5
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: detecting if player is runing

Postby Baker » Mon Apr 01, 2013 8:48 pm

Check onground flag and check velocity > 200 (or so depending on what you expect) ?

Sure this doesn't check the button, but if the player is pressing the run button and forward while standing in a corner facing the corner, is he actually running?

[Does QuakeC get to know "wish velocity" [desired speed client sends to server?]
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

Re: detecting if player is runing

Postby frag.machine » Tue Apr 02, 2013 1:05 am

Baker wrote:Check onground flag and check velocity > 200 (or so depending on what you expect) ?


This actually can work pretty well. I already used this. In Darkplaces the relation between running/walking speed is controlled by a cvar (cl_movespeedkey, default = 2.0). In other engines this relation is fixed in 2.
Basically, check your effective speed (doing some nasty math with self.velocity or directly with .movement if available) against sv_maxspeed / factor; if lower or equals, it's walking.

As a side note cl_movespeedkey with values below 1.0 actually slow down the player. This can be handy for stalking mods (like in the shadows).
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Re: detecting if player is runing

Postby Spike » Tue Apr 02, 2013 2:17 am

"Does QuakeC get to know "wish velocity" [desired speed client sends to server?]"
.movement is exactly that.
not fantastically different from velocity, but doesn't get clipped by sv_maxspeed, has lower latency, and works even if they're stupid enough to be running into a wall.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: detecting if player is runing

Postby r00k » Tue Apr 02, 2013 2:44 pm

player.qc uses this
Code: Select all
   if (self.velocity_x || self.velocity_y)
   {
      self.walkframe=0;
      player_run();
      return;
   }

you can just before the self.walkframe=0; test for how fast. Like Baker suggested >200 is running/+speed is on...

Spike I cant find .movement in vanilla qc... :|
r00k
 
Posts: 1110
Joined: Sat Nov 13, 2004 10:39 pm

Re: detecting if player is runing

Postby frag.machine » Wed Apr 03, 2013 1:33 am

r00k wrote:Spike I cant find .movement in vanilla qc... :|


IIRC not all engines support it, or it's like the .gravity field that is supported by Quake 1.08 and above, because it was added in hipnotic. Memory is failing a lot today (I need sleep)...
EDIT: also, vanilla QC just tests if the player is in movement, it doesn't check if running or just walking (since the animations are the same).
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Re: detecting if player is runing

Postby Spike » Wed Apr 03, 2013 1:46 am

.movement is a dp extension.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Re: detecting if player is runing

Postby r00k » Thu Apr 04, 2013 3:10 am

ack note toself add .movement extention
r00k
 
Posts: 1110
Joined: Sat Nov 13, 2004 10:39 pm

Re: detecting if player is runing

Postby drm_wayne » Tue Apr 09, 2013 6:40 pm

afaik p0x qcv1.06 addons have this feature in the footsteps, if you run the play faster...
User avatar
drm_wayne
 
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: detecting if player is runing

Postby leileilol » Tue Apr 09, 2013 8:11 pm

I believe the p0x method is dropping entities and comparing their vector lengths with the current player origin.
i should not be here
leileilol
 
Posts: 2783
Joined: Fri Oct 15, 2004 3:23 am


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest