Simba Code:
{$DEFINE SMART}
{$include_once GLX/GLXCore.Simba}
{$include_once GLX/Misc/Map.Simba}
{$include_once GLX/Misc/Smart.Simba}
{$include_once GLX/Misc/Graphics.Simba}
{$include_once GLX/Mouse.Simba}
{$include_once GLX/Login.Simba}
{$include_once GLX/Text.Simba}
{$include_once GLX/Bank.Simba}
{$include_once GLX/Inventory.Simba}
const
MyID = 648933015; //My player ID when not fishing.
FlyFish = True; //True to flyfish, False to barbarian fish.
UseInv = False; //False to Auto detect interface setup. True to use fixed coordinates for setup.
var
T: TSmart;
Inv: Tbox = [1035, 375, 1342, 596];
Procedure MarkTime(var T: Integer);
Begin
T := GetSystemTime;
End;
Function TimeFromMark(T: Integer): Integer;
Begin
Result := GetSystemTime - T;
End;
procedure TypeByte(k: Byte);
begin
{$IFDEF SMART}
If (K = 13) then
K:= 10;
{$ENDIF}
KeyDown(k);
Wait(10 + Random(50));
KeyUp(k);
end;
procedure TypeSend(Text: string);
var
I: Integer;
begin
for i := 1 to Length(Text) do
begin
{$IFDEF SIMBAMAJOR980}
SendKeys(Text[i], 40 + Random(40));
{$ELSE}
SendKeys(Text[i], 30 + Random(30), 30 + Random(30));
{$ENDIF}
Wait(40 + Random(40));
end;
end;
Function InvBox: TBox;
Begin
If UseInv Then
Result := Inv
Else
Result := GL_InvBounds;
End;
Function InvCount: Integer;
Begin
If (Length(glGetTextures(InvBox)) < 1) Then
Result := 0
Else If (GL_BankScreen) Then
Result := Length(glGetTextures(InvBox)) - 47
Else
Result := Length(glGetTextures(InvBox)) - 37;
If (Result < 0) Then Result := 0;
End;
Function InvFull: Boolean;
Begin
Result := InvCount >= 28;
End;
Function FindFishingSpot: TPoint;
var
TPA: TPointArray;
I, X1, Y1, X2, Y2: Integer;
FishingSpots: glModelArray;
Begin
FishingSpots := glGetModels(2648051121);
//Insert(glGetModels(203893359), FishingSpots);
//Insert(glGetModels(2948843458), FishingSpots);
//Insert(glGetModels(1421135458), FishingSpots);
SetLength(TPA, Length(FishingSpots));
For I := 0 To High(FishingSpots) Do
Begin
TPA[I] := Point(FishingSpots[I].X, FishingSpots[I].Y);
End;
If (Length(TPA) > 0) Then
Begin
GLXViewPort(X1, Y1, X2, Y2);
SortTPAFrom(TPA, Point((X2 - X1) div 2, (Y2 - Y1) div 2));
If (Length(TPA) > 0) then
Result := TPA[0]
else
Result := Point(-1, -1);
End;
End;
Function HasFeathersBait: Boolean;
Begin
Result := (Length(glGetTextures(80835, 2302754, 20)) > 0) or (Length(glGetTextures(36720, 460033, 20)) > 0);
End;
Function GetFishBoxes(Area: TBox): TBoxArray;
var
I, J: Integer;
Textures: glTextureArray;
Begin
Textures := glGetTextures(Area);
SetLength(Result, Length(Textures));
For I := 0 To High(Textures) do
Begin
If ((Textures[I].ID = 49470) and SimilarColors(Textures[I].ColourID, 1118479, 5))
or ((Textures[I].ID = 45900) and SimilarColors(Textures[I].ColourID, 724234, 5))
or ((Textures[I].ID = 62220) and SimilarColors(Textures[I].ColourID, 1249296, 5))
or ((Textures[I].ID = 71145) and SimilarColors(Textures[I].ColourID, 2628634, 5))
or ((Textures[I].ID = 71145) and SimilarColors(Textures[I].ColourID, 2697256, 5))
then
begin
Result[J] := Textures[I].Bounds;
Inc(J);
end;
End;
SetLength(Result, J);
End;
Function GetFlyFishBoxes(Salmon: Boolean; Area: TBox): TBoxArray;
var
I, J: Integer;
Textures: glTextureArray;
Begin
Textures := glGetTextures(Area);
SetLength(Result, Length(Textures));
For I := 0 To High(Textures) do
Begin
If (Salmon and ((Textures[I].ID = 71145) and SimilarColors(Textures[I].ColourID, 2628634, 5))) then
begin
Result[J] := Textures[I].Bounds;
Inc(J);
end else if (Not Salmon and ((Textures[I].ID = 71145) and SimilarColors(Textures[I].ColourID, 2697256, 5))) then
begin
Result[J] := Textures[I].Bounds;
Inc(J);
end;
End;
SetLength(Result, J);
End;
Procedure DropAll;
var
I, T: Integer;
Fish: TBoxArray;
Begin
MarkTime(T);
While(True) Do
Begin
Fish := [];
Fish := GetFishBoxes(InvBox);
If (Length(Fish) < 1) or (TimeFromMark(T) > 20000) Then Exit;
For I := 0 To High(Fish) Do
Begin
MouseBox(Fish[I], MOUSE_RIGHT);
GL_ChooseOptionMulti(['Drop', 'rop', 'Dro']);
End;
End;
End;
Procedure DropFlyFish;
var
I, T: Integer;
Salmon, Trout: TBoxArray;
Begin
MarkTime(T);
While(True) Do
Begin
//Salmon := glGetTextures(58905, 2628634, 5, IntToBox(51, 39, 84, 69));
//Trout := glGetTextures(58905, 2697256, 5, IntToBox(87, 39, 121, 70));
Salmon := GetFlyFishBoxes(True, InvBox);
Trout := GetFlyFishBoxes(False, InvBox);
If ((Length(Salmon) < 1) and (Length(Trout) < 1) or (TimeFromMark(T) > 20000)) Then Exit;
For I := 0 To High(Salmon) Do
Begin
TypeSend('1');
wait(50);
End;
For I := 0 To High(Trout) Do
Begin
TypeSend('2');
wait(50);
End;
End;
End;
function WaitFindModel(ID: Cardinal; WaitPerLoop, MaxTime: Integer): Boolean;
var
T: Integer;
begin
T := GetSystemTime + MaxTime;
while (GetSystemTime < T) do
begin
if (Length(glGetModels(ID)) < 1) then
begin
Result := True;
Exit;
end;
Wait(WaitPerLoop);
end;
end;
Procedure MainLoop;
var
P: TPoint;
MeBox, AnimBox: TBox;
X1, Y1, X2, Y2: Integer;
Begin
GLXViewPort(X1, Y1, X2, Y2);
MeBox := IntToBox(637, 291, 716, 367);
AnimBox := IntToBox(MeBox.X1 + 10, MeBox.Y1 + 10, MeBox.X2 - 10, MeBox.Y2 - 10);
While(True) Do
Begin
ClearDebug;
If (Length(GL_GetMouseUpText) > 0) Then
Mouse(RandomRange(867, 354), RandomRange(1041, 534), 0, 0);
If (InvCount >= 27) Then
Begin
writeln('Dropping Fish.');
while(Length(glGetTextures(183600, 6639632, 10, IntToBox(192, 611, 316, 644))) > 0) do
begin
TypeByte(32);
Wait(100);
end;
If (Not FlyFish) then
DropAll
Else
DropFlyFish;
End;
If (Not HasFeathersBait) Then
Begin
writeln('Ran Out Of Feathers/Bait.');
Exit;
End;
while(Length(glGetModels(MyID, MeBox)) < 1) do
begin
Wait(1000);
ClearDebug;
writeln('Fishing..');
end;
P := FindFishingSpot;
writeln('Found Fishing Spot: ' + ToStr(P));
If (P.X > 0 and P.Y > 0) Then
Begin
Mouse(P, 5, 5, MOUSE_RIGHT);
GL_ChooseOptionMulti(['Use-rod Fishing spot', 'Use-rod', 'rod Fishing spot', 'Lure Fish', 'Lure Fishing spot']);
WaitFindModel(MyID, 50, 3500);
End;
End;
End;
begin
ClearDebug;
T.Create(1350, 650, '', ['OpenGL32.dll']);
GLXMapHooks(T.CurrentClient);
glDebug(GL_MODE_MODELS, 0, 0, 0, T.Width, T.Height);
T.GetGraphics().Clear;
//writeln(glGetModels(IntToBox(624, 303, 695, 338)));
MainLoop;
TerminateScript();
end.