Results 1 to 5 of 5

Thread: need help with auto eater

  1. #1
    Join Date
    May 2009
    Posts
    32
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default need help with auto eater

    i making a auto eater my first script the idea is if hp is < a given admount than eat tell its >= another given admount but i cant figure out how to track hp this is my hole script so far

    SCAR Code:
    program eat;
    var
    x,y: integer;

    const
    food1= 5461344
    food2= 1521065

    begin

    end.

  2. #2
    Join Date
    Feb 2008
    Posts
    517
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Dunno if this is gonna help you but this is from a very old script I made a few years back, not sure if it still works as SRL may have changed, and I'm sure it wont compile since it uses other functions and variables from my code but it should give you an idea.

    And by all means, the idea is all I'm trying to give you here, don't just copy the code because you won't learn and because of previously said reasons.

    SCAR Code:
    function CountDTMs(dtm:integer):integer;
    var i, x, y : Integer;
        item : TBox;
    Begin
      Result := 0;
      gametab(tab_inv);
      For i := 1 to 28 do
      Begin
        Item := InvBox(i);
        If FindDTM(DTM, x, y, Item.x1-5, Item.y1-5, Item.x2+5, Item.y2+5) then
          Result := Result + 1;
      end;
    end;

    procedure CountFood;
    begin
         ntrout := CountDTMs(trout);
         nsalmon := CountDTMs(salmon);
         ntuna := CountDTMs(tuna);
         nlobby := CountDTMs(lobby);
         nswordie := CountDTMs(swordie);
    end;

    function eat():boolean;
    var x,y:integer;
    begin
         result := true;
         if ntrout <> 0 then
         begin
            gametab(tab_inv);
            FindDTM(trout, x, y, 560, 210, 560+42*4, 210+36*7);
            mouse(x,y,10,9,true);
            ntrout := ntrout - 1;
            wait(100+random(100));
            exit;
         end;
         if nsalmon <> 0 then
         begin
            gametab(tab_inv);
            FindDTM(salmon, x, y, 560, 210, 560+42*4, 210+36*7);
            mouse(x,y,10,9,true);
            nsalmon := nsalmon - 1;
            wait(100+random(100));
            exit;
         end;
         if ntuna <> 0 then
         begin
            gametab(tab_inv);
            FindDTM(tuna, x, y, 560, 210, 560+42*4, 210+36*7);
            mouse(x,y,10,9,true);
            ntuna := ntuna - 1;
            wait(100+random(100));
            exit;
         end;
         if nlobby <> 0 then
         begin
            gametab(tab_inv);
            FindDTM(lobby, x, y, 560, 210, 560+42*4, 210+36*7);
            mouse(x,y,10,9,true);
            nlobby := nlobby - 1;
            wait(100+random(100));
            exit;
         end;
         if nswordie <> 0 then
         begin
            gametab(tab_inv);
            FindDTM(swordie, x, y, 560, 210, 560+42*4, 210+36*7);
            mouse(x,y,10,9,true);
            nswordie := nswordie - 1;
            wait(100+random(100));
            exit;
         end;
         result := false;
    end;

  3. #3
    Join Date
    Jan 2010
    Posts
    1,414
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Simba Code:
    program AutoEaterExample;
    {$i SRL/SRL.scar}

    procedure HPChecking; // This will check our HP for us
    begin
      if HPPercent <= 30 then // If our HP is below or equal to 30% then do..
      begin
        // Procedure stuff here
      end;
    end;  

    begin
    end.

    The comments in the code should explain it. If not, feel free to ask questions.
    Last edited by RISK; 10-10-2010 at 04:32 AM.

  4. #4
    Join Date
    Oct 2006
    Location
    finland, helsinki
    Posts
    2,501
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Simba Code:
    Function Food: Integer;
    Var
      I: Integer;
      iBox: TBox;
      TPA: TPointArray;
    Begin
      Writeln('Finding food...');
      GameTab(tab_Inv);
      For I:= 1 To 28 Do
      Begin
        If(Not ExistsItem(I))Then Continue;
        MMouseItem(I);
        If(Not IsUpText('Eat'))Then Continue;
        GetInvItemBounds(I, iBox);
        FindColors(TPA, srl_outline_black, iBox.x1, iBox.y1, iBox.x2, iBox.y2);
        Result := GetArrayLength(TPA);
        Writeln('Food length: '+intToStr(Result));
        Exit;
      End;
      Writeln('No food found...');
    End;

    Procedure EatFood;
    Var
      Color: String;
      I, HP: Integer;
      iBox: TBox;
      TPA: TPointArray;
      Eat: Boolean;
    Begin
      Repeat
        HP := GetMMLevels('hp', Color);
        If(Color = 'Orange')Or(Eat)And(FoodLength > 0)Then
        Begin
          If(Color = 'Green')Then Exit;
          //Writeln('Low hp ' + IntToStr(Hp));
          For I:= 1 To 28 Do
          Begin
            If(Not ExistsItem(I))Then Continue;
            SetArrayLength(TPA, 0);
            GetInvItemBounds(I, iBox);
            FindColors(TPA, srl_outline_black, iBox.x1, iBox.y1, iBox.x2, iBox.y2);
            //Writeln(inttostr(i)+  ': remain: '+intToStr(GetArrayLength(TPA)));
            If(GetArrayLength(TPA) = FoodLength)Then
            Begin
              Writeln('Eating...');
              MouseItem(I, True);
              Wait(1000+random(500));
              Eat := True;
              Break;
            End;
          End;
          If(I = 29)And(Color = 'Red')Then
          Begin
            Writeln('Low HP and Out of food... Logging');
            Logout;
            Exit;
          End;
        End Else
          If(Color = 'Red')Then
          Begin
            Writeln('Low hp... Logging');
            Logout;
            Exit;
          End;
      Until(Not LoggedIn)Or(Color = 'Green')Or(Not Eat);
    End;

    use "Function Food: Integer;" in beginning of script declaring it to a variable called: FoodLength.

    Foodlength := Food;

    EatFood;

    Code:
    • Narcle: I recall Jukka releasing a bunch of scripts like this before... Its how he rolls I think. rofl
    • Solarwind: Dude, you are like... t3h s3x.
    • Hy71194: JuKKa you're a machine! You released 3 scripts in 10 minutes! :O
    • benjaa: woah.... Jukka is the man Guildminer pwns all
    • NaumanAkhlaQ: And JuKKa Is my Her0!

  5. #5
    Join Date
    May 2009
    Posts
    32
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    really helped thanks makes sence now

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
  •