Results 1 to 9 of 9

Thread: [CoD 1.1] Can you get player's bearing ?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Deleter/Deleted
    Join Date
    Jan 2023
    Posts
    76
    Thanks
    40
    Thanked 9 Times in 9 Posts

    [CoD 1.1] Can you get player's bearing ?

    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
    Last edited by raphael; 28th February 2023 at 12:03.

  2. #2
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    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.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  3. The Following User Says Thank You to IzNoGoD For This Useful Post:

    raphael (22nd March 2023)

  4. #3
    Deleter/Deleted
    Join Date
    Jan 2023
    Posts
    76
    Thanks
    40
    Thanked 9 Times in 9 Posts
    Quote Originally Posted by IzNoGoD View Post
    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
    viewpos compass.png

    Do you know if there could be a formula to obtain the compass degree value, using player.origin / getplayerangles() ?
    Last edited by raphael; 1st March 2023 at 12:18.

  5. #4
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,010
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    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
    timescale 0.01

  6. The Following User Says Thank You to kung foo man For This Useful Post:

    raphael (22nd March 2023)

  7. #5
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    cod4 has an option to set the "north" direction. Maybe that is at play here too?
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  8. The Following User Says Thank You to IzNoGoD For This Useful Post:

    kung foo man (5th March 2023)

  9. #6
    Deleter/Deleted
    Join Date
    Jan 2023
    Posts
    76
    Thanks
    40
    Thanked 9 Times in 9 Posts
    Quote Originally Posted by kung foo man View Post
    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 ?

    Quote Originally Posted by IzNoGoD View Post
    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...)
    Last edited by raphael; 4th March 2023 at 07:28.

  10. #7
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,010
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    player angles.jpg

    You can write a function like:

    PHP Code:
    checkAngles() {
        while (
    1) {
            
    players getentarray("player""classname");
            for (
    0players.sizei++) {
                
    player players[i];
                
    angles player getPlayerAngles();
                
    player iprintlnbold("angles"angles);
            }
            
    wait 1;
        }

    Or including the yaw in output:

    PHP Code:
    checkAngles() {
        while (
    1) {
            
    players getentarray("player""classname");
            for (
    0players.sizei++) {
                
    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)
    Attached Thumbnails Attached Thumbnails player angles.png  
    timescale 0.01

  11. The Following User Says Thank You to kung foo man For This Useful Post:

    raphael (22nd March 2023)

  12. #8
    Deleter/Deleted
    Join Date
    Jan 2023
    Posts
    76
    Thanks
    40
    Thanked 9 Times in 9 Posts
    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°

    viewpos compass 2.jpg
    from gsc.png

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

  13. #9
    Assadministrator kung foo man's Avatar
    Join Date
    Jun 2012
    Location
    trailerpark
    Posts
    2,010
    Thanks
    2,102
    Thanked 1,084 Times in 753 Posts
    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
    timescale 0.01

  14. The Following User Says Thank You to kung foo man For This Useful Post:

    raphael (12th March 2023)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •