Results 1 to 3 of 3

Thread: Just some snippets from my abandonned miner

  1. #1
    Join Date
    Feb 2013
    Posts
    103
    Mentioned
    0 Post(s)
    Quoted
    32 Post(s)

    Default Just some snippets from my abandonned miner

    It is what it says. Most of this is taken right out of my script, and I'm posting it here in case it's actually useable. I figure someone else might use it for their miner or something.

    Simba Code:
    var //Lets keep thes chronological where relevant. IE, Iron is before Mithril etc.
    MiningLevel, SmithingLevel, AttackLevel: Integer;
    PickaxeWieldInv: String; //Tells our procedures where the Pickaxe will be.
    {---DTM's---}
    Pickaxe, IronPickaxe, MithrilPickaxe, AdamantPickaxe, RunePickaxe, PickaxeEquipped, VTeleTab, TinOre, CopperOre, IronOre, CoalOre, Bar: Integer;    

    procedure DefineDTM;
    begin
     Pickaxe := DTMFromString('m/AEAAHictc7hBsJQGMbx56yVEYsiXU530dddTizLKikxoquMtf6zhyb6lL38vOd9HOe8K0mXSNphiweuuKHC3Spn7d0zTjigRIHcbxTOjtg7q/ljGaSGPqY/6S+IcwhdFmOEyHOCKVIsMMfM2cT3ZOtN9hkG0O79XU3PvzXc5p1f9Qb4Yxf+');
     IronPickaxe := DTMFromString('m1gAAAHic42JgYIgG4gQgTgbiWCCOAuIQKAaJpQNxNhA7A7E9lPYG4kCoXpA6DyB2hYpbm5kBSUaCmI2BOEDYJAhGAADhYgdl')
     MithrilPickaxe := DTMFromString('m1gAAAHic42JgYIgG4gQgTgbiWCCOAuIQKAaJpQNxNhA7A7E9lPYG4kCoXpA6DyB2hYrr6joBSUaCmI2BOEDYJAhGAADbvQda');
     AdamantPickaxe := DTMFromString('m1gAAAHic42JgYIgG4gQgTgbiWCCOAuIQKAaJpQNxNhA7A7E9lPYG4kCoXpA6DyB2hYrrW+sDSUaCmI2BOEDYJAhGAADaTwdX');
     RunePickaxe := DTMFromString('m1gAAAHic42JgYIgG4gQgTgbiWCCOAuIQKAaJpQNxNhA7A7E9lPYG4kCoXpA6DyB2hYrrO7gDSUaCmI2BOEDYJAhGAADo1Ad0');
     PickaxeEquipped := DTMFromString('maQEAAHicpc7BCkRQAIXhc+cNvMJo0ExYSEpCYiFpktK8/4vw686K5T31LU5nczxJ00Oq8MOCDgNGzPhixYb+srdoEBgpRIwPoj8fT2P3s7+RIkOOBDVKFC/OyDjZ5R63B9YtB2CmCYg=');
     VTeleTab := DTMFromString('mFQEAAHic42VgYMhlYmDIAeI0IC4G4nIgTgLifCDOgsqB2KlAnAzEJUB8E6jvFRA/QcKPgfgNlH4OxI+gap4B8Usgjo+MZJBRvocVT9qyDY6RxdmA+kjFjGRgFAAACI8iqw==')
     TinOre := DTMFromString('mqAEAAHicrc49CoNQEEbRsbV2QQoqRCWxUDG4GdO6F7GzeIIiGBR0UV7IlCnfB2eK+YHxRGTBgQ0XdqwYMaCH0d6kZp0bvTvx1f0nQqR4IEeBSr2QIUAEHzXeaLQXo0SC7tNSHWtcsRt7n/38yw0U+hax');
     CopperOre := DTMFromString('mqAEAAHicrc49CoNQEEbRsbXOYiwVNKAGtdAQcS/ZkdhZPEERlAi6BtfihUxp+T44U8wPzENEJmxYcOCHGT06tDDaG9Soc6N3O1bdzxAiRYwCJd4qxwsBIvj4oEajvScqJDi/HtWxxhW7sffZ310uHrEWug==');
     IronOre := DTMFromString('mqAEAAHicrc47CoNQEIXhSZvaHbgAtxBBBR+ohYriGoOdxRUSBIMBXZS/OKXlPfBNMQ8YR0S++GPBjhUzRgx4w2hvUh+dG73b8NP9HAFSxChRoVEFMvgI8UKLDr32ItRIzn3PpT6seYrd2PvscpcDKE8Vxw==');
     CoalOre := DTMFromString('mqAEAAHicrc5JCoAwEETRVlQwzhJn0JVXEO9/Mr9YS5dpeJui0mlvZj1izNgxoUKODrV45aZ+rmzFoXebug4DMqTKF/1hyiKUaDDKu6/V7gIJ7utUOwxnYSfcZZ+/eQADLgM1');
     Bar := DTMFromString('mKgEAAHic42NgYJjGxMDQCcXTgbgHiPuBeBIQLwDiJVA8H4jnQOUnAPFjoN7nQPwaiD8A8RsgfgvE74D4HhA/AOInQPwSKvcEKlaelwskGUnG/xnIA6TbBMGoAACsdBdp');
    end;

    procedure FreeOurDTMs;
    begin
     FreeDTM(Pickaxe);
     FreeDTM(IronPickaxe);
     FreeDTM(MithrilPickaxe);
     FreeDTM(AdamantPickaxe);
     FreeDTM(RunePickaxe);
     FreeDTM(VTeleTab);
     FreeDTM(PickaxeEquipped);
     FreeDTM(TinOre);
     FreeDTM(CopperOre);
     FreeDTM(IronOre);
     FReeDTM(Bar);
    end;                

    procedure CheckLevels;
    begin
     //Lets check our levels, so we know what to do.
     MiningLevel := GetSkillInfo('mining', false);
     SmithingLevel := GetSkillInfo('smithing', false);
     AttackLevel := GetSkillInfo ('attack', false);
    end;          

    function UsePickaxe(ToWield: String): Boolean;
    var
    x, y, col, EquipLevel: Integer;  //EquipLevel is attack level required for an item
    upt: TStringArray;
    begin
     case Lowercase(ToWield) of
      'iron' : begin EquipLevel := 1; If EquipLevel < AttackLevel then PickaxeWieldInv := 'inv' else PickaxeWieldInv := 'wield';  col := IRONPICK; upt:= ['Iron Pickaxe', 'Iron', 'ron', 'ro']; end;
      'mithril' : begin EquipLevel := 20; If EquipLevel < AttackLevel then PickaxeWieldInv := 'inv' else PickaxeWieldInv := 'wield'; col := MITHRILPICK; upt := ['Mithril Pickaxe', 'Mithril', 'thr', 'th']; end;
      'adamant' : begin EquipLevel := 30; If EquipLevel < AttackLevel then PickaxeWieldInv := 'inv' else PickaxeWieldInv := 'wield'; col := ADAMANTPICK; upt := ['Adamant Pickaxe', 'Adamant', 'dam', 'am']; end;
      'rune' : begin EquipLevel := 40; If EquipLevel < AttackLevel then PickaxeWieldInv := 'inv' else PickaxeWieldInv := 'wield'; col := RUNEPICK; upt := ['Rune Pickaxe',    'Rune',    'une', 'un']; end;
      else Exit;
     end;

     begin
      MouseBox(629, 173, 657, 200 ,1); //check inventory
      if FindColorTolerance(x, y, col, 550, 205, 735, 465, 6) then
       begin
       MMouse(x, y, 3, 3);
       if FindDTM(Pickaxe, x, y, x-25, y-25, x+25, y+25) or IsUpTextMultiCustom(upt) then
         begin
          wait(randomrange(400,600));
          ClickMouse2(mouse_left);
         end;
       end
      else
       begin
        Writeln('Did not find pickaxe in inventory');
        UsePickaxe(ToWield);
       end;
     end;
    end;

    procedure WieldWhatPick;
    begin
     case MiningLevel of
      1..6: begin if DoHaveIron = 'true' then begin UsePickaxe('iron'); end else Writeln('We can use an Iron pickaxe, but we do not have one. We need at least Iron for the script to work. Terminating!'); TerminateScript; end;
      21..31: begin if DoHaveMithril = 'true' then begin UsePickaxe('mithril'); end else UsePickaxe('iron'); Writeln('We have the mining level to use a Mithril pick, but we do not have one. Using Iron instead.'); end;
      31..41: begin if DoHaveAdamant = 'true' then begin UsePickaxe('adamant') end else UsePickaxe('mithril'); Writeln('We have the mining level to use a Adamant pick, but we do not have one. Using Mithril instead.'); end;
      else begin if DoHaveRune = 'true' then begin UsePickaxe('rune') end else UsePickaxe('adamant'); Writeln('We have the mining level to use a Rune pick, but we do not have one. Using Adamant instead.'); end;
     end;
    end;      

    function DoHavePickaxe: Boolean;
    var
    x, y: Integer;
    IsEquiped: String;
    begin
      begin
      if PickaxeWieldInv = 'wield' then
       begin
        MouseBox(629, 173, 657, 200, 1); //check equiped items tab
        if FindDTM(PickaxeEquipped, x, y, 567, 287, 606, 324) then
         begin
          Writeln('Pickaxe is equiped!');
          result := true;
         end;
       end;
      if PickaxeWieldInv = 'inv' then
       begin
        MouseBox(655, 174, 687, 201, 1); //check inventory
        if FindDTM(Pickaxe, x, y, 567, 287, 606, 324) then
         begin
          Writeln('We have our Pickaxe');
          result := true;
         end;
       end;
     if PickaxeWieldInv = '' then
      begin
       MouseBox (655, 174, 687, 201, 1);  //inv
       if FindDTM(Pickaxe, x, y, 567, 287, 606, 324) then
        begin
         Writeln('PickaxewieldInv was not set. However we found our pickaxe.');
         PickaxeWieldInv := 'inv';
         result := true;
        end
       else
       MouseBox(629, 173, 657, 200, 1); //equiped
       if FindDTM(PickaxeEquipped, x, y, 567, 287, 606, 324) then
        begin
         Writeln('PickaxewieldInv was not set. However we found our pickaxe.');
         PickaxeWieldInv := 'wield';
         result := true;
        end
       else
        begin
         Writeln('Could not find pickaxe anywhere. Terminating');
         TerminateScript;
        end;
      end;
     end;
    end;

    begin
     DefineDTM;
     CheckLevels;
     WieldWhatPick;
     //should probably withdraw it or something here
     DoHavePickaxe;
     FreeOurDTMs
    end.

    The above code will check your mining and attack level, and decide what pickaxe to use based on that. It will also check if you have your pickaxe and return true or false. If your attack level is lower than the required level for equipping the pick, it will change the PickaxeWieldInv variable to 'Inv'. The DoHavePickaxe function takes this into account when looking for the pickaxe and returning its value.

    Simba Code:
    function R_GetAnimation: Integer;
    var
      Me: Integer;
    Begin
      Me := SmartGetFieldObject(0, 'p.ho');
      Result := SmartGetFieldInt(Me, 'ay') * -1297342091;
      SmartFreeObject(Me);
    End;

    function R_IsAnimating: Boolean;
    Begin
      Result := R_GetAnimation > -1;
    End;                                    

    procedure MineOre(Ore: String);
    var
    tmpCTS,  i, l, r, timer, TinPerLoad, CopperPerLoad, IronPerLoad: Integer;
    TPAToUse: String;
    OreTPA: TPointArray;
    OreHue, OreSat: Extended;
    OreColor, Tol: Integer;
    WalkPoint1, WalkPoint2: Integer;  // the reflection co-ords for where we mine the ores
    begin
     case Lowercase(Ore) of
      'tin' : begin WalkPoint1 := 3283; WalkPoint2 := 3362; MakeCompass('E'); OreColor := 4605772; OreHue := 0.25; OreSat := 0.23; Tol := 14; end;
      'copper' : begin OreColor := 3627131; OreHue := 0.04; OreSat := 0.21; Tol := 8; end;
      'iron' : begin OreColor := 3030113; OreHue := 1.15; OreSat := 1.18; Tol:= 3; end; //you can add more ores here!
     end;
     tmpCTS := 0
     if DoHavePickaxe then
      begin
       LoadFont('UpChars07', true);
       SetToleranceSpeed2Modifiers(OreHue, OreSat);
       blindwalk (Point(WalkPoint1, WalkPoint2));
       while (IsMoving) do Wait(100);
       FindColorsSpiralTolerance(MSCX, MSCY, OreTPA, OreColor, 2, 2, 515, 335, Tol);
       SMART_DrawBox(intToBox(2, 2, 515, 335));
       SMART_DrawDots(OreTPA);
        L := High(OreTPA)
        marktime(timer);
        for i := 0 to L do
         begin
          r := random(L);
          wait(randomrange(60,200));
          MMouse(OreTPA[r].x, OreTPA[r].y, 2, 2);
           if waituptext('ine', 300) then
            if timefrommark(timer) > 5000 then
             begin
              Writeln('We failed to find an Ore of ' + Ore);
             end
            else
             begin
              Writeln('We found an Ore of ' + Ore);
              Wait(randomrange(700, 1200));
              ClickMouse2(Mouse_Left);
              while (R_IsAnimating) do wait(100); //replace with procedure with random checks, waits and anti ban
             end;
            end;
           end
        else begin Writeln('We do not have our pickaxe!');  end;
       SetColorToleranceSpeed(tmpCTS);
       SetToleranceSpeed2Modifiers(0.2, 0.2);
       FreeFont('UpChars07');
      end;

    Above is a fairly slow TPA Mining function. Use it by calling MineOre('iron'); (Can use tin, copper or iron.)

    I added the variables for in-built ore counting and things for this but never got around to implementing it.

  2. #2
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Just a tip I know your abandoning the miner but for future reference: The TPA function is so slow because:

    Your setting the color value everytime the procedure is called..

    Simba Code:
    case Lowercase(Ore) of
      'tin' : begin WalkPoint1 := 3283; WalkPoint2 := 3362; MakeCompass('E'); OreColor := 4605772; OreHue := 0.25; OreSat := 0.23; Tol := 14; end;
      'copper' : begin OreColor := 3627131; OreHue := 0.04; OreSat := 0.21; Tol := 8; end;
      'iron' : begin OreColor := 3030113; OreHue := 1.15; OreSat := 1.18; Tol:= 3; end; //you can add more ores here!
     end;

    Your loading a font

    Simba Code:
    LoadFont('UpChars07', true);

    Your walking to a spot everytime

    Simba Code:
    blindwalk (Point(WalkPoint1, WalkPoint2));


    This also eats up time, drawing all those dots on smart

    Simba Code:
    SMART_DrawBox(intToBox(2, 2, 515, 335));
       SMART_DrawDots(OreTPA);

  3. #3
    Join Date
    Feb 2013
    Posts
    103
    Mentioned
    0 Post(s)
    Quoted
    32 Post(s)

    Default

    Quote Originally Posted by Officer Barbrady View Post
    Just a tip I know your abandoning the miner but for future reference: The TPA function is so slow because:

    Your setting the color value everytime the procedure is called..

    Simba Code:
    case Lowercase(Ore) of
      'tin' : begin WalkPoint1 := 3283; WalkPoint2 := 3362; MakeCompass('E'); OreColor := 4605772; OreHue := 0.25; OreSat := 0.23; Tol := 14; end;
      'copper' : begin OreColor := 3627131; OreHue := 0.04; OreSat := 0.21; Tol := 8; end;
      'iron' : begin OreColor := 3030113; OreHue := 1.15; OreSat := 1.18; Tol:= 3; end; //you can add more ores here!
     end;

    Your loading a font

    Simba Code:
    LoadFont('UpChars07', true);

    Your walking to a spot everytime

    Simba Code:
    blindwalk (Point(WalkPoint1, WalkPoint2));


    This also eats up time, drawing all those dots on smart

    Simba Code:
    SMART_DrawBox(intToBox(2, 2, 515, 335));
       SMART_DrawDots(OreTPA);
    Thanks for the heads up and info on that, interesting and useful.

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
  •