Results 1 to 7 of 7

Thread: function DFindYew;

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

    Default function DFindYew;

    When using my own function to find Yews in Edgeville, my script occasionally fails and goes into a never-ending loop:

    SCAR Code:
    function DFindYew : boolean;
    var
      TPA : TPointArray;
      i, TreeColor : Integer;
    begin
      SetArrayLength(TPA, 5);
      if not LoggedIn then begin
        Result := False;
        Exit;
      end else begin
        FindColorTolerance(x, y, 4489077, MSX1, MSY1, MSX2, MSY2, 15); //Finds a preset color on the screen with large tolerance for no need to set colors.
        TreeColor := GetColor(x, y); //Autocolor the tree. It has never failed me before. If it ever does fail I will set this up differently.
        FindColorsSpiralTolerance(x, y, TPA, TreeColor, MSX1, MSY1, MSX2, MSY2, 0);
        for i := 0 to High(TPA) do begin
          MMouse(TPA[i].x, TPA[i].y, 7, 7)
          Wait(100 + Random(300));
          if IsUpText('ew') then begin
            Result := True;
            Cx := TPA[i].x; // used elsewhere in the script
            Cy := TPA[i].y; //used elsewhere in the script
            Exit;
            end else Result := False;
        end;
      end;
    end;

    Any Idea?? The loop triggers when there is no Yew tree to be found. I think it's something to do with my TPA but I'm not quite sure. The loop acts as if it's cycling through the TPA points to find a Yew tree, but it follows a color that is nothing like the yew tree. It's almost like it is skipping IsUpText();...


    Also I have one more question that's a bit off topic to this:
    When I apply to be a SRL member (planning on using this woodcutter for it), am I permitted to let others test my script(not a public beta. Just a couple members that I personally allow to test)?
    Unfortunately, no active scripts atm.

  2. #2
    Join Date
    Feb 2007
    Location
    @ SRL
    Posts
    402
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Here you go, give this a try..
    I havn't tested it, but it should work.. Let me know.

    SCAR Code:
    function DFindYew : boolean;
    var
      TPA : TPointArray;
      i, TreeColor, Tries : Integer;
      CTol : Integer;
    begin
      SetArrayLength(TPA, 5);
      if not LoggedIn then Exit;
      CTol := GetColorToleranceSpeed;
      begin
        repeat
          ColorToleranceSpeed(2);
          FindColorTolerance(x, y, 4489077, MSX1, MSY1, MSX2, MSY2, 15); //Finds a preset color on the screen with large tolerance for no need to set colors.
          TreeColor := GetColor(x, y); //Autocolor the tree. It has never failed me before. If it ever does fail I will set this up differently.
          FindColorsSpiralTolerance(x, y, TPA, TreeColor, MSX1, MSY1, MSX2, MSY2, 0);
          for i := 0 to High(TPA) do
          begin
            MMouse(TPA[i].x, TPA[i].y, 7, 7)
            Wait(100 + Random(300));
            Tries := Tries + 1;
            if IsUpText('Yew') then
            begin
              Result := True;
              ColorToleranceSpeed(CTol);
              Cx := TPA[i].x; // used elsewhere in the script
              Cy := TPA[i].y; //used elsewhere in the script
              Break;
              Exit;
            end;
          end;
        until(Result Or (Tries > 5));
        if not Result Then
        begin
          ColorToleranceSpeed(CTol);
          // Check's 6 times for the yew color
          // if it doesnt find the color, then itll do what is written here.
        end;
      end;
    end;
    The game has an unexplainable attraction that convinces the player they are having fun, despite the fact that all they are doing is performing repetitive tasks to increase their statistics. "The game is actually a graphical nightmare and its gameplay is simple at best. Yet something, perhaps by subliminal means, forces the player - against his will - to play the game, and to believe that they are having fun".

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

    Default

    Ahh I see. It works now I had assumed that because the length of the Array was only 5 that it would stop after 5 attempts. I briefly ran it (2-3mins) and it worked great. Now all I need to do is add reports, a couple more failsafes, and run an hour or so test run.

    Thank you!
    Unfortunately, no active scripts atm.

  4. #4
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,553
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Remove that Exit; if you break; first you wont call exit;
    ~Hermen

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

    Default

    I have no clue what I did but now I'm recieving this shortly after I click on a Yew:

    Code:
    ** Warning in GetSymbolColorIn: water is not a valid name.**
    ** Warning in GetSymbolColorIn: tree is not a valid name.**
    ** Warning in GetSymbolColorIn: tree is not a valid name.**
    ** Warning in GetSymbolColorIn: dungeon is not a valid name.**
    ** Warning in GetSymbolColorIn: water is not a valid name.**
    ** Warning in GetSymbolColorIn: water is not a valid name.**
    ** Warning in GetSymbolColorIn: tree is not a valid name.**
    ** Warning in GetSymbolColorIn: tree is not a valid name.**
    ** Warning in GetSymbolColorIn: dungeon is not a valid name.**
    ** Warning in GetSymbolColorIn: water is not a valid name.**
    [Runtime Error] : Exception: Access violation at address 006D4E35 in module 'scar.exe'.
    Read of address 00000030 in line 238 in script 
    C:\Program Files\SCAR 3.15\includes\SRL/SRL/Core/AntiRandoms/AntiRandoms.scar
    Failed when compiling
    I think it is something to do with my Antiban..

    SCAR Code:
    procedure DAntiBan;
    begin
      if not (LoggedIn) then Exit
        else begin
          case Random(20) of
            0 : RandomRClick;
            1 : Sleep(1000 + Random(2500));
            2 : begin
              HoverSkill('Woodcutting', False);
              Wait(1000 + Random(2000));
              GameTab(4);
              end;
            3 : RandomMovement;
            4 : begin
              GameTab(1 + Random(14));
              Wait(1000 + Random(1500));
              GameTab(4);
              end;
            5 : PickUpMouse;
            6 : Sleep(100 + Random(500));
            7 : BoredHuman;
            8 : sleep(100 + Random(500));
            9 : begin
              case Random(5) of
                0 : HoverSkill('Woodcutting', False);
                1 : HoverSkill('Prayer', False);
                2 : HoverSkill('Mining', False);
                3 : HoverSkill('RuneCrafting', False);
                4 : HoverSkill('Smithing', False);
              end;
              GameTab(4);
            end;
            10 : Sleep(1000 + Random(2500));
            11 : Sleep(100 + Random(500));
            12 : Sleep(500 + Random(1000));
            13 : Sleep(750 + Random(1500));
            14 : RandomMovement;
            15 : Sleep(1000 + Random(2500));
            16 : Sleep(750 + Random(1000));
            17 : RandomMovement;
            18 : Sleep(900 + Random(700));
            19 : Sleep(1500 + Random(3000));
          end;
        end;
        wait(100 + Random(300));
      end;

    OR my DeclarePlayers:

    SCAR Code:
    procedure DeclarePlayers;
    begin
      HowManyPlayers := 2;
      NumberOfPlayers(HowManyPlayers);
      SRLPlayerForm(True, [], [], [], []);
      if Players[CurrentPlayer].Active = False then begin
        CurrentPlayer := CurrentPlayer + 1;
        if CurrentPlayer > HowManyPlayers - 1 then CurrentPlayer := 0;
      end;
    end;

    Any ideas? I just redownloaded SRL earlier today so I know its not SRL... I'm probably missing something stupid because I'm so tired. I'm heading to bed and I'll check this in the morning and try reading over it again. If i still have no luck I'll start rewriting piece by piece.

    Thanks a ton!

    **Edit**

    I just looked more into that error because I realised that I had not used my DeclarePlayers procedure... It's a bitmap error, I think. The only place that I used bitmaps in this script is here:
    SCAR Code:
    function DFindAxe : string;
    var
      i, bx, by : integer;
    begin
      if not LoggedIn then Exit
      else begin
        GameTab(4);
        for i := 47 to 54 do begin
          if FindBitmapToleranceIn(SRL_GetBitmap(i), bx, by, MIX1, MIY1, MIX2, MIY2, 5) then
            Result := 'Inv'
          else Result := '';
          SRL_FreeBitmaps;
          if not(Result = '') then Exit;
        end;
        if not(Result = '') then Exit
        else begin
          GameTab(5);
          for i := 47 to 54 do begin
            if FindBitmapToleranceIn(SRL_GetBitmap(i), bx, by, 569, 288, 602, 319, 5) then
              Result := 'Equip'
            else Result := '';
            SRL_FreeBitmaps;
            if not(Result = '') then Exit;
          end;
        end;
      end;
    end;
    Unfortunately, no active scripts atm.

  6. #6
    Join Date
    Jan 2008
    Location
    Frankfurt, Germany
    Posts
    742
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Okay, here are a few things that might help you:
    -for the first problem, you must load teh symbols before you can use them... So every symbol you are going to use will have to be called with "LoadSymbolBitmapColor(Name: String)", so the water symbol would first have to be called and then used (for example):
    SCAR Code:
    LoadSymbolBitmapColor('water');
      if FindSymbol( x, y, 'water') then

    For you second problem... did you use "SetUpSRL" in the first line of your main loop? also I'd check you firewall settings, you will find them under "options"
    There is nothing right in my left brain and there is nothing left in my right brain.

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

    Default

    SetupSRL; is the first line of my script.

    The problem is in my DFindAxe; function. I commented out everywehre that this function is called and it started working right again.

    I created a custom FindAxe function because the one in SRL's Woodcutting does not state if it's in the inventory or not:

    SCAR Code:
    function DFindAxe : string;
    var
      i, bx, by : integer;
    begin
      if not LoggedIn then Exit
      else begin
        GameTab(4);
        for i := 47 to 54 do begin
          if FindBitmapToleranceIn(SRL_GetBitmap(i), bx, by, MIX1, MIY1, MIX2, MIY2, 5) then
            Result := 'Inv'
          else Result := '';
          SRL_FreeBitmaps;
          if not(Result = '') then Exit;
        end;
        if not(Result = '') then Exit
        else begin
          GameTab(5);
          for i := 47 to 54 do begin
            if FindBitmapToleranceIn(SRL_GetBitmap(i), bx, by, 569, 288, 602, 319, 5) then
              Result := 'Equip'
            else Result := '';
            SRL_FreeBitmaps;
            if not(Result = '') then Exit;
          end;
        end;
      end;
    end;

    I'll try rewriting this function to use DTMs instead of bitmaps to find the axe.

    **Edit**
    Rewriting this function worked. However, now it's starting to go back into the loop??
    The loop happens right after a tree disapears:

    SCAR Code:
    if DFindYew then begin
            WriteLn('Yew Found');
            Mouse(Cx, Cy, 0, 0, True);
            Flag;
            Wait(500 + Random(300));
            FindNormalRandoms;
            FindEnt(x, y, True);
            MarkTime(Mark);
            while (TimeFromMark(Mark) < (15000 + Random(10000))) and
                  (FindColorTolerance(x, y, 4489077, MSX1, MSY1, MSX2, MSY2, 10)) and
                  not InvFull do begin
            case Random(5) of
              0 : DAntiBan;
              1 : Sleep(200 + Random(300));
              2 : Sleep(300 + Random(400));
              3 : Sleep(400 + Random(500));
              4 : FindEnt(x, y, True);
            end;
            FindNormalRandoms;
            Wait(100 + Random(500));
              if not (FindColorTolerance(x, y, 4489077, MSX1, MSY1, MSX2, MSY2, 10)) and
                 (DGetLoc = 'Yew1') then begin
                MarkTime(Tree1);
                DGoToYew(2);
              end;
              if not (FindColorTolerance(x, y, 4489077, MSX1, MSY1, MSX2, MSY2, 10)) and
                 (DGetLoc = 'Yew2') then begin
                MarkTime(Tree2);
                DGoToYew(1);
              end;
            end;
          end;
    Unfortunately, no active scripts atm.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 2
    Last Post: 02-27-2008, 05:20 PM
  2. Replies: 2
    Last Post: 02-26-2008, 08:26 PM
  3. [FUNCTION] FindDoorColour: integer; By ZephyrsFury [FUNCTION]
    By ZephyrsFury in forum Research & Development Lounge
    Replies: 10
    Last Post: 07-27-2007, 08:45 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
  •