SRL Archive - OSR Help

Script Improvment and help?


Troll

2010-10-24 15:55:34

Well ive been wirting this for a couple of hours today and its a lure fisher. I know its far from done, as it dose not even have a loop. Im posting it so people can coment on it surgest stuff to add and improve it. Also im not sure how to add muti player and what fail safes to add.

Program new;
{$DEFINE SMART}
{$i srl\srl.scar}
{$i reflection\reflection.simba}

Const
Debug = True;
Power = True;
WORLD = 16;
MEMBERS = false;
SIGNED = true;

Var Pin,Loc:String;
Banked,AntiBann,Dropped,Walked:Integer;

Procedure DeclarePlayers;
Begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

With Players[0] Do
Begin
Name := '';
Pass := '';
Nick := '';
Active := True;
Pin := '';
End;
End;

Procedure DebugText(Text:String);
Begin
If Not Debug then Exit;
writeln(Text);
End;

Procedure AntiBan;
Begin
FindNormalRandoms;
Inc(AntiBann);
Case 10000 Of
0: RandomRClick;
2: PickUpMouse;
4: RandomMovement;
5: BoredHuman;
6: ExamineInv;
End;
End;

Procedure MyWait(Time:Integer);
Var I :integer;
Begin
MarkTime(I);
Repeat
AntiBan;
Wait(10+Random(70));
Until(TimeFromMark(I) >= Time)
End;

Function Fishing:Boolean;

Var NPCs : TNPCArray;
I,x,y : Integer;
FishSpot : TPoint;
Begin
If Not LoggedIn Then Exit;
If Not Loc = 'FishingSpot' Then Exit;
result := false;
NPCs := GetNPCsBy('Fishing spot')
If high(NPCs) > -1 Then // Should be -1, because a high of 0 means that one NPC was found, -1 means nothing was found
Begin
For i:= 0 To high(NPCs) Do
Begin
If (NPCs[i].Name = 'Fishing spot') Then
Begin
DebugText('Found Fishing spot');
If TileOnMS (NPCs[i].Tile, 0) Then
Begin
FishSpot := TileToMS(NPCs[i].Tile,5);
MMouse(FishSpot.x,FishSpot.y,3,3);
If R_IsUpText('Fishing spot') Then
Begin
GetMousePos(x,y);
If Not Random(15) = 5 Then
Begin
Mouse(x,y,0,0,true);
End Else
Begin
Mouse(x,y,0,0,False);
R_ChooseOption('ttac');
End;
Result := True;
Exit;
End else Begin
DebugText('Did not find fishspot uptext!');
Wait(750);
End;
end else DebugText('Spot #'+inttostr(i)+' not on mainscreen [dont worry too much about this msg]');
End;
End;
End; DebugText('Warning, array has nothing in it');
End;

{Function CheckForRod:Boolean; Not Working not sure why
Var Waste:TInvenItem;
Begin
Result := False
If Not R_ItemIDExists(Waste,309) Then
If Not R_ItemIDExists(Waste,314) Then
Begin
DebugText('Problem No rod and/or feathers');
TerminateScript;
End Else DebugText('Got Rod and feathers');
End;
}
Function LoadPath(Part,Where:Integer): TTileArray; //1 fishing spot to bank //2 fish spot to bank
Begin

Case Where Of

1: Case Part Of
0 : Result := [Point(3864, 2801), Point(3858, 2814), Point(3852, 2824),
Point(3846, 2831), Point(3843, 2842), Point(3848, 2854),
Point(3855, 2857)];
1 : Result := [Point(3862, 2800), Point(3853, 2807), Point(3849, 2815),
Point(3850, 2826), Point(3839, 2834), Point(3836, 2845),
Point(3834, 2856), Point(3836, 2869), Point(3847, 2860),
Point(3854, 2858)];
2 : Result := [Point(3862, 2800), Point(3858, 2812), Point(3857, 2821),
Point(3850, 2831), Point(3842, 2844), Point(3846, 2855),
Point(3854, 2857)];
End;
2 : Case Part Of
0 : Result := [Point(3848, 2855), Point(3843, 2847), Point(3841, 2835),
Point(3848, 2826), Point(3851, 2816), Point(3854, 2806),
Point(3860, 2802), Point(3866, 2795)];
1 : Result := [Point(3848, 2856), Point(3844, 2846), Point(3842, 2838),
Point(3846, 2828), Point(3847, 2816), Point(3850, 2804),
Point(3855, 2794), Point(3865, 2795)];
2 : Result := [Point(3848, 2852), Point(3845, 2847), Point(3846, 2836),
Point(3849, 2825), Point(3855, 2817), Point(3861, 2809),
Point(3864, 2797)];
End;
End;
End;

Function Walk(WhereTo:String):Boolean;
Begin
If Not LoggedIn Then Exit;

Inc(Walked);

If (WhereTo = 'Bank') Then
Begin
LoadPath(1,Random(3));
Loc := 'Bank'
Exit;
End;

If (WhereTo = 'FishingSpot') Then
Begin
LoadPath(2,Random(3));
Loc := 'FishingSpot'
Exit;
End;

writeln('walking failed stopping');
TerminateScript;
End;

Function WhenInvFull:Boolean;
Var Trout,Salmon,Stop:Boolean;
Begin

If Not LoggedIn Then Exit;
If Not InvFull Then Exit;

If Power Then
Begin
Salmon := False
Trout := False
Stop := False
Repeat
If Not R_ClickItemID(335,False,'Drop') Then
Trout := True;
Wait(500+Random(500));
If Not R_ClickItemID(331,False,'Drop') Then
Salmon := True;
Wait(500+Random(500));
If Trout And Salmon Then
Begin
Stop := True;
Inc(Dropped);
End;
Until(Stop);
End Else Begin //Banking
If Not Loc = 'Bank' Then
Walk('Bank');
R_OpenBankBooth('eb');
If R_PinScreen Then
InPin(Pin);
If R_BankScreen Then
Begin
R_DepositAllID(335);
Wait(250+Random(250));
R_DepositAllID(331);
Inc(Banked);
End Else
writeln('Problem Banking');
End;
End;

Procedure StartUp;
Begin
Smart_Members := MEMBERS;
Smart_Server := WORLD;
Smart_Signed := SIGNED;
SetupSRL;
SetUpReflectionEx(true);
DeclarePlayers;
LoginPlayer;
Wait(1500+Random(1500));
//CheckForRod;
End;

Procedure Proggy;
Begin
writeln('/////---Thanks for using the Trolls Fisher---\\\\');
Wait(500);
writeln('//// ---You banked '+IntToStr(Banked)+' times---\\\\');
wait(500);
writeln('////---You walked '+IntToStr(Walked)+' times---\\\\');
Wait(500);
writeln('////---You used AntiBan '+IntToStr(AntiBann)+' times---\\\\');
wait(500);
writeln('////-------------------------------------------\\\\');
wait(500);
End;


Function FindSpot:Boolean; //If at the right area but need more searching for example looking for a spot when in the right area
Begin
End;

Function WeAreFishing:Boolean;
Begin
Result := false
If GetAnimation = 623 Then
Result := True
End;

Procedure MainLoop;
Var I:Integer;
Begin

Repeat

If Loc = 'FishingSpot' Then
If Not InvFull Then
If Not WeAreFishing Then
Begin
I := 0
Repeat
If Not Fishing Then
Begin
DebugText('Problem In mainLoop looking for spot retrying');
Inc(I);
End Else Begin
I := 0
DebugText('Found fishing spot, resetting I in mainloop');
End;
While WeAreFishing Do
MyWait(RandomRange(200,1000));
If I = 10 Or 20 Or 30 Or 40 Then
FindSpot;
If I >= 50 Then
Begin
writeln('problem has happen stopping');
TerminateScript;
End;
Until(InvFull)
End;

WhenInvFull;

Until(False);
End;

Begin
End.

Thanks for anyhelp.

P.S. Yay first script ive ever posted here which i have remember to take my user and pass out

TomTuff

2010-10-24 16:12:11

multiplayer is mostly done in the main loop.

i luffs yeww

2010-10-24 16:35:19


Program new;
{$DEFINE SMART}
{$i srl\srl.scar}
{$i reflection\reflection.simba}

Const
Debug = True;
Power = True;
WORLD = 16;
MEMBERS = false;
SIGNED = true;

Var Pin,Loc:String;
Banked,AntiBann,Dropped,Walked:Integer;

Procedure DeclarePlayers;
Begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

With Players[0] Do
Begin
Name := '';
Pass := '';
Nick := '';
Active := True;
Pin := '';
End;

//To add multiplayer is really easy. Simply have more Players and use
//NextPlayer(True|False); (depending on if you want the player to be
//active or not.

//Example..

with Players[1] do //Notice it's Players[1] rather than Players[0]. ;)
begin
Name := '';
Pass := '';
Nick := '';
Pin := '';
Active := True;
end;

//You can add as many as you want, really (there is a cap, but it'd be
//silly to have that many anyway. Usually it's around 1-4 players per
//script.
End;

Procedure DebugText(Text:String);
Begin
If Not Debug then Exit;
writeln(Text);

//I think it looks nicer as..
{
if(Debug)then
Writeln(Text);
}
//But it doesn't really matter. :p
End;

Procedure AntiBan;
Begin
FindNormalRandoms;//I'd have this in an antirandoms procedure too
Inc(AntiBann);
Case 10000 Of
0: RandomRClick;
2: PickUpMouse;
4: RandomMovement;
5: BoredHuman;
6: ExamineInv;
End;
End;

Procedure MyWait(Time:Integer);
Var I :integer;
Begin
MarkTime(I);
Repeat
AntiBan;
Wait(10+Random(70));
Until(TimeFromMark(I) >= Time)
End;

Function Fishing:Boolean;

Var NPCs : TNPCArray;
I,x,y : Integer;
FishSpot : TPoint;
Begin
If Not LoggedIn Then Exit;
If Not Loc = 'FishingSpot' Then Exit;//Loc should be Players[CurrentPlayer].Loc or something.
result := false;
NPCs := GetNPCsBy('Fishing spot')
If high(NPCs) > -1 Then // Should be -1, because a high of 0 means that one NPC was found, -1 means nothing was found
Begin
For i:= 0 To high(NPCs) Do
Begin
If (NPCs[i].Name = 'Fishing spot') Then
Begin
DebugText('Found Fishing spot');
If TileOnMS (NPCs[i].Tile, 0) Then
Begin
FishSpot := TileToMS(NPCs[i].Tile,5); //Height of five?
MMouse(FishSpot.x,FishSpot.y,3,3);
If R_IsUpText('Fishing spot') Then
Begin
GetMousePos(x,y);
If Not Random(15) = 5 Then
Begin
Mouse(x,y,0,0,true);
End Else
Begin
Mouse(x,y,0,0,False);
R_ChooseOption('ttac'); //ttac? Wouldn't it be 'ish' or something? :p
End;
Result := True;
Exit;
End else Begin
DebugText('Did not find fishspot uptext!');
Wait(750);//Add randomness even if it's not necessary. Get in the habbit.
End;
end else DebugText('Spot #'+inttostr(i)+' not on mainscreen [dont worry too much about this msg]');
End;
End;
End; DebugText('Warning, array has nothing in it');
End;

{Function CheckForRod:Boolean; Not Working not sure why
Var Waste:TInvenItem;
Begin
Result := False
If Not R_ItemIDExists(Waste,309) Then //Your IDs could be wrong?
If Not R_ItemIDExists(Waste,314) Then
Begin
DebugText('Problem No rod and/or feathers');
TerminateScript;
End Else
DebugText('Got Rod and feathers');
End;
}
Function LoadPath(Part,Where:Integer): TTileArray; //1 fishing spot to bank //2 fish spot to bank
Begin //I'd use constants for these.

Case Where Of //Also try using RandomizeTile();.

1: Case Part Of
0 : Result := [Point(3864, 2801), Point(3858, 2814), Point(3852, 2824),
Point(3846, 2831), Point(3843, 2842), Point(3848, 2854),
Point(3855, 2857)];
1 : Result := [Point(3862, 2800), Point(3853, 2807), Point(3849, 2815),
Point(3850, 2826), Point(3839, 2834), Point(3836, 2845),
Point(3834, 2856), Point(3836, 2869), Point(3847, 2860),
Point(3854, 2858)];
2 : Result := [Point(3862, 2800), Point(3858, 2812), Point(3857, 2821),
Point(3850, 2831), Point(3842, 2844), Point(3846, 2855),
Point(3854, 2857)];
End;
2 : Case Part Of
0 : Result := [Point(3848, 2855), Point(3843, 2847), Point(3841, 2835),
Point(3848, 2826), Point(3851, 2816), Point(3854, 2806),
Point(3860, 2802), Point(3866, 2795)];
1 : Result := [Point(3848, 2856), Point(3844, 2846), Point(3842, 2838),
Point(3846, 2828), Point(3847, 2816), Point(3850, 2804),
Point(3855, 2794), Point(3865, 2795)];
2 : Result := [Point(3848, 2852), Point(3845, 2847), Point(3846, 2836),
Point(3849, 2825), Point(3855, 2817), Point(3861, 2809),
Point(3864, 2797)];
End;
End;
End;

Function Walk(WhereTo:String):Boolean;
Begin
If Not LoggedIn Then Exit;

Inc(Walked);

If (WhereTo = 'Bank') Then
Begin
LoadPath(1,Random(3));
Loc := 'Bank' //Players[CurrentPlayer].Loc := 'Bank';
Exit;
End;

If (WhereTo = 'FishingSpot') Then
Begin
LoadPath(2,Random(3));
Loc := 'FishingSpot' //Players[CurrentPlayer].Loc := 'Bank';
Exit;
End;

writeln('walking failed stopping');
TerminateScript;
End;

Function WhenInvFull:Boolean;
Var Trout,Salmon,Stop:Boolean;
Begin

If Not LoggedIn Then Exit;
If Not InvFull Then Exit;

If Power Then
Begin
Salmon := False
Trout := False
Stop := False
Repeat
If Not R_ClickItemID(335,False,'Drop') Then
Trout := True;
Wait(500+Random(500));
If Not R_ClickItemID(331,False,'Drop') Then
Salmon := True;
Wait(500+Random(500));
If Trout And Salmon Then
Begin
Stop := True;
Inc(Dropped);
End;
Until(Stop);
End Else Begin //Banking
If Not Loc = 'Bank' Then
Walk('Bank');
R_OpenBankBooth('eb');
If R_PinScreen Then
InPin(Pin);
If R_BankScreen Then
Begin
R_DepositAllID(335);
Wait(250+Random(250));
R_DepositAllID(331);
Inc(Banked);
End Else
writeln('Problem Banking');
End;
End;

Procedure StartUp;
Begin
Smart_Members := MEMBERS;
Smart_Server := WORLD;
Smart_Signed := SIGNED;
SetupSRL;
SetUpReflectionEx(true);
DeclarePlayers;
LoginPlayer;
Wait(1500+Random(1500));
//CheckForRod;
End;

Procedure Proggy; //Proggies shouldn't take two and a half seconds to show. :p
Begin
writeln('/////---Thanks for using the Trolls Fisher---\\\\');
Wait(500);
writeln('//// ---You banked '+IntToStr(Banked)+' times---\\\\');
wait(500);
writeln('////---You walked '+IntToStr(Walked)+' times---\\\\');
Wait(500);
writeln('////---You used AntiBan '+IntToStr(AntiBann)+' times---\\\\');
wait(500);
writeln('////-------------------------------------------\\\\');
wait(500);
End;


Function FindSpot:Boolean; //If at the right area but need more searching for example looking for a spot when in the right area
Begin
End;

Function WeAreFishing:Boolean;
Begin
{Result := false
If GetAnimation = 623 Then
Result := True}

Result := GetAnimation = 623;
End;

Procedure MainLoop;
Var I:Integer;
Begin

Repeat

If Loc = 'FishingSpot' Then
If Not InvFull Then
If Not WeAreFishing Then
Begin
I := 0
Repeat
If Not Fishing Then
Begin
DebugText('Problem In mainLoop looking for spot retrying');
Inc(I);
End Else Begin
I := 0
DebugText('Found fishing spot, resetting I in mainloop');
End;
While WeAreFishing Do
MyWait(RandomRange(200,1000));
If I = 10 Or 20 Or 30 Or 40 Then
FindSpot;
If I >= 50 Then
Begin
writeln('problem has happen stopping');
TerminateScript;
End;
Until(InvFull)
End;

WhenInvFull;

Until(False);
End;

Begin
End.

Didn't do too much. Didn't do standards because I don't have a mouse (:p I really can't without a mouse). Other than that it looks okay. Definitely a lot of improvements can be made, but I understand it's a work in progress. ;) I'll give more feedback when you're further along.

Great work so far! Keep it up.

Troll

2010-10-24 16:42:27

Thanks :) and yh its a work in progress but also my first :) And with the 'ttack' its because i copyed it from my failed fighting function :p

TomTuff

2010-10-24 16:47:03

another thing about multiplayer….

in your progress report, i would reccomend you use undeclared Player variables….
take a look at my progress report procedure from my karamja fisher
procedure Prog;
var
TLobFished, TTunaFished, TSwordFished, TLoads, TExp, i, ii: integer; //locally declared totals
begin
for i := 0 to (HowManyPlayers - 1) do //HowManyPlayers is in DeclarePlayers... Since i starts at 0, I subtracted that number by 1.
begin //this begin..end sequence procedure sums up the number into single totals for the overall progress
TLobFished := TLobFished + Players[i].Integers[10]; //Players[x].integers[10] is an undeclared Player variable that represents the # of lobsters that player fished
TTunaFished := TTunaFished + Players[i].Integers[12] + Players[i].Integers[13]; //Players[x].integers[13] is the number of tuna fished. It is undeclared like Integers[10]
TSwordFished := TSwordFished + Players[i].Integers[14]; //Integers[14] is the player's number of swordfish fished, it is also undeclared.
TLoads := TLoads + Players[i].Integers[11]; //Integers[11] is loads done by that player, and is again undeclared.
TExp := TExp + ((Players[i].Integers[10] * 90) + ((Players[i].Integers[12]) +(Players[i].Integers[13]) * 80) + (Players[i].Integers[14] * 100)); //the sum of the number of the types of fish fished * the exp value of the individual fished.
end;
WriteLn('');
WriteLn('[===================================================================]');
WriteLn('[ Stiles Fisher v 0.97 BETA by TomTuff ]');
WriteLn('[===================================================================]');
if (TLobFished > 0) then //it only writes the line for lobsters fished IF there were lobsters fished
WriteLn('[ Total Number of Lobsters Fished: ' + Padr(IntToStr(TLobFished), 32) + ']'); //Padr is a very useful function for report writing
if (TTunaFished > 0) then //same deal as lobsters
WriteLn('[ Total Number of Tuna Fished: ' + Padr(IntToStr(TTunaFished), 36) + ']');
if (TSwordFished > 0) then //same deal as lobsters/tuna
WriteLn('[ Total Number of Swordfish Fished: ' + Padr(IntToStr(TLobFished), 31) + ']');
WriteLn('[ Total Number of Loads Fished: ' + Padr(IntToStr(TLoads), 35) + ']');
WriteLn('[ Total Experience Gained: ' + Padr(IntToStr(TExp), 40) + ']');
WriteLn('[ Time Ran: ' + Padr(TimeRunning, 55) + ']'); //TimeRunning is an SRL function.
WriteLn('[===================================================================]');
for ii := 0 to (HowManyPlayers - 1) do //same deal as the i := 0 to (HowManyPlayers - 1) thing as above
begin
WriteLn('[ Player ' + Padl(IntToStr(ii), 2) + ': ' + Padr(Players[ii].Nick, 54) + ']');
if (Players[ii].Integers[10] > 0) then //only writes the lobsters line IF the player fished any lobsters
WriteLn('[ Lobsters Fished: ' + Padr(IntToStr(Players[ii].Integers[10]), 48) + ']');
if (Players[ii].Integers[12] > 0) then //same deal as lobsters
WriteLn('[ Tuna Dropped: ' + Padr(IntToStr(Players[ii].Integers[12]), 51) + ']');
if (Players[ii].Integers[13] > 0) then //same deal as lobsters/tuna dropped
WriteLn('[ Tuna Noted: ' + Padr(IntToStr(Players[ii].Integers[13]), 53) + ']');
if (Players[ii].Integers[14] > 0) then //same deal as lobsters/tuna
WriteLn('[ Swordfish Fished: ' + Padr(IntToStr(Players[ii].Integers[14]), 47) + ']');
WriteLn('[ Loads Fished: ' + Padr(IntToStr(Players[ii].Integers[11]), 51) + ']');
WriteLn('[ EXP Gained: ' + Padr(IntToStr((Players[ii].Integers[10] * 90) + ((Players[ii].Integers[12]) +(Players[ii].Integers[13]) * 80) + (Players[ii].Integers[14] * 100)), 53) + ']');
WriteLn('[ Worked: ' + Padr(MsToTime(PlayerWorked(ii), Time_Short), 57) + ']');
WriteLn('[===================================================================]');
end;
end;

read the comments :)

i luffs yeww

2010-10-24 16:49:26

:p I remember showing you some of that stuff, Tom. ^^

Troll

2010-10-24 16:50:41

Ok greats thanks, too tired now ill start work again in the morning :)

TomTuff

2010-10-24 16:52:37

From: i luffs yeww
:p I remember showing you some of that stuff, Tom. ^^


yeah. i'm such a creep, writing progress reports is my favorite thing to do in a script :pinch:

oh and btw Troll Man, when i say "Undeclared integer" i mean it's not shown in declare players.

Troll

2010-10-24 16:56:25

From: TomTuff
yeah. i'm such a creep, writing progress reports is my favorite thing to do in a script :pinch:

oh and btw Troll Man, when i say "Undeclared integer" i mean it's not shown in declare players.


Ok thanks and hav'nt i been kind of doing that?

TomTuff

2010-10-24 17:53:34

no, you've been using global variables.

Troll

2010-10-25 06:08:29

Oh ok now i see what you've done, thanks.