Forum

How to tell if the player is aiming straight up?

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

How to tell if the player is aiming straight up?

Postby DusterdooSmock » Wed Mar 23, 2011 6:39 pm

How can i tell it the player is aiming straight up?
I've already tried this:
Code: Select all
if(pointcontents(self.origin) == CONTENT_SKY)


But, sadly it didn't work.

Is there another way to check if the player is aiming up?

Thanks.
DusterdooSmock
 
Posts: 170
Joined: Thu Aug 19, 2010 9:58 pm

Postby ceriux » Wed Mar 23, 2011 7:01 pm

maybe use something like this instead?

Code: Select all
.vector      v_angle;      // view / targeting angle for players
User avatar
ceriux
 
Posts: 2223
Joined: Sat Sep 06, 2008 3:30 pm
Location: Indiana, USA

Postby Spike » Wed Mar 23, 2011 7:28 pm

check self.v_angle_z or something.
of course, it'll never be directly upwards, because you can't aim directly upwards in quake - you can normally only aim within 150 degrees.
and even in engines with such cheats enabled, there is always network precision issues, so really the best you can do is within 11 degrees of directly vertical or something clumsy like that.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby mh » Wed Mar 23, 2011 7:31 pm

v_angle is the one. By default Quake limits the pitch angle to between 80 and -70 degrees, so 80 is straight up. Some engines have relaxed this limitation, so that pitch can go from 90 to -90, and other engines have cvar-ized it, so a player might want to set a cl_maxpitch of 45 for some reason.

The values of cl_maxpitch, cl_fullpitch, pq_fullpitch or whatever cannot be reliably accessed from QC as QC runs on the server and these cvars only exist on the client.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Postby DusterdooSmock » Wed Mar 23, 2011 7:36 pm

Spike wrote:check self.v_angle_z or something.
of course, it'll never be directly upwards, because you can't aim directly upwards in quake - you can normally only aim within 150 degrees.
and even in engines with such cheats enabled, there is always network precision issues, so really the best you can do is within 11 degrees of directly vertical or something clumsy like that.


It didn't work. I checked for self.v_angle_z to equal 90 and i tried 150, but maybe i was doing it wrong..

This is how i tested it:
Code: Select all
if(self.v_angle_z == 90)
      centerprint(self, "You're aiming at the ceiling dumbass!\n");
DusterdooSmock
 
Posts: 170
Joined: Thu Aug 19, 2010 9:58 pm

Postby mh » Wed Mar 23, 2011 7:47 pm

Check my post above: 90 is not a valid value in most engines, 80 is the default max pitch. Also bear in mind what Spike said about network precision and 11 degrees or thereabouts. So you should really be checking for > 65 or so.
We had the power, we had the space, we had a sense of time and place
We knew the words, we knew the score, we knew what we were fighting for
User avatar
mh
 
Posts: 2292
Joined: Sat Jan 12, 2008 1:38 am

Postby DusterdooSmock » Wed Mar 23, 2011 8:09 pm

No luck, I even checked to see if it was > 0 but even that didnt work. :(
DusterdooSmock
 
Posts: 170
Joined: Thu Aug 19, 2010 9:58 pm

Postby metlslime » Wed Mar 23, 2011 8:31 pm

1. Positive values of pitch indicate looking downwards. Negative values are for looking up.

2. In default engines, -70 is the highest you can look upwards.

3. With 8-bit angles, the angle is sent over the network to the nearest multiple of 1.4 degrees, so add a margin of error of 1-2 degrees to be safe

4. angles are stored as pitch,yaw,roll i think, so _x is pitch, _y is yaw, and _z is roll -- you will have to check to confirm this.
metlslime
 
Posts: 316
Joined: Tue Feb 05, 2008 11:03 pm

Postby DusterdooSmock » Wed Mar 23, 2011 8:55 pm

metlslime wrote:1. Positive values of pitch indicate looking downwards. Negative values are for looking up.

2. In default engines, -70 is the highest you can look upwards.

3. With 8-bit angles, the angle is sent over the network to the nearest multiple of 1.4 degrees, so add a margin of error of 1-2 degrees to be safe

4. angles are stored as pitch,yaw,roll i think, so _x is pitch, _y is yaw, and _z is roll -- you will have to check to confirm this.


OK, i got it to recognize the angles..now i just have to do some adjusting.

Thanks guys.
DusterdooSmock
 
Posts: 170
Joined: Thu Aug 19, 2010 9:58 pm


Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest