Impulse?

Discuss programming in the QuakeC language.
Post Reply
Blackstar1000
Posts: 52
Joined: Mon Sep 13, 2010 5:16 pm

Impulse?

Post by Blackstar1000 »

Does Quake have a problem reading many Impulses at once? As far as I can tell if two are called simultaneously it may reject one of them?

If, for example I did something of this sort


bind a +walking_left
alias +walking_left "impulse 19; +moveleft"
alias -walking_left "impulse 19; -moveleft"

bind d +walking_right
alias +walking_right "impulse 18; +moveright"
alias -walking_right "impulse 18; -moveright"


If I were to press A and D at the same time, as far as I can tell, the impulses come out all screwy. Any Idea?
Knives out. Catch the mouse. Squash his head. Put him in your mouth.
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: Impulse?

Post by Spike »

inpulses are unreliable. issue two of them at once and it'll forget the older one. enjoy.
metlslime
Posts: 316
Joined: Tue Feb 05, 2008 11:03 pm

Re: Impulse?

Post by metlslime »

only one impulse can be sent by the client per frame.
Blackstar1000
Posts: 52
Joined: Mon Sep 13, 2010 5:16 pm

Re: Impulse?

Post by Blackstar1000 »

This is terrible news. =(
Knives out. Catch the mouse. Squash his head. Put him in your mouth.
Blackstar1000
Posts: 52
Joined: Mon Sep 13, 2010 5:16 pm

Re: Impulse?

Post by Blackstar1000 »

Follow up Question. If I have a " void Chaseright_Toggle() ' in my client.qc That is activated by an impulse when I press "D" to move right.

How would I substitute using an impulse? How in QuakeC could I say...

"If the player is walking to the right, activate void Chaseright_Toggle() " ?


in weapons.qc

Code: Select all

if (self.impulse == 18) {Chaseright_Toggle();}
in autoexec.cfg

Code: Select all

alias +walking_right "impulse 18; +moveright"
is the exact stuff I need to replace.
Knives out. Catch the mouse. Squash his head. Put him in your mouth.
metlslime
Posts: 316
Joined: Tue Feb 05, 2008 11:03 pm

Re: Impulse?

Post by metlslime »

maybe look at the player's "angles" and their "velocity" and figure out from that if they are moving towards their right or left
Blackstar1000
Posts: 52
Joined: Mon Sep 13, 2010 5:16 pm

Re: Impulse?

Post by Blackstar1000 »

Stayed up all night getting the velocity check right. Success!

Any hints on where to start getting the directions for Forward, Back, Left, and Right.?
Knives out. Catch the mouse. Squash his head. Put him in your mouth.
frag.machine
Posts: 2126
Joined: Sat Nov 25, 2006 1:49 pm

Re: Impulse?

Post by frag.machine »

Blackstar1000 wrote:Stayed up all night getting the velocity check right. Success!

Any hints on where to start getting the directions for Forward, Back, Left, and Right.?
Here goes some small code snippets from a mod I am working.
There are more stuff here than you're asking, but I think this can be useful for others, too.
I am assuming Darkplaces or any engine supporting the .movement vector.

First, to check the speed values to "run" or "walk", declare 2 globals like:

Code: Select all

float 	runspeed;
float 	walkspeed;
And then, place this at the top of PlayerPreThink:

Code: Select all

	runspeed = cvar ("sv_maxspeed");
	walkspeed = runspeed * cvar ("cl_movespeedkey");		
This way, no matter what the speed set for run or walk, the mod automatically "understands" it.

Check if the player is on air (jumping or falling) or over some solid surface:

Code: Select all

if (!self.flags & FL_ONGROUND)
Check if the player is strafing left:

Code: Select all

if (self.movement_y < -10)
Check if the player is strafing right:

Code: Select all

if (self.movement_y > 10)
Check for forward movement:

Code: Select all

if (self.movement_x > 0) {// walking or running}

Code: Select all

if (self.movement_x > walkspeed) {// running}
Check for backward movement:

Code: Select all

if (self.movement_x < 0) {// backwards}
To detect if the player is jumping or actually just walking over a slope (like stairs or a sidewalk). Took me a good amount of time to make it work right:

Code: Select all

float absspeed = fabs(self.velocity_z);
if (absspeed >= walkspeed) {
// play a jump animation, for example
}
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
Blackstar1000
Posts: 52
Joined: Mon Sep 13, 2010 5:16 pm

Re: Impulse?

Post by Blackstar1000 »

::EDIT:: Again ::: AGAIN::: ::AGAIN:::!! Saved me hours upon hours of work. These movement checks are unbelievable! My only problem was that I needed to add the .vector to the defs. ( I guess the darkplaces code comes with this initially )
But I figured it out immediately.

I was able to rewrite a huge chunk of my third person camera code more efficiently. It's amazing how perfect I was able to get it. The rest of these code blocks I am now looking into. Thanks again. I'm starting to feel more and more comfortable leaving my actionscript days behind me thanks to help like this.
Knives out. Catch the mouse. Squash his head. Put him in your mouth.
Post Reply