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

getting up from crouching Goto page 1, 2 Next

| Inside3d Forums Forum Index -> QuakeC Programming

View previous topic :: View next topic
Author | Message
--- | ---
Boss429 Joined: 03 Dec 2006 Posts: 22 |

Posted: Mon Dec 04, 2006 6:26 am Post subject: getting up from crouching |

I followed this tutorial: http://www.inside3d.com/showtutorial.php?id=169 I am trying to fix the bug where you don't stand up automatically after getting out of a tunnel. I put :

Code:
if (self.crouch && !self.impulse == 33) { crouch_off (); }

at the end of CheckPowerups in client.qc.
now when I hit crouch it hops up a little, like a jump or something.
Why does this happen?
My thinking was: IF crouch is on AND the button isn't held down AND you aren't in a tunnel THEN turn crouch off.

Back to top |

DieparBaby Joined: 05 Dec 2006 Posts: 44 Location: London, Ontario, Canada, eh |

Posted: Tue Dec 05, 2006 5:48 pm Post subject: Re: getting up from crouching |

Boss429 wrote:
I followed this tutorial: http://www.inside3d.com/showtutorial.php?id=169 I am trying to fix the bug where you don't stand up automatically after getting out of a tunnel. I put :

Code:
if (self.crouch && !self.impulse == 33) { crouch_off (); }

at the end of CheckPowerups in client.qc.
now when I hit crouch it hops up a little, like a jump or something.
Why does this happen?
My thinking was: IF crouch is on AND the button isn't held down AND you aren't in a tunnel THEN turn crouch off.

Couple problems here, I think. First "!self.impulse == 33" will never be true. It should
be "self.impulse != 33". This is because !self.impulse will be 1 if self.impulse is 0 and !self.impulse will be 0 if self.impulse is any other value.
Second, self.impulse will always be 0 in CheckPowerups because it is set to zero at the end of ImpulseCommands in weapons.qc. So unless an impulse calls a function that calls CheckPowerups, self.impulse will always be 0.

Back to top |

Boss429 Joined: 03 Dec 2006 Posts: 22 |

Posted: Tue Dec 05, 2006 6:34 pm Post subject: Re: getting up from crouching |

DieparBaby wrote:

Boss429 wrote:
I followed this tutorial: http://www.inside3d.com/showtutorial.php?id=169 I am trying to fix the bug where you don't stand up automatically after getting out of a tunnel. I put :

Code:
if (self.crouch && !self.impulse == 33) { crouch_off (); }

at the end of CheckPowerups in client.qc.
now when I hit crouch it hops up a little, like a jump or something.
Why does this happen?
My thinking was: IF crouch is on AND the button isn't held down AND you aren't in a tunnel THEN turn crouch off.

Couple problems here, I think. First "!self.impulse == 33" will never be true. It should
be "self.impulse != 33". This is because !self.impulse will be 1 if self.impulse is 0 and !self.impulse will be 0 if self.impulse is any other value.
Second, self.impulse will always be 0 in CheckPowerups because it is set to zero at the end of ImpulseCommands in weapons.qc. So unless an impulse calls a function that calls CheckPowerups, self.impulse will always be 0.

ah ok, thanks. How should I check to make sure the crouch button is held down?

Back to top |

DieparBaby Joined: 05 Dec 2006 Posts: 44 Location: London, Ontario, Canada, eh |

Posted: Tue Dec 05, 2006 8:22 pm Post subject: |

As far as I know, when you bind a key to an impulse, holding the key down is no different then simply tap the key once. For example, if you set up your mod so that the fire command was done through an impulse and you held down the key that was bound to the impulse, your weapon would only fire once. To fire again, you would have to release the key and hit it again.
According to the crouch tutorial, one impulse (key) makes you crouch and stay crouched and another impulse (key) makes you stand up. If you want to check if you are crouched you have to check the .crouch variable. If its 1 you are crouching, otherwise you aren't.

Back to top |

CocoT Joined: 14 Dec 2004 Posts: 599 Location: Belly-Gum |

Posted: Tue Dec 05, 2006 8:33 pm Post subject: |

Maybe this is going to sound super-silly and, be warned, I'm known in the mod community for my weird fixes and hacks... Maybe you could create an invisible entity at the end and start of tunnels which, once touched, would check if the player is crouching/standing or not and do the impulse for him/her? You know, at the end of whatever tunnel, if the player touches that entity and is close enough to the end to stand up, then that the touch function of that entity would send a signal for the player's impulse to be called?
I'm sure there are better ways to do this, though

Back to top |

DieparBaby Joined: 05 Dec 2006 Posts: 44 Location: London, Ontario, Canada, eh |

Posted: Tue Dec 05, 2006 8:36 pm Post subject: |

If you want to fix this bug, put a check in the code that makes you stand up that does a traceline to see if there is enough space to stand up. I think the player height is 56.

Back to top |

RenegadeC Joined: 15 Oct 2004 Posts: 370 Location: The freezing hell; Canada |

Posted: Tue Dec 05, 2006 8:49 pm Post subject: |

DieparBaby wrote:
If you want to fix this bug, put a check in the code that makes you stand up that does a traceline to see if there is enough space to stand up. I think the player height is 56.

You'll need more than a single traceline as you're only checking the center of the player (or wherever else you're tracelining from the player), you're going to have to check every possible angle along the players bounding box otherwise you're going to get stuck in geometry.
It's best to spawn an invisible entity that's the player size that checks if it's able to move (using walkmove(0,0)) before allowing the player to stand up.
So in possible order of coding:
1. Spawn an invisible entity
2. Invisible entity is players size, and probably above the player to check if it's okay to stand
3. Invisible entity runs a walkmove(0,0) which is stored in a variable that gets sent to the player entity
4. If the variable is true, then you can stand, otherwise no.
I really don't get why this method isn't used more often, I've used it for a few tricks in TAoV such as grabbing monsters and grabbing ledges. The only bad aspect is spawning entities sends a lot of network traffic, but so does the nailgun.

Back to top |

Sajt Joined: 16 Oct 2004 Posts: 1026 |

Posted: Tue Dec 05, 2006 9:12 pm Post subject: |

Invisible entities don't get sent over the network :O _________________ F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.

Back to top |

DieparBaby Joined: 05 Dec 2006 Posts: 44 Location: London, Ontario, Canada, eh |

Posted: Tue Dec 05, 2006 9:26 pm Post subject: |

Renegade: ah. That was kinda simplistic of me.

Back to top |

Boss429 Joined: 03 Dec 2006 Posts: 22 |

Posted: Wed Dec 06, 2006 1:02 am Post subject: |

Well I'd don't really like the thought of placing entities at the end of every tunnel And even if I did I still need to check if the crouch button is held down right? Because what if I'm going through a tunnel and when I get to the other side I keep holding down crouch, wouldn't I get up anyways?
So it sounds like there is no way to check if the crouch button is held down because it's an impulse right? So I'd need to make it like the weapon fire key. Could I make say a "button3" (in Defs.qc) without modifying the engine? I'm using DarkPlaces.

Back to top |

Sajt Joined: 16 Oct 2004 Posts: 1026 |

Posted: Wed Dec 06, 2006 2:06 am Post subject: |

The way you do this without a +button3 is: Console/CFG: alias +crouch "impulse 50" alias -crouch "impulse 51" then in the code, impulse 50 calls the crouching code (e.g. setting a 'crouching' flag), impulse 51 calls the uncrouching code (e.g. removing the 'crouching' flag).
DarkPlaces lets you use +button3, yes. If you look at DPMod, it comes with a file called dpextensions.qc. Just grab this and add it to your progs.src after defs.qc. It includes all the QC declarations required to use DarkPlaces's extra QC features. It includes .button3 (all the way through .button3). So you can check the player's button3 field instead of creating a new one and controlling it with impulses.
_________________
F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.

Back to top |

scar3crow Inside3D Staff Joined: 18 Jan 2005 Posts: 837 Location: Las Vegas, NV

Posted: Wed Dec 06, 2006 2:36 am Post subject: |

Is this for Transfusion? I would assume so since its involving crouching, and Darkplaces - if that is the case, an engine amendment would be acceptable since you guys use your own rate on using the binary... The trigger brush for correcting it would cause problems, aside from complicating map making, because you would have to more than likely have it disable crouching for a few seconds upon touch, otherwise if you held it down you could have a dominance fight between the brush and the player command.
I think RenegadeC got it with sending a test entity using walkmove to see if there is enough valid space - similar to if you would want to check if an area is large enough for a remote teleporter before allowing the player to go on through.

Back to top |

Sajt Joined: 16 Oct 2004 Posts: 1026 |

Posted: Wed Dec 06, 2006 6:10 am Post subject: |

CocoT's idea is completely unnecessary. RenegadeC got it right. Don't listen to CocoT! Sorry CocoT, here have some boobies. _________________ F. A. Špork, an enlightened nobleman and a great patron of art, had a stately Baroque spa complex built on the banks of the River Labe.

Back to top |

Boss429 Joined: 03 Dec 2006 Posts: 22 |

Posted: Wed Dec 06, 2006 6:38 am Post subject: |

Sajt wrote:
The way you do this without a +button3 is: Console/CFG: alias +crouch "impulse 50" alias -crouch "impulse 51" then in the code, impulse 50 calls the crouching code (e.g. setting a 'crouching' flag), impulse 51 calls the uncrouching code (e.g. removing the 'crouching' flag).
DarkPlaces lets you use +button3, yes. If you look at DPMod, it comes with a file called dpextensions.qc. Just grab this and add it to your progs.src after defs.qc. It includes all the QC declarations required to use DarkPlaces's extra QC features. It includes .button3 (all the way through .button3). So you can check the player's button3 field instead of creating a new one and controlling it with impulses.

Ok good, I'll try to adapt the code to use button3 instead of an impulse.

scar3crow wrote:
Is this for Transfusion? I would assume so since its involving crouching, and Darkplaces - if that is the case, an engine amendment would be acceptable since you guys use your own rate on using the binary...

No this isn't for Transfusion, Willis (I'm guessing it was him) already has it coded and it will be available with the next version of Transfusion. I'm just messing around and trying to learn a thing or two about QuakeC. Thanks for the info guys.

Back to top |

CocoT Joined: 14 Dec 2004 Posts: 599 Location: Belly-Gum |

Posted: Wed Dec 06, 2006 8:21 am Post subject: |

Oh n0, noOoOoOOOOooOOooOO! /me 's eyes burn, inflicting CocoT atrocious pain Note: Hey, at least I got the word "invisible" right! But yeah, erm, when it comes to coding tips, it's probably a good idea not to listen to me

Back to top |

Display posts from previous:

| Inside3d Forums Forum Index -> QuakeC Programming | All times are GMT Goto page 1, 2 Next
Page 1 of 2

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