lollage22
2009-07-13 20:54:38
Well, first post… worked for a while on this one.
This Autofighter fights Flesh Crawlers and giant rats, haven't had the opportunity to test it since SRL needs a revision… it compiles, however, and it worked a few weeks ago. Before publishing, I improved the readability and the procedures. Am I doing things right?
Question 1: I can't get the AntiRandom working. Is including FindNormalRandoms enough? I've done this, and when running I noticed a random. The script did not detect -.-
Question 2: Is there a nicer way to detect food and eat it?
Question 3: Because of lack of AntiRandoms: The Script logs out if no monster is attacked after 10 tries. Is this safe enough?
Question 4: How does DeclarePlayer work? The Script currently assumes that the account is already logged in.
Thanks in advance! :) I will also introduce myself here.
This Autofighter fights Flesh Crawlers and giant rats, haven't had the opportunity to test it since SRL needs a revision… it compiles, however, and it worked a few weeks ago. Before publishing, I improved the readability and the procedures. Am I doing things right?
Question 1: I can't get the AntiRandom working. Is including FindNormalRandoms enough? I've done this, and when running I noticed a random. The script did not detect -.-
Question 2: Is there a nicer way to detect food and eat it?
Question 3: Because of lack of AntiRandoms: The Script logs out if no monster is attacked after 10 tries. Is this safe enough?
Question 4: How does DeclarePlayer work? The Script currently assumes that the account is already logged in.
Thanks in advance! :) I will also introduce myself here.
//----------------------------------------------------------------------------//
//-- Lollage Autofighter 1.0 --//
//-- Notes: --//
//-- This AutoFighter is currently tweaked to --//
//-- fleshcrawlers and giant rats. The food that --//
//-- is eaten is salmon. --//
//----------------------------------------------------------------------------//
program New;
{.include SRL/SRL/misc/SMART.scar}
{.include SRL/SRL.scar}
{.Include SRL/SRL/skill/Fighting.scar} //why is that?
{****************************************************************************}
function CheckFood : Integer; // Counts amount of food.
var
p,x,y,Food :Integer;
begin
Food:=0;
for p:= 1 to 28 do
if (findcolortolerance(x,y,7899090, 566+41*(p mod 4), 235+36*trunc(p/4),
570+41*(p mod 4), 239+36*trunc(p/4), 20 {CT} ))
then Food:=Food+1;
writeln('Food left: ' + inttostr(Food));
Result:=Food;
end;
{****************************************************************************}
function EatFood(Food : Integer) : Integer; // Eats food when hp gets low.
var
HPColor : String;
FoodLocation : TPoint;
begin
if (getMMlevels('hp',HPColor)) < (40 + random(5)) then begin
GameTab(4);
FoodLocation:=ItemCoords(Food);
Result:=Food-1;
Mouse(FoodLocation.X, FoodLocation.Y, 2, 3, True);
end
else Result:=Food;
if Food=0 then begin
writeln('Ran out of food: Log Out!');
logout;
exit;
end;
end;
{****************************************************************************}
function FightFoe(FoeColors: array[1..6] of Integer; Foe : Integer) : Boolean;
begin
if(FightNPC(FoeColors, 5, 1000)) then begin
if InFight then begin
Foe:=Foe+1;
writeln('Foe number: '+ inttostr(Foe));
wait(200+random(800));
Result:=True;
end
else Result:=False;
end;
end;
{****************************************************************************}
procedure AntiBanThing;
begin
if random(500)=5 then begin
case random(3)+1 of
1:RandomRClick;
2:HoverSkill('Strength', False);
3:RandomMovement;
end;
end;
end;
{****************************************************************************}
var
FoeColors: array[1..6] of Integer;
Food,CountFoe,FailChecker : Integer;
begin //Main Loop.
//Setting up SMART and SRL
SMARTSetUpEX(55, False, True, False);
SetTargetDC(SMARTGetDC);
SetupSRL;
//Defining all kinds of values
FoeColors[1] := 8814987 ; //Pick 6 colors of the foes you want to fight.
FoeColors[2] := 8950675 ;
FoeColors[3] := 8950675;
FoeColors[4] := 5594201 ;
FoeColors[5] := 8814987;
FoeColors[6] := 5594201 ;
MouseSpeed:= 25;
CountFoe:=0; // Counting Foes killed.
FailChecker:=0; // Goes up when no foe is found.
wait(2000);
Food:=CheckFood;
SetRun(True);
repeat
if not InFight then begin
FindNormalRandoms;
FailChecker:=FailChecker+1
if FightFoe(FoeColors, CountFoe) then begin
FailChecker:=0;
CountFoe:= CountFoe+1;
end;
Food:=EatFood(Food);
end;
wait(200+random(800));
AntiBanThing;
if FailChecker=10 then begin
writeln('Cant attack! Log Out...');
logout;
exit;
end;
until false;
end.