Results 1 to 3 of 3

Thread: Help fixing an outdated script!

  1. #1
    Join Date
    Feb 2009
    Location
    Canada
    Posts
    58
    Mentioned
    1 Post(s)
    Quoted
    22 Post(s)

    Post Help fixing an outdated script!

    • Name - Reflection Miner (by Krazy_Meerkat)
    • The script is supposed to mine either coal or tin ores from the barbarian village mines and then bank them to the edgeville bank
    • The script used to work, however I believe it's now outdated and the OP(Krazy_Meerkat) will not update it.
    • Availble to anyone (F2P)
    • Difficulty to fix? Easy?
    Issue:

    • after filling the declare player, the script gives an error message at line 67 (highlighted line in the code).


    (66:70): Unknown identifier 'Widget_getItems' at line 67
    I'm currently running the latest simba version, the SRL-OSR include, and smart 8 (I did try to change the code to run with smart8 with no success.


    Code:
    program Reflection_Miner;
    {$Define Smart8}
    {$I SRL-OSR/SRL.Simba}
    {$I SRL-OSR/SRL/Reflection/Reflection.simba}
    
    var
      Loads, MiningLev, PickHead, PickHandle:integer;
      OreType: TStringArray;
      goback: Boolean;
      man:TNPC;
      phes: TNPCArray;
      spot: Tpoint;
    
    // Start at Edgeville bank or Barbarian village mines
    // Have a pick in the top-left slot of your inventory
    // Place extra picks in the top-left slot of the bank
    
    
    Procedure DeclarePlayers;
    begin
      HowManyPlayers := 1;
      NumberOfPlayers(HowManyPlayers);
      CurrentPlayer := 0;
      with Players[0] do
      begin
        OreType     := ['Tin', 'Coal']; //Tin and Coal supported
        Name        := '';
        Pass        := '';
        Nick        := '';
        Active      := True;
      end;
    end;
    
    type
      TInventoryItem2 = record
        ID, Quantity, Slot: Integer;
      end;
    
      TInventoryItemArray2 = Array of TInventoryItem2;
    
    function R_GetWidget2(Index, ChildIndex: Integer): Integer;
    begin
      Result := SmartGetFieldArray2DObject(SmartCurrentTarget, 0, client_widgets, Index, ChildIndex);
    end;
    (*
    R_GetInventoryItems2
    ~~~~~~~~~~~~~~
    
    .. code-block:: pascal
    
        R_GetInventoryItems2: TInventoryItemArray2;
    
    .. note::
    
      by Frement
    
    *)
    function R_GetInventoryItems2: TInventoryItemArray2;
    var
      _Inventory, _InventorySlot, _ItemID, _ItemQuantity: Integer;
    begin
      _Inventory := R_GetWidget2(149, 0);
      SetLength(Result, 28);
      for _InventorySlot := 0 to 27 do begin
        _ItemID := SmartGetFieldArrayInt(SmartCurrentTarget, _Inventory, Widget_getItems, _InventorySlot);
        if (_ItemID > 0) then begin
          _ItemQuantity := SmartGetFieldArrayInt(SmartCurrentTarget, _Inventory, Widget_getStackSizes, _InventorySlot);
          with Result[_InventorySlot] do begin
            ID := _ItemID;
            Quantity := _ItemQuantity;
            Slot := _InventorySlot + 1;
          end;
        end;
      end;
      SmartFreeObject(SmartCurrentTarget, _Inventory);
    end;
    
    (*
    R_InvCount2
    ~~~~~~~~~~~~~~
    
    .. code-block:: pascal
    
        R_InvCount2: Integer;
    
    .. note::
    
      by Frement
    
    *)
    function R_InvCount2: Integer;
    var
      I: Integer;
      _Items: TInventoryItemArray2;
    begin
      _Items := R_GetInventoryItems2;
      for I := 0 to high(_items) do begin
        if (_items[i].ID <> 0) then
          inc(result);
      end;
    end;
    
    (*
    R_HasInvItem
    ~~~~~~~~~~~~~~
    
    .. code-block:: pascal
    
        R_HasInvItem(ID: Integer): Boolean;
    
    .. note::
    
      by Krazy_Meerkat
    
    *)
    function R_HasInvItem(ID: Integer): Boolean;
    var
      I: Integer;
      _Items: TInventoryItemArray2;
    begin
      Result:= false;
      _Items := R_GetInventoryItems2;
      for I := 0 to high(_items) do
      begin
        if (_items[i].ID = ID) then
        begin
          Result:= true;
          Break;
        end;
      end;
    end;
    
    (*
    R_GetInvItemSlot
    ~~~~~~~~~~~~~~
    
    .. code-block:: pascal
    
        R_GetInvItemSlot(ID: Integer): Integer;
    
    .. note::
    
      by Krazy_Meerkat
    
    *)
    function R_GetInvItemSlot(ID: Integer): Integer;
    var
      I: Integer;
      _Items: TInventoryItemArray2;
    begin
      Result:= -1;
      _Items := R_GetInventoryItems2;
      for I := 0 to high(_items) do
      begin
        if (_items[i].ID = ID) then
        begin
          Result:= _items[i].Slot;
          Break;
        end;
      end;
    end;
    
    (*
    R_BankItems
    ~~~~~~~~~~~~~~
    
    .. code-block:: pascal
    
        R_BankItems(BoothTile: TPoint; DepositAll: Boolean; WithdrawAmount, WithdrawSlot: Integer);
    
    Attempts to bank at BoothTile.
    If DepositAll is true, all player items will be deposited.
    if WithdrawAmount is 0, no items will be withdrawn.
    Bank items will be withdrawn from WithdrawSlot.
    
    .. note::
    
      by Krazy_Meerkat
    
    .. example::
    
      R_BankItems(Point(x, y), true, 0, 0); //Open bank & deposit inventory
      R_BankItems(Point(x, y), false, 2, 1); //Open bank & withdraw 2 from slot 1
      R_BankItems(Point(x, y), true, 1, 2); //Open bank, deposit all & withdraw 1 from slot 2
    
    *)
    procedure R_BankItems(BoothTile: TPoint; DepositAll: Boolean; WithdrawAmount, WithdrawSlot: Integer);
    var
      u,x,y: Integer;
      BankPoint: Tpoint;
    begin
        R_PerfectPath([BoothTile]);
      for u:= 0 to 100 do
      begin
        R_InteractTile(BoothTile, 'Bank B');
        sleepandmovemouse(1000 + random(500));
        while R_IsWalking do
          wait(100);
        sleepandmovemouse(500 + random(500));
        if BankScreen then u:= 100;
      end;
      if not BankScreen then
      begin
        writeln('[R_BankItems] Didn''t find BankScreen, logging out & terminating.');
        if LoggedIn then LogOut;
        TerminateScript;
      end;
      if DepositAll then
      begin
        for u:= 0 to 100 do
        begin
          wait(70 + random(50));
          QuickDeposit('inv');
          sleepandmovemouse(900 + random(450));
          if (R_InvCount2 = 0) then u:= 100;
        end;
      end;
      if (WithdrawSlot > 0) then
        BankPoint := BankIndexToBankPoint(WithdrawSlot);
      Withdraw(BankPoint.x, BankPoint.y, WithdrawAmount);
      wait(70 + random(50));
      CloseBank;
      wait(70 + random(50));
    end;
    
    function GetToTile(TheTile, NextPoint: TPoint): Boolean; //check randoms while walking
    var
       msTile: TPoint;
       t: Integer;
    begin
      Result := false;
      msTile := R_TileToMM(TheTile);
      if not(rs_OnMiniMap(msTile)) then
        Exit;
      t := getsystemtime;
      if (NextPoint.x = -1) then
      begin
        repeat
          msTile := R_TileToMM(TheTile);
          MouseBox(msTile.x-1, msTile.y-1, msTile.x+1, msTile.y+1, Mouse_Left);
          Wait(RandomRange(80, 100));
          if (not(R_IsWalking)) then
          begin
            repeat
              wait(50+random(50));
              R_FindNormalRandoms;
            until(R_IsWalking or ((GetSystemTime - t) > (1000+random(500))));
          end;
          repeat
            wait(50+random(50));
            R_FindNormalRandoms;
          until(not(R_IsWalking));
        until((R_NearTile(TheTile, 5)) or ((GetSystemTime - t) > 59999));
      end;
      if (NextPoint.x > -1) then
      begin
        repeat
          msTile := R_TileToMM(TheTile);
          MouseBox(msTile.x-1, msTile.y-1, msTile.x+1, msTile.y+1, Mouse_Left);
          Wait(RandomRange(80, 100));
          if (not(R_IsWalking)) then
          begin
            repeat
              wait(50+random(50));
              R_FindNormalRandoms;
            until(R_IsWalking or ((GetSystemTime - t) > (1000+random(500))));
          end;
          repeat
            wait(50+random(50));
            R_FindNormalRandoms;
          until((R_NearTile(TheTile, 5) and R_TileOnMM(NextPoint)) or not(R_IsWalking));
        until((R_NearTile(TheTile, 5) and R_TileOnMM(NextPoint)) or ((GetSystemTime - t) > 59999));
      end;
      Result := (GetSystemTime - t) < 60000;
    end;
    
    function WebWalk(T: TPoint): Boolean;
    var
      I, ti: Integer;
      M: TPoint;
      CTRLPoints: TPointArray;
    begin
      Result:= false;
      ti:= GetSystemTime;
      repeat
        M := R_GetTileGlobal;
        CtrlPoints := r_WindPath(M.x, M.y, T.X, T.Y, 5.0, 2.5, 0.0, 0.0, 4.5, 2.5);
        for I:= High(CtrlPoints) DownTo 0 Do
          if (I = 0) then
          begin
            if GetToTile(CtrlPoints[i], Point(-1,-1)) Then
            begin
              Result := I = High(CtrlPoints);
              Break;
            end;
          end else
          begin
            if GetToTile(CtrlPoints[i], CtrlPoints[i-1]) Then
            begin
              Result := I = High(CtrlPoints);
              Break;
            end;
          end;
      until((Result) or ((GetSystemTime - ti) > 59999));
    end;
    
    procedure ElitePath(Path: TPointArray);
    var
      i, e, f, g: Integer;
      tpa: TPointArray;
    begin
      f:= 0;
      SetArrayLength(TPA, length(Path));
      for i:= 0 to high(path) do
        TPA[i]:= Path[i];
      SortTPAFrom(TPA, R_GetTileGlobal);
      for g := 0 to high(path) do
        if ((TPA[0].x=path[g].x) and (TPA[0].y=path[g].y)) then
          f := g;
      for i:= f to High(Path) do
      begin
        if (i = High(Path)) then
        begin
          repeat
            wait(100+random(50));
            if not(R_TileOnMM(Path[i])) then
              WebWalk(Path[i]);
          until(GetToTile(Path[i], Point(-1,-1)));
        end else
        begin
          for e:= f to High(Path) do
          begin
            if R_TileOnMM(Path[e]) then
              i:= e;
          end;
          if (i = High(Path)) then
          begin
            repeat
              wait(100+random(50));
              if not(R_TileOnMM(Path[i])) then
                WebWalk(Path[i]);
            until(GetToTile(Path[i], Point(-1,-1)));
          end else
          begin
            repeat
              wait(100+random(50));
              if not(R_TileOnMM(Path[i])) then
                WebWalk(Path[i]);
            until(GetToTile(Path[i], Path[i+1]));
          end;
        end;
      end;
    end;
    
    procedure FreeAllDTMs;
    begin
      FreeDTM(PickHead);
      FreeDTM(PickHandle);
    end;
    
    procedure DeclareBmp;
    begin
      PickHandle := DTMFromString('mAAEAAHic42FgYPBggmAfIPYFYm8g9gRiVyB2AWJHKHYGYjcgZmRkYPgD1PeDAUIzAPksQMwFxLxALAjE3EDMxgiRM1GGKiIS8zCQBog3GYKRAQDQtQcn');
      PickHead := DTMFromString('mlwAAAHicY2dgYAhkYmAIAeJQIPYDYm8gdgZiTyC+w8jAcB2ILwPxDSC+BcT3gfgeEOvKAzUzMGLFPAy4AXYdEAwFAMu3CJY=');
      AddOnTerminate('FreeAllDTMs');
    end;
    
    function FindPick:boolean;
    var
      i, x, y:Integer;
      Tpa:TPointArray;
      TempPoint:Tpoint;
    begin
      R_FindNormalRandoms;
      if (FindNPCChatTextMulti(['ine','ick','axe'],nothing)) then
      result := True;
      if result then
      begin
        writeln('Lost Pick');
        TempPoint := R_GetTileGlobal;
        findcolorstolerance(Tpa, 206, MMX1, MMY1, MMX2, MMY2, 5);
        SortTpaFrom(Tpa,Point(643,84));
        goback:= true;
        if Length(Tpa) = 0 then
        begin;
          writeln('Getting a new one from the bank');
        end;
        Mouse(Tpa[0].x,Tpa[0].y, 1, 1, true);
        Wait(randomrange(4000,6000));
        if not(R_InteractTile(R_GetTileGlobal, 'Take')) then
        begin
          findcolorstolerance(Tpa, 7981, MsX1, MsY1, MsX2, MsY2, 15);
          for i := 0 to High(Tpa) do
          begin
            MMouse(Tpa[i].x,Tpa[i].y, 1, 1);
            if R_WaitUpText('Take', 210) then
            begin
              clickmouse2(Mouse_Left);
              goback:= false;
              break;
            end;
          end;
        end else
        begin
          goback:= false;
        end;
        Wait(randomrange(4000,6000));
        if not(goback) then
        begin
          FindDTM(PickHead, x, y, 550, 205, 730, 490);
          MMouse(x,y, 1, 1);
          if WaitUpText('ic', 1500) then
            Clickmouse2(Mouse_Left);
          wait(1000);
          FindDTM(PickHandle, x, y, 550, 205, 730, 490);
          MMouse(x,y, 1, 1);
          if WaitUpText('ic', 1500) then
            Clickmouse2(Mouse_Left);
          wait(1000);
          ElitePath([TempPoint]);
        end;
      end;
    end;
    
    function GasVisible(xs, ys, xe, ye: Integer): Boolean;
    begin
      Result:= (CountColorTolerance(6321273, xs, ys, xe, ye, 20) > 120);
    end;
    
    Procedure FindGas(GasTile: TPoint);
    var
      p: TPoint;
    begin
      p:= R_TileToMs(GasTile);
      if (p.x > 0) then
        if GasVisible(p.x-25, p.y-50, p.x+25, p.y+25) then
        begin
          writeln('Found Explosive Gas TolCount: '+inttostr(CountColorTolerance(6321273, p.x-25, p.y-50, p.x+25, p.y+25, 20))+'.. Waiting for it to disappear');
          R_PerfectPath([GasTile]);
          repeat
            sleepandmovemouse(100+random(100));
          until(not(GasVisible(p.x-25, p.y-50, p.x+25, p.y+25)));
        end;
    end;
    
    procedure Progress;
    var
      i: Integer;
    begin
      cleardebug;
      writeln('****************************************');
      writeln('Krazy_Meerkat''s Edgeville Mining Script');
      writeln('****************************************');
      writeln('Running for '+tostr(TimeRunning));
      writeln('Banked about '+inttostr(Loads*27)+' ores');
      writeln('Completed '+inttostr(Loads)+' loads');
      writeln('Aquired '+inttostr(R_GetSkillLevel(skill_mining)-MiningLev)+' levels');
      for i := 0 to high(R_Randoms) do
      begin
        if (R_Randoms[i].Solved = 1) then
          writeln('Solved '+toStr(R_Randoms[i].solved)+' '+R_Randoms[i].RandName+' Random Event');
        if (R_Randoms[i].Solved > 1) then
          writeln('Solved '+toStr(R_Randoms[i].solved)+' '+R_Randoms[i].RandName+' Random Events');
      end;
      writeln('****************************************');
    end;
    
    procedure MiningAntiban;
    var
      randomn: Integer;
    begin
      if ((random(110) < 10) and (random(110) < 20)) then
      begin
        randomn:= random(8);
        case randomn of
          0: RandomRClick;
          1: PickUpMouse;
          2: HoverSkill(skill_mining, False);
          3: BoredHuman;
          4: ExamineInv;
          5: AdjustMouseSpeed(3, 10, 20);
          6: HoverOnlineFriend;
          7: HoverMovingObject;
        end;
      end;
    end;
    
    procedure MineRocks(Tiles: TPointArray);
    var
      u, i, e, x, y, prevcount: Integer;
      p: TPoint;
    begin
      goback:= false;
      repeat
        for u:= 0 to high(Tiles) do
        begin
          if not(R_NearTile(Tiles[u], 3)) then
            ElitePath([Tiles[u]]);
          R_FindNormalRandoms;
          prevcount:= InvCount;
          i:= 0;
          repeat
            sleepandmovemouse(100+random(50));
            inc(i);
            FindGas(Tiles[u]);
            FindPick;
          until(R_InteractTile(Tiles[u], 'Mine') or (i > 100));
          i:=0;
          repeat
            sleepandmovemouse(100+random(50));
            if R_IsAnimating then i:= 50;
            inc(i);
          until(i > 50);
          i:= 0;
          repeat
            R_FindNormalRandoms;
            sleepandmovemouse(100+random(50));
            LevelUpEx(false);
            inc(i);
            FindGas(Tiles[u]);
            FindPick;
            if ((InvCount > 27) or goback) then
            begin
              u:= high(Tiles);
            end else
              MiningAntiban;
          until((InvCount > prevcount) or not(R_IsAnimating) or (InvCount > 27) or (i > 150) or goback);
          wait(70+random(50));
          if ((InvCount > 27) or goback) then
          begin
            u:= high(Tiles);
          end;
        end;
        wait(70 + random(50));
      until((InvCount > 27) or (R_GetLoginState < 11) or (R_GetLoginState > 30) or goback);
    end;
    
    procedure MineRock;
    var
      RockCollection, Rocks: TPointArray;
    begin
      RockCollection:= [];
      if (StrInArr('Tin', OreType)) then
      begin
        if (Random(101) < 51) then
        begin
          Rocks:= [Point(3080, 3418),Point(3080, 3420),Point(3081, 3419)];
          if (Random(101) < 51) then
            InvertTPA(Rocks);
          RockCollection:= CombineTPA(RockCollection, Rocks);
        end else
        begin
          Rocks:= [Point(3080, 3420),Point(3079, 3421)];
          if (Random(101) < 51) then
            InvertTPA(Rocks);
          RockCollection:= CombineTPA(RockCollection, Rocks);
        end;
      end;
      if (StrInArr('Coal', OreType)) then
      begin
        Rocks:= [Point(3081, 3422),Point(3082, 3421),Point(3083, 3421)];
        if (Random(101) < 51) then
          InvertTPA(Rocks);
        RockCollection:= CombineTPA(RockCollection, Rocks);
      end;
      MineRocks(RockCollection);
    end;
    
    procedure MainLoop;
    begin
      makeCompass('S');
      if R_NearTile(Point(3094, 3491), 5) then
        ElitePath([Point(3095, 3485), Point(3099, 3475), Point(3099, 3468), Point(3089, 3464), Point(3086, 3458), Point(3086, 3449), Point(3087, 3440), Point(3088, 3431), Point(3085, 3425)]);
      MineRock;
      ElitePath([Point(3085, 3425), Point(3088, 3431), Point(3087, 3440), Point(3086, 3449), Point(3086, 3458), Point(3089, 3464), Point(3099, 3468), Point(3099, 3475), Point(3095, 3485), Point(3095, 3491)]);
      inc(Loads);
      Progress;
      R_BankItems(Point(3095, 3491), true, 1, 1);
    end;
    
    begin
      DeclarePlayers;
      SetupSRL;
      SetupReflection;
      if not LoggedIn then LogInPlayer;
      setAngle(SRL_ANGLE_HIGH);
      MiningLev:= R_GetSkillLevel(skill_mining);
      DeclareBmp;
      repeat
        MainLoop;
        wait(150+random(100));
      until((R_GetLoginState < 11) or (R_GetLoginState > 30));
    end.

  2. #2
    Join Date
    Dec 2011
    Posts
    69
    Mentioned
    0 Post(s)
    Quoted
    15 Post(s)

    Default

    if you have a throwaway you can let me test it with I could try to sort it out for you as I'm sure there would be more issues than getting it to compile


    I'm not sure if asking that is against the rules or not, so mods do as needed




    pm if that is an option

  3. #3
    Join Date
    Sep 2008
    Posts
    754
    Mentioned
    8 Post(s)
    Quoted
    275 Post(s)

    Default

    Some of the titles for the widgets needs re-naming:

    at line 45:

    Simba Code:
    {Line 45}

    From: SmartGetFieldArray2DObject(SmartCurrentTarget, 0, client_widgets, Index, ChildIndex);

    to: Result := SmartGetFieldArray2DObject(SmartCurrentTarget, 0, Client_GetWidgets, Index, ChildIndex);

    { Line 65}

    From: _ItemID := SmartGetFieldArrayInt(SmartCurrentTarget, _Inventory, Widget_getItems, _InventorySlot);

    to: _ItemID := SmartGetFieldArrayInt(SmartCurrentTarget, _Inventory, Widget_GetIDs, _InventorySlot);  

    {Line 67}

    from: _ItemQuantity := SmartGetFieldArrayInt(SmartCurrentTarget, _Inventory, Widget_getStackSizes, _InventorySlot);

    to: _ItemQuantity := SmartGetFieldArrayInt(SmartCurrentTarget, _Inventory, Widget_StackSizes, _InventorySlot);


    So it would look like...



    Simba Code:
    program Reflection_Miner;
    {$Define Smart8}
    {$I SRL-OSR/SRL.Simba}
    {$I SRL-OSR/SRL/Reflection/Reflection.simba}

    var
      Loads, MiningLev, PickHead, PickHandle:integer;
      OreType: TStringArray;
      goback: Boolean;
      man:TNPC;
      phes: TNPCArray;
      spot: Tpoint;

    // Start at Edgeville bank or Barbarian village mines
    // Have a pick in the top-left slot of your inventory
    // Place extra picks in the top-left slot of the bank


    Procedure DeclarePlayers;
    begin
      HowManyPlayers := 1;
      NumberOfPlayers(HowManyPlayers);
      CurrentPlayer := 0;
      with Players[0] do
      begin
        OreType     := ['Tin', 'Coal']; //Tin and Coal supported
        Name        := '';
        Pass        := '';
        Nick        := '';
        Active      := True;
      end;
    end;

    type
      TInventoryItem2 = record
        ID, Quantity, Slot: Integer;
      end;

      TInventoryItemArray2 = Array of TInventoryItem2;

    function R_GetWidget2(Index, ChildIndex: Integer): Integer;
    begin
      Result := SmartGetFieldArray2DObject(SmartCurrentTarget, 0, Client_GetWidgets, Index, ChildIndex);
    end;
    (*
    R_GetInventoryItems2
    ~~~~~~~~~~~~~~

    .. code-block:: pascal

        R_GetInventoryItems2: TInventoryItemArray2;

    .. note::

      by Frement

    *)

    function R_GetInventoryItems2: TInventoryItemArray2;
    var
      _Inventory, _InventorySlot, _ItemID, _ItemQuantity: Integer;
    begin
      _Inventory := R_GetWidget2(149, 0);
      SetLength(Result, 28);
      for _InventorySlot := 0 to 27 do begin
        _ItemID := SmartGetFieldArrayInt(SmartCurrentTarget, _Inventory, Widget_GetIDs, _InventorySlot);
        if (_ItemID > 0) then begin
          _ItemQuantity := SmartGetFieldArrayInt(SmartCurrentTarget, _Inventory, Widget_StackSizes, _InventorySlot);
          with Result[_InventorySlot] do begin
            ID := _ItemID;
            Quantity := _ItemQuantity;
            Slot := _InventorySlot + 1;
          end;
        end;
      end;
      SmartFreeObject(SmartCurrentTarget, _Inventory);
    end;

    (*
    R_InvCount2
    ~~~~~~~~~~~~~~

    .. code-block:: pascal

        R_InvCount2: Integer;

    .. note::

      by Frement

    *)

    function R_InvCount2: Integer;
    var
      I: Integer;
      _Items: TInventoryItemArray2;
    begin
      _Items := R_GetInventoryItems2;
      for I := 0 to high(_items) do begin
        if (_items[i].ID <> 0) then
          inc(result);
      end;
    end;

    (*
    R_HasInvItem
    ~~~~~~~~~~~~~~

    .. code-block:: pascal

        R_HasInvItem(ID: Integer): Boolean;

    .. note::

      by Krazy_Meerkat

    *)

    function R_HasInvItem(ID: Integer): Boolean;
    var
      I: Integer;
      _Items: TInventoryItemArray2;
    begin
      Result:= false;
      _Items := R_GetInventoryItems2;
      for I := 0 to high(_items) do
      begin
        if (_items[i].ID = ID) then
        begin
          Result:= true;
          Break;
        end;
      end;
    end;

    (*
    R_GetInvItemSlot
    ~~~~~~~~~~~~~~

    .. code-block:: pascal

        R_GetInvItemSlot(ID: Integer): Integer;

    .. note::

      by Krazy_Meerkat

    *)

    function R_GetInvItemSlot(ID: Integer): Integer;
    var
      I: Integer;
      _Items: TInventoryItemArray2;
    begin
      Result:= -1;
      _Items := R_GetInventoryItems2;
      for I := 0 to high(_items) do
      begin
        if (_items[i].ID = ID) then
        begin
          Result:= _items[i].Slot;
          Break;
        end;
      end;
    end;

    (*
    R_BankItems
    ~~~~~~~~~~~~~~

    .. code-block:: pascal

        R_BankItems(BoothTile: TPoint; DepositAll: Boolean; WithdrawAmount, WithdrawSlot: Integer);

    Attempts to bank at BoothTile.
    If DepositAll is true, all player items will be deposited.
    if WithdrawAmount is 0, no items will be withdrawn.
    Bank items will be withdrawn from WithdrawSlot.

    .. note::

      by Krazy_Meerkat

    .. example::

      R_BankItems(Point(x, y), true, 0, 0); //Open bank & deposit inventory
      R_BankItems(Point(x, y), false, 2, 1); //Open bank & withdraw 2 from slot 1
      R_BankItems(Point(x, y), true, 1, 2); //Open bank, deposit all & withdraw 1 from slot 2

    *)

    procedure R_BankItems(BoothTile: TPoint; DepositAll: Boolean; WithdrawAmount, WithdrawSlot: Integer);
    var
      u,x,y: Integer;
      BankPoint: Tpoint;
    begin
        R_PerfectPath([BoothTile]);
      for u:= 0 to 100 do
      begin
        R_InteractTile(BoothTile, 'Bank B');
        sleepandmovemouse(1000 + random(500));
        while R_IsWalking do
          wait(100);
        sleepandmovemouse(500 + random(500));
        if BankScreen then u:= 100;
      end;
      if not BankScreen then
      begin
        writeln('[R_BankItems] Didn''t find BankScreen, logging out & terminating.');
        if LoggedIn then LogOut;
        TerminateScript;
      end;
      if DepositAll then
      begin
        for u:= 0 to 100 do
        begin
          wait(70 + random(50));
          QuickDeposit('inv');
          sleepandmovemouse(900 + random(450));
          if (R_InvCount2 = 0) then u:= 100;
        end;
      end;
      if (WithdrawSlot > 0) then
        BankPoint := BankIndexToBankPoint(WithdrawSlot);
      Withdraw(BankPoint.x, BankPoint.y, WithdrawAmount);
      wait(70 + random(50));
      CloseBank;
      wait(70 + random(50));
    end;

    function GetToTile(TheTile, NextPoint: TPoint): Boolean; //check randoms while walking
    var
       msTile: TPoint;
       t: Integer;
    begin
      Result := false;
      msTile := R_TileToMM(TheTile);
      if not(rs_OnMiniMap(msTile)) then
        Exit;
      t := getsystemtime;
      if (NextPoint.x = -1) then
      begin
        repeat
          msTile := R_TileToMM(TheTile);
          MouseBox(msTile.x-1, msTile.y-1, msTile.x+1, msTile.y+1, Mouse_Left);
          Wait(RandomRange(80, 100));
          if (not(R_IsWalking)) then
          begin
            repeat
              wait(50+random(50));
              R_FindNormalRandoms;
            until(R_IsWalking or ((GetSystemTime - t) > (1000+random(500))));
          end;
          repeat
            wait(50+random(50));
            R_FindNormalRandoms;
          until(not(R_IsWalking));
        until((R_NearTile(TheTile, 5)) or ((GetSystemTime - t) > 59999));
      end;
      if (NextPoint.x > -1) then
      begin
        repeat
          msTile := R_TileToMM(TheTile);
          MouseBox(msTile.x-1, msTile.y-1, msTile.x+1, msTile.y+1, Mouse_Left);
          Wait(RandomRange(80, 100));
          if (not(R_IsWalking)) then
          begin
            repeat
              wait(50+random(50));
              R_FindNormalRandoms;
            until(R_IsWalking or ((GetSystemTime - t) > (1000+random(500))));
          end;
          repeat
            wait(50+random(50));
            R_FindNormalRandoms;
          until((R_NearTile(TheTile, 5) and R_TileOnMM(NextPoint)) or not(R_IsWalking));
        until((R_NearTile(TheTile, 5) and R_TileOnMM(NextPoint)) or ((GetSystemTime - t) > 59999));
      end;
      Result := (GetSystemTime - t) < 60000;
    end;

    function WebWalk(T: TPoint): Boolean;
    var
      I, ti: Integer;
      M: TPoint;
      CTRLPoints: TPointArray;
    begin
      Result:= false;
      ti:= GetSystemTime;
      repeat
        M := R_GetTileGlobal;
        CtrlPoints := r_WindPath(M.x, M.y, T.X, T.Y, 5.0, 2.5, 0.0, 0.0, 4.5, 2.5);
        for I:= High(CtrlPoints) DownTo 0 Do
          if (I = 0) then
          begin
            if GetToTile(CtrlPoints[i], Point(-1,-1)) Then
            begin
              Result := I = High(CtrlPoints);
              Break;
            end;
          end else
          begin
            if GetToTile(CtrlPoints[i], CtrlPoints[i-1]) Then
            begin
              Result := I = High(CtrlPoints);
              Break;
            end;
          end;
      until((Result) or ((GetSystemTime - ti) > 59999));
    end;

    procedure ElitePath(Path: TPointArray);
    var
      i, e, f, g: Integer;
      tpa: TPointArray;
    begin
      f:= 0;
      SetArrayLength(TPA, length(Path));
      for i:= 0 to high(path) do
        TPA[i]:= Path[i];
      SortTPAFrom(TPA, R_GetTileGlobal);
      for g := 0 to high(path) do
        if ((TPA[0].x=path[g].x) and (TPA[0].y=path[g].y)) then
          f := g;
      for i:= f to High(Path) do
      begin
        if (i = High(Path)) then
        begin
          repeat
            wait(100+random(50));
            if not(R_TileOnMM(Path[i])) then
              WebWalk(Path[i]);
          until(GetToTile(Path[i], Point(-1,-1)));
        end else
        begin
          for e:= f to High(Path) do
          begin
            if R_TileOnMM(Path[e]) then
              i:= e;
          end;
          if (i = High(Path)) then
          begin
            repeat
              wait(100+random(50));
              if not(R_TileOnMM(Path[i])) then
                WebWalk(Path[i]);
            until(GetToTile(Path[i], Point(-1,-1)));
          end else
          begin
            repeat
              wait(100+random(50));
              if not(R_TileOnMM(Path[i])) then
                WebWalk(Path[i]);
            until(GetToTile(Path[i], Path[i+1]));
          end;
        end;
      end;
    end;

    procedure FreeAllDTMs;
    begin
      FreeDTM(PickHead);
      FreeDTM(PickHandle);
    end;

    procedure DeclareBmp;
    begin
      PickHandle := DTMFromString('mAAEAAHic42FgYPBggmAfIPYFYm8g9gRiVyB2AWJHKHYGYjcgZmRkYPgD1PeDAUIzAPksQMwFxLxALAjE3EDMxgiRM1GGKiIS8zCQBog3GYKRAQDQtQcn');
      PickHead := DTMFromString('mlwAAAHicY2dgYAhkYmAIAeJQIPYDYm8gdgZiTyC+w8jAcB2ILwPxDSC+BcT3gfgeEOvKAzUzMGLFPAy4AXYdEAwFAMu3CJY=');
      AddOnTerminate('FreeAllDTMs');
    end;

    function FindPick:boolean;
    var
      i, x, y:Integer;
      Tpa:TPointArray;
      TempPoint:Tpoint;
    begin
      R_FindNormalRandoms;
      if (FindNPCChatTextMulti(['ine','ick','axe'],nothing)) then
      result := True;
      if result then
      begin
        writeln('Lost Pick');
        TempPoint := R_GetTileGlobal;
        findcolorstolerance(Tpa, 206, MMX1, MMY1, MMX2, MMY2, 5);
        SortTpaFrom(Tpa,Point(643,84));
        goback:= true;
        if Length(Tpa) = 0 then
        begin;
          writeln('Getting a new one from the bank');
        end;
        Mouse(Tpa[0].x,Tpa[0].y, 1, 1, true);
        Wait(randomrange(4000,6000));
        if not(R_InteractTile(R_GetTileGlobal, 'Take')) then
        begin
          findcolorstolerance(Tpa, 7981, MsX1, MsY1, MsX2, MsY2, 15);
          for i := 0 to High(Tpa) do
          begin
            MMouse(Tpa[i].x,Tpa[i].y, 1, 1);
            if R_WaitUpText('Take', 210) then
            begin
              clickmouse2(Mouse_Left);
              goback:= false;
              break;
            end;
          end;
        end else
        begin
          goback:= false;
        end;
        Wait(randomrange(4000,6000));
        if not(goback) then
        begin
          FindDTM(PickHead, x, y, 550, 205, 730, 490);
          MMouse(x,y, 1, 1);
          if WaitUpText('ic', 1500) then
            Clickmouse2(Mouse_Left);
          wait(1000);
          FindDTM(PickHandle, x, y, 550, 205, 730, 490);
          MMouse(x,y, 1, 1);
          if WaitUpText('ic', 1500) then
            Clickmouse2(Mouse_Left);
          wait(1000);
          ElitePath([TempPoint]);
        end;
      end;
    end;

    function GasVisible(xs, ys, xe, ye: Integer): Boolean;
    begin
      Result:= (CountColorTolerance(6321273, xs, ys, xe, ye, 20) > 120);
    end;

    Procedure FindGas(GasTile: TPoint);
    var
      p: TPoint;
    begin
      p:= R_TileToMs(GasTile);
      if (p.x > 0) then
        if GasVisible(p.x-25, p.y-50, p.x+25, p.y+25) then
        begin
          writeln('Found Explosive Gas TolCount: '+inttostr(CountColorTolerance(6321273, p.x-25, p.y-50, p.x+25, p.y+25, 20))+'.. Waiting for it to disappear');
          R_PerfectPath([GasTile]);
          repeat
            sleepandmovemouse(100+random(100));
          until(not(GasVisible(p.x-25, p.y-50, p.x+25, p.y+25)));
        end;
    end;

    procedure Progress;
    var
      i: Integer;
    begin
      cleardebug;
      writeln('****************************************');
      writeln('Krazy_Meerkat''s Edgeville Mining Script');
      writeln('****************************************');
      writeln('Running for '+tostr(TimeRunning));
      writeln('Banked about '+inttostr(Loads*27)+' ores');
      writeln('Completed '+inttostr(Loads)+' loads');
      writeln('Aquired '+inttostr(R_GetSkillLevel(skill_mining)-MiningLev)+' levels');
      for i := 0 to high(R_Randoms) do
      begin
        if (R_Randoms[i].Solved = 1) then
          writeln('Solved '+toStr(R_Randoms[i].solved)+' '+R_Randoms[i].RandName+' Random Event');
        if (R_Randoms[i].Solved > 1) then
          writeln('Solved '+toStr(R_Randoms[i].solved)+' '+R_Randoms[i].RandName+' Random Events');
      end;
      writeln('****************************************');
    end;

    procedure MiningAntiban;
    var
      randomn: Integer;
    begin
      if ((random(110) < 10) and (random(110) < 20)) then
      begin
        randomn:= random(8);
        case randomn of
          0: RandomRClick;
          1: PickUpMouse;
          2: HoverSkill(skill_mining, False);
          3: BoredHuman;
          4: ExamineInv;
          5: AdjustMouseSpeed(3, 10, 20);
          6: HoverOnlineFriend;
          7: HoverMovingObject;
        end;
      end;
    end;

    procedure MineRocks(Tiles: TPointArray);
    var
      u, i, e, x, y, prevcount: Integer;
      p: TPoint;
    begin
      goback:= false;
      repeat
        for u:= 0 to high(Tiles) do
        begin
          if not(R_NearTile(Tiles[u], 3)) then
            ElitePath([Tiles[u]]);
          R_FindNormalRandoms;
          prevcount:= InvCount;
          i:= 0;
          repeat
            sleepandmovemouse(100+random(50));
            inc(i);
            FindGas(Tiles[u]);
            FindPick;
          until(R_InteractTile(Tiles[u], 'Mine') or (i > 100));
          i:=0;
          repeat
            sleepandmovemouse(100+random(50));
            if R_IsAnimating then i:= 50;
            inc(i);
          until(i > 50);
          i:= 0;
          repeat
            R_FindNormalRandoms;
            sleepandmovemouse(100+random(50));
            LevelUpEx(false);
            inc(i);
            FindGas(Tiles[u]);
            FindPick;
            if ((InvCount > 27) or goback) then
            begin
              u:= high(Tiles);
            end else
              MiningAntiban;
          until((InvCount > prevcount) or not(R_IsAnimating) or (InvCount > 27) or (i > 150) or goback);
          wait(70+random(50));
          if ((InvCount > 27) or goback) then
          begin
            u:= high(Tiles);
          end;
        end;
        wait(70 + random(50));
      until((InvCount > 27) or (R_GetLoginState < 11) or (R_GetLoginState > 30) or goback);
    end;

    procedure MineRock;
    var
      RockCollection, Rocks: TPointArray;
    begin
      RockCollection:= [];
      if (StrInArr('Tin', OreType)) then
      begin
        if (Random(101) < 51) then
        begin
          Rocks:= [Point(3080, 3418),Point(3080, 3420),Point(3081, 3419)];
          if (Random(101) < 51) then
            InvertTPA(Rocks);
          RockCollection:= CombineTPA(RockCollection, Rocks);
        end else
        begin
          Rocks:= [Point(3080, 3420),Point(3079, 3421)];
          if (Random(101) < 51) then
            InvertTPA(Rocks);
          RockCollection:= CombineTPA(RockCollection, Rocks);
        end;
      end;
      if (StrInArr('Coal', OreType)) then
      begin
        Rocks:= [Point(3081, 3422),Point(3082, 3421),Point(3083, 3421)];
        if (Random(101) < 51) then
          InvertTPA(Rocks);
        RockCollection:= CombineTPA(RockCollection, Rocks);
      end;
      MineRocks(RockCollection);
    end;

    procedure MainLoop;
    begin
      makeCompass('S');
      if R_NearTile(Point(3094, 3491), 5) then
        ElitePath([Point(3095, 3485), Point(3099, 3475), Point(3099, 3468), Point(3089, 3464), Point(3086, 3458), Point(3086, 3449), Point(3087, 3440), Point(3088, 3431), Point(3085, 3425)]);
      MineRock;
      ElitePath([Point(3085, 3425), Point(3088, 3431), Point(3087, 3440), Point(3086, 3449), Point(3086, 3458), Point(3089, 3464), Point(3099, 3468), Point(3099, 3475), Point(3095, 3485), Point(3095, 3491)]);
      inc(Loads);
      Progress;
      R_BankItems(Point(3095, 3491), true, 1, 1);
    end;

    begin
      DeclarePlayers;
      SetupSRL;
      SetupReflection;
      if not LoggedIn then LogInPlayer;
      setAngle(SRL_ANGLE_HIGH);
      MiningLev:= R_GetSkillLevel(skill_mining);
      DeclareBmp;
      repeat
        MainLoop;
        wait(150+random(100));
      until((R_GetLoginState < 11) or (R_GetLoginState > 30));
    end.


    As long as you have the compiler set to pascal (and not lape) it should compile with:


    Compiled successfully in 640 ms.
    Now as it goes, you have to update the locations, ids and so on.. Which shouldn't be too hard if you use the reflection tools in your folder, can't help you there - i don't play video games anymore but good luck.
    Quit gaming

Thread Information

Users Browsing this Thread

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

Tags for this Thread

Posting Permissions

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