detecting if player is runing

Discuss programming in the QuakeC language.
Post Reply
Nahuel
Posts: 495
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

detecting if player is runing

Post by Nahuel »

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.
mankrip
Posts: 924
Joined: Fri Jul 04, 2008 3:02 am

Re: detecting if player is runing

Post by mankrip »

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
Nahuel
Posts: 495
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Re: detecting if player is runing

Post by Nahuel »

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.
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: detecting if player is runing

Post by Spike »

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
Baker
Posts: 3666
Joined: Tue Mar 14, 2006 5:15 am

Re: detecting if player is runing

Post by Baker »

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 ..
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Re: detecting if player is runing

Post by frag.machine »

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)
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: detecting if player is runing

Post by Spike »

"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.
r00k
Posts: 1111
Joined: Sat Nov 13, 2004 10:39 pm

Re: detecting if player is runing

Post by r00k »

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... :|
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Re: detecting if player is runing

Post by frag.machine »

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)
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: detecting if player is runing

Post by Spike »

.movement is a dp extension.
r00k
Posts: 1111
Joined: Sat Nov 13, 2004 10:39 pm

Re: detecting if player is runing

Post by r00k »

ack note toself add .movement extention
drm_wayne
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: detecting if player is runing

Post by drm_wayne »

afaik p0x qcv1.06 addons have this feature in the footsteps, if you run the play faster...
leileilol
Posts: 2783
Joined: Fri Oct 15, 2004 3:23 am

Re: detecting if player is runing

Post by leileilol »

I believe the p0x method is dropping entities and comparing their vector lengths with the current player origin.
i should not be here
Post Reply