SRL Archive - OSR Help

need help with auto eater


hopetobedabest

2010-10-09 23:21:03

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

program eat;
var
x,y: integer;

const
food1= 5461344
food2= 1521065

begin

end.

Feroc1ty

2010-10-10 00:09:14

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.

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;

RISK

2010-10-10 00:24:25


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.

JuKKa

2010-10-10 03:26:51


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;

hopetobedabest

2010-10-16 23:54:21

really helped thanks makes sence now