SRL Archive - Help and Support

I Hope I'm not asking too much but,


Claymore

2008-10-30 23:53:54

I need help with my Catherby Fisher. I just need people to review a function I made.




function SwitchSpots: Boolean;
var
Color, West, East, x, y: Integer;
begin
Result := False;
if FindFishingSpot(x, y) then
begin
Result := True;
Exit;
end;
case Lowercase(Players[CurrentPlayer].Loc) of
'west spot':
begin
Color := FindLadderColor;
if Color <> 0 then
begin
FindColorSpiral(x, y, Color, MMX1, MMY1, MMX2, MMY2);
Mouse(x+12, y, 3, 3, True);
Flag;
end
else
begin
RadialRoadWalk(FindWaterColor, 90, 130, 30, 1, 1);
Flag;
end;
Players[CurrentPlayer].Loc := 'South Spot';
if FindFishingSpot(x, y) then
begin
Result := True;
Exit;
end;
East := EastSpot;
if FindRotated(East, x, y, MMX1, MMY1, MMX2, MMY2, -5, 5, 0.1) then
begin
Mouse(x+12, y, 3, 3, True);
FreeDTM(East);
Flag;
end
else
begin
FreeDTM(East);
RadialRoadWalk(RoadColor, 110, 145, 47, 1, 1);
Flag;
end;
Players[CurrentPlayer].Loc := 'East Spot';
if FindFishingSpot(x, y) then
begin
Result := True;
Exit;
end;
WriteLn('Could not find a Lobster Fishing Spot.');
Exit;
end;
'east spot':
begin
Color := FindLadderColor;
if Color <> 0 then
begin
FindColorSpiral(x, y, Color, MMX1, MMY1, MMX2, MMY2);
Mouse(x+12, y, 3, 3, True);
Flag;
end
else
begin
RadialRoadWalk(FindWaterColor, 300, 260, 47, 1, 1);
Flag;
end;
Players[CurrentPlayer].Loc := 'South Spot';
if FindFishingSpot(x, y) then
begin
Result := True;
Exit;
end;
West := WestSpot;
if FindRotated(West, x, y, MMX1, MMY1, MMX2, MMY2, -5, 5, 0.1) then
begin
Mouse(x, y, 3, 3, True);
FreeDTM(West);
Flag;
end
else
begin
FreeDTM(West);
RadialRoadWalk(FindWaterColor, 300, 260, 27, 1, 1);
Flag;
end;
Players[CurrentPlayer].Loc := 'West Spot';
if FindFishingSpot(x, y) then
begin
Result := True;
Exit;
end;
WriteLn('Could not find a Lobster Fishing Spot.');
Exit;
end;
'south point':
begin
case Random(1) of
0:
begin
West := WestSpot;
if FindRotated(West, x, y, MMX1, MMY1, MMX2, MMY2, -5, 5, 0.5) then
begin
Mouse(x, y, 3, 3, True);
FreeDTM(West);
Flag;
end
else
begin
FreeDTM(West);
RadialRoadWalk(FindWaterColor, 300, 260, 27, 1, 1);
Flag;
end;
Players[CurrentPlayer].Loc := 'West Spot';
if FindFishingSpot(x, y) then
begin
Result := True;
Exit;
end;
WriteLn('Could not find a Lobster Fishing Spot.');
Exit;
end;
1:
begin
East := EastSpot;
if FindRotated(East, x, y, MMX1, MMY1, MMX2, MMY2, -5, 5, 0.5) then
begin
Mouse(x+12, y, 3, 3, True);
FreeDTM(East);
Flag;
end
else
begin
FreeDTM(East);
RadialRoadWalk(RoadColor, 110, 145, 47, 1, 1);
Flag;
end;
Players[CurrentPlayer].Loc := 'East Spot';
if FindFishingSpot(x, y) then
begin
Result := True;
Exit;
end;
WriteLn('Could not find a Lobster Fishing Spot.');
Exit;
end;
end;
end;
end;
WriteLn(Players[CurrentPlayer].Loc + ' is an invalid location.');
Exit;
end;

So if player is in the west spot, it will travel to the south then east. If it finds a spot in one of the following spots, it will fish and exit. Vice versa for the other spots, except if in south, it will choose a random location.

So if people could review this and make it better, ill add your name in the credits


~~Joker~~ -
Contributed to the script.

Narcle -
Improved function FindFishingSpot(x, y): Boolean;.

You could add yourself if you can help ;p

NiCbaZ

2008-11-05 00:00:58

south point':
begin
case Random(1) of
0:
begin
West := WestSpot;
if FindRotated(West, x, y, MMX1, MMY1, MMX2, MMY2, -5, 5, 0.5) then
begin
Mouse(x, y, 3, 3, True);
FreeDTM(West);
Flag;
end
else
begin
FreeDTM(West);
RadialRoadWalk(FindWaterColor, 300, 260, 27, 1, 1);
Flag;
end;
Players[CurrentPlayer].Loc := 'West Spot';
if FindFishingSpot(x, y) then
begin
Result := True;
Exit;
end;
WriteLn('Could not find a Lobster Fishing Spot.');
Exit;
end;
1:
begin
East := EastSpot;
if FindRotated(East, x, y, MMX1, MMY1, MMX2, MMY2, -5, 5, 0.5) then
begin
Mouse(x+12, y, 3, 3, True);
FreeDTM(East);
Flag;
end
else
begin
FreeDTM(East);
RadialRoadWalk(RoadColor, 110, 145, 47, 1, 1);
Flag;
end;
Players[CurrentPlayer].Loc := 'East Spot';
if FindFishingSpot(x, y) then
begin
Result := True;
Exit;
end;
WriteLn('Could not find a Lobster Fishing Spot.');
Exit;
end;
end;

It needs to be

Case Random(2) of

Because a case always starts at 0 .. eg

Case Random(5) of
0:
1:
2:
3:
4:
end;

A case statement of 5 would be

0,1,2,3,4

:) hope i helped.