SRL Archive - OSR Help

Simple Power FlyFish, long time no script has been written by me. Please take a look!


Eduard

2014-05-27 19:19:22

program FindObject;
{$DEFINE SMART8}
{$I SRL-OSR/SRL.Simba}
{$I SRL-OSR\SRL\misc\SmartGraphics.simba}

var
x, y: Integer;
PBox: TBox;

procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
Players[0].Name := '';
Players[0].Pass := '';
Players[0].Pin := '';
Players[0].Member := True;
Players[0].WorldInfo := [];
Players[0].Active := True;
Players[0].Nick := '';
Players[0].LampSkill := SKILL_Thieving;
end;

procedure PixelFishingTrue;
begin
SMART_DRAWTEXT(207, 120, 'UpChars', inttostr(AveragePixelShift(pBox, 250, 350)), 255);
end;

procedure DrawStatus(Text: string);
begin
SMART_ClearMS;
PixelFishingTrue;
SMART_DRAWTEXT(244, 120, 'UpChars', (Text), 16777215);
end;

procedure CustomLogin;
begin
if not LoggedIn then
begin
DrawStatus('LOGGING IN');
LogInPlayer;
MakeCompass('N');
SetAngle(0);
Wait(RandomRange(2000, 3500));
end;
end;

procedure FindFishingPool;
begin
DrawStatus('FIND FISHING POOL');
if (FindObjCustom(x, y, ['ure', 'ishin', 'ot'], [14597535, 15123609, 14794914, 14858129, 13216647, 14597268, 15123625, 14398100, 14729121], 3)) then
begin
DrawStatus('FOUND FISH SPOT');
MMouse(x, y, 2, 2);
Mouse(x, y, 2, 2, 1);
wait(1000 + random(50));
end
else
begin
DrawStatus('NO FISH SPOT FOUND');
end;
end;

function IsFishing: boolean;
begin
if (InvCount = 28) then
begin
DrawStatus('INV FULL');
Exit;
end;
begin
if (AveragePixelShift(pBox, 250, 350) > 60) then
begin
result := true;
FTWait(100 + random(10));
end
else
begin
DrawStatus('NOT FISHING');
result := false;
FTWait(100 + random(10));
end;
end;
end;

procedure mainloop;
begin
DrawStatus('MAIN LOOP');
repeat
DrawStatus('CHECKING RANDOMS');
FindNormalRandoms;
if (InvCount = 28) then
begin
DrawStatus('INV FULL');
break;
end;
if (InvCount < 2) then
begin
DrawStatus('NO RODS AVAILABLE');
LogOut;
end;
if not (isFishing) then
begin
DrawStatus('NOT FISHING');
FindFishingPool;
end;
while (isFishing = true) do
begin
FTWait(randomrange(2000, 3000));
end;
until (InvCount = 28) DrawStatus('INV FULL');
DropAllExcept([1, 2, 3, 4, 5, 6]);
DrawStatus('INV EMPTY');
MakeCompass('N');
FindFishingPool;
end;

begin
DeclarePlayers;
SetupSRL;
CustomLogin;
ClearDebug;
PBox := IntToBox(233, 149, 292, 193);
FindFishingPool;
repeat
if not (LoggedIn) then
begin
CustomLogin;
end;
mainloop;
until (not LoggedIn)
end.

Currently: No walking back and front. No good custom object finding. Just a plain/babysittable powerfisher that has bad random management written for quick babysit powerleveling.

blast me away with obv. mistakes.

Dervish

2014-05-27 22:45:05

Just FYI I'm rusty as heck when it comes to scripting but I think I can help you out in some places.

program FindObject; //call it Fishing or something ? :P
{$DEFINE SMART8}
{$I SRL-OSR/SRL.Simba}
{$I SRL-OSR\SRL\misc\SmartGraphics.simba}

var
x, y: Integer;
PBox: TBox;

procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
Players[0].Name := '';
Players[0].Pass := '';
Players[0].Pin := '';
Players[0].Member := True;
Players[0].WorldInfo := [];
Players[0].Active := True;
Players[0].Nick := '';
Players[0].LampSkill := SKILL_Thieving;
end;

procedure PixelFishingTrue;
begin
SMART_DRAWTEXT(207, 120, 'UpChars', inttostr(AveragePixelShift(pBox, 250, 350)), 255);
end;

{what is the purpose of this function ?}

procedure DrawStatus(Text: string); // I also love on-screen debug :)
begin
SMART_ClearMS;
PixelFishingTrue;
SMART_DRAWTEXT(244, 120, 'UpChars', (Text), 16777215);
end;

procedure CustomLogin;
begin
if not LoggedIn then
begin
DrawStatus('LOGGING IN');
LogInPlayer;
MakeCompass('N');
SetAngle(0);
Wait(RandomRange(2000, 3500));
end;
end;

procedure FindFishingPool;
begin
DrawStatus('FIND FISHING POOL');
if (FindObjCustom(x, y, ['ure', 'ishin', 'ot'], [14597535, 15123609, 14794914, 14858129, 13216647, 14597268, 15123625, 14398100, 14729121], 3)) then
//I must admit I've never tried to find Fishing Spots by color, does this work ?
//seems difficult to me,
//also you should try not to use the pre-made Object finding functions (in my opinion) :).
begin
DrawStatus('FOUND FISH SPOT'); // You confirm you found the fishing spot so :
MMouse(x, y, 2, 2); //here you move the mouse again after hovering the fishing spot,
//why ? :P
Mouse(x, y, 2, 2, 1); //More randomness after hovering the fishing spot to click ?
//Pretty bot-like behavior in my opinion :P
wait(1000 + random(50));
end //we're gonna change this part too, using exit;
else //
begin
DrawStatus('NO FISH SPOT FOUND');
end;
end;

{
In my opinion you should change FindFishingPool to a function like you did with IsFishing !
And the changes I'd do are :
function FindFishingPool:boolean;

begin
DrawStatus('FIND FISHING POOL');
if (FindObjCustom(x, y, ['ure', 'ishin', 'ot'], [14597535, 15123609, 14794914, 14858129, 13216647, 14597268, 15123625, 14398100, 14729121], 3)) then
begin
result:=true;
GetMousePos(x,y); //<- if FindObjCustom found the object, you're already hovering it
//so GetMousePos(x,y) stores the current mouse's position into x and y
Mouse(x,y,0,0,1); //You're already hovering the object, no need to add randomness ;)
Wait(1000+random(50));
Exit;
end;
result:=false;
DrawStatus('NO FISH SPOT FOUND'); //Since we added Exit; at the end of the if...then
//segment, this will only be called if the object is not
//found, removing the need for any complications with end else etc.
end;
}

function IsFishing: boolean;
begin
if (InvCount = 28) then //use "if (InvFull) then" instead ;)
begin
DrawStatus('INV FULL');
Exit;
end;
begin //no need for a begin..end; segment here !
if (AveragePixelShift(pBox, 250, 350) > 60) then
begin
result := true;
FTWait(100 + random(10));
end //we will play with exit; here too.
else
begin
DrawStatus('NOT FISHING');
result := false;
FTWait(100 + random(10));
end;
end;
end;

{
function IsFishing: boolean;
begin
if (InvFull) then
begin
DrawStatus('INV FULL');
Exit;
end;
if (AveragePixelShift(pBox, 250, 350) > 60) then
begin
result := true;
FTWait(100 + random(10));
exit;
end;
DrawStatus('NOT FISHING');
result := false;
FTWait(100 + random(10));
end;
}

procedure mainloop;
begin
DrawStatus('MAIN LOOP');
repeat
DrawStatus('CHECKING RANDOMS'); //I'd do a separate procedure for randoms
FindNormalRandoms;
if (InvCount = 28) then //use "if (InvFull) then" instead ;)
begin
DrawStatus('INV FULL');
break;
end;
if (InvCount < 2) then //when would this happen ?
begin
DrawStatus('NO RODS AVAILABLE');
LogOut;
end;
if not (isFishing) then
begin
DrawStatus('NOT FISHING'); //You already have this in the IsFishing function :P
FindFishingPool;
end;
while (isFishing = true) do //no need to have "= true" here.
begin
FTWait(randomrange(2000, 3000));
end;
until (InvCount = 28); //(InvFull) ;)
DrawStatus('INV FULL');
DropAllExcept([1, 2, 3, 4, 5, 6]);//Try to learn about DTMs and BMPs here to find the fish
//and dropping it specificly instead of fixed items spots ;)

DrawStatus('INV EMPTY');
MakeCompass('N');
FindFishingPool; //unnecessary, the script will already try to find one
end;

begin
DeclarePlayers;
SetupSRL;
CustomLogin;
ClearDebug;
PBox := IntToBox(233, 149, 292, 193);
FindFishingPool; //unnecessary, the script will already try to find one
//in mainloop;
repeat
if not (LoggedIn) then
begin
CustomLogin;
end;
mainloop;
until (not LoggedIn)
end.

Here are my first comments about this !
Overall its good :), I do think you can babysit it, but I definitely wouldn't let it run while I'm away ^^.

// are followed up by comments about your procedures and functions and what you should change in my opinion
In {..} are the procedures/functions with the quick changes I had in mind

You can ask me by PM for any questions .