PDA

View Full Version : v_angle.y is always 0 ???


Austin
24-02-2005, 07:02
In cz, client, these are always 0.
LOG_CONSOLE(PLID, "v_angle= %d\n",serverEntity->v.v_angle.y);
LOG_CONSOLE(PLID, "angles = %d\n",serverEntity->v.angles.y);

Why is that?
I need to
1) have the direction the player is pointing (like when you turn using the mouse and look in some direction)
2) I need to set the direction to 0 to force the player to look in the 0 direction.

Whistler
24-02-2005, 08:21
the "serverEntity" seems to be INDEXENT(0), which is the worldspawn entity instead of players...

also I don't think CZero is different from CS 1.6, as the dll file is actually the same (use "fc" in Windows or diff in GNU/Linux to check). The client's pev->angles.y and pev->v_angle.y shouldn't be zero

Whistler
24-02-2005, 09:06
I think I've found your problem... the problem is about the "%d":

whistler@www:~$ cat 1.c
#include <stdio.h>
main()
{
float a = 20;
printf("%d\n", a);
printf("%f\n", a);
}

whistler@www:~$ gcc 1.c
whistler@www:~$ ./a.out
0
20.000000
whistler@www:~$

use %f instead, or cast it to integer value and you'll get the right result

Pierre-Marie Baty
24-02-2005, 12:15
aren't you ashamed of asking questions like that, Austin man... :D

Austin
24-02-2005, 21:13
Da! -DAAAAAhh!!!
Ok can I say it was REALLY late last night!
Noooo. please wipe delete this msg from the server!...
Ashamed, yes, totally shamed... Balaaagg...

But even so you wouldn't think the implicit cast would work that way now do ya...


Either give me a compile warning, or do a "reasonable" cast ok?

tx. everyone.

Rick
24-02-2005, 21:53
Its better to use %f than casting...
Otherwise you can try c++ style casting:

LOG_CONSOLE(PLID, "v_angle= %d\n",static_cast<int>(serverEntity->v.v_angle.y));

Pierre-Marie Baty
24-02-2005, 22:52
that's the problem with you guys overused to C++... you cannot even format a printf string properly :D

If you want to round a float value use %.nf, where n is the number of digits you want after the dot.

dub
25-02-2005, 01:46
ex.

LOG_CONSOLE (PLID, "v_angle= %0.2f\n", serverEntity->v.v_angle.y);

round it to two decimal points ;).
Sorry guys i haven`t been here for awhile, ive been really busy helping out a cs : s clan :D.

Austin
25-02-2005, 08:57
Ok, now that I am printing out the angles.
I am trying to create spawn points for my map editor.

I need to generate a line like this:
"angles" "0 90 0"
For spawn points the angles are 0,90,180,270,

My primitive understanding of angles is:
In the map we have x,y,z coordinates.

If I spawn into the map with a spawnpoint like this:
{
"origin" "16 -1872 -416"
"angles" "0 0 0"
"classname" "info_player_deathmatch"
}

I will spawn into the map aligned on the x axis facing the direction where x “get smaller”

This is true for the MAP coordinates I guess.
But it looks like the angles go from 0 to180 and 0 to –180.

I could do the conversion but I bet there is some standard code or a function call to convert this to 0-360.

Any suggestions?

Rick
25-02-2005, 11:35
Just substract -180 from the y and z angle and wrap them with something like this:

float WrapYZAngle(float angle)
{
while (angle >= 360.0f) angle -= 360.0f;
while (angle < 0.0f) angle += 360.0f;

return angle;
}

koraX
25-02-2005, 15:07
Just substract -180 from the y and z angle and wrap them with something like this:float WrapYZAngle(float angle)
{
while (angle >= 360.0f) angle -= 360.0f;
while (angle < 0.0f) angle += 360.0f;
return angle;
}
bad solution, if angle is big number, subtracting 360 won't help and you have deadlock.

http://wiki.bots-united.com/index.php/Bot_Aiming#The_WrapAngle_facility

And for austin, all about angles (http://wiki.bots-united.com/index.php/Player_angles)

Pierre-Marie Baty
25-02-2005, 15:25
good, KoraX ;)
Feed our wiki, guys, feed our wiki :)

Rick
25-02-2005, 17:17
bad solution, if angle is big number, subtracting 360 won't help and you have deadlock.

http://wiki.bots-united.com/index.php/Bot_Aiming#The_WrapAngle_facility

And for austin, all about angles (http://wiki.bots-united.com/index.php/Player_angles)

Heh I just copied that code from Cube :-\ Something is wrong if you have very big numbers anyway...
But I like your macros, going to use that :)

stefanhendriks
25-02-2005, 17:24
Da! -DAAAAAhh!!!
Ok can I say it was REALLY late last night!
Noooo. please wipe delete this msg from the server!...
Ashamed, yes, totally shamed... Balaaagg...

But even so you wouldn't think the implicit cast would work that way now do ya...


Either give me a compile warning, or do a "reasonable" cast ok?

tx. everyone.

perhaps you could turn up your warning level of y our compiler? I used to set the MSVC compiler on pretty high (level 4?) so it would complain about every 'conversion' i did with %d (and use floats, etc)...

Whistler
26-02-2005, 07:48
perhaps you could turn up your warning level of y our compiler? I used to set the MSVC compiler on pretty high (level 4?) so it would complain about every 'conversion' i did with %d (and use floats, etc)...

then you will get a lot (really lot!) of warnings from Valve's code, Metamod code and STL files :) And that's actually why I 'stripped' all the external codes like Valve SDK and Metamod, only necessary part is left.

koraX
26-02-2005, 10:51
then you will get a lot (really lot!) of warnings from Valve's code, Metamod code and STL files :) And that's actually why I 'stripped' all the external codes like Valve SDK and Metamod, only necessary part is left.

I heavily stripped metamod (into one file) because it collided with my code.
I also stripped SDK a lot.
I've got warning level 4, I'm using STL everywhere and get no warning. So it is possible :)

Austin
26-02-2005, 21:22
1) The reason I don't chagne my warning level is as you say, it generates too many warnings to be useful. You could use pragma warning but that is a hassle and probably not worth the effort except in certain cases.

2) By modify source from 3rd parties you get into a difficult situation.
What do you do when updates come out? You have to re-clean the 3rd party source. Time consuming and not fun. Perhaps it is ok with the hl1 sdk that doesn't change much if at all, but what about the new source sdk that is and will be changing "every time you logon to steam?..."

sfx1999
27-02-2005, 02:39
You could probably optimize that so if the loop goes five times, you would use modulus intead. It probably won't go five times anyway, but try it.