Results 1 to 2 of 2

Thread: UndergroundHerbalist

  1. #1
    Join Date
    Nov 2011
    Posts
    1,532
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default UndergroundHerbalist

    Originally I have planned to put this in Farming section - that would make me really proud should I finish it, but I don't think I have time anytime soon. I will just illustrate what I have managed to come up with.

    The method in a nutshell - It exploits the fact that you can high alch the cleaned herbs obtained by farming the herb seeds for more than it costs in Daemonheim. Given enough start up cash, this is a self-sufficient yet extremely slow way of training farming. (Don't ask how much XP/H, it is only used to so that you only need to babysit it instead of doing it legit)

    I have come across with this discussion thread -http://villavu.com/forum/showthread.php?t=71419 and I have decided to code a makeshift simba script as a proof of concept. It is extremely time-consuming to set this up (not to mention extremely expensive for that few farming XP), so I probably won't improve it anytime soon, but I guess this is not too bad for me to take the Friday evening off to work on something interesting. More so I believe if someone is interested, they can start off where I left this at and hopefully get something useful.

    This is only to show that if you actually decide to go through all the painful work to set up the starting room for this, this rest can actually be done by a script

    I got myself some 10 levels over 4 hours working on this.

    Compulsory Requirements:
    - Complexity 6 Dungeoneering to unlock Farming in dung
    - Level 7 Farming for farming the lowest available Daemonheim herb
    - Dung ring set to Gatherer and Level 1 Upgrade purchased

    Requirements for self-sufficient runs (actually compulsory in this setup):
    - High combat (or a friend?)- to make starting cash for seeds and to replace farming patch
    - Level 25 Construction - to replace gatestone portal to farming patch
    - Fire staff - either make your own or ask someone to make you one
    - Max Nature runes binded - the more the better
    - Level 44 Runecrafting for nature RC
    - Level 55 Magic for high alch - to replenish your cash

    I'll describe how I set this up. Assume Fire staff and natures are binded (if not, figure out how to get them yourself ). Sell whatever you don't need right after you enter the dungeon. Now go kill some monsters or do whatever for cash. With 12k you should be able to buy 5 bathus ores and 5 seeping elm. Now smelt the bars and replace gatestone portal with farming patch. Finally obtain more cash to buy seeds to run it. RC Natures if needed.

    This is what I get after setting up all that crap - I can tell you, it takes a while and it's really painful. Good thing is, once you're done you only need to babysit it and you can be a boss



    Script is below. It is by no means finished and is buggy , but I am sure if you're interested you can pick up where I left at. Included are the DTMs for grimy Valerian and clean Valerian. Script does not rebuy/rc nats when out of materials. Babysit at all times and buy those materials when you need them

    I hope someone will find use of this Feel free to share what you've managed to do if you modified upon my work - as long as you have the courtesy to credit back me it would be fine It's time to deal with IRL again, school has virtually made my life fall apart.

    Simba Code:
    program UndergroundHerbalist;
    {$DEFINE SMART}
    {.include SRL/SRL.simba}

    //{$DEFINE DEBUG}      //uncomment if you need debug info
    {$DEFINE DEBUG_DRAW} //uncomment if you need debug info
    {$IFDEF DEBUG_DRAW}
    {$I SRL/SRL/misc/debug.simba}
    {$I SRL/SRL/misc/paintsmart.simba}
    {$ENDIF}


    const
        NumbOfPlayers= 1;
        StartPlayer= 0;

        //Dung slots
        DUNG_CASH_SLOT = 1;
        DUNG_SEED_SLOT = 2;

        //SMART Setup
        SmartWorld = 7;
        Members = False;
        SignedClient = True;
        HighDetail = False;

    procedure DeclarePlayers; //Already forgot where I copied this :(
    var i:integer;
    begin
      NumberOfPlayers(NumbOfPlayers);
      CurrentPlayer := StartPlayer;
      for i := 0 to NumbOfPlayers-1 do
        Players[i].BoxRewards  := ['mote', 'ostume', 'XP', 'Gem', 'ithril', 'oal', 'une', 'oins'];

      with Players[0] do
      begin
        Name        := '';     //Player username.
        Pass        := '';     //Player password.
        Nick        := ''; //Player nickname - 3-4 letters of Player username.
        Active      := True;
      end;

    end;

    procedure DoLogin;
    var t: integer;
    begin
      MarkTime(t);
      while (not LoggedIn) do
      begin
        if LogInPlayer then
          break;
        wait(10000+random(500));
        if (TimeFromMark(t) > 180000) then
        begin
          writeln('Failed to login after 180s... Terminating');
          TerminateScript;
        end;
      end;
    end;

    function objFind(color, tol: integer; hmod, smod: extended; w,h, minc: integer;
                     left: boolean; uptext, option: string): boolean;
    var tcts, i, x, y: integer;
        tpa: TPointArray;
        atpa: T2DPointArray;
    begin
      Result:=False;
      tcts:= getToleranceSpeed;
      setColorToleranceSpeed(2);
      setColorSpeed2Modifiers(hmod, smod);
      if FindColorsSpiralTolerance(MSCX, MSCY, tpa, color, MSX1, MSY1, MSX2, MSY2, tol) then
      begin
        atpa:= TPAtoATPAEx(tpa, 20, 20);
        {$IFDEF DEBUG_DRAW}
        debugATPABounds(atpa);
        {$ENDIF}
        for i:=0 to high(atpa) do
        begin
          writeln('atpa['+IntToStr(i)+']: '+IntToStr(length(atpa[i])));
          if (minc > 0) and (length(atpa[i]) < minc) then continue;
          MiddleTPAEx(atpa[i], x, y);
          Mouse(x, y, 3, 3, mouse_move);
          if waitUptext(uptext, 1000) then
          begin
            if left then
            begin
              ClickMouse2(mouse_left);
              Result:= DidRedClick;
            end
            else
            begin
              ClickMouse2(mouse_right);
              Result:= WaitOption(option, 1000);
            end;
            if Result then
            begin
              writeln('objfind success!');
              break;
            end;
          end;
        end;
      end;
      setColorToleranceSpeed(tcts);
    end;

    //Returns true if *object* in question should exist based on the threshold
    function objScan(color, tol: integer; hmod, smod: extended;
                     w,h, minc: integer): boolean;
    var tcts, i, x, y: integer;
        tpa: TPointArray;
        atpa: T2DPointArray;
    begin
      Result:=False;
      tcts:= getToleranceSpeed;
      setColorToleranceSpeed(2);
      setColorSpeed2Modifiers(hmod, smod);
      if FindColorsSpiralTolerance(MSCX, MSCY, tpa, color, MSX1, MSY1, MSX2, MSY2, tol) then
      begin
        atpa:= TPAtoATPAEx(tpa, 20, 20);
        {$IFDEF DEBUG_DRAW}
        debugATPABounds(atpa);
        {$ENDIF}
        for i:=0 to high(atpa) do
        begin
          Result:= (length(atpa[i]) >= minc);
          if Result then break;
        end;
      end;
      setColorToleranceSpeed(tcts);
    end;

    function PlantSeed: boolean;
    var t, c: integer;
        v: TVariantArray;
    begin
      Result:=False;
      if ExistsItem(DUNG_SEED_SLOT) then
      begin
        //Select seed
        MarkTime(t);
        while (TimeFromMark(t) < 10000) do
        begin
          MouseItem(DUNG_SEED_SLOT, mouse_left);
          v:=[DUNG_SEED_SLOT];
          if WaitFuncEx('itemActivated', v, 500, 3000) then
            break;
        end;
        //Timeout, something is wrong?
        if TimeFromMark(t) > 10000 then Exit;

        c:= GetAmountBox(InvBox(DUNG_SEED_SLOT));
        if ObjFind(5334906, 12, 0.05, 1.23, 20, 20, 100, true, 'atc', '') then
        begin
          MarkTime(t);
          while TimeFromMark(t) < 5000 do
          begin
            Result:= GetAmountBox(InvBox(DUNG_SEED_SLOT)) < c;
            if Result then Exit;
          end;
        end;
      end;
    end;

    procedure AddArray(var a: TIntegerArray; n: integer);
    var i: integer;
        t: TIntegerArray;
    begin
      setLength(t, length(a)+1);
      for i:=0 to high(a) do
        t[i]:=a[i];
      t[length(t)-1]:=n;
      a:=t;
    end;

    function HerbPosition(dtm: integer): TIntegerArray;
    var i, x, y: integer;
        tb: TBox;
    begin
      setLength(result, 0);
      for i:=1 to 28 do
      begin
        tb:= InvBox(i);
        if ExistsItem(i) then
          if FindDTM(dtm, x, y, tb.X1, tb.Y1, tb.X2, tb.Y2) then
            AddArray(result, i);
      end;
      if length(result) = 0 then
        writeln('no herbs found')
      else
      begin
        for i:=0 to high(result) do
          writeln(result[i]);
      end;
    end;

    procedure CleanHerb(dtm: integer);
    var i, x, y: integer;
        tb: TBox;
        da: TIntegerArray;
        dropArr: array [0..27] of integer;
    begin
      //Set an array to mark where our herbs are
      for i:=0 to 27 do
        dropArr[i]:=0;

      //Locate herbs using DTM
      da:= HerbPosition(dtm);

      //Finally clean them
      for i:=0 to high(da) do
        MouseItem(da[i], mouse_left);
    end;

    function Invtab(ttab: integer): boolean;
    begin
      result:= (GetCurrentTab = ttab);
    end;

    procedure AlchHerb(dtm: integer);
    var i: integer;
        v: TVariantArray;
        da: TIntegerArray;
    begin
      da:= HerbPosition(dtm);
      v:=[tab_magic];
      //Switch to spell tab
      if WaitFuncEx('FTab', v, 1000, 5000) then
      begin
        for i:=1 to length(da) do
        begin
          //select high alch
          //todo
          Mouse(570, 300, randomRange(-5, 5), randomRange(-5, 5), mouse_left);
          v:=[tab_inv];
          if WaitFuncEx('Invtab', v, 500, 5000) then
          begin
            MouseItem(da[i-1], mouse_left);
            wait(3000+random(100)); //high alch takes 3s for casting
            v:=[tab_magic];
            WaitFuncEx('Invtab', v, 500, 5000);
          end;
        end;
      end;
      //Switch back to inventory
      v:=[tab_inv];
      WaitFuncEx('FTab', v, 500, 5000);
    end;

    function FinishCollection: boolean;
    var s:string;
    begin
      s:= getBlackChatMessage;
      Result:= ExecRegExpr('thing', s);
      writeln('debug: '+s);
    end;

    procedure FarmHerbs(dtm, dtm2: integer);
    var action: string;
    begin
      action:='plant';
      while LoggedIn do
      begin
        writeln({padts}('current action is ' + action));
        case action of
        'plant': begin
                   if PlantSeed then action:= 'collect';
                 end;
        'collect': begin
                     if objScan(6789997, 13, 0.06, 1.04, 20, 20, 50) then
                       if ObjFind(5334906, 12, 0.05, 1.23, 20, 20, 100, false, 'atc', 'vest') then
                       begin
                         WaitFunc(@FinishCollection, 500, 10000);
                         action:='alch';
                       end;
                   end;
        'alch': begin
                   CleanHerb(dtm);
                   wait(3000);
                   AlchHerb(dtm2);
                   action:= 'plant';
                 end;
        'buy':;
        end;
        wait(50);
        writeln({padts}('current action is ' + action));
      end;

    end;

    var DTM, dtm2: integer;
    var t: TIntegerArray;i: integer;
    begin
      Smart_Server := SmartWorld;
      Smart_Members := Members;
      Smart_Signed := SignedClient;
      Smart_SuperDetail := HighDetail;

      setupSRL();
      DeclarePlayers;
      DoLogin;
      dtm:= DTMFromString('mrAAAAHic42BgYJBkY2CQAmJ5IFYBYg0oDRIXBeKpTAwMvUA8AYgnAfEUIJ4BxPOAeBEQO3o5AE1hwon/M+AHjAQwDAAAlCsHyQ==');
      dtm2:= DTMFromString('mrAAAAHic42BgYEhkY2BIBuJ0IC4E4hwgTgXiFCj/OBMDw0Eg3gfEB4D4GBBfAuJrQHwYiM3szICmMOHE/xnwA0YCGAYApjELgQ==');
      FarmHerbs(dtm, dtm2);
    //  PlantSeed;
    //                 if ObjFind(5334906, 12, 0.05, 1.23, 20, 20, 100, false, 'atc', 'vest') then
    ;
    //                   WaitFunc(@FinishCollection, 500, 10000);
    //  AlchHerb(dtm2);
    //  mouse(570,300,0,0,mouse_move);
      FreeDTM(dtm);
      FreeDTM(dtm2);
    end.
    Current activity: Recovering from vacation
    - Nulla pars vitae vacare officio potest -
    SRL membership? Can I buy that?
    Scripts - AGS - SWF - WAR - EMS - W100S-EM
    If you need scripting help, you can pm me. Remember, if you need help you have to ask for it properly though

  2. #2
    Join Date
    Jul 2008
    Location
    NSW, Australia
    Posts
    881
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

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
  •