Page 4 of 4 FirstFirst ... 234
Results 76 to 83 of 83

Thread: [OGL] ClarityWells

  1. #76
    Join Date
    Apr 2016
    Posts
    126
    Mentioned
    1 Post(s)
    Quoted
    37 Post(s)

    Default

    Quote Originally Posted by Obscurity View Post
    Simba Code:
    ogl.setDebugMode('models');

    Thank you!!!

  2. #77
    Join Date
    Mar 2016
    Posts
    48
    Mentioned
    2 Post(s)
    Quoted
    32 Post(s)

    Default

    Looks a great script just going to try it out.

  3. #78
    Join Date
    Dec 2011
    Posts
    59
    Mentioned
    1 Post(s)
    Quoted
    11 Post(s)

    Default

    I'm trying to make my own edits to this so it solely relies on other's wells. I could do with some guidance please as it keeps trying to open the bank when there is no well nearby and I can't see why in the code. Here's what I currently have, you can see what I have commented out,

    Code:
    program ClarityWells;
    {$i oglib/lib/core/core.simba}
    
    {ClarityWells v1.3}
    
    {SCRIPT SETTINGS}
    
    const
      BANK_MODEL_ID = 910041455;           //Champion's Guild Bank Chest, 756483783 - Shantay Bank Chest, 910041455 - Lumbridge Combat Academy
      BANK_OPTION_TEXT = 'Use Bank chest';  //Right click text for the bank
      MINIMUM_REACTION_WAIT = 700;          //Minimum delay between actions and reactions
      MAXIMUM_REACTION_WAIT = 1800;         //Maximum delay between actions and reactions
      RIGHT_CLICK_CHANCE = 6;               //Chance of right-clicking well or bank
      KEYBIND_CHANCE = 3;                   //Chance of using keybind to place a well
      WELL_KEYBIND = '4';                   //Actionbar key for well placement
      SHOW_PAINT = true;                    //Show script progress paint?
    
    {END OF SETTINGS}
    
    const
      scriptVersion = '1.3';
    
    var
      nextRotateCamera, nextReaction: tCountDown;
      presetString: string;
      didNotMix, rightClick, startingXP, scriptPaintBMP: integer;
      didClickWell: boolean;
    
    {PROCEDURE -- ClarityDebug
    Purpose: Custom console debugging procedure.
    Comments: None.}
    procedure ClarityDebug(message: string);
    begin
      writeln('ClarityWells v' + scriptVersion + ' || ' + toStr(getTimeRunning) + ' || ' + message);
    end;
    
    {PROCEDURE -- doNothing}
    procedure doNothing;
    begin
    end;
    
    {PROCEDURE -- withdrawPreset
    Purpose: Withdraws a bank preset.
    Comments: None.}
    procedure withdrawPreset;
    begin
      ClarityDebug('Withdrawing bank preset ' + toStr(presetString) + '.');
      if random(2) then
        sendKeys(presetString, 60 + random(60), 60 + random(60))
      else
        bank.clickPreset(strToIntDef(presetString, 1));
      repeat
        wait(random(300, 400));
      until (not bank.hasBank());
      nextReaction.setTime(random(MINIMUM_REACTION_WAIT, MAXIMUM_REACTION_WAIT));
    end;
    
    {PROCEDURE -- makePotions
    Purpose: Clicks on the make button within the well interface.
    Comments: None.}
    procedure makePotions;
    begin
      ClarityDebug('Making our potions at the well.');
      if dialogue.hasDialogue() then
        typeByte(VK_ESCAPE);
      if random(2) then
        sendKeys(' ', 60 + random(60), 60 + random(60))
      else
        production.setMake();
      nextReaction.setTime(random(MINIMUM_REACTION_WAIT + 1000, MAXIMUM_REACTION_WAIT + 2000));
    end;
    
    {PROCEDURE -- placeWell
    Purpose: Places a new well if one has expired.
    Comments: None.}
    procedure placeWell;
    begin
      ClarityDebug('Placing a new portable well.');
      repeat
        if (random(KEYBIND_CHANCE) = 0) then
          sendKeys(WELL_KEYBIND, 60 + random(60), 60 + random(60))
        else
          inventory.clickItem(52275, 854794);
        wait(random(600, 1200));
      until dialogue.hasDialogue();
      sendKeys('1', 60 + random(60), 60 + random(60));
      repeat
        wait(random(600, 1200));
      until ogl.getModels(4264156587).indexes;
      nextReaction.setTime(random(MINIMUM_REACTION_WAIT, MAXIMUM_REACTION_WAIT));
    end;
    
    {PROCEDURE -- useBankChest
    Purpose: Uses whatever bank has been specified in script settings.
    Comments: None.}
    procedure useBankChest;
    var
      modelsBank: glModelArray;
      bankTPA: TPointArray;
    begin
      if combat.hasTarget() then exit;
      if dialogue.hasDialogue() then
        typeByte(VK_ESCAPE);
      inc(didNotMix);
      if didNotMix > 10 then
      begin
        ClarityDebug('Out of supplies!  Terminating script.');
        terminateScript;
      end;
      ClarityDebug('Clicking on the bank chest.');
      if (modelsBank := ogl.getModels(BANK_MODEL_ID)).indexes then
      begin
        bankTPA := modelsBank.closestTo(ogl.getClientMidPoint()).toPointArray();
        if (random(rightClick) = 0) then
          mouse.rightClickOption(bankTPA[0].adjustPosition(0, -10).randomizePointEllipse(40), [BANK_OPTION_TEXT])
        else
          mouse.click(bankTPA[0].adjustPosition(0, -10).randomizePointEllipse(40));
      end;
      nextReaction.setTime(random(MINIMUM_REACTION_WAIT, MAXIMUM_REACTION_WAIT));
    end;
    
    {PROCEDURE -- useWell
    Purpose: Uses the nearest portable well.
    Comments: None.}
    procedure useWell;
    var
      modelsWell: glModelArray;
      wellTPA: TPointArray;
    begin
      ClarityDebug('Clicking on the portable well.');
      if dialogue.hasDialogue() then
        typeByte(VK_ESCAPE);
      if (modelsWell := ogl.getModels(4264156587)).indexes then
      begin
        wellTPA := modelsWell.closestTo(ogl.getClientMidPoint()).toPointArray();
        if (random(rightClick) = 0) then
          mouse.rightClickOption(wellTPA[0].adjustPosition(0, -10).randomizePointEllipse(40), ['Mix potions Portable well'])
        else
          mouse.click(wellTPA[0].adjustPosition(0, -10).randomizePointEllipse(40));
      end;
      nextReaction.setTime(random(MINIMUM_REACTION_WAIT, MAXIMUM_REACTION_WAIT));
    end;
    
    {PROCEDURE -- checkXP
      Purpose:  Checks the current overall XP gained.
      Comments: Will be pushed to ogLib soon.}
    function checkXP(): integer;
    var
      xpTextures: glTextureArray;
      textureBox: TBox;
      currentXP: string;
      position: integer;
    begin
      xpTextures := ogl.getTextures(48705, 4736586);
      if length(xpTextures) then
      begin
        textureBox := xpTextures[0].bounds;
        currentXP := ogl.getChars(IntToBox(textureBox.X1 - 150, textureBox.Y1, textureBox.X2, textureBox.Y2)).toString();
        position := pos('xp', currentXP);
        if (position > 0) then
        begin
          currentXP := '*' + currentXP;
          currentXP := between('*',' +', currentXP);
        end;
        result := strToIntDef(extractFromStr(currentXP, numbers), 0);
      end;
    end;
    
    {PROCEDURE -- getTime
    Purpose: Translates ms to a readable format.
    Comments: Written by Ross.}
    function getTime(time: uint32): string;
    var
      h, m, s: integer;
    begin
      s := time mod 3600000 mod 60000 div 1000;
      m := time mod 3600000 div 60000;
      h := time div 3600000;
      result:= (toStr(h) + ' h ' + toStr(m) + ' m ' + toStr(s) + ' s');
    end;
    
    {PROCEDURE -- progressReport
    Purpose: Calculates and paints progress on the screen.
    Comments: None.}
    procedure progressReport();
    var
      gainedXP, gainedRespect, gainedXPPerHour, gainedRespectPerHour: extended;
      gainedXPString, gainedXPPerHourString: string;
      time: string;
    begin
      time := getTime(getTimeRunning());
      gainedXP := checkXP() - startingXP;
      gainedXPPerHour := Round(gainedXP * (3600.0 / (GetTimeRunning / 1000.0)));
      gainedXPString := format('%n', [gainedXP]);
      gainedXPPerHourString := format('%n', [gainedXPPerHour]);
      setLength(gainedXPString, length(gainedXPString) - 3);
      setLength(gainedXPPerHourString, length(gainedXPPerHourString) - 3);
      if SHOW_PAINT then
      begin
        smart.graphics.drawBitmap(scriptPaintBMP, Point(3, 461));
        smart.graphics.drawText(ToStr(time), 'smallChars', Point(127, 517), 1);
        smart.graphics.drawText(ToStr(time), 'smallChars', Point(126, 516), clWhite);
        smart.graphics.drawText(gainedXPString + ' XP', 'smallChars', Point(114, 538), 1);
        smart.graphics.drawText(gainedXPString + ' XP', 'smallChars', Point(113, 537), clWhite);
        smart.graphics.drawText(gainedXPPerHourString + ' XP','smallChars', Point(114, 560), 1);
        smart.graphics.drawText(gainedXPPerHourString + ' XP','smallChars', Point(113, 559), clWhite);
      end;
    end;
    
    {PROCEDURE -- waitToBank
    Purpose: Waits while potions are being made.
    Comments: None.}
    procedure waitToBank;
    var
      cd: tcountdown;
    begin
      ClarityDebug('Waiting for potion mixing to finish.');
      cd.setTime(random(29000, 33000));
      repeat
        if nextRotateCamera.isFinished() then
        begin
          //minimap.setDegrees(random(360));
          nextRotateCamera.setTime(random(300000));
        end;
        didNotMix := 0;
      until (production.hasProduction() = 'progress') = false;
      progressReport;
      useBankChest;
    end;
    
    {PROCEDURE -- mainLoop
    Purpose: Script main loop.
    Comments: None.}
    procedure mainLoop;
    var
      reaction: procedure() = @doNothing;
    begin
      if (not nextReaction.isFinished()) then
        exit;
      if bank.hasBank() and ogl.getModels(4264156587).indexes then
      begin
        presetString := '1';
        reaction := @withdrawPreset
      end
      //else if bank.hasBank() and (not ogl.getModels(4264156587).indexes) then
     // begin
     //   presetString := '2';
      //  reaction := @withdrawPreset
     // end
      else if (production.hasProduction() = 'progress') = false then
      begin
        if (production.hasProduction() = 'production') then
        begin
          reaction := @makePotions;
        end
        //else if (inventory.getItems(52275, 854794).indexes and (not ogl.getModels(4264156587).indexes)) then
        //  reaction := @placeWell
        else if ogl.getModels(4264156587).indexes and inventory.isFull() then
          reaction := @useWell
        else if ogl.getModels(BANK_MODEL_ID).indexes then
          reaction := @useBankChest;
      end
      else
        reaction := @waitToBank;
      reaction();
    end;
    
    {PROCEDURE -- autoUpdateMe
    Purpose: Autoupdates the script.
    Comments: By Shuttleu, modified by Ashaman88 and Clarity}
    procedure autoUpdateMe;
    var
      Neifile: Integer;
      OnlineVersion, NewScript, NeiFeilNennen: string;
    begin
      ClarityDebug('Checking for script updates...');
      OnlineVersion := GetPage('http://pastebin.com/raw.php?i=xzkYu1a2');
      ClarityDebug('Online Script Version: ' + OnlineVersion);
      ClarityDebug('Local Script Version: ' + ScriptVersion) if (trim(OnlineVersion) > ScriptVersion) then
      begin
        ClarityDebug('Newer script version online!');
        ClarityDebug('Autoupdating to newer version.');
        NewScript := GetPage('http://pastebin.com/raw.php?i=wxtDh8Vr');
        NeiFeilNennen := ScriptPath + 'ClarityWells v' + OnlineVersion + '.simba';
        Neifile := Rewritefile(NeiFeilNennen, true);
        try
          WriteFileString(Neifile, NewScript);
        except
          begin
            ClarityDebug('Fatal error writing to ' + NeiFeilNennen + '!');
            Terminatescript;
          end;
        end;
        CloseFile(Neifile);
        ClarityDebug('New script downloaded to ' + NeiFeilNennen + '! Terminating old script, please use the new version.');
        writeln('New script downloaded to ' + NeiFeilNennen + '! Terminating old script, please use the new version.');
        TerminateScript;
      end
      else
        ClarityDebug('You have the latest version of the script!');
    end;
    
    {PROCEDURE -- checkForFiles
    Purpose: Checks to see if file downloading is required.
    Comments: By Kevin, modified by Clarity}
    procedure checkForFiles(filePath, message, link: string);
    var
      progFile: longInt;
      fileName: string;
    begin
      fileName := AppPath + filePath;
      try
        if not fileExists(fileName) then
        begin
          ClarityDebug('-- INSTALLATION STATUS: ' + message + ' does not exist - Downloading now.');
          progFile := createFile(fileName);
        end
        else
        begin
          ClarityDebug('-- INSTALLATION STATUS: ' + message + ' exists.');
          exit;
        end;
        closeFile(progFile);
        progFile := rewriteFile(fileName, false);
        writeFileString(progFile, getPage(link));
        ClarityDebug('-- INSTALLATION STATUS: ' + message + ' has been downloaded.');
      finally
        if (progFile > 0) then
          closeFile(progFile);
      end;
    end;
    
    {PROCEDURE -- installClarityWellsAssets
      Purpose:  Determines whether files exist and dictates their installation.
      Comments: None.}
    procedure installClarityWellsAssets;
    begin
      ClarityDebug('Please wait...now installing ClarityWells image assets to your computer...');
      if not directoryExists(appPath + 'scripts/ClarityWellsImages/') then
      begin
        try
          createDirectory(appPath + 'scripts/ClarityWellsImages/');
          ClarityDebug('Created a new folder in Simba/Scripts/');
        except
        end;
      end;
      checkForFiles('scripts/ClarityWellsImages/scriptpaint.png', 'Script Paint', 'http://i.imgur.com/8ng7x2n.png');
    end;
    
    {PROCEDURE -- freeBMP
      Purpose:  Frees bitmaps used in the script.
      Comments: None.}
    procedure freeBMP();
    begin
      freeBitmap(scriptPaintBMP);
    end;
    
    begin
      addOnTerminate('freeBMP');
      clearDebug();
      ogl.setup(800, 600);
      ogl.setCacheTime(120);
      ogl.setColourTolerance(2);
      ogl.setDebugMode('none');
      autoUpdateMe;
      installClarityWellsAssets();
      if SHOW_PAINT then
      begin
        scriptPaintBMP := loadBitmap(appPath + '/Scripts/ClarityWellsImages/scriptpaint.png');
        fastReplaceColor(scriptPaintBMP, 0, 1);
      end;
      startingXP := checkXP();
      ClarityDebug('Starting XP was set as: ' + toStr(checkXP));
      rightClick := random(RIGHT_CLICK_CHANCE - 1, RIGHT_CLICK_CHANCE + 1);
      if (rightClick < 0) then
        rightClick := 0;
      nextReaction.setTime(random(MINIMUM_REACTION_WAIT, MAXIMUM_REACTION_WAIT));
      repeat
        mainLoop;
      until false;
    end;

  4. #79
    Join Date
    Feb 2015
    Posts
    422
    Mentioned
    41 Post(s)
    Quoted
    226 Post(s)

    Default

    Quote Originally Posted by Man16 View Post
    I'm trying to make my own edits to this so it solely relies on other's wells. I could do with some guidance please as it keeps trying to open the bank when there is no well nearby and I can't see why in the code. Here's what I currently have, you can see what I have commented out,

    Code:
    program ClarityWells;
    {$i oglib/lib/core/core.simba}
    
    {ClarityWells v1.3}
    
    {SCRIPT SETTINGS}
    
    const
      BANK_MODEL_ID = 910041455;           //Champion's Guild Bank Chest, 756483783 - Shantay Bank Chest, 910041455 - Lumbridge Combat Academy
      BANK_OPTION_TEXT = 'Use Bank chest';  //Right click text for the bank
      MINIMUM_REACTION_WAIT = 700;          //Minimum delay between actions and reactions
      MAXIMUM_REACTION_WAIT = 1800;         //Maximum delay between actions and reactions
      RIGHT_CLICK_CHANCE = 6;               //Chance of right-clicking well or bank
      KEYBIND_CHANCE = 3;                   //Chance of using keybind to place a well
      WELL_KEYBIND = '4';                   //Actionbar key for well placement
      SHOW_PAINT = true;                    //Show script progress paint?
    
    {END OF SETTINGS}
    
    const
      scriptVersion = '1.3';
    
    var
      nextRotateCamera, nextReaction: tCountDown;
      presetString: string;
      didNotMix, rightClick, startingXP, scriptPaintBMP: integer;
      didClickWell: boolean;
    
    {PROCEDURE -- ClarityDebug
    Purpose: Custom console debugging procedure.
    Comments: None.}
    procedure ClarityDebug(message: string);
    begin
      writeln('ClarityWells v' + scriptVersion + ' || ' + toStr(getTimeRunning) + ' || ' + message);
    end;
    
    {PROCEDURE -- doNothing}
    procedure doNothing;
    begin
    end;
    
    {PROCEDURE -- withdrawPreset
    Purpose: Withdraws a bank preset.
    Comments: None.}
    procedure withdrawPreset;
    begin
      ClarityDebug('Withdrawing bank preset ' + toStr(presetString) + '.');
      if random(2) then
        sendKeys(presetString, 60 + random(60), 60 + random(60))
      else
        bank.clickPreset(strToIntDef(presetString, 1));
      repeat
        wait(random(300, 400));
      until (not bank.hasBank());
      nextReaction.setTime(random(MINIMUM_REACTION_WAIT, MAXIMUM_REACTION_WAIT));
    end;
    
    {PROCEDURE -- makePotions
    Purpose: Clicks on the make button within the well interface.
    Comments: None.}
    procedure makePotions;
    begin
      ClarityDebug('Making our potions at the well.');
      if dialogue.hasDialogue() then
        typeByte(VK_ESCAPE);
      if random(2) then
        sendKeys(' ', 60 + random(60), 60 + random(60))
      else
        production.setMake();
      nextReaction.setTime(random(MINIMUM_REACTION_WAIT + 1000, MAXIMUM_REACTION_WAIT + 2000));
    end;
    
    {PROCEDURE -- placeWell
    Purpose: Places a new well if one has expired.
    Comments: None.}
    procedure placeWell;
    begin
      ClarityDebug('Placing a new portable well.');
      repeat
        if (random(KEYBIND_CHANCE) = 0) then
          sendKeys(WELL_KEYBIND, 60 + random(60), 60 + random(60))
        else
          inventory.clickItem(52275, 854794);
        wait(random(600, 1200));
      until dialogue.hasDialogue();
      sendKeys('1', 60 + random(60), 60 + random(60));
      repeat
        wait(random(600, 1200));
      until ogl.getModels(4264156587).indexes;
      nextReaction.setTime(random(MINIMUM_REACTION_WAIT, MAXIMUM_REACTION_WAIT));
    end;
    
    {PROCEDURE -- useBankChest
    Purpose: Uses whatever bank has been specified in script settings.
    Comments: None.}
    procedure useBankChest;
    var
      modelsBank: glModelArray;
      bankTPA: TPointArray;
    begin
      if combat.hasTarget() then exit;
      if dialogue.hasDialogue() then
        typeByte(VK_ESCAPE);
      inc(didNotMix);
      if didNotMix > 10 then
      begin
        ClarityDebug('Out of supplies!  Terminating script.');
        terminateScript;
      end;
      ClarityDebug('Clicking on the bank chest.');
      if (modelsBank := ogl.getModels(BANK_MODEL_ID)).indexes then
      begin
        bankTPA := modelsBank.closestTo(ogl.getClientMidPoint()).toPointArray();
        if (random(rightClick) = 0) then
          mouse.rightClickOption(bankTPA[0].adjustPosition(0, -10).randomizePointEllipse(40), [BANK_OPTION_TEXT])
        else
          mouse.click(bankTPA[0].adjustPosition(0, -10).randomizePointEllipse(40));
      end;
      nextReaction.setTime(random(MINIMUM_REACTION_WAIT, MAXIMUM_REACTION_WAIT));
    end;
    
    {PROCEDURE -- useWell
    Purpose: Uses the nearest portable well.
    Comments: None.}
    procedure useWell;
    var
      modelsWell: glModelArray;
      wellTPA: TPointArray;
    begin
      ClarityDebug('Clicking on the portable well.');
      if dialogue.hasDialogue() then
        typeByte(VK_ESCAPE);
      if (modelsWell := ogl.getModels(4264156587)).indexes then
      begin
        wellTPA := modelsWell.closestTo(ogl.getClientMidPoint()).toPointArray();
        if (random(rightClick) = 0) then
          mouse.rightClickOption(wellTPA[0].adjustPosition(0, -10).randomizePointEllipse(40), ['Mix potions Portable well'])
        else
          mouse.click(wellTPA[0].adjustPosition(0, -10).randomizePointEllipse(40));
      end;
      nextReaction.setTime(random(MINIMUM_REACTION_WAIT, MAXIMUM_REACTION_WAIT));
    end;
    
    {PROCEDURE -- checkXP
      Purpose:  Checks the current overall XP gained.
      Comments: Will be pushed to ogLib soon.}
    function checkXP(): integer;
    var
      xpTextures: glTextureArray;
      textureBox: TBox;
      currentXP: string;
      position: integer;
    begin
      xpTextures := ogl.getTextures(48705, 4736586);
      if length(xpTextures) then
      begin
        textureBox := xpTextures[0].bounds;
        currentXP := ogl.getChars(IntToBox(textureBox.X1 - 150, textureBox.Y1, textureBox.X2, textureBox.Y2)).toString();
        position := pos('xp', currentXP);
        if (position > 0) then
        begin
          currentXP := '*' + currentXP;
          currentXP := between('*',' +', currentXP);
        end;
        result := strToIntDef(extractFromStr(currentXP, numbers), 0);
      end;
    end;
    
    {PROCEDURE -- getTime
    Purpose: Translates ms to a readable format.
    Comments: Written by Ross.}
    function getTime(time: uint32): string;
    var
      h, m, s: integer;
    begin
      s := time mod 3600000 mod 60000 div 1000;
      m := time mod 3600000 div 60000;
      h := time div 3600000;
      result:= (toStr(h) + ' h ' + toStr(m) + ' m ' + toStr(s) + ' s');
    end;
    
    {PROCEDURE -- progressReport
    Purpose: Calculates and paints progress on the screen.
    Comments: None.}
    procedure progressReport();
    var
      gainedXP, gainedRespect, gainedXPPerHour, gainedRespectPerHour: extended;
      gainedXPString, gainedXPPerHourString: string;
      time: string;
    begin
      time := getTime(getTimeRunning());
      gainedXP := checkXP() - startingXP;
      gainedXPPerHour := Round(gainedXP * (3600.0 / (GetTimeRunning / 1000.0)));
      gainedXPString := format('%n', [gainedXP]);
      gainedXPPerHourString := format('%n', [gainedXPPerHour]);
      setLength(gainedXPString, length(gainedXPString) - 3);
      setLength(gainedXPPerHourString, length(gainedXPPerHourString) - 3);
      if SHOW_PAINT then
      begin
        smart.graphics.drawBitmap(scriptPaintBMP, Point(3, 461));
        smart.graphics.drawText(ToStr(time), 'smallChars', Point(127, 517), 1);
        smart.graphics.drawText(ToStr(time), 'smallChars', Point(126, 516), clWhite);
        smart.graphics.drawText(gainedXPString + ' XP', 'smallChars', Point(114, 538), 1);
        smart.graphics.drawText(gainedXPString + ' XP', 'smallChars', Point(113, 537), clWhite);
        smart.graphics.drawText(gainedXPPerHourString + ' XP','smallChars', Point(114, 560), 1);
        smart.graphics.drawText(gainedXPPerHourString + ' XP','smallChars', Point(113, 559), clWhite);
      end;
    end;
    
    {PROCEDURE -- waitToBank
    Purpose: Waits while potions are being made.
    Comments: None.}
    procedure waitToBank;
    var
      cd: tcountdown;
    begin
      ClarityDebug('Waiting for potion mixing to finish.');
      cd.setTime(random(29000, 33000));
      repeat
        if nextRotateCamera.isFinished() then
        begin
          //minimap.setDegrees(random(360));
          nextRotateCamera.setTime(random(300000));
        end;
        didNotMix := 0;
      until (production.hasProduction() = 'progress') = false;
      progressReport;
      useBankChest;
    end;
    
    {PROCEDURE -- mainLoop
    Purpose: Script main loop.
    Comments: None.}
    procedure mainLoop;
    var
      reaction: procedure() = @doNothing;
    begin
      if (not nextReaction.isFinished()) then
        exit;
      if bank.hasBank() and ogl.getModels(4264156587).indexes then
      begin
        presetString := '1';
        reaction := @withdrawPreset
      end
      //else if bank.hasBank() and (not ogl.getModels(4264156587).indexes) then
     // begin
     //   presetString := '2';
      //  reaction := @withdrawPreset
     // end
      else if (production.hasProduction() = 'progress') = false then
      begin
        if (production.hasProduction() = 'production') then
        begin
          reaction := @makePotions;
        end
        //else if (inventory.getItems(52275, 854794).indexes and (not ogl.getModels(4264156587).indexes)) then
        //  reaction := @placeWell
        else if ogl.getModels(4264156587).indexes and inventory.isFull() then
          reaction := @useWell
        else if ogl.getModels(BANK_MODEL_ID).indexes then
          reaction := @useBankChest;
      end
      else
        reaction := @waitToBank;
      reaction();
    end;
    
    {PROCEDURE -- autoUpdateMe
    Purpose: Autoupdates the script.
    Comments: By Shuttleu, modified by Ashaman88 and Clarity}
    procedure autoUpdateMe;
    var
      Neifile: Integer;
      OnlineVersion, NewScript, NeiFeilNennen: string;
    begin
      ClarityDebug('Checking for script updates...');
      OnlineVersion := GetPage('http://pastebin.com/raw.php?i=xzkYu1a2');
      ClarityDebug('Online Script Version: ' + OnlineVersion);
      ClarityDebug('Local Script Version: ' + ScriptVersion) if (trim(OnlineVersion) > ScriptVersion) then
      begin
        ClarityDebug('Newer script version online!');
        ClarityDebug('Autoupdating to newer version.');
        NewScript := GetPage('http://pastebin.com/raw.php?i=wxtDh8Vr');
        NeiFeilNennen := ScriptPath + 'ClarityWells v' + OnlineVersion + '.simba';
        Neifile := Rewritefile(NeiFeilNennen, true);
        try
          WriteFileString(Neifile, NewScript);
        except
          begin
            ClarityDebug('Fatal error writing to ' + NeiFeilNennen + '!');
            Terminatescript;
          end;
        end;
        CloseFile(Neifile);
        ClarityDebug('New script downloaded to ' + NeiFeilNennen + '! Terminating old script, please use the new version.');
        writeln('New script downloaded to ' + NeiFeilNennen + '! Terminating old script, please use the new version.');
        TerminateScript;
      end
      else
        ClarityDebug('You have the latest version of the script!');
    end;
    
    {PROCEDURE -- checkForFiles
    Purpose: Checks to see if file downloading is required.
    Comments: By Kevin, modified by Clarity}
    procedure checkForFiles(filePath, message, link: string);
    var
      progFile: longInt;
      fileName: string;
    begin
      fileName := AppPath + filePath;
      try
        if not fileExists(fileName) then
        begin
          ClarityDebug('-- INSTALLATION STATUS: ' + message + ' does not exist - Downloading now.');
          progFile := createFile(fileName);
        end
        else
        begin
          ClarityDebug('-- INSTALLATION STATUS: ' + message + ' exists.');
          exit;
        end;
        closeFile(progFile);
        progFile := rewriteFile(fileName, false);
        writeFileString(progFile, getPage(link));
        ClarityDebug('-- INSTALLATION STATUS: ' + message + ' has been downloaded.');
      finally
        if (progFile > 0) then
          closeFile(progFile);
      end;
    end;
    
    {PROCEDURE -- installClarityWellsAssets
      Purpose:  Determines whether files exist and dictates their installation.
      Comments: None.}
    procedure installClarityWellsAssets;
    begin
      ClarityDebug('Please wait...now installing ClarityWells image assets to your computer...');
      if not directoryExists(appPath + 'scripts/ClarityWellsImages/') then
      begin
        try
          createDirectory(appPath + 'scripts/ClarityWellsImages/');
          ClarityDebug('Created a new folder in Simba/Scripts/');
        except
        end;
      end;
      checkForFiles('scripts/ClarityWellsImages/scriptpaint.png', 'Script Paint', 'http://i.imgur.com/8ng7x2n.png');
    end;
    
    {PROCEDURE -- freeBMP
      Purpose:  Frees bitmaps used in the script.
      Comments: None.}
    procedure freeBMP();
    begin
      freeBitmap(scriptPaintBMP);
    end;
    
    begin
      addOnTerminate('freeBMP');
      clearDebug();
      ogl.setup(800, 600);
      ogl.setCacheTime(120);
      ogl.setColourTolerance(2);
      ogl.setDebugMode('none');
      autoUpdateMe;
      installClarityWellsAssets();
      if SHOW_PAINT then
      begin
        scriptPaintBMP := loadBitmap(appPath + '/Scripts/ClarityWellsImages/scriptpaint.png');
        fastReplaceColor(scriptPaintBMP, 0, 1);
      end;
      startingXP := checkXP();
      ClarityDebug('Starting XP was set as: ' + toStr(checkXP));
      rightClick := random(RIGHT_CLICK_CHANCE - 1, RIGHT_CLICK_CHANCE + 1);
      if (rightClick < 0) then
        rightClick := 0;
      nextReaction.setTime(random(MINIMUM_REACTION_WAIT, MAXIMUM_REACTION_WAIT));
      repeat
        mainLoop;
      until false;
    end;
    I have a script called AIO Portable-O-Matic that will do exactly what you want to do.

    It's in my signature, or you can find it in the multi skill section

  5. #80
    Join Date
    Dec 2011
    Posts
    59
    Mentioned
    1 Post(s)
    Quoted
    11 Post(s)

    Default

    Quote Originally Posted by fady View Post
    I have a script called AIO Portable-O-Matic that will do exactly what you want to do.

    It's in my signature, or you can find it in the multi skill section
    Thank you, god bless.

  6. #81
    Join Date
    Nov 2011
    Posts
    67
    Mentioned
    0 Post(s)
    Quoted
    8 Post(s)

    Default

    Due to lag, sometimes it opens up a bank and clicks the preset but it doesnt actually withdraw a preset. Just keeps the same inventory. The script then clicks on the well and cant make any pots and is thus stuck. Would it be possible to add a failsafe where the script looks for a user defined raw material like clean avantoe in inventory before proceeding to click the well? or being able to re bank if its unable to make anything at the well for say 10 secs.

  7. #82
    Join Date
    Dec 2016
    Posts
    39
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Script has gained alot of levels for me

  8. #83
    Join Date
    Mar 2016
    Posts
    2
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Thanks for this, working really well so far

Page 4 of 4 FirstFirst ... 234

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
  •