PDA

View Full Version : [CoD 1.1] Can you get player's bearing ?



raphael
28th February 2023, 11:01
Hi

When I enter /viewpos, I don't get the degree bearing value of the compass, I don't know if there is a command to get it

Is there a formula to calculate the bearing using player's position ?

I would like players on my server to get a "bar compass" on top of the screen like in modern games

IzNoGoD
28th February 2023, 20:48
use getplayerangles() from a script (gsc) file. player.angles is kinda bugged and only returns a nonzero value for the [1] index.

Also, in cod2 /viewpos returns your left/right angle as the final number, not sure about cod1.

raphael
1st March 2023, 11:16
use getplayerangles() from a script (gsc) file. player.angles is kinda bugged and only returns a nonzero value for the [1] index.

Also, in cod2 /viewpos returns your left/right angle as the final number, not sure about cod1.

I didn't know about getplayerangles() vs player.angles, thank you

I struggle to understand all these values, this is the first time I use angles/vectors, and I don't practice math.

Attached is a screenshot showing a /viewpos output and the compass
1696

Do you know if there could be a formula to obtain the compass degree value, using player.origin / getplayerangles() ?

kung foo man
2nd March 2023, 09:20
The last number is already the euler angle, in CoD2 it seems to be 360 - theGivenLastNumber.

Based on the image in CoD1, it could be -161 + 360 + 40 = 239

IzNoGoD
2nd March 2023, 19:05
cod4 has an option to set the "north" direction. Maybe that is at play here too?

raphael
4th March 2023, 06:11
it could be -161 + 360 + 40 = 239

Do you know how the third number could be obtained ?
I guess you need to use player.origin and some data from the map file ?


cod4 has an option to set the "north" direction. Maybe that is at play here too?

Is this option to get the compass to always face the north ? Or to make it think that the west is the north for example ?

_______

I'm sorry I should install the game and search in it, and try harder to find how to get the third value
The thing is that I think I'm giving up on this "bar compass"
Mostly because if I manage to put that on top of players' screen, I would really want to modify the stock compass to remove the degree info and the needle

But doing so I think I would have to use fs_game to prevent the changes from being applied on other servers

And with 1.1, when you go to a server after being on a modded server, you get a cd key error, game restart is needed (i don't remember if entering key again works), and I don't want my server to cause this error anymore (i prefer not to replace players' .exe client file actually)

I would have also liked to make a new radar and remove the stock one (because it shows dead friends, pointers are too small/not enough flashy imo etc...)

kung foo man
5th March 2023, 09:33
1698

You can write a function like:



checkAngles() {
while (1) {
players = getentarray("player", "classname");
for (i = 0; i < players.size; i++) {
player = players[i];
angles = player getPlayerAngles();
player iprintlnbold("angles", angles);
}
wait 1;
}
}

Or including the yaw in output:



checkAngles() {
while (1) {
players = getentarray("player", "classname");
for (i = 0; i < players.size; i++) {
player = players[i];
angles = player getPlayerAngles();
yaw = angles[1];
player iprintlnbold("angles ", angles, "yaw ", yaw);
}
wait 1;
}
}

And just add it somewhere via thread checkAngles();

So the actual value is yaw = player getPlayerAngles()[1] (as @IzNoGoD pointed out)

raphael
7th March 2023, 17:34
By third number I meant 40 from here :

-161 + 360 + 40 = 239

But thank you for your message, it's really appreciated

Did you mean 40 is the yaw ?

Here I attach two new screenshots with all the info I've been able to grab when having a compass bearing of 120°

1701
1702

I really don't see how to obtain 120 using all that :/

kung foo man
8th March 2023, 12:59
It should be rather easy, simply note the numbers:

0, 45, 90, 135, 180, 225, 270, 315, 360 (same as 0)

And write down the corresponding degrees you see on the compass... after max 2/3 numbers you should see the pattern, since it should be a simple linear offset