Results 1 to 10 of 10

Thread: Script doing things I never told it to do...

  1. #1
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Script doing things I never told it to do...

    My WorldMAPWalk (see link on my sig for details) was working before. Now there are two things that it is doing that make no sense.

    1: It clicks on the button to show the overview twice (I only tell it to do so once) and never drags the red rectangle to the location of the Destination DTM.

    2: When it walks, it clicks outside of the runescape screen which makes no sense whatsoever.

    Here is the script, see the link on my sig for further details about what it does.

    SCAR Code:
    program New;
    {.include SRL/SRL.scar}
    var
      x, y, DTM: Integer;
    function Loading: Boolean;
    var
      Load, x, y: integer;
    begin
      Load := BitmapFromString(29, 3, 'beNr7/x8CGFABsiCagv+oAJ' +
           'd6kowlnk0TYwEHnoCA');
      if FindBitmap(Load, x, y) then Result:=True else Result:=False;
      FreeBitmap(Load);
    end;

    function OpenMap: Boolean;
    var
      a: Integer;
    begin
      Mouse(530, 130, 20, 20, true);
      a:=0;
      Wait(1000);
      repeat
        Wait(1500+Random(1000));
        a:=a+1;
      until(not(Loading))or(a=15);
      if(a>14)then
      begin
        WriteLn('Error: Could not open map: Loading for too long');
        Result:=False;
        Exit;
      end;
      Result:=True;
    end;

    procedure CloseMap;
    begin
      Mouse(740, 10, 15, 15, True);
      Wait(2000 + Random(1000));
    end;

    function FindAngle(L, D: Tpoint):Extended;
    var
    TrigAngle: Integer;
    begin
      if(L.x=D.x)then //if must go perfect n or s
      begin
        if(L.y>D.y)then //if go p north
        begin
          Result:=0;
          Exit;
        end else  //if go p south
        begin
          Result:=180;
          Exit;
        end;
      end;
      if(L.y=D.y)then //if must go perfect e or w
      begin
        if(L.x>D.x)then //if go p west
        begin
          Result:=270;
          Exit;
        end else  //if go p east
        begin
          Result:=90;
          Exit;
        end;
      end;
      TrigAngle:=Round(Degrees(ArcTan(Abs(D.y-L.y)/Abs(D.x-L.x))));
      if(L.y>D.y)then //if need go north (destination higher than location
      begin
        if(L.x<D.x)then Result:=90-TrigAngle; //If need go NorthEast
        if(L.x>D.x)then Result:=270+TrigAngle; //if need go NorthWest
      end;
      if(L.y<D.y)then          //if need go south
      begin
        if(L.x<D.x)then Result:=90+TrigAngle;      //if need go SouthEast
        if(L.x>D.x)then Result:=270-TrigAngle;    //If need southwest
      end;
    end;

    function ChangeZoom(CurrentZoom, Zoom: Integer): Boolean;
    var
      ColCheck: array[0..1] of integer;
    begin
      if(CurrentZoom=Zoom)then Exit;
      ColCheck[0]:=GetColor(565, 342);
      ColCheck[1]:=GetColor(565, 373);
      Mouse(562, 472, 27, 17, True);
      Wait(100 + Random(100));
      if(ColCheck[0]=GetColor(565, 342))and(ColCheck[1]=GetColor(565, 373))then
      begin
        Result:=False;
        Exit;
      end;
      case(Zoom)of
        37: Mouse(562, 340, 27, 17, True);
        50: Mouse(562, 371, 27, 17, True);
        75: Mouse(562, 402, 27, 17, True);
        100: Mouse(562, 433, 27, 17, True);
      end;
      Mouse(562, 472, 27, 17, True);
      Result:=True;
    end;

    function FindBRCorner(x, y: integer): Tpoint;
    var
      EdgeCol: integer;
    begin
      EdgeCol:=GetColor(x, y);
      repeat
      begin
        x:=x+1;
      end;
      until(not(GetColor(x+1, y)=EdgeCol));
      repeat
      begin
        y:=y+1;
      end;
      until(not(GetColor(x, y+1)=EdgeCol));
      Result.x:=x;
      Result.y:=y;
    end;

    function MoveMap(x, y: integer): boolean;
    var
      Cx, Cy, x1, y1, x2, y2: Integer;
      BR, Change: Tpoint;
    begin
      Mouse(670, 470, 27, 17, True);
      Wait(400 + Random(100));
      if(not(FindColorTolerance(x2, y2, 255, 605, 310, 760, 460, 5)))then
      begin
        Result:=False;
        Exit;
      end;
      BR:=FindBRCorner(x2, y2);
      Change.x:=x-x2;
      Change.y:=y-y2;
      Cx:=(BR.x-x2)/4;
      Cy:=(BR.y-y2)/4;
      MMouse(x2+Cx, y2+Cy, 2*Cx, 2*Cy);
      GetMousePos(x1, y1);
      HoldMouse(x1, y1, True);
      GetMousePos(x1, y1);
      x2:=x1+Change.x-5+Random(10);
      y2:=y1+Change.y-5+Random(10);
      MMouse(x2, y2, 10, 10);
      Wait(100+Random(100));
      GetMousePos(x1, y1);
      ReleaseMouse(x1, y1, True);
      Result:=True;
    end;

    procedure AngleWalk(Degrees, Radius: Integer);
    var
      x1, y1, Quad, Angle, x, y: Integer;
    begin
      Angle:=Round(rs_GetCompassAngleDegrees+Degrees);
      if(Angle>=360)then Angle:=Angle-360;
      if(Angle<0)then Angle:=Angle+360;
      case Angle of
        0..90: Quad:=1;
        91..179: Quad:=2;
        180..270: Quad:=3;
        271..359: Quad:=4;
      end;
      y:= Round((cos(Radians(Angle))) * Radius);
      x:= Round((sin(Radians(Angle))) * Radius);
      case Quad of
        1:
        begin
          y1:=MMCY-y
          x1:=MMCX+x
        end;

        2:
        begin
          y1:=MMCY+x
          x1:=MMCX+y
        end;

        3:
        begin
          y1:=MMCY+y
          x1:=MMCX-x
        end;

        4:
        begin
          y1:=MMCY-x
          x1:=MMCX-y
        end;
      end;
      MouseFlag(x, y, 0, 0);
    end;

    function WorldMAPWalk(DestinationDTM: Integer; MLx, MLy: Integer): Boolean;
    var
      RDis, Trav, TDis, Dis, Angle, x, y, a: integer;
      MC, Loc, Des: Tpoint;
      Check, Stop: Boolean;
    begin
      MC.x:=MSX2/2;
      MC.y:=MSY2/2;
      for a:=0 to 5 do
      begin
        if(DTMRotated(DestinationDTM, x, y, MMX1, MMY1, MMX2, MMY2))then
        begin
          MakeCompass('n');
          MouseFlag(x, y, 10, 10);
          WriteLn('Arrived at destination');
          Result:=True;
          Exit;
        end;
        Wait(500);
      end;
      repeat
      begin
        if(not(OpenMap))then
        begin
          Result:=False;
          Exit;
        end;
        Check:=False;
        if(DTMRotated(DestinationDTM, x, y, 0, 0, 764, 502))then
        begin
          Des.x:=x;
          Des.y:=y;
          Angle:=Round(FindAngle(MC, Des));
          Dis:=Distance(MC.x, MC.y, Des.x, Des.y);
          Check:=True;
          CloseMap;
        end else
        begin
          Mouse(670, 470, 27, 17, True);
          Wait(400 + Random(100));
          if(not(FindColorTolerance(x, y, 255, 605, 310, 760, 460, 5)))then
          begin
            Result:=False;
            Exit;
          end;
          Loc.x:=x;
          Loc.y:=y;
          Des.x:=MLx;
          Des.y:=MLy;
          Dis:=(Distance(x, y, MLx, MLy)*455)/8;
          Angle:=Round(FindAngle(Loc, Des));
          MoveMap(MLx, MLy);
          Wait(2000+Random(1000));//IdleTime(2000, 1000, 7);
          CloseMap;
        end;
        WriteLn(Floattostr(Angle));
        case Dis of
          0..400: RDis:=Dis;

          401..899: RDis:=Round(Dis/2+50)+Random(100);

          900..1600: RDis:=Round((Dis/2)+Random(100));

          else RDis:=800+Random(100);
        end;
        Trav:=0;
        repeat
        begin
          case RDis-Trav of
            (0-10)..10:Stop:=True;

            0..75:
            begin
              TDis:=RDis-Trav;
              AngleWalk(Angle-4+Random(8), TDis);
            end;

            76..120:
            begin
              TDis:=Round(((RDis-Trav)/2)-5+Random(10));
              AngleWalk(Angle-4+Random(8), TDis);
            end;

            else
            begin
              TDis:=45+Random(30);
              AngleWalk(Angle-5+Random(10), TDis);
            end;
          end;
          Trav:=Trav+TDis;
        end;
        until(Stop);
        if(Check)then
        begin
          MakeCompass('n');
          for a:=0 to 5 do
          begin
            if(DTMRotated(DestinationDTM, x, y, MMX1, MMY1, MMX2, MMY2))then
            begin
              if(Distance(MMCX, MMCY, x, y)>20)then MouseFlag(x, y, 10, 10);
              WriteLn('Arrived at destination');
              Result:=True;
              Exit;
            end;
            Wait(250+Random(500));
          end;
          Check:=False;
        end;
      end;
      until(false);
    end;
    begin
      SetupSRL;
      ActivateClient;
      DTM := DTMFromString('78DA639CCDC0C0B0950105E46426836946289' +
           'F710690B886AAE6CC9933A86A3611A1662790388FAAC6D3551655' +
           'CD5420B112BF3900E6A51026');
      WorldMAPWalk(DTM, 698, 373);
    end.

  2. #2
    Join Date
    Jul 2008
    Location
    California
    Posts
    255
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Make sure you're targeting the runescape client. I've missed this once before and man I was lost :P.
    Unfortunately, no active scripts atm.

  3. #3
    Join Date
    Mar 2008
    Location
    The Netherlands
    Posts
    1,395
    Mentioned
    1 Post(s)
    Quoted
    1 Post(s)

    Default

    Quote Originally Posted by doom0791 View Post
    Make sure you're targeting the runescape client. I've missed this once before and man I was lost :P.
    I dont think that, as he uses the Mouse command and it works. Sorry man, I don't see it as the click is only called once.


  4. #4
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    nope, I selected the client... Anyone else have an idea?

  5. #5
    Join Date
    Jul 2007
    Location
    Ottawa, Canada
    Posts
    930
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I am analyzing it, but this is the first thing i noticed, ill keep you posted

    SCAR Code:
    repeat
        Wait(1000);
        a:=a+1;
      until(not(Loading))or(a=15+Random(10)); //the random 10 could dodge  a //every time, make a to be >
    SCAR Code:
    if(DTMRotated(DestinationDTM, x, y, MSX1, MSY1, MSX2, MSY2))then // should this be MM?
        begin
          MakeCompass('n');
          MouseFlag(x, y, 10, 10);
          WriteLn('Arrived at destination');
          Result:=True;
          Exit;
        end;

    You also never free your dtm, which probably explains all of your runtime problems

    anyways brb gota poo
    ~ Metagen

  6. #6
    Join Date
    Mar 2007
    Location
    <3
    Posts
    2,683
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    With the click twice problem, Ive recently had this same problem :/

    Try debugging the Mouse & your function...

    That will give you a lead on were to start ^^

  7. #7
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I still need help here

  8. #8
    Join Date
    Mar 2007
    Location
    <3
    Posts
    2,683
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Didnt debuggin work out with any result?
    Or your to lazy to just test it XD

  9. #9
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    Mentagen came up with some nice finds, did you edit your script for that?

    and i also saw this in you for a := 0 to 5 do loop:

    Wait(500);
    a:=a+1;

    Why do you add 1 to a? the for to do loop adds 1 to a automaticly. if you want the loop to be faster, just decrease the X in 'for a := 0 to X do'.
    Omg! it sounds like i think ure a noob now... i dont

    FAKE-EDIT: It seems like you do that in all ur for to do loops....

  10. #10
    Join Date
    Jul 2007
    Location
    Massachusetts
    Posts
    896
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    ah shit, i have to swear for this one. So u know I left scar for a while right? Well thats because I was doing c++. In C++ you say what it increases by each time IN the for loop statement. Scar doesn't have this so I must have gotten confused and figured I had to increase it myself. Not to mention that I am only programming at midnight and later ( its 5 AM for me right now...)

    I have been making SO MANY FRICKIN MISTAKES now because im still in the C++ mindset and its PISSING ME OFF....lol

    soooo thats the kind of thing I need you to look for so thanks.

    Nike- The double click thing doesnt really bother me that much right now. im gunna fix some other stuff that I found and then see if it works. Edit: I looked at it very briefly and didnt seem to find anything...

    Edit Edit: Im such a dooshbag. Fixed now

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. i told my friend about this...
    By Solkrieg in forum NOTA
    Replies: 3
    Last Post: 11-01-2008, 11:57 PM
  2. Requesting several things (In one script would be godly.. ;D)
    By smartshark in forum RS3 Outdated / Broken Scripts
    Replies: 7
    Last Post: 11-17-2007, 04:21 AM
  3. Help Fixing Things with my first script
    By japman in forum OSR Help
    Replies: 12
    Last Post: 01-04-2007, 05:39 AM

Posting Permissions

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