Results 1 to 12 of 12

Thread: CompassMovement Specific Rotation Direction?

  1. #1
    Join Date
    Jan 2016
    Posts
    77
    Mentioned
    0 Post(s)
    Quoted
    44 Post(s)

    Default CompassMovement Specific Rotation Direction?

    Hello,

    When using the compassmovement function is there anyway to specify which way to rotate the camera? For example, I am using it in a color script to detect a bank chest when the chest is not in view. For the sake of my script I know that the bank chest will always be to the LEFT whenever it is out of view. Sure I could use Setcompass to set it to a specific angle every time but I dont want to always rotate the camera since sometimes the chest will be in view without the need for a shift in camera. Perhaps there is a different function I can use rather than compassmovement altogether?

    The reason I like compassmovement is because the movement of angle is random but I just wish it was possible to make the direction of movement NOT random.

    Thank you.

  2. #2
    Join Date
    Apr 2016
    Location
    New Zealand
    Posts
    76
    Mentioned
    0 Post(s)
    Quoted
    32 Post(s)

    Default

    As CompassMovement is part of the anti-ban section, as well as looking at the code, it seems like it isn't the correct function to be using.

    Pseudo code:
    Simba Code:
    if not FindBankChest then
    SetAngle(RandomRange(255, 285)); // West = 270, +-15

  3. #3
    Join Date
    Dec 2011
    Posts
    193
    Mentioned
    5 Post(s)
    Quoted
    51 Post(s)

    Default

    Seems like you're asking two questions?

    1) How do I make it so the camera is rotated as if the left arrow key is always used?
    2) How do I only move the camera when the bank chest is out of view and not every time?

    First one first. setCompass should rotate the camera which ever direction is quicker to get to your desired angle. So if you're at rotation 250 and you wanna get to 270, it'll use the left key as that's only 20 degrees away while going right will be 340. If you're saying that function will incorrectly determine the shorter turn direction, that's a bug.

    If for whatever reason, you want the function to always turn left EVEN if it's not the faster way to turn, the quick'n'dirty way is to simply copy the function into the script, rename it to something like "setCompassLeft" and then within the function find where "Left" is assigned a Boolean via some math wizardry and instead do Left := True;

    Now call that version whenever you want to rotate left only. Also you can do setCompass(Random(260,280)); if you want to add some randomness into it.


    Second one after first one. Simply only call the compass function if the bank is not found.

    OSRS Color Scripts: Borland_Salamanders | Borland_Iron_Ores
    Utilities & Snippets: [Color] OSBuddy Item Looting

  4. #4
    Join Date
    Jan 2016
    Posts
    77
    Mentioned
    0 Post(s)
    Quoted
    44 Post(s)

    Default

    Thank you very much for the answers! Is there any way to store the current angle? That way maybe I can add a random degree amount to my current angle?

  5. #5
    Join Date
    Jun 2013
    Location
    Scranton
    Posts
    496
    Mentioned
    5 Post(s)
    Quoted
    220 Post(s)

    Default

    Quote Originally Posted by Hellzonee View Post
    Thank you very much for the answers! Is there any way to store the current angle? That way maybe I can add a random degree amount to my current angle?
    Store getCompassAngle(); in an extended variable

  6. #6
    Join Date
    Jan 2016
    Posts
    77
    Mentioned
    0 Post(s)
    Quoted
    44 Post(s)

    Default

    Quote Originally Posted by jstemper View Post
    Store getCompassAngle(); in an extended variable
    Do you have an example you can share please?

  7. #7
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    Quote Originally Posted by Hellzonee View Post
    Do you have an example you can share please?
    Simba Code:
    procedure example();
    var
      angle: extended;
    begin
      angle := getCompassAngle();
    end;

  8. #8
    Join Date
    Dec 2011
    Posts
    193
    Mentioned
    5 Post(s)
    Quoted
    51 Post(s)

    Default

    Quote Originally Posted by Hellzonee View Post
    Do you have an example you can share please?
    I'd recommend storing it as an integer if you're gonna use it with other integers. The Round() function will do this.

    OSRS Color Scripts: Borland_Salamanders | Borland_Iron_Ores
    Utilities & Snippets: [Color] OSBuddy Item Looting

  9. #9
    Join Date
    Jan 2016
    Posts
    77
    Mentioned
    0 Post(s)
    Quoted
    44 Post(s)

    Default

    Thanks again for the help. Please bear with me as I am very noob. I'm still having some issues, here is what I have done. I declared the procedure as such:

    procedure ccompass(angle: extended);

    begin
    angle := getCompassAngle();
    end;

    Afterwards, I called the procedure in a different procedure as so:

    procedure cookHandler();
    var
    aa: extended;
    angle, Timer, world, I, rand: Integer;

    ccompass(aa);
    angle := round(aa);
    setcompass(angle + 15);


    Everything is executing but the camera is not changing at all, it just stays frozen. Anything Im doing wrong?

  10. #10
    Join Date
    May 2012
    Location
    Glorious Nippon
    Posts
    1,011
    Mentioned
    50 Post(s)
    Quoted
    505 Post(s)

    Default

    Your ccompass() procedure is totally pointless. Just use getCompassAngle() in cookHandler()

  11. #11
    Join Date
    Dec 2011
    Posts
    193
    Mentioned
    5 Post(s)
    Quoted
    51 Post(s)

    Default

    Quote Originally Posted by Hellzonee View Post
    Thanks again for the help. Please bear with me as I am very noob. I'm still having some issues, here is what I have done. I declared the procedure as such:

    procedure ccompass(angle: extended);

    begin
    angle := getCompassAngle();
    end;

    Afterwards, I called the procedure in a different procedure as so:

    procedure cookHandler();
    var
    aa: extended;
    angle, Timer, world, I, rand: Integer;

    ccompass(aa);
    angle := round(aa);
    setcompass(angle + 15);


    Everything is executing but the camera is not changing at all, it just stays frozen. Anything Im doing wrong?
    I'd recommend you read some tutorials on procedures and functions. You're trying to assign a value to aa, you have the right idea on how this is accomplished but you executed incorrectly. Look at your ccompass procedure, the values inside brakcets after a procedure/functions name are values you will be giving to it, not taking. With function you can have a returned value that you can take and assign to a variable elsewhere.

    Simba Code:
    function returnAngle: Integer; //this function will give back an integer value
    begin
      Result := Round(getCompassAngle); //result is what we use to assign the above integer a value
    end;

    //Here's an example of what you use values in brackets for
    function returnAngle(Number: Integer): Integer; //Number is a value we'll be giving to this function
    begin
      Result := Round(getCompassAngle) + Number; //Here we use number to change the result.
    end;

    //So calling the below function will get the current angle and add 20 to it
    Angle := returnAngle(20);

    But as Citrus has pointed out, the use of a wrapper procedure here is redundant. Just do Angle := Round(getCompassAngle);

    OSRS Color Scripts: Borland_Salamanders | Borland_Iron_Ores
    Utilities & Snippets: [Color] OSBuddy Item Looting

  12. #12
    Join Date
    Jan 2016
    Posts
    77
    Mentioned
    0 Post(s)
    Quoted
    44 Post(s)

    Default

    Quote Originally Posted by Borland View Post
    I'd recommend you read some tutorials on procedures and functions. You're trying to assign a value to aa, you have the right idea on how this is accomplished but you executed incorrectly. Look at your ccompass procedure, the values inside brakcets after a procedure/functions name are values you will be giving to it, not taking. With function you can have a returned value that you can take and assign to a variable elsewhere.

    Simba Code:
    function returnAngle: Integer; //this function will give back an integer value
    begin
      Result := Round(getCompassAngle); //result is what we use to assign the above integer a value
    end;

    //Here's an example of what you use values in brackets for
    function returnAngle(Number: Integer): Integer; //Number is a value we'll be giving to this function
    begin
      Result := Round(getCompassAngle) + Number; //Here we use number to change the result.
    end;

    //So calling the below function will get the current angle and add 20 to it
    Angle := returnAngle(20);

    But as Citrus has pointed out, the use of a wrapper procedure here is redundant. Just do Angle := Round(getCompassAngle);

    Angle := Round(getCompassAngle); works perfectly, thank you and @Citrus for the help!

    For anyone looking for the final product here's what I used:


    Angle := round(getcompassangle);
    setcompass(angle-randomrange(18,25));

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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