Simba Code:
program new;
//{$DEFINE SMART}
{$I SRL/osr.simba}
(*
TODO:
BreakHandler:
--just started
Debug:
Needs Salmon and trout counting fixing.
Make pretty.
ScreenSorting:
Works without fail but can take upto 1.3 second.s
Cooking:
works but ugly as hell
*)
type TCell = Record
Cell : TBox;
Points : TPointArray;
NumP : Integer;
end;
const
UsePixelShift = True;//Used to Increase accuracy at the cost of speed Note you need this at barb village and for cooking
DoCooking = true;//well do you want to Cook
type TFFinder = Record
Grid : Array of Array of Tcell;
SGrid : Array of Tcell;
FishingAt : Tcell;
FireCell : Tcell;
Rows, Cols : Integer;
BestFound : Integer;
RandomsIgnored : Integer;
LevelUpFishing : Integer;
LevelUpCooking : Integer;
SalmonCooked : Integer;
TroutCooked : Integer;
FireLogColor : Integer;
SFireLogCol : TColorSettings;
FireColor : Integer;
SFireCol : TColorSettings;
WaterColor : Integer;
SWaterCol : TColorSettings;
FSpeckle : Integer;
SSpeckleCol : TColorSettings;
DebugImage : TMufasaBitmap;
end;
var
LastAngle : Integer;
FFinder, EFinder : TFFinder;
FishCaught, InvCountTimer, LastInvCount : Integer;
MapAngle : array [0..2] of Integer;
function TFFinder.SettupScreen(W, H : Integer) : Array of Array of Tcell;
var i, j : integer;
begin
Rows := Round(514 / W);
Cols := Round(336 / H);
SetLength(Result , Rows, Cols);
for i := 0 to Rows-1 do
for j := 0 to Cols-1 do
Result[i][j].Cell := pointtobox(Point((W * i), (H * j)), Point((W+W) + (W * i), H + (H * j)));
end;
{removed grabing of speckle colors}
Function TFFinder.SortByColorAndArea(BoxesToSort : Array of array of TCell) : Array of TCell;
var
j, i, X, Y, C, B, Dist, TDist : Integer;
SpeckleTPA, FireTPA : TPointArray;
TempArrayA, TempArrayB : Array of TCell;
begin
for i := 0 to Rows-1 do
begin
for j := 0 to Cols-1 do
if (CountColorTolerance(WaterColor, BoxesToSort[i][j].Cell, 9, SWaterCol) > 4) then
begin
SetLength(TempArrayA, C + 1);
TempArrayA[C].Cell := BoxesToSort[i][j].Cell;
inc(C);
end else
begin
if DoCooking then
begin
if (CountColorTolerance(FireColor, BoxesToSort[i][j].Cell, 14, SFireCol) > 2) and (FindColorsTolerance(FireTPA, FireLogColor, BoxesToSort[i][j].Cell, 15, SFireLogCol))then
begin
if (srl.GetPixelShift(BoxesToSort[i][j].Cell, 75) > 2) then
begin
if FFinder.FireCell.NumP < 1 then
begin
writeln('found fire');
FFinder.FireCell.Points := FireTPA;
FFinder.FireCell.NumP := Length(FFinder.FireCell.Points);
FFinder.FireCell.Cell := IntToBox(BoxesToSort[i][j].Cell.X1, BoxesToSort[i][j].Cell.Y1, BoxesToSort[i][j].Cell.X2 + 8, BoxesToSort[i][j].Cell.Y2 + 8);
end;
end;
end;
end;
end;
end;
for C := 0 to Length(TempArrayA)-1 do
begin
if (FindColorTolerance(x, y, 15123625, TempArrayA[C].Cell, 16{, SSpeckleCol}))then
begin
SetLength(TempArrayB, B + 1);
//TempArrayB[B].Points := SpeckleTPA;
// TempArrayB[B].NumP := Length(TempArrayA[C].Points);
TempArrayB[B].Cell := TempArrayA[C].Cell;
Inc(B);
end;
end;
B := 0;
for C := 0 to Length(TempArrayB)-1 do
begin
if (srl.GetPixelShift(TempArrayB[C].Cell, 75) > 2) then
begin
// if PointInBox(TempArrayB[C].Points[0], IntToBox(TempArrayB[C].Cell.X1, TempArrayB[C].Cell.Y1, TempArrayB[C].Cell.X2 + 10, TempArrayB[C].Cell.Y2 + 10))then
SetLength(Result, B + 1);
// Result[B].Points := TempArrayB[C].Points;
//Result[B].NumP := TempArrayB[C].NumP;
Result[B].Cell := TempArrayB[C].Cell;
inc(B);
end;
end;
TDist := 9999;
for i := 0 to Length(Result)-1 do
begin
Dist := Distance(Result[i].Cell.Middle, MainScreen.GetMiddle);
if Dist < TDist then
begin
TDist := Dist;
FFinder.BestFound := i;
FFinder.FishingAt := Result[i];
FFinder.FishingAt.Cell := IntToBox(Result[i].Cell.X1, Result[i].Cell.Y1, Result[i].Cell.X2 + 10, Result[i].Cell.Y2 + 10);
// FFinder.FishingAt.Cell.Middle
end;
end;
end;
{
//Draws and Offsets the text to be centred at given position
Offset Normal
^ ^
}
procedure TMufasaBitmap.DrawText(Text : String; At : TPoint; Color: TColor; Centred : Boolean); overload;
begin
if Centred then Self.DrawText(Text, Point((At.X - Length(Text) * 3), At.Y), Color)
else Self.DrawText(Text, 'StatChars', At, True, Color);
end;
//drawTextMulti
procedure TMufasaBitmap.drawTextMulti(Text1, Text2 : String; At : TPoint; Color1, Color2: TColor);
begin
Self.DrawText(Text1, At, Color1);
Self.DrawText(Text2, Point((At.X + Length(Text1) * 5), At.Y), Color2);
end;
//spam mouse
procedure TMouse.Click(Middle: TPoint; Radius, Button: Int32; NumClicks : Integer = 1); overload;
var
i : Integer;
begin
for i := 1 to NumClicks do
Self.Click(srl.RandomPoint(Middle, Radius), Button);
end;
procedure PrintDebug;
var
i, j, Debugim : Integer;
begin
FFinder.DebugImage := GetMufasaBitmap(BitmapFromClient(MainScreen.GetBounds));
FFinder.DebugImage.SetSize(527, 400);
for i := 0 to Length(FFinder.SGrid)-1 do
begin
FFinder.DebugImage.DrawCross(FFinder.SGrid[i].Cell.Middle, 5, clRed);
FFinder.DebugImage.DrawBox(FFinder.SGrid[i].Cell, False, clGreen);
if PointInbox(FFinder.FireCell.Cell.Middle, MainScreen.FBounds)then FFinder.DebugImage.DrawBox(FFinder.FireCell.Cell, False, clRed);
end;
FFinder.DebugImage.DrawBox(FFinder.FishingAt.Cell, False, clBlue);
FFinder.DebugImage.DrawText('Marks OSR PowerFisher', Point(Round(FFinder.DebugImage.GetWidth / 2)-50, 340) , clGreen);
FFinder.DebugImage.DrawText('Time Running = ' + SRL.TimeRunning , Point(Round(FFinder.DebugImage.GetWidth / 2), 20) , clAqua, true);
FFinder.DebugImage.drawTextMulti('Fish Caught = ', IntToStr(FishCaught), Point(385, 350) , clRed, clWhite);
FFinder.DebugImage.drawTextMulti('Fishing Lvls Gained = ', IntToStr(FFinder.LevelUpFishing), Point(385, 362) , clRed, clWhite);
if DoCooking then
begin
FFinder.DebugImage.DrawText('Fish Cooked = ' + 'Salmon : ' + IntToStr(FFinder.SalmonCooked) + ' Trout : ' + IntToStr(FFinder.TroutCooked), Point(0, 350) , clRed);
FFinder.DebugImage.drawTextMulti('Cooking Lvls Gained = ', IntToStr(FFinder.LevelUpCooking), Point(0, 363) , clRed, clWhite);
FFinder.DebugImage.drawTextMulti('Fish Cooked H/R = ', IntToStr(Round((FishCaught * 3600) / (GetTimeRunning / 1000))), Point(0, 375) , clRed, clWhite);
end else FFinder.DebugImage.drawTextMulti('Fish Caught H/R = ', IntToStr(Round((FishCaught * 3600) / (GetTimeRunning / 1000))), Point(385, 375) , clRed, clWhite);
FFinder.DebugImage.drawTextMulti('Randoms Avoided = ', IntToStr(FFinder.RandomsIgnored), Point(0, 385) , clRed, clWhite);
// FFinder.DebugImage.Debug;//this shit flickers????why
Debugim := BitmapFromString(FFinder.DebugImage.GetWidth, FFinder.DebugImage.GetHeight, FFinder.DebugImage.ToString);
DrawBitmapDebugImg(DebugIm);
DisplayDebugImgWindow(FFinder.DebugImage.GetWidth, FFinder.DebugImage.GetHeight);
FreeBitMap(DebugIm);
FFinder.DebugImage.Free;
end;
function IsFishSpotActive(WaitTime : Integer) : Boolean;
var X, Y : Integer;
begin
if (srl.GetPixelShift(FFinder.FishingAt.Cell, WaitTime) > 1) and (FindColorTolerance(X, Y, FFinder.FSpeckle, FFinder.FishingAt.Cell, 16, FFinder.SSpeckleCol)) then
Result := True
else Result := False;
end;
procedure TFFinder.Free;
begin
FFinder.Grid := EFinder.Grid;
FFinder.FishingAt := EFinder.FishingAt;
FFinder.FireCell := EFinder.FireCell;
FFinder.SGrid := EFinder.SGrid;
end;
procedure TFFinder.Find;
var X, Y, SortTimer : Integer;
begin
SortTimer := GetTimeRunning;
if (IsFishSpotActive(Random(75, 150))) and FindColorTolerance(X, Y, FFinder.FireColor, FFinder.FireCell.Cell, 15, FFinder.SFireCol) then exit;
FFinder.Free;
{* Color Setup}
WaterColor := 8153439;
SWaterCol := ColorSetting(2, 0.12, 0.53);
FSpeckle := 14461113;//Fishing Spot Speckle
SSpeckleCol := ColorSetting(2, 0.97, 1.58);
FireColor := 2269658;
SFireCol := ColorSetting(2, 0.16, 1.20);
FireLogColor := 11576;
SFireLogCol := ColorSetting(2, 0.19, 0.00);
{* Grid Setup}
FFinder.Grid := FFinder.SettupScreen(9, 9);
{* Find Spot}
FFinder.SGrid := FFinder.SortByColorAndArea(FFinder.Grid);
WriteLn('Took ' + FloatToStr((GetTimeRunning - SortTimer) / 1000) + ' Seconds to find spot');
PrintDebug;
end;
procedure AntiBan;
var R, Ra, Rb : Integer;
begin
R := Random(100, 200);
if not Inrange(R, 123, 152) then Mouse.Move(Point(Random(0, 600), Random(0, 500)));
case R of
123..152 : Begin
Rb := Random(2);
repeat
inc(Ra);
mouse.Speed := Random(12, 16);
Mouse.Move(Point(Random(0, 600), Random(0, 500)));
//mouse.Click(1);
Until Ra > Rb;
Ra := 0;
end;
173..176 : begin
MiniMap.SetCompassAngle(Random(-360, 360), True);
end;
end;
end;
procedure FlipAngle;
begin
MiniMap.SetCompassAngle(Random(-360, 360), True);
{ case LastAngle of
1 : begin
MiniMap.SetCompassAngle(Random(85, 95), True);
LastAngle := Random(2, 3);
end;
2 : begin
MiniMap.SetCompassAngle(Random(250, 270), True);
repeat
LastAngle := Random(2);
until(LastAngle = 1) or (LastAngle = 3);
end;
3 : begin
MiniMap.SetCompassAngle(Random(-15, 15), True);
LastAngle := Random(1, 2);
end
end;}
end;
function TFFinder.ClickCellUpText(Cell : TCell; UpText : TStringArray; ClickType : Integer): Boolean;
begin
FFinder.Find;
if Assigned(Cell) then
begin
case Random(1,2) of
1 : mouse.Move(Cell.Cell);
2 : Mouse.Miss(Cell.Cell.Middle, True, Random(0, 150));
end;
if MainScreen.IsUpText(UpText)then
begin
Mouse.Click(ClickType);
True;
end else
begin
Mouse.Click(2);
if ChooseOption.Select(UpText, 1, true, true) then True
else False;
end;
end else False;
while MiniMap.isFlagPresent do wait(75);
end;
function TFFinder.Click : Boolean; //
var X, Y : Integer;
begin
mouse.Speed := Random(13, 17);
if (FFinder.FishingAt.Cell.X1 > 0) and (FindColorTolerance(X, Y, FFinder.FSpeckle, FFinder.FishingAt.Cell, 16, FFinder.SSpeckleCol)) then
begin
case Random(1,2) of
1 : mouse.Move(Point(X, Y));
2 : Mouse.Miss(Point(X, Y), True, Random(0, 150));
end;
if MainScreen.IsUpText(['ure', 'od'])then
begin
mouse.Click(1);
MiniMap.WaitPlayerMoving();
Result := True;
AntiBan;
end else
begin
WriteLn('Failed To Find Fishing Spot');
Result := False;
end;
end else Result := False;
PrintDebug;
end;
procedure FindFish;
begin
if Inventory.IsFull then Exit;
if IsFishSpotActive(Random(75, 150)) then Exit;
if not FFinder.Click then FFinder.Find;
end;
//DropItemsExcept not working correctly take a look
procedure DropAll;
var i : integer;
DropOrder : TIntegerArray = [2, 3, 7, 6, 5, 4, 8, 9, 10, 11, 15, 14, 13, 12, 16, 17, 18, 19, 23, 22, 21, 20 ,24, 25, 26, 27];
begin
for i := 0 to 25 do
if inventory.IsSlotUsed(DropOrder[i], False)then
begin
KEYBOARD.KeyDown(VK_SHIFT);
Mouse.Move(Point(Random(inventory.GetSlotBox(DropOrder[i]).Middle.X-5, inventory.GetSlotBox(DropOrder[i]).Middle.X+5) ,Random(inventory.GetSlotBox(DropOrder[i]).Middle.Y-5, inventory.GetSlotBox(DropOrder[i]).Middle.Y+5)));
mouse.Click(1);
wait(Random(77,265));
KEYBOARD.KeyUp(VK_Shift);
end;
//Inventory.DropItemsExcept([1,2], DROP_PATTERN_SNAKE);//does not work correctly
end;
//rewrite this
function TFFinder.Cook(UpText : String;DTM, ChatButtonCol : Integer) : Boolean;
var
TPA : TPointArray;
X, Y, TimeOut : Integer;
begin
FFinder.Find;
FindDTMs(DTM, TPA, Inventory.FBounds);
if not PointInbox(FFinder.FireCell.Cell.Middle, MainScreen.FBounds)then
begin
FlipAngle;
Result := False;
exit;
end;
If Length(TPA) > 0 then
begin
if Inventory.GetActiveSlot <> 0 then Mouse.Move(TPA[0]);
if (MainScreen.IsUpText(UpText))then
begin
if Inventory.GetActiveSlot <> 0 then Mouse.Click(1);
Mouse.Move(FFinder.FireCell.Cell);
if MainScreen.IsUpText('Fire')then //chooseoption.Select add right click option
begin
mouse.Click(1);
MiniMap.WaitPlayerMoving();
Timeout := GetTimeRunning;
Repeat
if GetTimeRunning - TimeOut > 8000 then Exit;
Until FindColorTolerance(X, Y, ChatButtonCol, ChatBox.FBounds, 15);
mouse.Click(X, Y, 1);
Timeout := GetTimeRunning;
FindDTMs(DTM, TPA, Inventory.FBounds);
Repeat
if GetTimeRunning - TimeOut > Random(31344, 51241) then
begin
Result := False;
Exit;
end;
FindDTMs(DTM, TPA, Inventory.FBounds);
writeln(UpText+' Left to cook: ' + IntToStr(Round(Length(TPA) / 9)));
Result := True;
if ChatBox.HandleLevelUp then
begin
Inc(FFinder.LevelUpCooking);
Result := False;
Exit;
end;
Until Length(TPA) < 1;
end else
begin
FlipAngle;
Result := False;
Exit;
end;
end else
begin
Result := False;
Exit;
end;
end else
begin
Result := False;
Exit;
end;
end;
procedure Cook;//rewrite
var
RawTroutDTM, RawSalmonDTM, CookTimer, a, b : Integer;
begin
RawTroutDTM := DTMFromString('mFQEAAHicvcuxCoJQAIXh/+YQFErYq7o2Oil4h5tCEVJLbUKbttXiIg2BQvQs0QFbeoEOfMs5HB/IJ7CXg5Syk40U4iSTRFKxspaZgbe+nhlNzdj5spBQlhLI/LufT0e21lI6R54mXOuae9vy6DqaquLZ97yGgdulIYtjVlGEbn/xkw/VvSQC');
RawSalmonDTM := DTMFromString('mKgEAAHic42NgYDjIxMCwFYhPAfF+IN4HxHuAeCcQbwPiHVDxI0B8DIgPAfFJIH4G1PsOiG8D8QMgfswAEXsBxK+gcm+hYiC5h1B1m4pSGQ4uXcDQmp/NkB4axFDi6cTQFe7HMC0hlGHzlH6GIyuWMCzrbGU431rKsKEghSHFwZJhZU4CA9BKsjAjmRgVAAAdsywG');
CookTimer := GetTimeRunning;
repeat
if GetTimeRunning - CookTimer > 60000 then break;
if FFinder.Cook('almon', RawSalmonDTM, 6977467) then a := 1;
if FFinder.Cook('rout', RawTroutDTM, 12040385)then b := 1;
Until( a = 1) and (b = 1);
if ((GetTimeRunning - CookTimer) > 60000) then writeln('Failed To Cook After' + IntToStr(Round((GetTimeRunning - CookTimer) / 1000 )) + ' Seconds');
FreeDTMs([RawSalmonDTM, RawTroutDTM]);
end;
procedure HandleInventory;
begin
if Inventory.IsFull then
begin
if DoCooking then Cook; ///cooking needs more work
DropAll;
Inc(FishCaught, 26);
if not IsFishSpotActive(Random(400, 743)) then
begin
FindFish;
end else FFinder.Click;
end;
if ChatBox.HandleLevelUp then
begin
Inc(FFinder.LevelUpFishing);
end;
ChatBox.ClickContinue;
if GetTimeRunning - InvCountTimer > Random(6852, 7152) then
begin
InvCountTimer := GetTimeRunning;
if LastInvCount = Inventory.Count then
begin
LastInvCount := Inventory.Count;
if not IsFishSpotActive(Random(400, 743)) then
begin
FindFish;
end else FFinder.Click;
end;
LastInvCount := Inventory.Count
end;
end;
{In minutes}
function SetBreakTime(Minutes : Integer): Integer;
begin
Result := Minutes * 60000;
end;
//make an advanced breaking handling fatigue style example toilet, drink, food, browse net allow to timeout
(*procedure BreakHandling;
var
player : Tplayer;
begin
if GetTimeRunning - WhenToBreak > WhenToBreak then
begin
Case Random(121,1212) of
0..121 : begin
Wait(Random(SetBreakTime(Random(1,15))));
{Browse the net for 1 - 15 minutes
Allow to time out dont log out
LogBack In
}
if LoginScreen.IsOpen then
begin
if not player.Login then
begin
writeln('failed to log back in do something');
TerminateScript;
end;
end;
//player.Login
WhenToBreak := SetBreakTime(Random(6,77)) + GetTimeRunning;//6 to 77 minutes sets a new time to break at
end;
122..555 :
556..824 :
825..1012 :
1013..1212 :
end;
end;
end; *)
begin
SRL.Setup;
Inventory.ShiftDrop := true;
InvCountTimer := GetTimeRunning;
LastInvCount := Inventory.Count;
FFinder.Find;
findfish;
MapAngle := [Random(85, 95), Random(-15, 15), Random(175, 185)];
LastAngle := Random(3);
repeat
//FFinder.Find;///working
PrintDebug;
if SRL.DismissRandom then Inc(FFinder.RandomsIgnored);
if not IsFishSpotActive(Random(400, 743)) then
begin
FlipAngle;
findfish;
end;
HandleInventory;
until false;
end.