JuKKa
2007-08-30 10:58:32
Well i started to make a pestcontroll script a few weeks ago and snapped up and added a few things today and felt like i should post it to people to know im working on one. BUT This one is special. It walks/runs to the portals and attacks them. Walking is not done yet, BUT its EASY to make it the only problem is .. GATES! Another problem is .. I need a working Autocolor for the middle of the PC island This could be done with Auto Color Aid, and i might do it too.
Heres your task :) Make a autocolor and post it here and ill test it the one that works the best gets it included in the script and credits to a awesome script (Soon to bee) Of course.. DISCUSS!
Please look through the code and of course post if i should add anything!
Heres your task :) Make a autocolor and post it here and ill test it the one that works the best gets it included in the script and credits to a awesome script (Soon to bee) Of course.. DISCUSS!
Program PestControll;
{.Include SRL/SRL.Scar}
Var
Energy: Boolean;
X, Y, Dx, Dy, MaxTime, Specials, PlayTime: Integer;
PortalColors: Array [1..4] Of Integer;
Win, Loss, PCCenter, DoorColor: Integer;
Procedure DeclarePlayers;
Begin
MaxTime:= 120;
CurrentPlayer:= 0;
HowManyPlayers:= 1;
NumberOfPlayers(HowManyPlayers);
Players[0].Name := '';
Players[0].Pass := '';
Players[0].Nick := '';
Players[0].Booleans[0]:= True;
Players[0].Strings[0] := 'Attack';
Players[0].Integers[0]:= 5;
Players[0].Active:= True;
End;
Function WaitR(Time : Integer) : Boolean;
Var Time1: Integer;
Begin
Marktime(time1)
Repeat
Wait(50);
If(FindTalk)Then
Result := True;
Until(result)or(TimeFromMark(Time1)>Time);
End;
Function FindFastRandoms: Boolean; //by WT-Fakawi
var
i: Integer;
begin
for i:=1 to 8 do
begin
case I of
1: If FindDead then
Result := True;
2: If FindMod then
Result := True;
3: If FindMime then
Result := True;
4: If FindMaze then
Result := True;
5: If FindQuiz then
Result := True;
6: If FindDemon then
Result := True;
7: begin
if NoGameTab then
begin
Result := True;
Players[CurrentPlayer].loc := 'No GameTab';
Logout;
Exit;
end;
end;
8: begin
if InBlack then
begin
Result := True;
Players[CurrentPlayer].loc := 'InBlack';
Logout;
Exit;
end;
end;
end;
wait(1);
end;
end;
Procedure AutoRetaliate(act : boolean);
Begin
GameTab(1)
If(FindColorTolerance(X, Y, 2106255, 580, 364, 715, 394, 10))Then
Begin
If(Not Act)Then
Mouse(657, 376, 30, 10, True)
End Else
If(Act)Then
Mouse(657, 376, 30, 10, True);
End;
Procedure SpecialEnergy;
Begin
Energy:= False;
If(Players[CurrentPlayer].Booleans[0])Then
If(FindColorTolerance(X, Y, 3899706, 572, 417, 712, 428, 15))Then
Energy:= True;
Specials:= 0;
End;
Procedure SetFight(Mode: String);
Begin
Case LowerCase(Mode) Of
'strength': SetFightMode(2);
'attack' : SetFightMode(1);
'defence' : SetFightMode(3);
'random' : SetFightMode(1+Random(3));
End
End;
Procedure InitPlayer;
Begin
If(Not Loggedin)Then Exit;
SpecialEnergy;
AutoRetaliate(False);
SetFight(Players[CurrentPlayer].Strings[0]);
End;
Procedure Setup;
Begin
ClearDeBug;
Writeln('Successfully compiled');
SetupSRL;
DeclarePlayers;
MaxTime:= MaxTime * 60 * 1000;
ActivateClient;
Wait(1000);
If(Not Loggedin)Then
LoginPlayer;
MarkTime(PlayTime);
MakeCompass('n');
HighestAngle;
SetRun(True);
End;
{
PortalShield = 7171703;
PortalCross = 1649347;
}
Function GoToPortal: Integer;
Var
I: Integer;
Begin
If(Not Loggedin)Then Exit;
For I:= 0 To 4 Do
Begin
Wait(100);
Case I Of
0: If(Not FindColorSpiralTolerance(Dx, Dy, 10189984, 366-3, 40-3, 366+3, 40+3, 4))Or
(Not FindColorSpiralTolerance(Dx, Dy, 10519684, 395-3, 40-3, 412+3, 40+3, 4))Or
(Not FindColorSpiralTolerance(Dx, Dy, 8232864, 395-3, 40-3, 412+3, 40+3, 4))Or
(Not FindColorSpiralTolerance(Dx, Dy, 4532366, 395-3, 40-3, 412+3, 40+3, 4))Then
Begin
Result:= 5;
Break;
End;
1: If(Not FindColorSpiralTolerance(Dx, Dy, 7171703, 361, 50, 375, 56, 7))Then
If(Not FindColorSpiralTolerance(Dx, Dy, 1649347, 369 - 3, 44-3, 370+3, 44+3,5))Then
Begin
Result:= 1;
Break;
End;
2: If(Not FindColorSpiralTolerance(Dx, Dy, 7171703, 395, 50, 412, 56, 7))Then
If(Not FindColorSpiralTolerance(Dx, Dy, 1649347, 407-3, 44-3, 407+3, 44+3, 5))Then
Begin
Result:= 2;
Break;
End;
3: If(Not FindColorSpiralTolerance(Dx, Dy, 7171703, 433, 50, 452, 56, 7))Then
If(Not FindColorSpiralTolerance(Dx, Dy, 1649347, 445-3, 44-3, 445+3, 44+3, 5))Then
Begin
Result:= 3;
Break;
End;
4: If(Not FindColorSpiralTolerance(Dx, Dy, 7171703, 472, 50, 489, 58, 7))Then
If(Not FindColorSpiralTolerance(Dx, Dy, 1649347, 481-3, 44-3, 481+3, 44+3, 5))Then
Begin
Result:= 4;
Break;
End;
End
Wait(100);
End;
{Case Result Of
0: Begin
Writeln('No Portals To Attack');
End;
1: Writeln('West');
2: Writeln('East');
3: Writeln('South East');
4: Writeln('South West');
5: Writeln('Not in pestcontrol');
End}
End;
Function PortalAlive(Portal: String): Boolean;
Begin
Case LowerCase(Portal) Of
'west': Result:= FindColorSpiralTolerance(Dx, Dy, 1649347, 369 - 3, 44-3, 370+3, 44+3,5)
'east': Result:= FindColorSpiralTolerance(Dx, Dy, 1649347, 407-3, 44-3, 407+3, 44+3, 5)
'south east': Result:= FindColorSpiralTolerance(Dx, Dy, 1649347, 445-3, 44-3, 445+3, 44+3, 5)
'south west': Result:= FindColorSpiralTolerance(Dx, Dy, 1649347, 481-3, 44-3, 481+3, 44+3, 5)
End
End;
Function FindClosestColor(xx, yy, Color: Integer; Txt: String; Tolerance: Integer): Boolean;
Var
I, Closest: Integer;
ColorTPA: TPointArray;
Begin
ColorToleranceSpeed(0);
Closest:= 9999;
FindColorsSpiralTolerance(xx, yy, ColorTPA, Color, MSX1, MSY1, MSX2, MSY2,Tolerance);
For I:= 0 To GetArrayLength(ColorTPA)-1 Do
Begin
If(Distance(MSCX, MSCY, ColorTPA[I].X, ColorTPA[I].Y) <= Closest)Then
Begin
Closest:= Distance(MSCX, MSCY, ColorTPA[I].X, ColorTPA[I].Y)
xx:= ColorTPA[I].X;
yy:= ColorTPA[I].Y;
End;
End;
If(GetArrayLength(ColorTPA)-1 >= 1)Then
Begin
MMouse(XX, YY, 1, 1);
Wait(25);
If(IsUpText(Txt))Then
Begin
Result:= True;
Exit;
End;
End;
End;
Procedure GetOnBoat;
Var
Tries: Integer;
Begin
If(Not Loggedin)Then Exit;
Repeat
If(FindClosestColor(X, Y, 5008776, 'ross', 5))Then
Begin
GetMousePos(X, Y);
Mouse(X, Y, 0, 0, True);
Break;
End Else
Tries:= Tries + 1;
Wait(500+Random(300));
If(Tries >= 5)Then
Begin
Players[CurrentPlayer].Loc:= 'Couldnt Find Boat';
Logout;
Break;
End;
Until(Not Loggedin);
End;
Procedure HowerFast(Skill: String);
Var
TPCords: TPoint;
Begin
TPCords:= SkillToCoords(LowerCase(Skill));
Case LowerCase(Skill) Of
'attack' : MMouse(TPCords.X, TPCords.Y, 5, 5);
'strength': MMouse(TPCords.X, TPCords.Y, 5, 5);
'defence' : MMouse(TPCords.X, TPCords.Y, 5, 5);
'range' : MMouse(TPCords.X, TPCords.Y, 5, 5);
'magic' : MMouse(TPCords.X, TPCords.Y, 5, 5);
'prayer' : MMouse(TPCords.X, TPCords.Y, 5, 5);
End
End;
Function IsLoading: Boolean;
Begin
If(GetColor(26,12) = 0)And
(GetColor(40,12) = 0)And
(GetColor(64,12) = 0)Then
Result:= True;
End;
Procedure IdleUntilInPestControll;
Var
Idleskill, HowerTime: Integer;
Begin
If(Not Loggedin)Then Exit;
Repeat
FindFastRandoms;
If(TimeFromMark(HowerTime)>= 5000)Then
IdleSkill:= 1+Random(8);
Case IdleSkill Of
1: HowerFast('Attack');
2: HowerFast('Strength');
3: HowerFast('Defence');
4: HowerFast('Range');
5: HowerFast('Magic');
6: HowerFast('Prayer');
7: GameTab(1+Random(14));
8: Begin
LowestAngle;
WaitR(Random(1000));
HighestAngle;
End;
End
WaitR(300+Random(300));
Respond;
WaitR(300+Random(300));
MarkTime(HowerTime);
Until(Not Loggedin)Or(IsLoading);
End;
Procedure PestPrayer(Pray1, Pray2: Integer);
Begin
If(Not Loggedin)Then Exit;
End;
Procedure DoSpecial;
Begin
GameTab(1);
If(FindColorTolerance(X, Y, 3899706, 572, 417, 712, 428, 15))Then
If(Not FindColorTolerance(X, Y, 65535, 572, 417, 712, 428, 5))Then
Begin
Mouse(572+Random(138), 417+Random(10), 0, 0, True);
Specials:= Specials + 1;
End;
End;
function PestWalk(Color, StartRadial, EndRadial, Radius, Xoff, Yoff: Integer): Boolean;
var
i, X1, Y1: Integer;
begin
Result := False;
if (StartRadial = EndRadial) then
WriteLn('ERROR - PestWalk can''t have the same values for both Start and End Radials!')
else if (StartRadial < EndRadial) then
begin
repeat
for i := StartRadial to EndRadial do
begin
x1 := Round(Radius * Sine(i)) + 646;
y1 := Round(-Radius * Cose(i)) + 84;
if Not LoggedIn then Exit;
if FindColor(x, y, Color, X1, Y1, X1 + 1, Y1 + 1) then
begin
Mouse(x + Xoff, y + Yoff, 5, 5, True);
Result := True;
FFlag(5);
Exit;
end;
end;
Radius := Radius - 4;
until Radius <= 1;
end else
if (StartRadial > EndRadial) then
begin
repeat
for i := StartRadial downto EndRadial do
begin
x1 := Round(Radius * Sine(i)) + 646;
y1 := Round(-Radius * Cose(i)) + 84;
if Not LoggedIn then Exit;
if (FindColor(x, y, Color, X1, Y1, X1 + 1, Y1 + 1)) then
begin
Mouse(x + Xoff, y + Yoff, 5, 5, True);
Result := True;
FFlag(5);
Exit;
end;
end;
Radius := Radius - 4;
until Radius <= 1;
end;
end;
Function PestWalkTo(iFromT, iToT: String): Boolean;
Begin
If(Not Loggedin)Then Exit;
If(iFromT = 'boat')And
(iToT = 'center')Then
Begin
PestWalk(PCCenter,200, 155, 65, 0, 0);
Result:= True;
Exit;
End;
If(iFromT = 'center')And
(iToT = 'west')Then
Begin
If(Not PestWalk(DoorColor, 300, 269, 73, 5, 20))Then
RunTo('w',true);
RunTo('w',false);
Result:= True;
Exit;
End;
If(iFromT = 'center')And
(iToT = 'east')Then
Begin
If(Not PestWalk(DoorColor, 55, 90, 73, 5, 20))Then
RunTo('e',true);
RunTo('e',false);
Result:= True;
Exit;
End;
If(iFromT = 'west')And
(iToT = 'center')Then
Begin
RunTo('e',false);
RunTo('e',true);
If(Not PestWalk(PCCenter, 67, 107, 65, 0, 0))Then
RunTo('e', false);
Result:= True;
Exit;
End;
End;
Procedure AttackPortal(Portal: String);
Var
I: Integer;
Begin
If(Not Loggedin)Then Exit;
Case LowerCase(Portal) Of
'west': I:= 1;
'east': I:= 2;
'south east': I:= 3;
'south west': I:= 4;
End
If(FindClosestColor(X, Y, PortalColors[I], 'tack', 10))Then
Begin
GetMousePos(X, Y);
Mouse(X, Y, 0, 0, True);
Flag;
Repeat
Wait(100);
Respond;
Wait(100);
If(Specials >= Players[CurrentPlayer].Integers[0])Then
DoSpecial
Else
If(GetHp = 0)Then
Begin
Wait(3000+Random(2000));
PestWalkTo('Boat','Center');
Break;
End;
Until(Not PortalAlive(Portal))Or(Not Loggedin);
End;
End;
Function GetDoorColor: Integer;
Var
DoorTPA: TPointArray;
X, Y, I: Integer;
Begin
FindColorsSpiralTolerance(X, Y, DoorTPA, 200, MMX1, MMY1, MMX2, MMY2, 50);
For I:= 0 To GetArrayLength(DoorTPA)-1 Do
Begin
If(GetColor(DoorTPA[i].X, DoorTPA[i].Y) > 200)And
(GetColor(DoorTPA[i].X, DoorTPA[i].Y) < 255)Then
If(GetColor(DoorTPA[i].X+1, DoorTPA[i].Y) > 200)And
(GetColor(DoorTPA[i].X+1, DoorTPA[i].Y) < 255)Then
If(GetColor(DoorTPA[i].X+2, DoorTPA[i].Y) > 200)And
(GetColor(DoorTPA[i].X+2, DoorTPA[i].Y) < 255)Then
If(GetColor(DoorTPA[i].X+3, DoorTPA[i].Y) > 200)And
(GetColor(DoorTPA[i].X+3, DoorTPA[i].Y) < 255)Then
Begin
Result:= GetColor(DoorTPA[i].X, DoorTPA[i].Y);
Break;
End;
If(GetColor(DoorTPA[i].X, DoorTPA[i].Y) > 200)And
(GetColor(DoorTPA[i].X, DoorTPA[i].Y) < 255)Then
If(GetColor(DoorTPA[i].X, DoorTPA[i].Y+1) > 200)And
(GetColor(DoorTPA[i].X, DoorTPA[i].Y+1) < 255)Then
If(GetColor(DoorTPA[i].X, DoorTPA[i].Y+2) > 200)And
(GetColor(DoorTPA[i].X, DoorTPA[i].Y+2) < 255)Then
If(GetColor(DoorTPA[i].X, DoorTPA[i].Y+3) > 200)And
(GetColor(DoorTPA[i].X, DoorTPA[i].Y+3) < 255)Then
Begin
Result:= GetColor(DoorTPA[i].X, DoorTPA[i].Y);
Break;
End;
End;
If(Result <> 0)Then
Writeln('Door Color: ' + IntToStr(Result))
Else Writeln('Couldnt Get Door Color');
End;
Function GetPestCenterColor: Integer;
Begin
Result:= -1;
End;
Function FollowColor(AtX, AtY, Color: Integer): TPoint;
Begin
If(FindColorSpiral(X, Y, Color, AtX-10, AtY-10, AtX + 10, AtY + 10))Then
Begin
Repeat
Wait(10);
If(FindColor(X, Y, Color, AtX-10, AtY-10, AtX + 10, AtY + 10))Then
Begin
Result.X:= X;
Result.Y:= Y;
End;
Until(Not FlagPresent)Or(Not Loggedin);
End;
End;
Function AttackMonsters: Boolean;
Var
HPBar: TPoint;
Fight: Integer;
Begin
If(Not Loggedin)Then Exit;
If(FindColorSpiral(X, Y, 65280, MSX1, MSY1, MSX2, MSY2))Then
Begin
MMouse(X, Y+10, 3, 3);
Wait(25);
If(IsUpText('tack'))Then
Begin
GetMousePos(X, Y);
Mouse(X, Y, 0, 0, True);
Result:= True;
HPBar:= FollowColor( X, Y, 65280 );
End;
End;
If(FindFight)Or(Result)Then
Begin
MarkTime(Fight);
Repeat
WaitR(300+Random(300));
If(Not FindColor(X, Y, 65280, HPBar.X-10, HPBar.Y-10, HPBar.X+10, HPBar.Y+10))Then
Break;
If(TimeFromMark(Fight)>5000)Then
Break;
Until(Not Loggedin);
End;
End;
Procedure ProgressReport;
Begin
Writeln(' ');
Writeln(' Pest Controll Script Made By JuKKa ');
Writeln(' Wins: '+ InttoStr(Win) + '');
Writeln(' Loss: '+ InttoStr(Loss)+ '');
Writeln(' Points: '+ InttoStr(Win * 2) + '');
End;
Begin
Setup;
Repeat
InitPlayer;
GetOnBoat;
IdleUntilInPestControll;
DoorColor:= GetDoorColor;
PCCenter:= GetPestCenterColor;
PestWalkTo('Boat', 'Center');
Repeat
If(Not Loggedin)Then Break;
Case GoToPortal Of
0: AttackMonsters;
1: Begin
PestWalkTo('Center','West');
AttackPortal('West');
PestWalkTo('West','Center');
End;
2: Begin
PestWalkTo('Center','East');
AttackPortal('East');
PestWalkTo('East', 'Center');
End;
3: Begin
PestWalkTo('Center', 'South East');
AttackPortal('South East');
PestWalkTo('South East', 'Center');
End;
4: Begin
PestWalkTo('Center', 'South West');
AttackPortal('South West');
PestWalkTo('SouthWest', 'Center');
End;
5: Break;
End
Respond;
Until(ClickToContinue)Or(Not Loggedin);
If(ClickToContinue)Then
Win:= Win + 1 Else Loss:= Loss + 1;
ProgressReport;
Until(PlayTime >= MaxTime)Or(Not Loggedin);
If(Loggedin)Then
Logout;
ClearDeBug;
ProgressReport;
End.
Please look through the code and of course post if i should add anything!