Results 1 to 6 of 6

Thread: Oak Dungeon Door builder

  1. #1
    Join Date
    Jan 2012
    Posts
    369
    Mentioned
    6 Post(s)
    Quoted
    91 Post(s)

    Default Oak Dungeon Door builder

    Well this is my 1st script... with Simba, it gets about 100k experience per hour (I know lazy... i need to improve it *sigh* )

    Don't be too harsh on me


    To set it up, you place yourself there with all of the oak planks banked, and cash in Money Pouch.



    Start the script and it should be working


    Simba Code:
    program Conbot2;

    {$DEFINE SRL5}
    {$DEFINE SMART}
    {$i srl/srl.simba}
    {$i sps/sps.simba}
    {$i SRL/SRL/misc/paintsmart.simba}
    Var


      PlankCount,BuiltCount,ExpPer,mx, my: Integer;
      Charge: Integer;
      TBuilt,TBuiltH,StartTime,Sec,XPH: Integer;
      Door,UnDoor,DemonButlerNE,DemonButlerS: Integer;
      Clock: TIntegerArray;
      x,y,i: Integer;
      ButlerCheck,DoorCheck:Integer;
      ex: Integer;



    procedure DeclarePlayers;
    begin
      ExpPer := 600; //enter exp of item used here  (0 if unknown)
      HowManyPlayers := 1; // Number of Players to use
      NumberOfPlayers(HowManyPlayers);
      CurrentPlayer := 0; // Player to start with, first one is 0
      Players[0].Name := ''; // Username
      Players[0].Pass := ''; // Password
      Players[0].Active := True; // True if you are using this player
      Players[0].Pin := ''; // Bank Pin. Leave it if you don't have one.
      Players[0].Integers[1] := 10000; // Number of loads
    end;



    Procedure LoadVariables;
    begin

     //ignore these DemonButlerNE := DTMFromString('mWAAAAHicY2FgYNBghGAVINYE4ilAsQlAPAmI5wIxHy8vGGfZ6zPs376NgR8ohoyZoJgRikEAAFKpBo8=');
    //  DemonButlerS := DTMFromString('mggAAAHicY2NgYPgLxAyMCPwDSLEA6T1Aej8Q7wTiQ0B8BIiPAjEfHx+Du6YYQ667IYOtsjDD8oULGJx0VRn4gXLYMCMODAEAvwYLZw==');
      UnDoor := DTMFromString('mbQAAAHicY2VgYJBhgAAuIJYDYnkgNgViPSC2gsoVAfHR/bsZ5kzvY7CwUGPYuXEjQ3WSCwM/UBwdM2LBYAAAQP8Jmg==');
      Door := DTMFromString('mbQAAAHicY2VgYFBjgAAVKFsaiE2A2B6Im6ByIP66GSUM82dNYCiPd2Lg5eVlCA72YOAHiqNjRiwYDADodge6');

      end;


    Procedure PrintOnSmart(TP: TStringArray; Placement: TPoint; Colour: integer);
    var
    Pic, I, B, H, TPH, Numb: Integer;
    TTP: TPointArray;
    Canvas: TCanvas;
    begin
      SmartSetDebug(True);
      GetClientDimensions(mx, my);
      Pic := BitmapFromString(mx, my, '');
      TPH := High(TP);
      for I := 0 to TPH do
      begin
        TTP := LoadTextTPA(TP[i], SmallChars, H);
        for B := 0 to High(TTP) do
        begin
          Numb := ((I + 1) * 13);
          FastSetPixel(Pic, TTP[b].x + 1, TTP[b].y + Numb + 1,1118738);
          FastSetPixel(Pic, TTP[b].x, TTP[b].y + Numb, 16777215);
        end;
      end;
      Canvas := TCANVAS.Create;
      Canvas.Handle := SmartGetDebugDC;
      DrawBitmap(Pic, Canvas, Placement.x, Placement.y);

      FreeBitmap(Pic);
    end;

      function GetDemon(var fx, fy: Integer): Boolean;
    var
      arP: TPointArray;
      ararP: T2DPointArray;
      tmpCTS, i, arL: Integer;
      P: TPoint;
    begin
      tmpCTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(2);
      SetColorSpeed2Modifiers(0.22, 1.13);

      if not(FindColorsTolerance(arP, 1712962, MSX1, MSY1, MSX2, MSY2, 14)) then
      begin
        Writeln('Failed to find the color, no object found.');
        ColorToleranceSpeed(tmpCTS);
        SetColorSpeed2Modifiers(0.2, 0.2);
        Exit;
      end;

      SortTPAFrom(arP, Point(MSCX, MSCY));
      ararP := SplitTPAEx(arP, 10, 10);
      arL := High(ararP);

      for i := 0 to arL do
      begin
        P := MiddleTPA(ararP[i]);
        MMouse(P.x, P.y, 5, 5);
        Wait(100 + Random(100));
        if (IsUpText('Demon')) then
        begin;
          Result := True;
          Break;
        end;
      end;

      ColorToleranceSpeed(tmpCTS);
      SetColorSpeed2Modifiers(0.2, 0.2);

      if (i = arL + 1) then
      begin
        Writeln('FindObject could not find object.');
        Exit;
      end;

      GetMousePos(fx, fy);
    end;




    Procedure RemoveDoor;
    begin
        if FindDTM(Door,x,y,MSX1, MSY1, MSX2, MSY2)   Then
        begin
          wait(400+Random(200));
          MMouse(x,y,4,4);
          if (WaitUpTextMulti(['oor'],700)) then
          begin
             wait(400+Random(200));
             GetMousePos(x,y);
             Mouse(x,y,0,0,False);
             wait(400+Random(200));
             ChooseOption('emove');
             wait(900+Random(200));
             FindNPCChatText('es', ClickLeft);
             wait(1390+Random(350));

           end else
           begin
             Writeln('There is no Built Door!');
              wait(600+Random(250));
           end;
        end;
    end;


     Procedure FindDemon;

    begin

      if  GetDemon(x,y) Then
      begin
        MMouse(x,y,3,3);
        writeln('Demon Found!');
        if (WaitUpTextMulti(['emon','utler'],700)) then
       begin
         GetMousePos(x,y);
         if (BuiltCount = 0) then
         begin
           Case Random(2) Of
             0 : begin
             Mouse(x,y,2,2,False);
             wait(300+Random(100));
             ChooseOption('Talk-to');
             end;
             1 : Mouse(x,y,2,2,True);
           end;
           wait(1420+Random(150));
           Case Random(2) Of
             0 : ClickContinue(True,True);
             1 : ClickContinue(False,True);
           end;
           wait(930+Random(150));
           if (FindNPCChatText('coins.',ClickLeft)) then
             begin
             wait(930+Random(150));
             FindDemon;
             end;
           FindNPCChatText('bank', ClickLeft);
           wait(1420+Random(250));
           FindNPCChatText('ring', ClickLeft);
           wait(1420+Random(250));
           FindNPCChatText('Oak', ClickLeft);
           wait(1420+Random(250));
           TypeSend('20');
           Inc(BuiltCount);
          // writeln(BuiltCount);
           RemoveDoor;
           wait(4590+Random(200));
         end else
         begin
            // writeln('Sending demon to fetch 20 more Planks');
             Mouse(x,y,2,2,False);
             wait(400+Random(100));
             ChooseOption('etch');
             wait(890+Random(150));
             Case Random(2) Of
             0 : ClickContinue(True,True);
             1 : ClickContinue(False,True);
              end;
              wait(1040+Random(250));
             if (FindNPCChatText('coins.',ClickLeft)) then
             begin
             wait(1090+Random(250));
             FindDemon;
             end;
             FindNPCChatText('etch', ClickLeft);
         end;


       end;
    RemoveDoor;
    wait(4590+Random(200));
      end else
      begin
      Inc(ButlerCheck);
      if (ButlerCheck > 15)  Then
      begin
          writeln('After 15 attempts we could not find the damn buttler, closing script');
          TerminateScript;
      end;
      Writeln('Butler Could not be Found, retrying.');
      wait(600+Random(250));
      RemoveDoor;
      FindDemon;
      end;

      //writeln('Going back to building doors.');
    end;






    Procedure CheckPlanks;
    begin
       wait(600+Random(250));
      PlankCount := 0;
          for i := 1 to 28 do
            if ExistsItem(i) then
            Inc(PlankCount);
     //     writeln('Found UnDoor Spot at '+tostr(x)+tostr(y));
          if  (PlankCount < 10) then
          begin
            writeln('We need more planks.');
            ButlerCheck := 0;
            FindDemon;
          end;
    end;




    Procedure BuildDoor;
    begin
        RemoveDoor;
        if FindDTM(UnDoor,x,y,MSX1, MSY1, MSX2, MSY2)   Then
        begin
          wait(800+Random(200));
          Mouse(x,y,2,2,False);
          wait(800+Random(200));
          if (ChooseOption('pace')) then
          begin
          wait(1300+Random(200));
          MMouse(109,76,7,7);
          if (WaitUpTextMulti(['ak'],700)) then
           begin
             wait(500+Random(100));
             GetMousePos(x,y);
             Mouse(x,y,0,0,True);
             wait(1490+Random(200));
             Inc(TBuilt);
             DoorCheck := 0;
           end else
           begin
             writeln('Building window not opened, attempting to re-open');
              wait(600+Random(250));
             BuildDoor;
           end;
           end else
           begin
              wait(600+Random(250));
              BuildDoor;
           end;

        end else
        begin
        Inc(DoorCheck);
        if (DoorCheck > 15) Then
        begin
          Writeln('Could not find the Unbuilt Door Spot, shuting down...');

        //  Logout;
          TerminateScript;

        end;
        writeln('UnDoor Spot not found, trying to remove door');
        BuildDoor;
        end;
    end;






    Procedure DTMFree;
    begin
      //FreeDTM(DemonButlerNE);
     // FreeDTM(DemonButlerS);
    end;


    Procedure ProgressReport;
    begin
        Sec:= (1+((Getsystemtime-StartTime)/1000));
        TBuiltH:=(3600*(TBuilt))/(Sec);
        XPH:=(TbuiltH*ExpPer);
        Clock := [0,0,0];
        ConvertTime(GetTimeRunning,Clock[0],Clock[1],Clock[2]);
        writeln('Time Ran: '+tostr(Clock[0])+':'+tostr(Clock[1])+':'+tostr(Clock[2]));
        writeln('Built '+IntToStr(TBuilt)+' Oak doors');
        writeln('Gained '+IntToStr(TBuilt*ExpPer)+' Construction Xp.');
        writeln('At a rate of '+IntToStr(XPH)+'/h');
         PrintOnSmart(['Speedster Door Builder', 'Time Ran: '+tostr(Clock[0])+':'+tostr(Clock[1])+':'+tostr(Clock[2])
      , 'Doors Built: '+IntToStr(TBuilt) , 'Gained '+IntToStr(TBuilt*ExpPer)+' Xp.' , IntToStr(XPH)+'/h'  ], Point(10, 85), 255);
    end;



    begin
      BuiltCount := 0;
      TBuilt :=0;
      TBuiltH :=0;
      MouseSpeed := RandomRange(7,9);
      smart_server := 41;
      smart_members := false;
      smart_signed := true;
      smart_superDetail := false;
      ClearDebug;
      SetupSRL;
      SMART_ClearCanvas;
      DeclarePlayers;
      LoginPlayer;
      Mouse(543,25,12,18,True);
      SetAngle(0);
      StartTime:=GetSystemTime;
      If Not (GameTab(Tab_inv)) then
        GameTab(Tab_Inv);
      LoadVariables;
      DoorCheck := 0 ;
      Repeat
      CloseWindow ;
      CheckPlanks;
      BuildDoor;
      ProgressReport;
      Until(Not (LoggedIn));
      DTMFree;
      FreeBitmap(ex);

    end.

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

    Default

    The code looks nice, can't test it, but you should remember about the standards. Those double enters and spare lines inside functions/procedures make the script much harder to read.
    "Egoist: person, who cares more about himself rather then me." J.Tuwim

  3. #3
    Join Date
    Jan 2012
    Posts
    369
    Mentioned
    6 Post(s)
    Quoted
    91 Post(s)

    Default

    Hey yeah I know, I haven't put in a lot of effort in formatting the code. Just wanted it to put it up here asap

    Thanks for letting me know tough!
    Last edited by speedster; 03-13-2012 at 09:04 PM.

  4. #4
    Join Date
    Dec 2011
    Posts
    80
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    did you comment out DemonButlerNE and DemonButlerS on purpose?

  5. #5
    Join Date
    Mar 2012
    Posts
    26
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Great script, Speedster is a baws I got 90 > 99 construction with it on double exp weekend...read around 195k exp/hr without the included bonus exp

  6. #6
    Join Date
    Feb 2012
    Posts
    9
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Just need to speed it up speedster

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
  •