Method
2008-08-25 23:50:19
I've recently been working on my Draynor Shrimp Trawler that nets and banks in Draynor, and apart from one "bug" the script is working flawlessly. For some reason, at seemingly random times on random load numbers, the script seems to think I'm logged out. It breaks from my FishLoop and proceeds to the NextPlayer(False) at the bottom of the script. My current attempt at bypassing it is to wait half a second then check again (though I haven't tested this way yet). I've tried using both LoggedIn and R_LoggedIn and have received the same issues with both. Hopefully someone can come up with a solution to this ongoing frustration. Here's the script:
Thank you very much! :)
{===================================================================]
[ Method's Draynor Shrimp Trawler ]
[ ]
[ NAME : Draynor Shrimp Trawler ]
[ WRITER : Method ]
[ CATEGORY : Fishing ]
[ DESCRIPTION : Catches shrimp in Draynor Village ]
[ USAGE : Start in the Draynor Village bank ]
[ AUTOCOLOR : Yes ]
[ SRL Used : Revision #23 ]
[ Released : Not yet ]
[ ]
[===================================================================]
[ Instructions. ]
[===================================================================]
[ 1. USE Runescape with Low Detail, Very Bright. ]
[ 2. Set your Screen to 32 bit TRUE color. ]
[ 3. Use SRL 4 Revision #23 and SCAR 3.15b. ]
[ 4. Setup the constants to your liking. ]
[ 5. Position your players in the Draynor Village bank with a net ]
[ in the inventory and extras inside the bank. ]
[ 6. Hit run and fill in your players' info in the form. ]
[ 7. Start autoing and enjoy! ]
[ 8. Post proggies and feedback please! :) ]
[===================================================================]
[ Credits. ]
[===================================================================]
[ Wizzup - Your fisher helped create this. ]
[ ZephyrsFury - My progress report was inspired by yours. ]
[ IRC - For keeping me entertained in the making of the script. :) ]
[===================================================================}
program DraynorShrimpTrawler;
{.include SRL\SRL\misc\Smart.scar}
{.include SRL\SRL.scar}
{.include SRL\SRL\Reflection\Reflection.scar}
{.include SRL\SRL\misc\Users.scar}
const
SMARTWorld = '62'; { World number to use }
MySRLID = ''; { Your SRL Stats username }
MySRLPassword = ''; { Your SRL Stats password }
DeleteDebug = False; { Delete debug each progress report }
Loads = 5; { Number of loads per player }
MaxLoadTime = 10; { Max time per load in minutes }
Version = '1.0'; { Version number of the script }
{ --------------------------
No need to edit anything
below this line.
-------------------------- }
var
dtmNet, dtmShrimp, dtmAnchovie, Shrimp, Anchovies, Fish, Nets, LoadTime,
ReportTime, PlayerTime: Integer;
BankTile, FishTile: TPoint;
BankPath, FishPath: TPointArray;
MissingNet: Boolean;
procedure DeclarePlayers;
var
i: Integer;
begin
if (MySRLID <> '') then
SRLID := MySRLID;
if (MySRLPassword <> '') then
SRLPassword := MySRLPassword;
SRLPlayerForm(True, [], [], [], []);
WriteLn(IntToStr(HowManyPlayers) + ' player[s]');
for i := 0 to (HowManyPlayers - 1) do
Players[i].Loc := 'Bank';
end;
procedure FillMemory;
begin
dtmNet := DTMFromString('78DA637461626078C680023414C419FE03694' +
'620FE0F048CD64035F718D000231209A49D816A6E1150E30F54F3' +
'80801A1FA09AF704D4D803D5BC25A0C618A8E6397E3500176B0D8' +
'D');
dtmShrimp := DTMFromString('78DA639CC4C4C0F08401059C9F51C92009A41' +
'981F83F10307602D5DC6740038C482490EE06AA794340CD2CA09A' +
'0F04D42C01AA79488439B7F1AB01009B590EEC');
dtmAnchovie := DTMFromString('78DA634C65626078C28002EAEAE7336800694' +
'620FE0F048C8940357719D000231209A473816AEE1050534E849A' +
'42A09AF704D480DCFC01BF1A00EFD80DB6');
{DTMFromString('78DA63CC65626078CA80024242F3182481342' +
'310FF0702C664A09ABB0C6880118904D2894035CF08A84901AA79' +
'4F404D1150CD5B026A2A816AEE1350530854731BBF1A008C050E7' +
'E');}
end;
procedure LoadTiles;
begin
BankTile := Point(3092, 3245);
FishTile := Point(3087, 3228);
FishPath := [Point(3087, 3235), FishTile];
BankPath := [Point(3090, 3237), BankTile];
end;
procedure AntiBan;
begin
if (not(LoggedIn)) then
Exit;
case Random(25) of
0: if (Random(20) < 5) then
MMouse(MSX1, MSY1, MSX2, MSY2);
5: if (Random(20) < 3) then
RandomRClick;
10: if (Random(20) < 3) then
HoverSkill('random', False);
15: if (Random(20) < 3) then
HoverSkill('fishing', False);
else
Wait(500 + Random(150));
end;
end;
function WalkPath(Destination: string): Boolean;
var
i: Integer;
Path: TPointArray;
Tile: TPoint;
begin
if (not(LoggedIn)) then
Exit;
Status('Walking to ' + Destination);
case Destination of
'Bank': Path := BankPath;
'Fish': Path := FishPath;
end;
for i := 0 to High(Path) do
WalkToTile(Path[i], 2, 0);
case Destination of
'Bank': Tile := BankTile;
'Fish': Tile := FishTile;
end;
Result := (DistanceFrom(Tile) < 5);
if (Result) then
Players[CurrentPlayer].Loc := Destination;
end;
function CheckLocation: Boolean;
begin
if (not(LoggedIn)) then
Exit;
Status('Checking our player''s location');
Result := (DistanceFrom(FishTile) > 5);
if (not(Result)) then
Exit;
Result := (not(WalkToTile(FishTile, 2, 0)));
if (Result) then
begin
WriteLn('Could not calibrate player');
Players[CurrentPlayer].Loc := 'NoLoc';
Players[CurrentPlayer].Active := False;
Logout;
end;
end;
function FindRandoms: Boolean;
var
MyChar: TMe;
begin
if (not(LoggedIn)) then
Exit;
Status('Searching for random events');
if (FindNormalRandoms) then
Result := True;
MyChar := GetMe;
if (MyChar.InFight) then
begin
Result := True;
WriteLn('Fight found!');
Fights := Fights + 1;
RunAway('S', True, 1, 5000);
end;
if (ClickContinue(True, True)) then
Result := True;
end;
function HaveNet: Boolean;
var
nx, ny: Integer;
begin
if (not(LoggedIn)) then
Exit;
GameTab(4);
Wait(100);
Result := FindDTM(dtmNet, nx, ny, MIX1, MIY1, MIX2, MIY2);
MissingNet := (not(Result));
end;
function FindNet: Boolean;
var
Items: array of TGroundItem;
begin
if (not(LoggedIn)) then
Exit;
Result := HaveNet;
if (Result) then
Exit;
Status('Searching for net on ground');
MissingNet := True;
if (FindGroundItems(Items, [303], 8)) then
begin
Writeln('Found our net on the ground');
if (not(TileOnMS(Items[0].Tile, 1))) then
WalkToTile(Items[0].Tile, 0, 0);
Items[0].MS := TileToMS(Items[0].Tile, 1);
MMouse(Items[0].MS.X, Items[0].MS.Y, 3, 3);
Wait(200 + Random(50));
if (IsUpText('ake')) then
begin
GetMousePos(Items[0].MS.X, Items[0].MS.Y);
Mouse(Items[0].MS.X, Items[0].MS.Y, 0, 0, True);
FFlag(0);
Wait(500 + Random(100));
if (HaveNet) then
begin
Result := True;
Inc(Nets);
Inc(ReportVars[3]);
MissingNet := False;
end;
end;
end;
end;
procedure DoSomeMath;
var
tShrimp, tAnchovies: Integer;
begin
if (not(LoggedIn)) then
Exit;
Players[CurrentPlayer].Level[17] := GetMe.Levels[10];
tShrimp := CountItemsIn('inv', 'dtm', dtmShrimp, [0]);
Shrimp := Shrimp + tShrimp;
IncEx(ReportVars[0], tShrimp);
tAnchovies := CountItemsIn('inv', 'dtm', dtmAnchovie, [0]);
Anchovies := Anchovies + tAnchovies;
IncEx(ReportVars[1], tAnchovies);
IncEx(Fish, tAnchovies + tShrimp);
IncEx(Players[CurrentPlayer].Integers[10], tAnchovies + tShrimp);
end;
procedure Bank;
var
t, nx, ny: Integer;
begin
if (not(LoggedIn)) then
Exit;
Status('Opening bank');
repeat
OpenBankReflection('db');
FFlag(0);
Wait(500);
Inc(t);
until (BankScreen) or (PinScreen) or (t > 4);
if (PinScreen) then
InPin(Players[CurrentPlayer].Pin);
if (BankScreen) then
begin
DoSomeMath;
Deposit(2, 28, True);
HaveNet;
if (MissingNet) then
begin
FixBank;
Wait(500 + Random(500));
if (FindDTM(dtmNet, nx, ny, MSX1, MSY1, MSX2, MSY2)) then
begin
MMouse(nx, ny, 3, 3);
GetMousePos(nx, ny);
Wait(150 + Random(50));
if (IsUpText('mall')) then
Mouse(nx, ny, 0, 0, True);
MissingNet := False;
end else
begin
WriteLn('No nets found in bank');
Players[CurrentPlayer].Loc := 'No net';
Players[CurrentPlayer].Active := False;
Logout;
Exit;
end;
end;
CloseBank;
Inc(Players[CurrentPlayer].Banked);
Inc(Banks);
end else
begin
WriteLn('Could not open bank');
Players[CurrentPlayer].Loc := 'No bank';
Players[CurrentPlayer].Active := False;
Logout;
end;
end;
function FindWhirlPool: Boolean;
var
NPCs: array of TNPC;
WhirlPoolIDs: TIntegerArray;
MyPos: TPoint;
i, c: Integer;
begin
if (not(LoggedIn)) then
Exit;
Status('Looking for whirlpool');
WhirlPoolIDs := [403, 404, 406];
MyPos := GetMyPos;
for c := 0 to 2 do
begin
NPCs := SortNPCs(GetNPCsByID(WhirlPoolIDs[c]));
if (GetArrayLength(NPCs) > 0) then
for i := 0 to High(NPCs) do
begin
Result := PointInBox(NPCs[i].Tile, IntToBox(MyPos.x - 1, MyPos.y - 1, MyPos.x + 1, MyPos.y + 1));
if (Result) then
WriteLn('Whirlpool found!');
end;
end;
end;
function FindFishingSpots: T2DPointArray;
var
NPCs: array of TNPC;
i: Integer;
begin
if (not(LoggedIn)) then
Exit;
NPCs := SortNPCs(GetNPCsByID(327));
SetArrayLength(Result, GetArrayLength(NPCs));
for i := 0 to High(Result) do
begin
SetArrayLength(Result[i], 2);
Result[i][0] := NPCs[i].Tile;
Result[i][1] := NPCs[i].MS;
end;
end;
function FindFishingSpot(var fx, fy: Integer): Boolean;
var
FishSpots: T2DPointArray;
i: Integer;
begin
if (not(LoggedIn)) then
Exit;
Status('Searching for a fishing spot');
FishSpots := FindFishingSpots;
for i := 0 to High(FishSpots) do
begin
if (not(TileOnMS(FishSpots[i][0], 1))) then
begin
WalkToTile(FishSpots[i][0], 1, 0);
FishSpots[i][1] := TileToMS(FishSpots[i][0], 1);
end;
MMouse(FishSpots[i][1].x, FishSpots[i][1].y, 5, 5);
Wait(150 + Random(50));
if (IsUpText('ishing')) then
begin
Result := True;
GetMousePos(fx, fy);
Exit;
end;
end;
end;
function FishLoop: Boolean;
var
FishTime, fx, fy: Integer;
MyChar: TMe;
begin
if (not(LoggedIn)) then
Exit;
FindRandoms;
if (FindFishingSpot(fx, fy)) then
begin
Mouse(fx, fy, 0, 0, True);
FFlag(0);
Wait(500);
Result := True;
MarkTime(FishTime);
repeat
if (not(LoggedIn)) then
Break;
Wait(100);
if (FindWhirlPool) then
begin
MFNF(630, 85, -3, -3);
FFlag(0);
Inc(WhirlPools);
Inc(ReportVars[2]);
Break;
end;
Wait(100);
FindNet;
Wait(100);
MyChar := GetMe;
if (MyChar.Animation = -1) then
Break;
Wait(100);
if (InvFull) then
begin
WriteLn('Inventory is full');
Break;
end;
if (FindRandoms) then
Break;
if (TimeFromMark(FishTime) > 120000) then
Break;
AntiBan;
Wait(250);
until (False);
end;
end;
procedure ProgressReport;
var
PNumber, PNick, PActive, PLocation, PFish, PLvl, PLoads, PTime: string;
i: Integer;
begin
if (DeleteDebug) then
ClearDebug;
IncEx(Players[CurrentPlayer].Integers[11], (PlayerTime / 1000 / 60));
WriteLn('[---------------------------------------------------------------]');
WriteLn('[ Method`s Draynor Shrimp Trawler Ver ' + Version + ' ]');
WriteLn('[---------------------------------------------------------------]');
WriteLn(PadR('[ Time Running: ' + TimeRunning, 64) + ']');
WriteLn(PadR('[ Loads Done: ' + IntToStr(Banks), 64) + ']');
WriteLn(PadR('[ Fish Caught: ' + IntToStr(Fish), 64) + ']');
if (Shrimp > 0) then
WriteLn(PadR('[ x Shrimp: ' + IntToStr(Shrimp), 64) + ']');
if (Anchovies > 0) then
WriteLn(PadR('[ x Anchovies: ' + IntToStr(Anchovies), 64) + ']');
if (Nets > 0) then
WriteLn(PadR('[ Nets Found: ' + IntToStr(Nets), 64) +']');
if (WhirlPools > 0) then
WriteLn(PadR('[ Whirlpools Avoided: ' + IntToStr(WhirlPools), 64) + ']');
WriteLn('[---------------------------------------------------------------]');
WriteLn('[ # | Nickname | Act | Location | Fish | Lvl | Loads | Time ]');
for i := 0 to High(Players) do
begin
PNumber := PadR(' ' + IntToStr(i), 3);
PNick := PadR(' ' + Players[i].Nick, 10);
PActive := PadR(' ' + BoolToStr(Players[i].Active)[1], 5);
PLocation := PadR(' ' + Players[i].Loc, 10);
PFish := PadR(' ' + IntToStr(Players[i].Integers[10]), 6);
PLvl := PadR(' ' + IntToStr(Players[i].Level[17]), 5);
PLoads := PadR(' ' + IntToStr(Players[i].Banked), 7);
PTime := PadR(' ' + IntToStr(Players[i].Integers[11]), 10);
WriteLn(PadR('[' + PNumber + '|' + PNick + '|' + PActive + '|' + PLocation +
'|' + PFish + '|' + PLvl + '|' + PLoads + '|' + PTime, 64) + ']');
end;
WriteLn('[---------------------------------------------------------------]');
WriteLn('');
if (TimeFromMark(ReportTime) > 305000) then
begin
SRLRandomsReport;
MarkTime(ReportTime);
end;
end;
procedure SetupPlayer;
var
MyChar: TMe;
begin
Status('Setting up player');
if (not(LoggedIn)) then
LoginPlayer;
Wait(1000);
MarkTime(PlayerTime);
SetAllChats('on', 'friends', 'friends', 'friends', 'friends');
Wait(500 + Random(500));
MakeCompass('N');
Wait(250 + Random(500));
SetAngle(True);
MyChar := GetMe;
Players[CurrentPlayer].Level[17] := MyChar.Levels[10];
Wait(1000 + Random(500));
end;
procedure SetupScript;
begin
SmartSetup('world' + SMARTWorld, True, True, False);
SetTargetDC(SmartGetDC);
SetupSRL;
ScriptID := '977';
FillMemory;
LoadTiles;
ClearDebug;
DeclarePlayers;
Wait(1000);
SetupPlayer;
end;
procedure ScriptTerminate;
begin
FreeDTM(dtmNet);
FreeDTM(dtmShrimp);
FreeDTM(dtmAnchovie);
ProgressReport;
end;
begin
SetupScript;
Wait(1000);
MarkTime(ReportTime);
repeat
if (Players[CurrentPlayer].Loc = 'Bank') then
begin
if (not(LoggedIn)) then
Exit;
if (not(HaveNet)) then
Bank;
WalkPath('Fish');
end;
if (Players[CurrentPlayer].Loc = 'Fish') then
begin
MarkTime(LoadTime);
repeat
if (not(LoggedIn)) then
Break;
if (not(FishLoop)) then
CheckLocation;
if (TimeFromMark(LoadTime) > (MaxLoadTime * 60000)) then
Break;
FindRandoms;
until (InvFull);
WalkPath('Bank');
Bank;
end;
if (Players[CurrentPlayer].Banked mod Loads = 0) and (LoggedIn) then
begin
repeat
Logout;
FindRandoms;
Wait(100);
until (not(LoggedIn));
WriteLn('Loads completed, switching to the next player.');
Status('Switching players');
NextPlayer(True);
SetupPlayer;
end;
if (not(LoggedIn)) then
begin
Wait(500);
if (not(LoggedIn)) and (PlayersActive > 0) then
begin
WriteLn('Player is not logged in, switching players.');
Status('Switching players');
NextPlayer(False);
end;
end;
ProgressReport;
until (PlayersActive = 0);
end.Thank you very much! :)