Results 1 to 5 of 5

Thread: Procedure RandomCompass(MinAngle,MaxAngle,Range:integer;AltA ngle:char);

  1. #1
    Join Date
    May 2006
    Location
    Amsterdam
    Posts
    3,620
    Mentioned
    5 Post(s)
    Quoted
    0 Post(s)

    Default Procedure RandomCompass(MinAngle,MaxAngle,Range:integer;AltA ngle:char);

    Well, i needed this for my script and i thought maybe someone would like it . It is so complicated because you can also let it rotate between like 270 and 20.

    I will give a example of how this works:
    RandomCompass(50,300,10,'n')
    This will make the compass a random degree between 50 and 300. It will stop rotating if the Compass is in a range of -5 or +5 of the new degree. If messes up somehow it will make the compass North.

    Another example:
    RandomCompass(280,20,20,'s')
    This will make the compass a random degree between 280 and 20, BUT it chooses a value like 340,300,12,288,8 etc. So basicly it will start from MinAngle and stop at MaxAngle . This one stops rotating if the Compass is in a range of +10 or -10 of the new degree and if it messes up it will make the compass South.

    P.S. if you fill in 0 range it will change it to 10. You really need a range value because the Compass detection isn't 100% perfect. I think you need like 8-14 more is always possible. Sometimes it will turns the wrong side, but this is because lag or because it doesn't return the right degree of the compass

    If anyone can make this more clear in proper English please do it. Or if you know a faster way, tell me.

    ~Raymond

    Oh and fix this, found it while i was playing with compass functions!: http://www.srl-forums.com/forum/show...hlight=compass
    SCAR Code:
    {*******************************************************************************
    Procedure RandomCompass(MinAngle,MaxAngle,Range:integer;AltAngle:char);
    By: Mastaraymond
    Description: It changes the compass to a random degree value between MinAngle and MaxAngle.
    Valid Arguments:
    MinAngle = This must be the starting degree, fill in something between 360
    MaxAngle = This must be the maximum degree, fill in something between 360
    Range = It will stop turning if the current compass degree is in the of the random one range.
    AltAngle = If it messes up it will make the compass North, South, East or West. 'n','s','e' or 'w'.
    *******************************************************************************}



    Procedure RandomCompass(MinAngle,MaxAngle,Range:integer;AltAngle:char);
    var
      I,II,K,Duration,TheKey,MaxAngleNew:integer;
      IsOverNull,Checker:Boolean;
    begin;
      if Range = 0 then Range := 10;
      Range:= Round(Range div 2);
      If MinAngle > MaxAngle then
      begin;
        MaxAngleNew := MaxAngle + 360;
        IsOverNull:=True;
      end else
      begin;
        MaxAngleNew:=MaxAngle;
        IsOverNull:=false;
      end;
      I:= RandomRange(MinAngle,MaxAngleNew);
      If I >= 360 then II:= I - 360
      else II := I;
      K:= trunc(rs_GetCompassAngleDegrees);
      if ((Abs(II-K)) < 10) then
      repeat
        I:= RandomRange(MinAngle,MaxAngleNew);
        If I >= 360 then II:= I - 360
        else II:=I;
        Wait(10);
      until not((Abs(II-K)) < 10)
      if IsOverNull then if ((K <= 360) and (K >= MinAngle)) or ((K>=0) and (K <=MaxAngle)) then Checker:=true;
      if Checker then
      Begin;
        if ((MaxAngle - I) < 5) then I:= I-(5+Random(30));
        If ((I - MinAngle) < 5) then I:= I+(5+random(30));
        if (I>=360) then I:= I - 360;
        if (K=I) then
        begin;
          MakeCompass(AltAngle);
          Exit;
        end;
        if (I>= MinAngle) and ( I<=360) then
        begin;
          if ( K >= MinAngle ) and ( K <= 360 ) then
          begin;
            if K > I then TheKey:= VK_left
            else if K < I then TheKey:= VK_right;
          end else TheKey:=VK_left;
        end else if ( I>= 0) and ( I<=MaxAngle) then
        begin;
          if ( K >= 0 ) and ( K <= MaxAngle ) then
          begin;
            if K > I then TheKey:= VK_left
            else if K < I then TheKey:= VK_right;
          end else TheKey:=VK_right;
        end else
        begin;
          MakeCompass(altAngle);
          Exit;
        end;
        Duration:=GetSystemTime;
        KeyDown(TheKey);
        Repeat
          Wait(50);
          if ((GetSystemTime - Duration) >= 10*1000) then
          begin
            KeyUp(TheKey);
            MakeCompass(AltAngle);
            exit;
          end;
        until (InRange((trunc(rs_GetCompassAngleDegrees)),II-range,II+range))
        KeyUp(TheKey);
      end else
      begin;
        if K > I then TheKey := VK_Left
        else if K < I then TheKey := VK_Right
        else begin;
          MakeCompass(AltAngle);
          exit;
        end;
        Duration:=GetSystemTime;
        KeyDown(TheKey);
        Repeat
          Wait(50);
          if ((GetSystemTime - Duration) >= 10*1000) then
          begin
            KeyUp(TheKey);
            MakeCompass(AltAngle);
            exit;
          end;
        until (InRange((trunc(rs_GetCompassAngleDegrees)),I-range,I+range))
        KeyUp(TheKey);
      end;
    end;
    Verrekte Koekwous

  2. #2
    Join Date
    Jan 2007
    Location
    Not here
    Posts
    1,604
    Mentioned
    2 Post(s)
    Quoted
    19 Post(s)

    Default

    wow nice, handi anti-ban....good stuff
    Sleeping...

  3. #3
    Join Date
    May 2006
    Location
    Amsterdam
    Posts
    3,620
    Mentioned
    5 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by rkroxpunk View Post
    wow nice, handi anti-ban....good stuff
    Yes, i made this one for anti-ban and anti-logout .
    Verrekte Koekwous

  4. #4
    Join Date
    Feb 2006
    Location
    Aussie
    Posts
    937
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    wow. well done. would like to see it implemented.

  5. #5
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    Gotta admit it looks like puer paanage.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Char*, Char *, Char *var, Char var[] ... Me is confused...
    By Jason2gs in forum C/C++ Help and Tutorials
    Replies: 11
    Last Post: 04-17-2008, 02:56 PM

Posting Permissions

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