Reflector
2014-01-13 06:36:54
My first script although I shouldn't be too proud since most of the functions essential to it are taken from other scripts.
It's also pretty buggy and doesn't exactly function well without baby sitting..
Bugs:
- Can't distinguish the first fishing point from the second fishing point and this makes it extremely bot like as it will just click the symbol and the mouse will circle around the water looking for the fishing spot
- The colour searching isn't exactly too accurate either but that's probably because i have to update the colour information
So yeah…
How to use:
- Start at the bank in edgeville or at the fishing spot either one. The script will take it from there :)
Credits to: footballjds, ashaman98 and Coh3n
Download: [ATTACH]22705[/ATTACH]
or If you prefer code :)
FlyFisher.simba
It's also pretty buggy and doesn't exactly function well without baby sitting..
Bugs:
- Can't distinguish the first fishing point from the second fishing point and this makes it extremely bot like as it will just click the symbol and the mouse will circle around the water looking for the fishing spot
- The colour searching isn't exactly too accurate either but that's probably because i have to update the colour information
So yeah…
How to use:
- Start at the bank in edgeville or at the fishing spot either one. The script will take it from there :)
Credits to: footballjds, ashaman98 and Coh3n
Download: [ATTACH]22705[/ATTACH]
or If you prefer code :)
FlyFisher.simba
program ProFisher;
{$DEFINE SMART}
{$i srl-6/srl.simba}
{$i sps/lib/sps-rs3.simba}
type
ColorRecord = record
cts: TColorSettings;
color, tolerance, min: integer;
area: TBox;
end;
const
BANKING = false;
threshold = 20000;
// Don't change any of this!!
DEBUG_FATAL = 1;
DEBUG_SUCCESS = 0;
DEBUG_INFO = 2;
BANK = 0;
FISHSPOT = 1;
var
x, y, i: Integer;
PixelShiftBoxm, CurrentSpot: TBox;
BankerDTM: Integer;
TP: TPoint;
fishies: ColorRecord;
procedure declarePlayers;
begin
Players.setup(['naveenmathew']);
with players[0] do
begin
isActive := true;
isMember := true;
world := 0;
end;
currentPlayer := 0;
end;
procedure PrintDebug(debugType: integer; message: string);
begin
case debugType of
0: print('[SUCCESS] ' + message, TDebug.Sub);
1: print('[FATAL] ' + message, TDebug.Error);
2: print('[INFO] ' + message, TDebug.Sub);
end;
end;
procedure ScriptTerminate();
begin
PrintDebug(DEBUG_INFO, 'Shuttting down script ...');
takeScreenshot(scriptName + ' ' + theTime + '.png');
{if isLoggedIn() then
players[currentPlayer].logout();}
// Free DTM's
FreeDTM(BankerDTM);
end;
procedure initialize();
begin
BankerDTM := DTMFromString('mbQAAAHicY2VgYMhhZGDIZ4TQuUCcBcQLgeIT' +
'gLgPiFcC8TIgVpQyYYiwFmRYV6rEYKrjzqAhb' +
'8fADxRHx4xYMBgAAIzICQw=');
with fishies do
begin
cts.CTS := 2;
cts.modifier.hue := 0.04; //0.04;
cts.modifier.saturation := 0.64; //0.64;
cts.modifier.sensitivity := 15; // Change this if needed
color := 11832167; //11832167;
area := mainscreen.getBounds;
tolerance := 28; // 28;
min := 28; //28;
end;
MouseSpeed := 10 + randomRange(1, 5); // Change!!
end;
{*******************************************************************************
function TRSChatbox.getXP: Integer;
By: ashaman88
Description: Monitors the exp counter
*******************************************************************************}
function TRSChatBox.getXP: Integer;
var
b: TBox;
s: String;
tpa : TPointArray;
atpa : T2DPointArray;
i,p: Integer;
begin
b := self.getBounds();
b.edit(+(b.x2-b.x1)-140, +10, -5, -94);
smartimage.drawbox(b,false,clred);
findColorsTolerance(tpa, 14013909, b, 4, colorSetting(2, 0.00, 0.00));
if length(tpa) < 2 then
begin
PrintDebug(DEBUG_FATAL, 'No XP found');
exit;
end;
atpa := tpa.cluster(5);
b:= atpa.getbounds;
b.edit(-2,-2,+2,+2);
smartimage.drawbox(b,false,clred);
s:=tesseractgettext(b.x1,b.y1,b.x2,b.y2, FILTER_SMALL_CHARS);
P := Pos('x', S);
if P > 0 then
Result := StrToIntDef(ExtractFromStr(Copy(s, P, Length(S)), Numbers), 0)
else
Result := StrToIntDef(ExtractFromStr(S, Numbers), 0);
end;
{*******************************************************************************
procedure antiban();
By: Coh3n
Description: Antiban taken from Draynor Chop N' Bank
*******************************************************************************}
procedure antiban();
begin
case Random(200) of
10: RandomRClickItem();
20: MouseOffClient(Random(5));
30: RandomCompass(0, 180, false);
40: PickUpMouse;
50: ;
60: MouseMovingObject();
70: SleepAndMoveMouse(200 + Random(50));
90: PickUpMouse();
100: ;
end;
end;
{*******************************************************************************
function isAtFishingSpot: Boolean;
By: naveenmathew
Description: not isAtBank();
*******************************************************************************}
function isAtFishingSpot: Boolean;
begin
if (minimap.findSymbol(TP, MM_SYMBOL_FISHING, minimap.getBounds)) then
result := true
else
result := false;
end;
{*******************************************************************************
function isAtBank: Boolean;
By: naveenmathew
Description: Checks to see that our character is at the bank
*******************************************************************************}
function isAtBank: Boolean;
begin
if (minimap.findSymbol(TP, MM_SYMBOL_BANK, minimap.getBounds)) then
result := true
else
result := false;
end;
{*******************************************************************************
function Walk(destination: Integer): Boolean;
By: naveenmathew
Description: Attempts to walk to destination using color
It starts with a tolerance of 1 and slowly increases it
*******************************************************************************}
function Walk(destination: Integer): Boolean;
var
i: Integer;
begin
if (destination = BANK) then
begin
if (not minimap.findSymbol(TP, MM_SYMBOL_BANK, minimap.getBounds)) then
begin
repeat
for i := 1 to 6 do
minimap.radialWalk(7693658, i, 100, 20, 0, 10);
wait(1000);
until (minimap.findSymbol(TP, MM_SYMBOL_BANK, minimap.getBounds));
end;
if (minimap.findSymbol(TP, MM_SYMBOL_BANK, minimap.getBounds)) then
begin
mouse(TP, MOUSE_LEFT);
wait(500 + random(500));
minimap.waitFlag(10);
end
end else if (destination = FISHSPOT) then
begin
if (not minimap.findSymbol(TP, MM_SYMBOL_FISHING, minimap.getBounds)) then
begin
repeat
for i := 1 to 6 do
minimap.radialWalk(7693658, i, 100, 180, 120, 10);
wait(1000);
until (minimap.findSymbol(TP, MM_SYMBOL_FISHING, minimap.getBounds));
end;
if (minimap.findSymbol(TP, MM_SYMBOL_FISHING, minimap.getBounds)) then
begin
mouse(TP, MOUSE_LEFT);
wait(500 + random(500));
minimap.waitFlag(10);
end;
end;
end;
{*******************************************************************************
function ClickBanker: Boolean
By: naveenmathew
Description: Clicks the banker
*******************************************************************************}
function ClickBanker: Boolean;
var
aFound: Extended;
begin
if FindDTMRotated(BankerDTM, x, y, mainscreen.getBounds(), -Pi, Pi, Pi/30, aFound) then
begin
Mouse(x, y, 4, 4, MOUSE_LEFT);
PrintDebug(DEBUG_INFO, 'Found banker at [' + intToStr(x) + ',' +
intToStr(y) + ']');
PrintDebug(DEBUG_INFO, 'Opening bank');
end else
begin
PrintDebug(DEBUG_FATAL, 'Failed to find banker');
end;
end;
{*******************************************************************************
function findFishingSpot(minWait: Integer; searchArea: TBox;
out fish2D: T2DPointArray;
exitOnFind: boolean): Boolean;
By: footballjds
Description: Finds the fishing spot
*******************************************************************************}
function findFishingSpot(minWait: Integer; searchArea: TBox;
out fish2D: T2DPointArray;
exitOnFind: Boolean): Boolean;
var
fishingSpots: T2DPointArray;
fishingPoints: TPointArray;
findTime, i, h: Integer;
begin
fish2D := [];
findTime := getSystemTime + randomRange(minWait, round(minWait*1.3));
while getSystemTime < findTime do
begin
if findColorsTolerance(fishingPoints, fishies.color, searchArea,
fishies.tolerance, fishies.cts) then
if exitOnFind then exit(true) else insert(fishingPoints, fishingSpots);
wait(randomRange(100, 200));
end;
if length(fishingSpots) > 0 then
begin
fishingPoints := fishingSpots.merge;
fishingPoints.clearEquals;
fishingSpots := fishingPoints.toATPA(25, 25);
if length(fishingSpots) > 0 then
begin
fish2D := fishingSpots;
result := true;
end;
end;
end;
{*******************************************************************************
function setSpot(spot: TPoint): Boolean
By: footballjds
Description: Sets the fishing spot
*******************************************************************************}
function setSpot(spot: TPoint): Boolean;
var
p: TPointArray;
begin
//Points to check for fishing
//Clockwise starting at the top
p := [[287, 172], [318, 202], [287, 230], [260, 202]];
p.sortFromPoint(spot);
CurrentSpot := [p[0].x-8, p[0].y-8, p[0].x+8, p[0].y+8];
end;
{*******************************************************************************
function isSpotGone: Boolean
By: footballjds
Description: Checks whether the fishing spot is gone
*******************************************************************************}
function isSpotGone: Boolean;
var
tmpRay: T2DPointArray;
begin
if tabBackpack.isFull then exit(true);
result := currentSpot.equals([0, 0]);
if not result then
result := not findFishingSpot(1500, currentSpot, tmpRay, true);
result := false;
end;
{*******************************************************************************
function isPlayerFishing: Boolean;
By: naveenmathew
Description: Checks whether the player is fishing by checking to see whether
the backpack count has increased.
*******************************************************************************}
function isPlayerFishing: Boolean;
var
initialCount, t, y: Integer;
begin
initialCount := tabBackPack.count;
t := getSystemTime + randomRange(threshold,
(threshold - randomRange(100, 300)));
y := getSystemTime + randomRange(100, 500) + threshold;
while (t > getSystemTime) and (y > threshold) do
begin
wait(randomRange(3000, 5000));
if (tabBackPack.count > initialCount) then
begin
if (tabBackPack.count >= randomRange(25, 27)) then
exit;
PrintDebug(DEBUG_INFO, 'Fishing ...');
result := true;
end else
begin
PrintDebug(DEBUG_INFO, 'Not fishing ...');
result := false;
exit;
end;
end;
end;
{*******************************************************************************
function TPointArray.centerPoint(): TPoint;
By: footballjds
Description: Finds the center point of a tpoint
*******************************************************************************}
function TPointArray.centerPoint(): TPoint;
var
tmpArray: TPointArray;
begin
if length(self) < 1 then exit;
tmpArray := self;
tmpArray.sortFromPoint(self.getMiddle);
result := tmpArray[0];
end;
{*******************************************************************************
function GoFishing: Boolean
By: naveenmathew
Description: Goes fishing
*******************************************************************************}
function GoFishing: Boolean;
var
x,y,i,h: Integer;
fish: TPointArray;
spots: T2DPointArray;
fishType: string;
begin
for i := 20 to 24 do
begin
if tabBackpack.isFull then exit;
CurrentSpot := [0, 0];
if findFishingSpot(1200, mainscreen.getBounds, spots, false) then
begin
h := high(spots);
for i := 0 to h do
insert(spots[i].centerPoint, fish);
fish.sortFromPoint(mainscreen.playerPoint);
for i := 0 to h do
begin
mouse(fish[i].randRange(-3, 3), Mouse_Right);
if chooseOption.select(['Lure'], randomRange(1000, 2000)) then
begin
PrintDebug(DEBUG_INFO, 'Clicked on fishing spot');
exit;
end else
begin
PrintDebug(DEBUG_INFO, 'Failed to find fishing spot');
walk(FISHSPOT);
exit;
end;
end;
end;
end;
end;
procedure SetupMainloop();
begin
if (tabBackPack.isFull and BANKING = true) then
begin
if isAtFishingSpot then
walk(BANK);
if isAtBank then
begin
clickBanker();
end;
end;
if (tabBackPack.isFull and not BANKING) then
begin
tabBackPack.dropItemsExcept([28], DROP_PATTERN_SNAKE);
end;
if not isAtFishingSpot then
walk(FISHSPOT);
if not tabBackPack.isFull then
begin
if not isPlayerFishing and not isSpotGone then
begin
MouseSpeed := 10 + randomRange(1, 5);
goFishing;
end else if isSpotGone then
begin
walk(FISHSPOT);
end else if isPlayerFishing then
begin
antiban();
end;
end;
end;
begin
AddOnTerminate('scriptTerminate');
ClearDebug();
smartEnableDrawing := true;
SetupSRL();
initialize();
declarePlayers();
if not isLoggedIn then if players[currentPlayer].login then
begin
wait(random(500, 1500));
minimap.clickCompass;
wait(random(500, 1500));
mainscreen.setAngle(MS_ANGLE_HIGH);
minimap.setAngle(MM_DIRECTION_SOUTH);
wait(random(1, 1500));
end;
while (players.getActive > 0) do
begin
if (not players[currentPlayer].login()) then break;
ExitSquealOfFortune();
SetupMainloop();
end;
end.