Results 1 to 6 of 6

Thread: Feedback

  1. #1
    Join Date
    Oct 2007
    Location
    Denmark
    Posts
    409
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Feedback

    Hi,

    I'm working on a Rimmington Miner and I consider it done.
    However, I'm sure that there are things I might be able to improve so please post any suggestions

    The script:
    SCAR Code:
    program RimmingtonMiner;
    {.include SRL/SRL/Misc/Smart.Scar}
    {.include SRL/SRL.Scar}
    {.include SRL/SRL/Skill/Mining.Scar}
    {.include FrtAntiBan.Scar}

    const
      SleepTime = 3;
      MaxLoads = 200;

    var
      x, y, TheFS: Integer;
      TheOre, Loads: Integer;
     
    function Counter: Integer; forward;
    procedure Proggie; forward;
    procedure GetMiningLvl(var Return: Integer); forward;

    procedure DeclarePlayers;
    begin
      Skills := ['Mining', 'Smithing', 'Hitpoints', 'Fishing', 'Cooking']; // Maximum is 5
      HowManyPlayers := 3;
      NumberOfPlayers(HowManyPlayers);
      CurrentPlayer := 0;

      Players[0].Name       := '';
      Players[0].Pass       := '';
      Players[0].Nick       := '';
      Players[0].Active     := True;   // Active
      Players[0].Integers[0] := 5;     // Loads to do before switching
      Players[0].Strings[0] := 'Iron'; // Copper, Tin, Iron, Gold, Auto

      Players[1].Name       := '';
      Players[1].Pass       := '';
      Players[1].Nick       := '';
      Players[1].Active     := True;   // Use this account?
      Players[1].Integers[0] := 5;     // Loads to do before switching
      Players[1].Strings[0] := 'Iron'; // Copper, Tin, Iron, Gold

      Players[2].Name       := '';
      Players[2].Pass       := '';
      Players[2].Nick       := '';
      Players[2].Active     := True;      // Use this account?
      Players[2].Integers[0] := 5;       // Loads to do before switching
      Players[2].Strings[0] := 'Iron'; // Copper, Tin, Iron, Gold
    end;

    procedure W(Timer: Integer);
    begin
      Wait(Timer + Random(500));
    end;

    function FS(Times: Integer): Boolean;
    begin
      if (TheFS >= Times) then
      begin
        TheFS := 0;
        Result := True;
      end;
      Inc(TheFS);
    end;

    procedure Reset;
    begin
      TheFS := 0;
    end;

    function ContinueScript: Boolean;
    begin
      if LoggedIn then
      begin
        if FindPickHeadColor then
          Result := True;
      end;
    end;

    function InShop: Boolean;
    begin
      if FindObj(x, y, 'adder', 2510699, 5) then
        Result := (Distance(MSCX, MSCY, x, y) < 100);
    end;

    function MakeDDTM(Which: String): Integer;
    var
      dtmMainPoint: TDTMPointDef;
      dtmSubPoints: Array [0..3] of TDTMPointDef;
      TempTDTM: TDTM;
      i, x, y: Integer;
      Tole, Stone, BStone, Dirt: Integer;
    begin
      Stone := 6054490;
      BStone := 3431561;
      Dirt := 935539;
      case Lowercase(Which) of
        'iron':
        begin
          dtmMainPoint.x := 623;
          dtmMainPoint.y := 114;
          dtmMainPoint.Color := 1786987;

          dtmSubPoints[0].x := 623;
          dtmSubPoints[0].y := 114;
          dtmSubPoints[0].Color := 1786987;

          dtmSubPoints[1].x := 614;
          dtmSubPoints[1].y := 105;
          dtmSubPoints[1].Color := Stone;

          dtmSubPoints[2].x := 610;
          dtmSubPoints[2].y := 120;
          dtmSubPoints[2].Color := Stone;

          dtmSubPoints[3].x := 624;
          dtmSubPoints[3].y := 124;
          dtmSubPoints[3].Color := Stone;
        end;
        'copper':
        begin
          dtmMainPoint.x := 652;
          dtmMainPoint.y := 85;
          dtmMainPoint.Color := Dirt;

          dtmSubPoints[0].x := 652;
          dtmSubPoints[0].y := 85;
          dtmSubPoints[0].Color := Dirt;

          dtmSubPoints[1].x := 648;
          dtmSubPoints[1].y := 76;
          dtmSubPoints[1].Color := BStone;

          dtmSubPoints[2].x := 643;
          dtmSubPoints[2].y := 88;
          dtmSubPoints[2].Color := BStone;

          dtmSubPoints[3].x := 636;
          dtmSubPoints[3].y := 83;
          dtmSubPoints[3].Color := Stone;
        end;
        'tin':
        begin
          dtmMainPoint.x := 679;
          dtmMainPoint.y := 130;
          dtmMainPoint.Color := Dirt;

          dtmSubPoints[0].x := 679;
          dtmSubPoints[0].y := 130;
          dtmSubPoints[0].Color := Dirt;

          dtmSubPoints[1].x := 675;
          dtmSubPoints[1].y := 115;
          dtmSubPoints[1].Color := Stone;

          dtmSubPoints[2].x := 684;
          dtmSubPoints[2].y := 122;
          dtmSubPoints[2].Color := Stone;

          dtmSubPoints[3].x := 681;
          dtmSubPoints[3].y := 106;
          dtmSubPoints[3].Color := BStone;
        end;
        'gold':
        begin
          dtmMainPoint.x := 643;
          dtmMainPoint.y := 145;
          dtmMainPoint.Color := Dirt;

          dtmSubPoints[0].x := 643;
          dtmSubPoints[0].y := 145;
          dtmSubPoints[0].Color := Dirt;

          dtmSubPoints[1].x := 641;
          dtmSubPoints[1].y := 133;
          dtmSubPoints[1].Color := Stone;

          dtmSubPoints[2].x := 651;
          dtmSubPoints[2].y := 135;
          dtmSubPoints[2].Color := Stone;

          dtmSubPoints[3].x := 639;
          dtmSubPoints[3].y := 156;
          dtmSubPoints[3].Color := 15658734;
        end;
      end;

      repeat
        Tole := tole + 5;
        dtmMainPoint.AreaSize := 7;
        dtmMainPoint.AreaShape := 0;
        dtmMainPoint.Tolerance := Tole;
        for i := 0 to High(dtmSubPoints) do
        begin
          dtmSubPoints[i].AreaSize := 7;
          dtmsubPoints[i].AreaShape := 0;
          dtmSubPoints[i].Tolerance := Tole;
        end;

        TempTDTM.MainPoint := dtmMainPoint;
        TempTDTM.SubPoints := dtmSubPoints;
        try
          FreeDTM(Result);
        except
        end;
        Result := AddDTM(TempTDTM);
      until DTMRotated(Result, x, y, MMX1, MMY1, MMX2, MMY2) or (Tole > 15);
    end;

    function ReturnOreDTM(Str: String): Integer;
    begin
      case Lowercase(Str) of
        'tin': Result := DTMFromString('78DA63CC606260E0656440058C482490CE01A' +
           'A6122A0A618A8E60F037E35594035BF09A88907AA612560571C50' +
           '8D202361BBC408A82903AA1120420D170135D584C30700A08206C' +
           '8');
        'iron': Result := DTMFromString('78DA63CC66626078C18006189148209D05547' +
           '39D809A78A09A8704D4C402D5BC26A0261DA8E61301356540356F' +
           '08A8A902AA7944404D0950CD1D026A0A806A6EE057030032C30BF' +
           '9');
        'copper': Result := DTMFromString('78DA63DCC7C4C0C0C5C8800A189148207D0CA' +
           '8E60F037E3527806A980998731AA8868F08BB0409A801B9598C80' +
           '9A4D4498B311A88693809A6D40354C04D45C00AA61C1AF0600833' +
           'D091E');
        'gold': Result := DTMFromString('78DA63B4636260E0656440058C4824907603A' +
           'AF9C3805F8D0350CD6F026ACC816A9808D8650C54C34F408D3D50' +
           '8D180135EE44F8CB0BA84690801A3FA01A4E026A02816A1889B08' +
           'B01BF1A006A89057B');
      end;
    end;

    procedure DTMSetup(What: String; var Return: Integer);
    var
      Temp: String;
      Skill: Integer;
    begin
      Temp := Lowercase(Players[CurrentPlayer].Strings[0]);
      if GameTab(4) then
      begin
        GetMiningLvl(Skill);
        if (Temp = 'auto') then
        begin
          case Skill of
            0..20:
              begin
                case Random(2) of
                  0: Temp := 'copper';
                  1: Temp := 'tin';
                end;
              end;
            21..45: Temp := 'iron';
            46..99: Temp := 'gold';
          end;
        end;
      end else
      begin
        if (Temp = 'auto') then
        begin
          case Random(2) of
            0: Temp := 'copper';
            1: Temp := 'tin';
          end;
        end;
      end;
      case Lowercase(What) of
        'oredtm': Return := ReturnOreDTM(Temp);
        'minedtm': Return := MakeDDTM(Temp);
        'miningstone':
          begin
            case Temp of
              'copper': Return := rimmington_copper;
              'tin': Return := rimmington_tin;
              'iron': Return := rimmington_iron;
              'gold': Return := rimmington_gold;
            end;
          end;
      end;
    end;

    function WalkToSpecific: Boolean;
    var
      TempD: Integer;
    begin
      TempD := MakeDDTM(Players[CurrentPlayer].Strings[0]);
      if DTMRotated(TempD, x, y, MMX1, MMY1, MMX2, MMY2) then
      begin
        Mouse(x, y, 5, 5, True);
        FFlag(5);
        W(1000);
        Result := True;
      end;
      FreeDTM(TempD);
    end;

    function WalkToMine: Boolean;
    begin
      if not ContinueScript then Exit;
      SetRun(True);
      if FindSymbol(x, y, 'shop') then
      begin
        if (Distance(MMCX, MMCY, x, y) > 25) then
        begin
          Mouse(x + 10, y, 5, 5, True);
          FFlag(5);
        end;
      end;
      if FindSymbol(x, y, 'portal') then
      begin
        Mouse(x, y, 5, 5, True);
        FFlag(5);
      end;
      RadialRoadWalk(FindRoadColor, 45, 90, 70, 2, 2);
      while not FindSymbol(x, y, 'mining spot') do
      begin
        if FS(1) then Break;
        Mouse(MMCX + 50, MMCY - 40, 5, 5, True);
        FFlag(5);
      end;
      Reset;
      if FindSymbol(x, y, 'mining spot') then
      begin
        Mouse(x, y, 5, 5, True);
        FFlag(5);
        Result := True;
      end;
      if not WalkToSpecific then
      begin
        Logout;
        Players[CurrentPlayer].Active := False;
        Exit;
      end;
    end;

    function WalkToShop: Boolean;
    begin
      if not ContinueScript then Exit;
      Inc(Players[CurrentPlayer].Integers[1]);
      Inc(Loads);
      Players[CurrentPlayer].Integers[2] := Players[CurrentPlayer].Integers[2] + Counter;
      SetRun(True);
      if FindSymbol(x, y, 'mining spot') then
      begin
        Mouse(x, y, 5, 5, True);
        FFlag(5);
      end;
      while not RadialRoadWalk(FindRoadColor, 160, 270, 70, 2, 2) do
      begin
        if FS(1) then Break;
        Mouse(MMCX - 20, MMCY + 60, 5, 5, True);
        FFlag(5);
      end;
      Reset;
      RadialRoadWalk(FindRoadColor, 230, 270, 60, 2, 2);
      if FindSymbol(x, y, 'portal') then
      begin
        if (Distance(MMCX, MMCY, x, y) > 25) and (MMCY < y - 20) then
        begin
          Mouse(x, y, 5, 5, True);
          FFlag(5);
        end;
      end;
      while not InShop do
      begin
        if FS(5) then Break;
        if FindSymbol(x, y, 'shop') then
        begin
          Mouse(x + 5, y, 2, 2, True);
          FFlag(5);
        end;
      end;
      if InShop then
        Result := True;
      Reset;
      if FindObj(x, y, 'hop', 5206412, 5) then
        Result := True;
    end;

    function LocationCheck: String;
    var
      x, y: Integer;
    begin
      if FindSymbol(x, y, 'water') then
        Result := 'Town'
      else if FindSymbol(x, y, 'mining spot') then
        Result := 'Mine'
      else if FindSymbol(x, y, 'portal') then
        Result := 'Portal'
      else Result := 'Unknown';
      Result := Lowercase(Result);
    end;

    procedure UseLocation(ToMine: Boolean);
    var
      Temp: String;
      Doer: Boolean;
    begin
      Temp := LocationCheck;
      case Temp of
        'town':
        begin
          if ToMine then
            Doer := True;
        end;
        'portal': Doer := True;
        'mine':
        begin
          if not ToMine then
            Doer := True;
        end;
      end;
      if Doer then
      begin
        if ToMine then
        begin
          if not WalkToMine then
          begin
            Logout;
            Players[CurrentPlayer].Active := False;
            Exit;
          end;
        end else
        begin
          if not WalkToShop then
          begin
            Logout;
            Players[CurrentPlayer].Active := False;
            Exit;
          end;
        end;
      end;
      if (Temp = 'unknown') then
      begin
        Logout;
        Players[CurrentPlayer].Active := False;
        Exit;
      end;
    end;

    procedure Miner;
    var
      Inv, C: Integer;
    begin
      if not ContinueScript then Exit;
      while not InvFull do
      begin
        Inv := InvCount;
        Inc(C);
        if (C > 75) then Break;
        if FindObjRock(x, y, TheOre) then
        begin
          case Random(4) of
            0..2: Mouse(x, y, 2, 2, True);
            3:
              begin
                Mouse(x, y, 2, 2, False);
                W(500);
                ChooseOption('ine');
              end;
          end;
          while (Inv = InvCount) do
          begin
            W(1000);
            case Random(5) of
              0: FrtAntiBan;
            end;
            if FS(15) then Break;
          end;
          Reset;
        end else
        begin
          W(2000);
          case Random(5) of
            0: FrtAntiBan;
          end;
        end;
      end;
    end;

    procedure Seller;
    var
      i, TempD: Integer;
      B: TBox;
    begin
      if not ContinueScript then Exit;
      DTMSetup('OreDTM', TempD);
      if FindObj(x, y, 'hop', 5206412, 5) then
      begin
        Mouse(x, y, 3, 3, False);
        W(200);
        if ChooseOption('rade') then
        begin
          W(4000);
          for i := 1 to 28 do
          begin
            B := InvBox(i);
            if FindDTM(TempD, x, y, B.X1, B.Y1, B.X2, B.Y2) then
            begin
              MouseItem(i, False);
              ChooseOption('50');
              W(1000);
              Break;
            end;
          end;
        end;
        Mouse(485, 43, 3, 3, True);
        ArrangeInv;
      end;
      FreeDTM(TempD);
      Proggie;
    end;

    procedure GetMiningLvl(var Return: Integer);
    var
      Tempx: Integer;
    begin
      if not LoggedIn then Exit;
      Tempx := GetCurrentTab;
      Return := GetSkillLevel('mining');
      GameTab(Tempx);
    end;

    function Counter: Integer;
    var
      i, TempD: Integer;
      B: TBox;
    begin
      if not LoggedIn then Exit;
      DTMSetup('OreDTM', TempD);
      GameTab(4);
      for i := 1 to 28 do
      begin
        B := InvBox(i);
        if FindDTM(TempD, x, y, B.X1, B.Y1, B.X2, B.Y2) then
          Inc(Result);
      end;
      FreeDTM(TempD);
    end;

    function CalcXp(Ores, Player: Integer): Extended;
    var
      xp: Extended;
    begin
      case Lowercase(Players[Player].Strings[0]) of
        'tin': xp := 17.5;
        'copper': xp := 17.5;
        'iron': xp := 35;
        'gold': xp := 65;
      end;
      Result := xp * StrToFloat(IntToStr(Ores));
    end;

    function WhatMining(Play: Integer): String;
    begin
      if (Lowercase(Players[Play].Strings[0]) = 'auto') then
      begin
        case Players[Play].Integers[3] of
          0: Result := 'unknown';
          1..20: Result := 'copper/tin';
          21..45: Result := 'iron';
          46..99: Result := 'gold';
        end;
      end else
        Result := Players[Play].Strings[0];
    end;

    procedure Proggie;
    var
      i: Integer;
    begin
      ClearDebug;
      Writeln('Frt''s Rimmington Miner');
      Writeln('Ran for ' + TimeRunning);
      Writeln('');
      for i := 0 to High(Players) do
      begin
        Writeln(Players[i].Nick + ': ' + IntToStr(Players[i].Integers[1]) +
                ' loads | ' + IntToStr(Players[i].Integers[2]) + ' ' + WhatMining(i) + ' ores mined | ' +
                FloatToStr(CalcXp(Players[i].Integers[2], i)) + ' xp gained.');
      end;
    end;

    // Credit: Bam Bam for helping :)
    procedure TheNext;
    var
      Status: Boolean;
    begin
      Status := LoggedIn;
      Logout;
      W(SleepTime * 60 * 1000);
      if (Players[CurrentPlayer].Integers[1] >= MaxLoads) then
        Status := False;
      NextPlayer(Status);
      Loads := 0;
      Proggie;
    end;

    procedure Setup;
    begin
      SmartSetupEx(121, False, True, False);
      SetTargetDC(SmartGetDC);
      SetupSRL;
      SetupMining;
      DeclarePlayers;
      SetupFrtAntiBan;
      ActivateClient;
      LoginPlayer;
      ClearDebug;
      Proggie;
    end;

    begin
    Setup;
    repeat
      DTMSetup('Miningstone', TheOre);
      SetAngle(True);
      MakeCompass('n');
      while (Loads < Players[CurrentPlayer].Integers[0]) do
      begin
        GetMiningLvl(Players[CurrentPlayer].Integers[3]);
        UseLocation(True);
        Miner;
        UseLocation(False);
        Seller;
        if not LoggedIn then Break;
      end;
      TheNext;
    until AllPlayersInactive;
    end.

  2. #2
    Join Date
    Dec 2007
    Location
    192.168.1.73
    Posts
    2,439
    Mentioned
    6 Post(s)
    Quoted
    119 Post(s)

    Default

    As far as I can see its pretty good. But surely with the DDTMs you can shorten them into one and have a variable colour like this:

    SCAR Code:
    unction MakeDDTM(Which: String): Integer;
    var
      dtmMainPoint: TDTMPointDef;
      dtmSubPoints: Array [0..3] of TDTMPointDef;
      TempTDTM: TDTM;
      i, x, y, Colour: Integer;
      Tole, Stone, BStone, Dirt: Integer;
    begin
      Stone := 6054490;
      BStone := 3431561;
      Dirt := 935539;
      case Lowercase(Which) of
        'iron': Colour := {something};
        'copper': Colour := {something};
        etc.
       end;
       begin
         dtmMainPoint.x := ***;
         dtmMainPoint.y := ***;
         dtmMainPoint.Color := Colour;

         dtmSubPoints[0].x := ***;
         dtmSubPoints[0].y := ***;
         dtmSubPoints[0].Color := ********;

         etc.
       end;
        repeat
        Tole := tole + 5;
        dtmMainPoint.AreaSize := 7;
        dtmMainPoint.AreaShape := 0;
        dtmMainPoint.Tolerance := Tole;
        for i := 0 to High(dtmSubPoints) do
        begin
          dtmSubPoints[i].AreaSize := 7;
          dtmsubPoints[i].AreaShape := 0;
          dtmSubPoints[i].Tolerance := Tole;
        end;

        TempTDTM.MainPoint := dtmMainPoint;
        TempTDTM.SubPoints := dtmSubPoints;
        try
          FreeDTM(Result);
        except
        end;
        Result := AddDTM(TempTDTM);
      until DTMRotated(Result, x, y, MMX1, MMY1, MMX2, MMY2) or (Tole > 15);
    end;

  3. #3
    Join Date
    Apr 2007
    Posts
    2,593
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Viewing all of the proc's/func's, I'll be editing this post quite a bit.

    EDIT1:
    Code:
    function ContinueScript: Boolean;
    begin
      if LoggedIn then
      begin
        if FindPickHeadColor then
          Result := True;
      end;
    end;
    This can be shortened to:
    Code:
    function ContinueScript: boolean;
    begin
      if LoggedIn then
        if FindPickHeadColor then
          Result := True;
    end;
    EDIT2: What Richard said.

  4. #4
    Join Date
    Oct 2007
    Location
    Denmark
    Posts
    409
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Richard View Post
    As far as I can see its pretty good. But surely with the DDTMs you can shorten them into one and have a variable colour like this:

    SCAR Code:
    unction MakeDDTM(Which: String): Integer;
    var
      dtmMainPoint: TDTMPointDef;
      dtmSubPoints: Array [0..3] of TDTMPointDef;
      TempTDTM: TDTM;
      i, x, y, Colour: Integer;
      Tole, Stone, BStone, Dirt: Integer;
    begin
      Stone := 6054490;
      BStone := 3431561;
      Dirt := 935539;
      case Lowercase(Which) of
        'iron': Colour := {something};
        'copper': Colour := {something};
        etc.
       end;
       begin
         dtmMainPoint.x := ***;
         dtmMainPoint.y := ***;
         dtmMainPoint.Color := Colour;

         dtmSubPoints[0].x := ***;
         dtmSubPoints[0].y := ***;
         dtmSubPoints[0].Color := ********;

         etc.
       end;
        repeat
        Tole := tole + 5;
        dtmMainPoint.AreaSize := 7;
        dtmMainPoint.AreaShape := 0;
        dtmMainPoint.Tolerance := Tole;
        for i := 0 to High(dtmSubPoints) do
        begin
          dtmSubPoints[i].AreaSize := 7;
          dtmsubPoints[i].AreaShape := 0;
          dtmSubPoints[i].Tolerance := Tole;
        end;

        TempTDTM.MainPoint := dtmMainPoint;
        TempTDTM.SubPoints := dtmSubPoints;
        try
          FreeDTM(Result);
        except
        end;
        Result := AddDTM(TempTDTM);
      until DTMRotated(Result, x, y, MMX1, MMY1, MMX2, MMY2) or (Tole > 15);
    end;
    Thanks for the feedback.
    I just don't get how the subpoints would get the correct coordinates if made into one.

  5. #5
    Join Date
    Dec 2007
    Location
    192.168.1.73
    Posts
    2,439
    Mentioned
    6 Post(s)
    Quoted
    119 Post(s)

    Default

    Just make sure the colour that changes is always the same point of the ore. Its not what the coordinates are, its that they are within the same distant that they are in the coordinates.

  6. #6
    Join Date
    Oct 2007
    Location
    Denmark
    Posts
    409
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    It's not a DTM of a ore.
    It's a DTM of the MM like where to go at the mine.

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
  •