Results 1 to 1 of 1

Thread: Molten Glass, need guidance

  1. #1
    Join Date
    Dec 2012
    Posts
    11
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default Molten Glass, need guidance

    This is the first script that i have tried to make.

    Would it be better for me to work off of the gutted script or work with the original

    i would appreciate any ideas, accepting criticism.


    Current problem- to go from withdraw to walk to furnace.
    http://paste.villavu.com/show/4796/
    Code:
    program Molten;
    
    //Beastmode script 1\\
    //Based off of Swimdude's Port Phasmatys Smelter \\
    
    {$DEFINE SMART8}
    {$I SRL-OSR/SRL.simba}
    {$I SRL/SRL/Misc/Debug.Simba}
    {$I SRL-OSR/SRL/Misc/SmartGraphics.Simba}
    
    var
    x, y: integer;
    SandDTM, AshDTM: integer;
    bucketDTM, MGlassDTM,FurnDTM: integer;
    glassMade: integer;
    doorOpen: boolean;
    
    const
      bankcolour1 = 5204065;
      bankcolour2 = 4479573;
    
      // *** YOU CAN CHANGE THESE *** \\
      GlassToMake = 6357;     // How many bars are you making?
    
    Procedure DeclarePlayer;
    begin
      HowManyPlayers := 1;
      NumberOfPlayers(HowManyPlayers);
      CurrentPlayer := 0;
      Players[0].Name := '';  //Username goes here
      Players[0].Pass := '';  //Password goes here
      Players[0].Nick := '';  //Character name goes here (used for anti
      Players[0].Active := True;                //-randoms)
    end;
    //////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
    //---------------------------^User Config ends here^-------------------------\\
    //////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
    procedure SetupDTM;
    begin
      SandDTM := DTMFromString('mbQAAAHicY2VgYPBgYmBwBmI/IA4CYnsgVmRkYDAEYgMgloPiyU3BQNWMaBgTsOJSBQAmZgOy');
      AshDTM := DTMFromString('mwQAAAHic42RgYOAAYl4gZgdiZgYIANGcQMwDxEJQORBgAmIWKJ8LKs8JFd+xbi2QZMSLWRkIA/wmQDAcAABKbAKx');
      MGlassDTM := DTMFromString('mlwAAAHicY2dgYPBlYmDwAWI7ILYBYjcgDoZiRkYGBm4gZgHiP0C1P4H4FxBzAvlnKsOBLEYcGDfApQNJFwDnEwbK');
      BucketDTM := DTMFromString('mlwAAAHicY2dgYJjNxMAwFYinAfESIF4KxPOBeDIQZzEyMJQDcRIQpwBxMRBXAXE2ECf7iAN1M+LAuAEuHUi6ANWyCDA=');
      FurnDTM := DTMFromString('mbQAAAHicY2VgYJjHxMAwG4gXA/EiIJ4JxLOA4nOAeCoQLwDiaUD8DIg19ZQZLMrswbRVjScDNsCIBYMBAO1FCfM=');
    end;
      Procedure KillDTM;
    begin
      FreeDTM(SandDTM);
      FreeDTM(AshDTM);
      FreeDTM(MGlassDTM);
      FreeDTM(BucketDTM);
      FreeDTM(FurnDTM);
    end;
    Procedure randomWaitTime;
    begin
      case random(1000) of
        1..800:    Wait(RandomRange(300, 700));
        801..960:  Wait(RandomRange(400, 900));
        961..1000: Wait(RandomRange(500, 1000));
      end;
    end;
    
    Procedure antiBan;
    begin
      //writeln('antiban debug!');
      Case Random(130) Of
        1: HoverSkill(skill_crafting, false);
        3: Boredhuman;
        4: Wait(2500 + random(4500));
        5: PickUpMouse;
        6: RandomMovement;
        7: RandomRClick;
        8: MakeCompass('random');
      end;
    end;
    
    procedure openScreen;
    begin
      if(FindObjCustom(x, y, ['Bank', 'ank', 'booth', 'ooth'], [bankcolour1, bankcolour2], 5)) then repeat
        begin
          if(FindObjCustom(x, y, ['Bank', 'ank', 'booth', 'ooth'], [bankcolour1, bankcolour2], 5)) then
            begin
              writeln('Trying to open the bank.');
              mmouse(x, y, 5, 5);
              wait(RandomRange(300, 600));
              ClickMouse2(mouse_right);
              wait(RandomRange(500, 700));
              ChooseOptionMulti(['Bank']);
              Flag;
              wait(RandomRange(1000, 2000));
            end;
        end;
      until(bankscreen);
    end;
    
    procedure openDoor;
    begin
      if(WaitUptext('Open', randomRange(300, 600))) then
        begin
          repeat
            Writeln('Door is closed!');
            mmouse(x, y, 1, 1);
            wait(RandomRange(300, 600));
            ClickMouse2(mouse_left);
            wait(RandomRange(300, 600));
            Flag;
            wait(RandomRange(1000, 2000));
          until(not(WaitUptext('Open', randomRange(300, 600))));
          doorOpen := true;
        end
      else if(WaitUptext('Close', randomRange(300, 600))) then
        begin
          writeln('Door is open!');
          doorOpen := true;
        end
      else
        begin
          writeln('Could not find the door!');
          doorOpen := true;
        end;
    end;
    
    procedure withdrawRaw;
    begin
      makecompass(180.0);
      if(bankscreen) then
        begin
           writeln('banking all');
           Wait(randomRange(921,1024));
           Deposit(1,14,True);
           Wait(randomRange(921,1024));
          if(InvFull) then
            begin
              writeln('Banking Inventory');
              Wait(randomRange(921,1024));
              Deposit(1,14,True);
              randomWaitTime;
              Wait(randomRange(921,1024));
            end;
           Wait(randomRange(921,1024));
           Withdraw(0, 0, 14);
           Wait(randomRange(921,1500));
           Withdraw(1, 0, 14);
           Wait(randomRange(921,1600));
           closebank;
           mmouse(657, 137, 3, 3);
          wait(RandomRange(300, 600));
    
               { mmouse(97, 77, 3, 3);
          wait(RandomRange(300, 600));
          ClickMouse2(mouse_right);
          wait(RandomRange(300, 600));
          chooseOptionMulti(['X']);
          wait(RandomRange(1200, 1500));
          TypeSend('14');
          mmouse(137, 77, 3, 3);
          wait(RandomRange(300, 600));
          ClickMouse2(mouse_right);
          wait(RandomRange(300, 600));
          chooseOptionMulti(['X']);
          wait(RandomRange(1200, 1500));
          TypeSend('14');  }
        end
      else
        begin
          openScreen;
        end;
    end;
    
    
    procedure walkToFurnace;
    begin
       if (FindDTM(FurnDTM,x,y,MMX1,MMY1,MMX2,MMY2))then
        Mouse(x, y, 5, 5, mouse_Left);
        Wait(RandomRange(750, 900));
           MMouse(x, y, 3, 3);
        ClickMouse2(MOUSE_LEFT);
      end;
    
    
    procedure findSmelter;
    var
    i: integer;
    furnaceFound: boolean;
    
    begin
      doorOpen := false;
      furnaceFound := false
      makecompass(180.0);
      writeln('Checking if door is open');
      if(FindObj(x, y, 'oor', 596760, 20)) then repeat
        begin
          openDoor;
          inc(i);
        end
      until(doorOpen);
      writeln('i is: ' + IntToStr(i));
      writeln('Finding furnace');
      if(FindObjEx(x, y, ['urnace'], [4013378, 3421241, 4276549], 20, 50, MSX1, MSY1 + 50, MSCX, MSY2)) then
        begin
          furnaceFound := true;
          mmouse(x, y, 3, 3);
          wait(RandomRange(300, 600));
          ClickMouse2(mouse_left);
          Flag;
          wait(RandomRange(1000, 1500));
        end;
      if(not(furnaceFound)) then
        begin
        writeln('Furnace not found.');
          if(FindColor(x, y, 11843261, 577, 1, 650, 57)) then
            begin
              mmouse(x, y, 3, 3);
              wait(RandomRange(300, 600));
              ClickMouse2(mouse_left);
              wait(RandomRange(300, 600));
              Flag;
              findSmelter;
            end;
        end;
    end;
    
    procedure MakeGlass;
    begin
          writeln('Smelting Glass');
          mmouse(259, 415, 6, 6);     //moves to iron bar option on furnace
          wait(RandomRange(300, 500));
          ClickMouse2(mouse_right);
          wait(RandomRange(300, 500));
          chooseOptionMulti(['X']);
          wait(RandomRange(1200, 1500));
          TypeSend('44');
          wait(RandomRange(2000, 3000));
    
      // REPEAT UNTIL GLASS ARE MADE \\
      repeat
        antiBan;
        Wait(RandomRange(1074, 3142));
        if(not(GameTab(tab_Inv))) then
          begin
            GameTab(tab_Inv);
          end;
      until(findDTM(MglassDTM, x, y, 686, 430, 732, 471));
    
      makecompass(180.0);
      writeln('Done Heating');
    
      glassMade := glassMade + 14;
    
    end;
    
    procedure walkFromFurnace;
    begin
      if(FindObj(x, y, 'oor', 596760, 20)) then repeat
        begin
          openDoor;
        end
      until(doorOpen);
    
      if(FindColor(x, y, 11843261, 577, 1, 650, 57)) then
        begin
          wait(RandomRange(500, 700));
          mmouse(x, y, 3, 3);
          wait(RandomRange(500, 700));
          ClickMouse2(mouse_left);
          Flag;
        end;
    end;
    
    
    
    //////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
    //-----------------------------v|Main Method|v-------------------------------\\
    //////////////////////////////////////\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
    begin
      DeclarePlayer;
      SetupSRL();
      SetupDTM;
      Addonterminate('KillDTM')
      ClearDebug;
      if(not LoggedIn) then
        begin
          LogInPlayer;
          wait(750);
        end;
      repeat
        clearDebug;
    {    writeln('================================');
        writeln('Glass Made: ' + IntToStr(glassMade));
        writeln('================================'); }
        SetupDTM;
        withdrawRaw;
        walkToFurnace;
        findSmelter;
        MakeGlass;
        walkFromFurnace;
        openScreen;
    
      until(GlassMade > glassToMake);
    end.
    Gutted the script and added comments of what needs to be done
    Code:
    program Gutted;
     //Beastmode \\
     //Basic outline from  Swimdude's Port Phasmatys Smelter \\
     // rough outline of Making Molten Glass
     {Things to add
     (FS)Failsafes(FS)
     notes
     correct dtm to furnace, bank.
     antiban
     antirandom}
    
    
    
    {$DEFINE SMART8}
    {$I SRL-OSR/SRL.simba}
    {$I SRL/SRL/Misc/Debug.Simba}
    {$I SRL-OSR/SRL/Misc/SmartGraphics.Simba}
    
    var
    x, y: integer;
    SandDTM   :integer;
    AshDTM    :integer;
    bucketDTM :integer;
    MGlassDTM :integer;
    glassMade :integer;
    FurnDTM   :integer;
    //MoltenchatDTM :integer;
    const
      bankcolour1 = 5204065;
      bankcolour2 = 4479573;
    
      GlassToMake = 1000;
    procedure DeclarePlayer;        //Works
    begin
      HowManyPlayers := 1;
      NumberOfPlayers(HowManyPlayers);
      CurrentPlayer := 0;
      Players[0].Name := '';
      Players[0].Pass := '';
      Players[0].Nick := '';
      Players[0].Active := True;
    end;
    
    procedure SetupDTM;
    begin
      SandDTM := DTMFromString('mbQAAAHicY2VgYPBgYmBwBmI/IA4CYnsgVmRkYDAEYgMgloPiyU3BQNWMaBgTsOJSBQAmZgOy');
      AshDTM := DTMFromString('mwQAAAHic42RgYOAAYl4gZgdiZgYIANGcQMwDxEJQORBgAmIWKJ8LKs8JFd+xbi2QZMSLWRkIA/wmQDAcAABKbAKx');
      MGlassDTM := DTMFromString('mlwAAAHicY2dgYPBlYmDwAWI7ILYBYjcgDoZiRkYGBm4gZgHiP0C1P4H4FxBzAvlnKsOBLEYcGDfApQNJFwDnEwbK');
      BucketDTM := DTMFromString('mlwAAAHicY2dgYJjNxMAwFYinAfESIF4KxPOBeDIQZzEyMJQDcRIQpwBxMRBXAXE2ECf7iAN1M+LAuAEuHUi6ANWyCDA=');
    
      //{FurnDTM is icon of furnace,not reliable if white dot(Player)is under}
     // FurnDTM:= DTMFromString('mbQAAAHicY2VgYJjHxMAwG4gXA/EiIJ4JxLOA4nOAeCoQLwDiaUD8DIg19ZQZLMrswbRVjScDNsCIBYMBAO1FCfM=');
    
      //Molten Glass dtm of chat  "how many would you like to make" and pic of Flass,  MoltenChatDTM
      //MoltenChatDTM := DTMFromString('mggAAAHicY2NgYGBjZGBgB+I3QPZvIOYDsoWBeA4QrwDi2UA8AYoXAvGrDdMZ7k0xYXgyw4zh7opGhsPVYQwri3UY+BmwA0YcGAIAD+cQRg==');
    
      //dtm of the walls for inside furn room
      //InFurnRoomDTM := DTMFromString('mWAAAAHicY2FgYMhnYmDIAuIMIC4BYnmgmCoDhJYG4v///zPw8ovBMTpgRMMgAABZmQXX');
    
      //bankDTM  -  Need
    end;
    
      Procedure KillDTM;     //Proper free dtm procedure?
    begin
      FreeDTM(SandDTM);
      FreeDTM(AshDTM);
      FreeDTM(MGlassDTM);
      FreeDTM(BucketDTM);
      //FreeDTM(FurnDTM);
    end;
    
    Procedure randomWaitTime;
    begin
      case random(1000) of
        1..800:    Wait(RandomRange(300, 700));
        801..960:  Wait(RandomRange(400, 900));
        961..1000: Wait(RandomRange(500, 1000));
      end;
    end;
    
    Procedure antiBan;
    begin
      //writeln('antiban debug!');
      Case Random(130) Of
        1: HoverSkill(skill_crafting, false);
        3: Boredhuman;
        4: Wait(2500 + random(4500));
        5: PickUpMouse;
        6: RandomMovement;
        7: RandomRClick;
        8: MakeCompass('random');
      end;
    end;
    
    procedure openBank;               //need failsafe..by a bankboot dtm?
    begin
          if(FindObjCustom(x, y, ['Bank', 'ank', 'booth', 'ooth'], [bankcolour1, bankcolour2], 5)) then
            begin
              writeln('Trying to open the bank.');
              mmouse(x, y, 5, 5);
              wait(RandomRange(300, 600));
              ClickMouse2(mouse_right);
              wait(RandomRange(500, 700));
              ChooseOptionMulti(['Bank']);
              wait(RandomRange(1000, 2000));
            end;
    end;
    
    procedure withdrawRaw;
    begin                       //i need to have set up so i can
                               //deposit 14(Buckets)                  // BucketDTM
           Deposit(1,14,True); //withdraw 14 sand                    //SandDTM
           Withdraw(0, 0, 14);  //deposit 14 molten glass of slot   // MGlassDTM
           Withdraw(1, 0, 14);   //withdraw 14 soda ash            // AshDTM
           closebank;
    end;
    
    procedure walkToFurnace;    //need way to walk {Object DTMs: A Walking/Positioning System  http://villavu.com/forum/showthread.php?t=72067 }
                                                   { Object DTMs: A Comprehensive Set of Tutorials http://villavu.com/forum/showthread.php?t=72067}
    begin                                                  //validate door if closed go to openopen
       if (FindDTM(FurnDTM,x,y,MMX1,MMY1,MMX2,MMY2))then    //
       click
    end;
    
    procedure openDoor;    //open door set to true for walking to furnace, walking to bank
    begin
    
    end;
    
    procedure findSmelter;
    var                               //find furnace
    i: integer;
    furnaceFound: boolean;
    
    begin
      if(FindObjEx(x, y, ['urnace'], [4013378, 3421241, 4276549], 20, 50, MSX1, MSY1 + 50, MSCX, MSY2)) then
        begin
          mmouse(x, y, 3, 3);
          ClickMouse2(mouse_left);
    end;
    procedure MakeGlass;
    begin
          mmouse(259, 415, 6, 6);                //Use invin1...or SandDTM? on furnace
          ClickMouse2(mouse_right);             //(FS) i can't reach that (FS)
          chooseOptionMulti(['All']);          //choose molten glass option (254,410) option all, (FS)by MoltenChatDTM  icon of glass in chatbox
      until(findDTM(MglassDTM, x, y, 686, 430, 732, 471)); // until (FindBlackChatMessage('run out'))or x amount of time
      glassMade := glassMade + 14;
    
    end;
    procedure walkFromFurnace;
    begin
        begin
          mmouse(x, y, 3, 3);            // walk to bank
          ClickMouse2(mouse_left);
          Flag;                          //door validation if closed(false) goto openDoor
        end;
    end;
    begin
      DeclarePlayer;
      SetupSRL();
      ClearDebug;
      SetupDTM;
      Addonterminate('KillDTM')           //Need: proper free DTM
      ClearDebug;
      if(not LoggedIn) then
        begin
          LogInPlayer;
          wait(750);
        end;
        openbank;                           //Need:Find spot for repeat
        withdrawRaw;                        //Need:mark time
        walkToFurnace;                      //Failsafes
        findSmelter;                        //Improved order
        MakeGlass;
        walkFromFurnace;
        openScreen;
    
      until(GlassMade > glassToMake);
    end.
    Last edited by beastmode92; 05-13-2013 at 03:37 PM. Reason: added code gutted and with comments

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
  •