TViYH
10-02-2008, 09:14 PM
Well. This time I'm going to try to follow through with creating the script.
Here's what I have so far:
program New;
{.include SRL\SRL\Misc\Smart.scar}
{.include SRL\SRL.scar}
{.include SRL\SRL\Reflection\Reflection.scar}
var
GuildFork, BottomGuild,
BelowGate, BareSpot, AlmostThere, SuccessSpot,
ArcRoadSpot, ArcForkRoadSpot, RockRoadSpot,
TreeRoadSpot, BelowGateSpot, BottomGuildSpot,
TopGuildSpot, BankSpot: TPoint;
x, y, BareSpotDTM, RuinColor, AltarColor, PortalColor: Integer;
procedure DeclarePlayers;
begin
CurrentPlayer := 0;
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
Players[0].Name := '';
Players[0].Pass := '';
Players[0].Nick := '';
Players[0].Active := True;
end;
procedure SetupScript;
begin
GuildFork := Point(3007, 3344);
BottomGuild := Point(3007, 3333);
BelowGate := Point(3007, 3316);
BareSpotDTM := DTMFromString('78DA630C606260A866400159B50A0CFC409 A1' +
'188FF0301632C504D09AA1A3F7D2630CD08E533C603F9F9A8 6AAC' +
'FDD950D580CCC94455A3E5C080AA260AA8A699805DC9986E1 6614' +
'533270DA8A614558D8C0BAA1A00B6150D66');
BareSpot := Point(2998, 3308);
AlmostThere := Point(2992, 3301);
SuccessSpot := Point(2985, 3294);
ArcRoadSpot := Point(2992, 3282);
ArcForkRoadSpot := Point(3004, 3286);
RockRoadSpot := Point(3006, 3299);
TreeRoadSpot := Point(3006, 3307);
BelowGateSpot := Point(3008, 3317);
BottomGuildSpot := Point(3006, 3329);
TopGuildSpot := Point(3007, 3344);
BankSpot := Point(3012, 3355);
end;
function WalkToStone: boolean;
var
sx, sy: integer;
begin
if not LoggedIn then Exit;
if not WalkToTile(GuildFork, 3, 0) then
begin
if not RadialRoadWalk(FindFallyRoadColor, 190, 244, 48, 0, 0) then //Guild Fork
begin
Players[CurrentPlayer].Loc := 'bank';
Exit;
end;
end;
r_Flag;
FindNormalRandoms;
if not WalkToTile(BottomGuild, 3, 0) then
begin
if not RadialRoadWalk(FindFallyRoadColor, 186, 236, 61, 0, 0) then //Bottom of guild
begin
Players[CurrentPlayer].Loc := 'Guild Fork'; //bott
Exit;
end;
end;
r_Flag;
FindNormalRandoms;
if not WalkToTile(BelowGate, 3, 0) then
begin
if not RadialRoadWalk(FindRoadColor, 133, 203, 68, 0, 0) then //Below the gate
begin
Players[CurrentPlayer].Loc := 'Bottom of the Guild'; //bel
Exit;
end;
end;
r_Flag;
FindNormalRandoms;
if not WalkToTile(BareSpot, 3, 0) then
begin
if not DTMRotated(BareSpotDTM, sx, sy, MMX1, MMY1, MMX2, MMY2) then
begin
Players[CurrentPlayer].Loc := 'Below the Gate'; //bare
Exit;
end else
Mouse(sx, sy, 2, 2, True);
end;
r_Flag;
FindNormalRandoms;
if not WalkToTile(AlmostThere, 3, 0) then
begin
Players[CurrentPlayer].Loc := 'Bare Spot'; //alm
Exit;
end;
r_Flag;
FindNormalRandoms;
if not WalkToTile(SuccessSpot, 1, 0) then
begin
Players[CurrentPlayer].Loc := 'Almost There';
Exit;
end;
Result := True;
Players[CurrentPlayer].Loc := 'There';
end;
function WalkToBank: boolean;
var sx, sy: integer;
begin
if not LoggedIn then Exit;
if not RadialRoadWalk(FindRoadColor, 107, 147, 48, 0, 0) then
begin
if not WalkToTile(ArcRoadSpot, 3, 0) then
begin
Players[CurrentPlayer].Loc := 'Altar';
Exit;
end;
end;
r_Flag;
FindNormalRandoms;
if not WalkToTile(ArcForkRoadSpot, 3, 0) then
begin
Players[CurrentPlayer].Loc := 'Arc Road Spot';
Exit;
end;
r_Flag;
FindNormalRandoms;
if not WalkToTile(RockRoadSpot, 3, 0) then
begin
Players[CurrentPlayer].Loc := 'Arc Fork Road Spot';
Exit;
end;
r_Flag;
FindNormalRandoms;
if not WalkToTile(TreeRoadSpot, 3, 0) then
begin
Players[CurrentPlayer].Loc := 'Rock Road Spot';
Exit;
end;
r_Flag;
FindNormalRandoms;
if not WalkToTile(BelowGateSpot, 3, 0) then
begin
Players[CurrentPlayer].Loc := 'Tree Road Spot';
Exit;
end;
r_Flag;
FindNormalRandoms;
if not WalkToTile(BottomGuildSpot, 3, 0) then
begin
Players[CurrentPlayer].Loc := 'Below Gate Spot';
Exit;
end;
r_Flag;
FindNormalRandoms;
if not WalkToTile(TopGuildSpot, 3, 0) then
begin
Players[CurrentPlayer].Loc := 'Bottom Guild Spot';
Exit;
end;
r_Flag;
FindNormalRandoms;
if not FindSymbol(sx, sy, 'bank') then
begin
if not WalkToTile(BankSpot, 1, 0) then
begin
Players[CurrentPlayer].Loc := 'Top Guild Spot';
Exit;
end;
end
else
Mouse(sx, sy, 0, 0, True);
if TileOnMS(BankSpot, 0) then
begin
Result := True;
Players[CurrentPlayer].Loc := 'Bank';
end;
end;
function FindObjectATPASpiralTolerance(Color, Tolerance: Integer; UpText: string): TPoint;
var
i, Timer: Integer;
tempPoint: TPoint;
tempTPA: TPointArray;
tempATPA: T2DPointArray;
begin
FindColorsSpiralTolerance(MSCX, MSCY, tempTPA, Color, MSX1, MSY1, MSX2, MSY2, Tolerance);
repeat
MarkTime(Timer);
if length(tempTPA)=0 then
begin
Inc(Tolerance);
FindColorsSpiralTolerance(MSCX, MSCY, tempTPA, Color, MSX1, MSY1, MSX2, MSY2, Tolerance);
end;
until((length(tempTPA)>0) or (TimeFromMark(Timer)>=60000));
tempATPA := SplitTPA(tempTPA, 5);
SortATPASize(tempATPA, True);
for i := 0 to High(tempATPA) do
begin
tempPoint := MiddleTPA(tempATPA[i]);
MMouse(tempPoint.x, tempPoint.y, 0, 0);
Wait(250 + Random(150));
if IsUpText(UpText) then
begin
Result := tempPoint;
Exit;
end;
end;
end;
function FindRuin: boolean;
var
RuinPoint: TPoint;
begin
if not LoggedIn then Exit;
RuinColor := 9272937;
RuinPoint := FindObjectATPASpiralTolerance(RuinColor, 5, 'ruin');
MMouse(RuinPoint.x, RuinPoint.y, 0, 0);
Wait(125 + Random(500));
if IsUpText('ruin') then
begin
Mouse(RuinPoint.x, RuinPoint.y, 0, 0, True);
Result := True;
end
else
WriteLn('Couldn''t find ruin!');
Exit;
end;
function FindAltar: boolean;
var
AltarPoint: TPoint;
begin
if not LoggedIn then Exit;
AltarColor := 6051161;
AltarPoint := FindObjectATPASpiralTolerance(AltarColor, 5, 'Altar');
MMouse(AltarPoint.x, AltarPoint.y, 0, 0);
Wait(125 + Random(500));
if IsUpText('Altar') then
begin
Mouse(AltarPoint.x, AltarPoint.y, 0, 0, True);
Result := True;
end
else
WriteLn('Couldn''t find altar!');
Exit;
end;
function FindPortal: boolean;
var
PortalPoint: TPoint;
begin
if not LoggedIn then Exit;
PortalColor := 8959933;
PortalPoint := FindObjectATPASpiralTolerance(PortalColor, 5, 'Portal');
MMouse(PortalPoint.x, PortalPoint.y, 0, 0);
Wait(125 + Random(500));
if IsUpText('Portal') then
begin
Mouse(PortalPoint.x, PortalPoint.y, 0, 0, True);
Result := True;
end
else
WriteLn('Couldn''t find portal!');
Exit;
end;
begin
SetupSRL;
DeclarePlayers;
SmartSetupEx(161, True, True, False);
SetTargetDC(SmartGetDC);
LoginPlayer;
SetupScript;
if not WalkToStone then WriteLn('Player got lost at: ' + Players[CurrentPlayer].Loc);
if (Players[CurrentPlayer].Loc = 'There') then
begin
Wait(1250);
FindNormalRandoms;
r_Flag;
Wait(1000 + Random(250));
FindNormalRandoms;
if FindRuin then
begin
WriteLn('Found ruin.');
repeat
Wait(100);
FindNormalRandoms;
Status('RoadCheck');
ClearDebug;
until not FindColor(x, y, FindRoadColor, MMX1, MMY1, MMX2, MMY2);
WriteLn('RoadCheck := Success');
if FindAltar then
begin
WriteLn('Found altar.');
r_Flag;
Wait(1000 + Random(350));
r_Flag;
if FindPortal then
begin
WriteLn('Found portal.');
r_Flag;
FindNormalRandoms;
if not WalkToBank then WriteLn(Players[CurrentPlayer].Loc);
end;
end;
end;
end;
end.
It uses reflection as it's main walking tool, with RRW as a backup. Right now, I only have it being able to walk from Fally East Bank to the ruins, then open the ruin, craft the ess, open the portal, then walk to the bank.
If you want to help me, PLEASE DO!
Here's what I have so far:
program New;
{.include SRL\SRL\Misc\Smart.scar}
{.include SRL\SRL.scar}
{.include SRL\SRL\Reflection\Reflection.scar}
var
GuildFork, BottomGuild,
BelowGate, BareSpot, AlmostThere, SuccessSpot,
ArcRoadSpot, ArcForkRoadSpot, RockRoadSpot,
TreeRoadSpot, BelowGateSpot, BottomGuildSpot,
TopGuildSpot, BankSpot: TPoint;
x, y, BareSpotDTM, RuinColor, AltarColor, PortalColor: Integer;
procedure DeclarePlayers;
begin
CurrentPlayer := 0;
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
Players[0].Name := '';
Players[0].Pass := '';
Players[0].Nick := '';
Players[0].Active := True;
end;
procedure SetupScript;
begin
GuildFork := Point(3007, 3344);
BottomGuild := Point(3007, 3333);
BelowGate := Point(3007, 3316);
BareSpotDTM := DTMFromString('78DA630C606260A866400159B50A0CFC409 A1' +
'188FF0301632C504D09AA1A3F7D2630CD08E533C603F9F9A8 6AAC' +
'FDD950D580CCC94455A3E5C080AA260AA8A699805DC9986E1 6614' +
'533270DA8A614558D8C0BAA1A00B6150D66');
BareSpot := Point(2998, 3308);
AlmostThere := Point(2992, 3301);
SuccessSpot := Point(2985, 3294);
ArcRoadSpot := Point(2992, 3282);
ArcForkRoadSpot := Point(3004, 3286);
RockRoadSpot := Point(3006, 3299);
TreeRoadSpot := Point(3006, 3307);
BelowGateSpot := Point(3008, 3317);
BottomGuildSpot := Point(3006, 3329);
TopGuildSpot := Point(3007, 3344);
BankSpot := Point(3012, 3355);
end;
function WalkToStone: boolean;
var
sx, sy: integer;
begin
if not LoggedIn then Exit;
if not WalkToTile(GuildFork, 3, 0) then
begin
if not RadialRoadWalk(FindFallyRoadColor, 190, 244, 48, 0, 0) then //Guild Fork
begin
Players[CurrentPlayer].Loc := 'bank';
Exit;
end;
end;
r_Flag;
FindNormalRandoms;
if not WalkToTile(BottomGuild, 3, 0) then
begin
if not RadialRoadWalk(FindFallyRoadColor, 186, 236, 61, 0, 0) then //Bottom of guild
begin
Players[CurrentPlayer].Loc := 'Guild Fork'; //bott
Exit;
end;
end;
r_Flag;
FindNormalRandoms;
if not WalkToTile(BelowGate, 3, 0) then
begin
if not RadialRoadWalk(FindRoadColor, 133, 203, 68, 0, 0) then //Below the gate
begin
Players[CurrentPlayer].Loc := 'Bottom of the Guild'; //bel
Exit;
end;
end;
r_Flag;
FindNormalRandoms;
if not WalkToTile(BareSpot, 3, 0) then
begin
if not DTMRotated(BareSpotDTM, sx, sy, MMX1, MMY1, MMX2, MMY2) then
begin
Players[CurrentPlayer].Loc := 'Below the Gate'; //bare
Exit;
end else
Mouse(sx, sy, 2, 2, True);
end;
r_Flag;
FindNormalRandoms;
if not WalkToTile(AlmostThere, 3, 0) then
begin
Players[CurrentPlayer].Loc := 'Bare Spot'; //alm
Exit;
end;
r_Flag;
FindNormalRandoms;
if not WalkToTile(SuccessSpot, 1, 0) then
begin
Players[CurrentPlayer].Loc := 'Almost There';
Exit;
end;
Result := True;
Players[CurrentPlayer].Loc := 'There';
end;
function WalkToBank: boolean;
var sx, sy: integer;
begin
if not LoggedIn then Exit;
if not RadialRoadWalk(FindRoadColor, 107, 147, 48, 0, 0) then
begin
if not WalkToTile(ArcRoadSpot, 3, 0) then
begin
Players[CurrentPlayer].Loc := 'Altar';
Exit;
end;
end;
r_Flag;
FindNormalRandoms;
if not WalkToTile(ArcForkRoadSpot, 3, 0) then
begin
Players[CurrentPlayer].Loc := 'Arc Road Spot';
Exit;
end;
r_Flag;
FindNormalRandoms;
if not WalkToTile(RockRoadSpot, 3, 0) then
begin
Players[CurrentPlayer].Loc := 'Arc Fork Road Spot';
Exit;
end;
r_Flag;
FindNormalRandoms;
if not WalkToTile(TreeRoadSpot, 3, 0) then
begin
Players[CurrentPlayer].Loc := 'Rock Road Spot';
Exit;
end;
r_Flag;
FindNormalRandoms;
if not WalkToTile(BelowGateSpot, 3, 0) then
begin
Players[CurrentPlayer].Loc := 'Tree Road Spot';
Exit;
end;
r_Flag;
FindNormalRandoms;
if not WalkToTile(BottomGuildSpot, 3, 0) then
begin
Players[CurrentPlayer].Loc := 'Below Gate Spot';
Exit;
end;
r_Flag;
FindNormalRandoms;
if not WalkToTile(TopGuildSpot, 3, 0) then
begin
Players[CurrentPlayer].Loc := 'Bottom Guild Spot';
Exit;
end;
r_Flag;
FindNormalRandoms;
if not FindSymbol(sx, sy, 'bank') then
begin
if not WalkToTile(BankSpot, 1, 0) then
begin
Players[CurrentPlayer].Loc := 'Top Guild Spot';
Exit;
end;
end
else
Mouse(sx, sy, 0, 0, True);
if TileOnMS(BankSpot, 0) then
begin
Result := True;
Players[CurrentPlayer].Loc := 'Bank';
end;
end;
function FindObjectATPASpiralTolerance(Color, Tolerance: Integer; UpText: string): TPoint;
var
i, Timer: Integer;
tempPoint: TPoint;
tempTPA: TPointArray;
tempATPA: T2DPointArray;
begin
FindColorsSpiralTolerance(MSCX, MSCY, tempTPA, Color, MSX1, MSY1, MSX2, MSY2, Tolerance);
repeat
MarkTime(Timer);
if length(tempTPA)=0 then
begin
Inc(Tolerance);
FindColorsSpiralTolerance(MSCX, MSCY, tempTPA, Color, MSX1, MSY1, MSX2, MSY2, Tolerance);
end;
until((length(tempTPA)>0) or (TimeFromMark(Timer)>=60000));
tempATPA := SplitTPA(tempTPA, 5);
SortATPASize(tempATPA, True);
for i := 0 to High(tempATPA) do
begin
tempPoint := MiddleTPA(tempATPA[i]);
MMouse(tempPoint.x, tempPoint.y, 0, 0);
Wait(250 + Random(150));
if IsUpText(UpText) then
begin
Result := tempPoint;
Exit;
end;
end;
end;
function FindRuin: boolean;
var
RuinPoint: TPoint;
begin
if not LoggedIn then Exit;
RuinColor := 9272937;
RuinPoint := FindObjectATPASpiralTolerance(RuinColor, 5, 'ruin');
MMouse(RuinPoint.x, RuinPoint.y, 0, 0);
Wait(125 + Random(500));
if IsUpText('ruin') then
begin
Mouse(RuinPoint.x, RuinPoint.y, 0, 0, True);
Result := True;
end
else
WriteLn('Couldn''t find ruin!');
Exit;
end;
function FindAltar: boolean;
var
AltarPoint: TPoint;
begin
if not LoggedIn then Exit;
AltarColor := 6051161;
AltarPoint := FindObjectATPASpiralTolerance(AltarColor, 5, 'Altar');
MMouse(AltarPoint.x, AltarPoint.y, 0, 0);
Wait(125 + Random(500));
if IsUpText('Altar') then
begin
Mouse(AltarPoint.x, AltarPoint.y, 0, 0, True);
Result := True;
end
else
WriteLn('Couldn''t find altar!');
Exit;
end;
function FindPortal: boolean;
var
PortalPoint: TPoint;
begin
if not LoggedIn then Exit;
PortalColor := 8959933;
PortalPoint := FindObjectATPASpiralTolerance(PortalColor, 5, 'Portal');
MMouse(PortalPoint.x, PortalPoint.y, 0, 0);
Wait(125 + Random(500));
if IsUpText('Portal') then
begin
Mouse(PortalPoint.x, PortalPoint.y, 0, 0, True);
Result := True;
end
else
WriteLn('Couldn''t find portal!');
Exit;
end;
begin
SetupSRL;
DeclarePlayers;
SmartSetupEx(161, True, True, False);
SetTargetDC(SmartGetDC);
LoginPlayer;
SetupScript;
if not WalkToStone then WriteLn('Player got lost at: ' + Players[CurrentPlayer].Loc);
if (Players[CurrentPlayer].Loc = 'There') then
begin
Wait(1250);
FindNormalRandoms;
r_Flag;
Wait(1000 + Random(250));
FindNormalRandoms;
if FindRuin then
begin
WriteLn('Found ruin.');
repeat
Wait(100);
FindNormalRandoms;
Status('RoadCheck');
ClearDebug;
until not FindColor(x, y, FindRoadColor, MMX1, MMY1, MMX2, MMY2);
WriteLn('RoadCheck := Success');
if FindAltar then
begin
WriteLn('Found altar.');
r_Flag;
Wait(1000 + Random(350));
r_Flag;
if FindPortal then
begin
WriteLn('Found portal.');
r_Flag;
FindNormalRandoms;
if not WalkToBank then WriteLn(Players[CurrentPlayer].Loc);
end;
end;
end;
end;
end.
It uses reflection as it's main walking tool, with RRW as a backup. Right now, I only have it being able to walk from Fally East Bank to the ruins, then open the ruin, craft the ess, open the portal, then walk to the bank.
If you want to help me, PLEASE DO!