BobboHobbo
2009-05-09 13:54:03
Well i get
And that line is:
BUT i call Findrandoms when the script starts, Has no problems! but when it gets to the walking procedure where it has FindRandoms in it, it errors. Im so lost.
And when i {} out the findlamp code it works btw.
I tried both DEV SRL and rev #32 same thing happens. Help?
script:
[Runtime Error] : Exception: Access violation at address 0065865D in module 'scar.exe'. Read of address 00000040 in line 354 in script E:\Program Files\SCAR 3.20D\includes\SRL/SRL/Core/AntiRandoms/AntiRandoms.scar
And that line is:
function FindLamp(skill: string): Boolean;
var
LampTime, x, y, i: Integer;
begin
GameTab(4);
if FindColorTolerance(x, y, 1084300, MIX1, MIY1, MIX2, MIY2, 40) then
if (FindBitmapToleranceIn(Lamp, x, y, MIX1, MIY1, MIX2, MIY2, 40)) then
begin
Result := True;
Inc(RandSolved[rand_Lamp]);
TakeScreen('Lamp Random Solved');
AddToSRLLog('******** SOLVED LAMP RANDOM ********');
WriteLn('******** SOLVED LAMP RANDOM ********');
Mouse(x, y, 1, 1, True);
Wait(1500 + Random(500));
MarkTime(LampTime);
for i:= 1 to 4 do
BUT i call Findrandoms when the script starts, Has no problems! but when it gets to the walking procedure where it has FindRandoms in it, it errors. Im so lost.
And when i {} out the findlamp code it works btw.
I tried both DEV SRL and rev #32 same thing happens. Help?
script:
program BH_EYC;
{.include SRL/SRL/Misc/Smart.scar}
{.include SRL/SRL.scar}
{.include srl/srl/misc/users.scar}
const
Vers = '0.00';
procedure DeclarePlayers;
begin
HowManyPlayers := 1;
CurrentPlayer := 0;
NumberOfPlayers(HowManyPlayers);
Players[0].Name := 'r';
Players[0].Pass := 'hms';
Players[0].Nick := 'ar';
Players[0].BoxRewards := ['mote', 'ostume', 'XP', 'Gem', 'ithril', 'oal', 'une', 'oins'];
Players[0].Active := True;
end;
var
x, y, Chopped, Banked, Answer, Laptime, BestLapTimeBH, dsx, dsy, Xc, Yc, BankDTM: integer;
FoundAxe: byte;
WalkAngle: Extended;
function LoggedInFailsafe: Boolean;
var
cx, cy, t1: Integer;
begin
if not FindColor(cx, cy, 16777215, 439, 491, 440, 492) then
begin
repeat
inc(T1);
wait(500);
writeln('Suspected of logging out - ' + inttostr(T1) + ' tries..');
until (T1 >= 5) or (FindColor(cx, cy, 16777215, 439, 491, 440, 492));
end;
if FindColor(cx, cy, 16777215, 439, 491, 440, 492) then
Result := true;
exit;
if (T1 >= 5) then
Result := false;
end;
function ConvertTimeBH(TheTimer: integer): string;
var
RHours, Minutes, Seconds, RMinutes, RSeconds: LongInt;
Time: string;
begin
Seconds := TheTimer div 1000;
Minutes := Seconds div 60;
RHours := Minutes div 60;
Time := IntToStr(Seconds) + ' Seconds';
if Minutes <> 0 then
begin
RSeconds := Seconds mod (Minutes * 60);
Time := IntToStr(Minutes) + ' Minutes and ' + IntToStr(RSeconds) + ' Seconds';
end;
if RHours <> 0 then
begin
RMinutes := Minutes mod (RHours * 60);
RSeconds := Seconds mod (Minutes * 60);
Time := IntToStr(RHours) + ' Hours, ' + IntToStr(RMinutes) + ' Minutes and ' + IntToStr(RSeconds) + ' Seconds';
end;
Result := Time;
end;
function GetMarkedTime(TheInteger: Integer): integer;
begin
Result := GetSystemTime - TheInteger;
end;
procedure BeatRecordTiming(TheLapTimeBH: integer);
begin
if BestLapTimeBH = 0 then
begin
BestLapTimeBH := GetMarkedTime(TheLapTimeBH);
exit;
end;
if GetMarkedTime(TheLapTimeBH) <= BestLapTimeBH then
begin
BestLapTimeBH := GetMarkedTime(TheLapTimeBH);
end;
end;
procedure FindRandoms;
begin
if (not (LoggedIn)) then
Exit;
FindNormalRandoms;
if (FindFight) then
begin
RunTo('W', True) FFlag(3);
Wait(100 + random(500));
end;
end;
procedure PlayerStats;
var
Active: string;
Loc: string;
i: Integer;
begin
if Players[CurrentPlayer].Integers[2] = 0 then
begin
Players[CurrentPlayer].Integers[2] := GetSkillInfo('WoodCutting', False);
end
else if Players[CurrentPlayer].Active = True then
Active := 'True'
else
Active := 'False';
Writeln(' Name : ' + Players[CurrentPlayer].Name);
Writeln(' Player : ' + inttostr(CurrentPlayer));
Writeln(' Active : ' + Active);
Writeln(' Location :' + Players[CurrentPlayer].loc);
Writeln(' Using a : ' + Players[CurrentPlayer].Strings[0] + ' Axe.');
Writeln(' Worked : ' + IntToStr(Players[i].Worked) + ' Minutes');
Writeln(' Random In : ' + Players[i].Rand);
Writeln(' Start WC Lv : ' + IntToStr(Players[CurrentPlayer].Integers[2]));
Writeln(' Total WC Lvs Gained : ' + IntToStr(Answer));
WriteLn('[------------------------------------------------------------------------------------]');
for I := 0 to HowManyPlayers - 1 do
begin
if Players[i].loc = '' then
begin
loc := 'Unknown';
end;
if Players[i].Active then
Active := 'True. '
else
Active := 'False. ';
Writeln(' ' + (IntToStr(I)) + ': ' + Players[I].Name + ' = ' + Active + + 'WC Lv: ' + IntToStr(Players[I].Integers[2]) + ' ' + 'Worked: ' + IntToStr(Players[i].Worked) + ' min. ' + 'Axe: ' + Players[CurrentPlayer].Strings[0] + ' ' + 'Loc:' + Players[i].loc + '. ' + 'Rand: ' + Players[i].Rand);
end;
WriteLn('[------------------------------------------------------------------------------------]');
end;
procedure ProgressReport;
begin
ClearDebug;
SRLRandomsReport;
WriteLn('[----------------------------------------------------]');
WriteLn('[ ~ BH - Edgeville Yew Cutter V ' + Vers + ' ]');
WriteLn('[----------------------------------------------------]');
Writeln('[ Script Worked for ' + TimeRunning);
Writeln('[ Banked ' + IntToStr(Banked) + ' Times.');
Writeln('[ Chopped ' + IntToStr(Chopped) + ' Logs.');
Writeln('[ Cutting Rate: ' + IntToStr(Round((Chopped * 3600) / (GetTimeRunning / 1000))) + ' Per Hour');
if Answer > 0 then
Writeln('[ Gained ' + IntToStr(Answer) + ' WC Levels');
Writeln('[ Fastest Load ' + ConvertTimeBH(BestLapTimeBH));
writeln('[----------------------------------------------------]');
PlayerStats;
end;
procedure Information(say: string);
begin
Writeln(' ' + say);
Players[CurrentPlayer].Loc := Say;
end;
procedure AntiBan;
var
AB: integer;
begin
FindRandoms;
if (TimeFromMark(AB) < 15000 + random(5000)) or (Invfull) then
begin
Exit;
end
else
Getmousepos(xC, yC);
case random(36) of
0:
begin
IdleTime(1000 + Random(1000), 500, 0.5);
Wait(200 + random(800));
end;
1:
begin
HoverSkill('random', false);
gametab(4);
MarkTime(AB);
end;
13:
begin
PickUpMouse;
MarkTime(AB);
end;
4:
begin
GameTab(1 + Random(12));
wait(800 + random(500));
GameTab(4);
MarkTime(AB);
end;
8:
begin
RandomRClick;
wait(500 + random(500));
MarkTime(AB);
end;
9:
begin
GameTab(1 + random(10));
wait(100 + random(1000));
GameTab(1 + random(10));
wait(100 + random(1000));
GameTab(4);
MarkTime(AB);
end;
end;
MMouse(xC, yC, 8, 8);
end;
function GetSymbolColorWhere(var rx, ry: Integer; Name, WhereAbouts: string): Integer;
var
x1, y1, x2, y2: integer;
begin
case LowerCase(WhereAbouts) of
'top':
begin
x1 := 541;
y1 := 12;
x2 := 693;
y2 := 51;
end;
'bottom':
begin
x1 := 552;
y1 := 107;
x2 := 696;
y2 := 165;
end;
end;
Result := GetSymbolColorIn(rx, ry, LowerCase(Name), x1, y1, x2, y2);
end;
function FindSymbolDirection(var rx, ry: Integer; Name, Where: string): boolean;
begin
Result := (GetSymbolColorWhere(rx, ry, LowerCase(Name), Where) > 0);
end;
procedure SwitchYews;
begin
if (not (LoggedIn)) then
Exit;
if FindSymbolDirection(x, y, 'tree', 'bottom') then
begin
mouse(x, y - 9, 3, 3, true);
fflag(1);
writeln('sa');
exit;
end;
if FindSymbolDirection(x, y, 'tree', 'top') then
begin
mouse(x, y + 9, 3, 3, true);
writeln('sdsdsa');
end;
FFlag(1);
end;
function FindObjTPAEx(var X, Y: Integer; Color, Tol, CTS, ObjWidth, ObjHeight, minCount: Integer; UpText: TStringArray): Boolean;
var
I, j, tCTS: Integer;
myPoint: TPoint;
Points: TPointArray;
aPoints: T2DPointArray;
s: string;
begin
Result := False;
if not LoggedIn then
exit;
tCTS := GetColorToleranceSpeed;
if CTS * 9 mod 3 <> 0 then
CTS := 1;
ColorToleranceSpeed(CTS);
FindColorsSpiralTolerance(X, Y, Points, Color, 114, 4, 365, 288, Tol);
if Length(Points) = 0 then
begin
ColorToleranceSpeed(tCTS);
Exit;
end;
ColorToleranceSpeed(1);
aPoints := TPAtoATPAEx(Points, ObjWidth, ObjHeight);
SetLength(Points, 0);
for I := 0 to High(aPoints) do
begin
if Length(aPoints[I]) < minCount then
Continue;
myPoint := MiddleTPA(aPoints[I]);
MMouse(myPoint.X, myPoint.Y, 0, 0);
Wait(100 + Random(50));
s := RS_GetUpText;
for j := 0 to High(UpText) do
if Pos(uptext[j], s) > 0 then
begin
GetMousePos(X, Y);
Result := True;
ColorToleranceSpeed(tCTS);
Exit;
end;
end;
ColorToleranceSpeed(tCTS);
end;
function FindYew(var X, Y: Integer; Click: boolean): Boolean;
var
TPA: TPointArray;
ATPA: T2DPointArray;
I, H: Integer;
begin
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 4690308, MSX1, MSY1, MSX2, MSY2, 15);
ATPA := TPAtoATPA(TPA, 25);
if Length(ATPA) = 0 then
Exit;
H := High(ATPA);
for I := 0 to H do
begin
MiddleTPAEx(ATPA[i], X, Y);
MMouse(X, Y, 3, 3);
Wait(50 + Random(50));
if IsUpText('Yew') then
begin
if (Click) then
begin
Mouse(x, y, 0, 0, true);
GetMousePos(X, Y);
Writeln('Found Yew Tree at X: ' + IntToStr(X) + ' Y: ' + IntToStr(Y));
end;
Result := True;
Exit;
end;
end;
end;
function FindYewTPA(Click: boolean): boolean;
var
hhx, hhy: integer;
begin
Result := FindObjTPAEx(hhx, hhy, 2581595, 11, - 1, 75, 60, 300, ['Yew']);
if (Result) then
begin
if (Click) then
begin
if IsupText('Yew') then
begin
Mouse(hhx, hhy, 0, 0, true);
Writeln('Found Yew Tree at X: ' + IntToStr(HHx) + ' Y: ' + IntToStr(HHy));
FFlag(0);
end;
end;
end;
end;
procedure CutYew;
var
Timer, NoWoodcutting: integer;
begin
if (not (LoggedIn)) then
Exit;
repeat
if FindYew(x, y, true) then
begin
MarkTime(Timer);
repeat
FindRandoms;
wait(500 + random(400));
AntiBan;
until (not IsUpText('Yew') or (TimeFromMark(Timer) > 250000 + Random(20000)) or not loggedIn);
SwitchYews;
end;
if not FindYew(x, y, false) then
begin
MarkTime(Timer);
repeat
FindRandoms;
wait(500 + random(500));
AntiBan;
until (FindYew(x, y, False) or (TimeFromMark(Timer) > 150000 + Random(20000)));
if (TimeFromMark(Timer) > 150000 + Random(20000)) then
SwitchYews;
end;
until ((InvFull) or not (LoggedIn));
end;
function FindEVRoadColour: Integer;
var
arP: TPointArray;
arC: TIntegerArray;
tmpCTS, i, arL: Integer;
R, G, B: Integer;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(1);
if not (FindColorsTolerance(arP, 7764864, MMX1, MMY1, MMX2, MMY2, 0)) then
begin
Writeln('Failed to find the color, no result.');
ColorToleranceSpeed(tmpCTS);
Exit;
end;
arC := GetColors(arP);
ClearSameIntegers(arC);
arL := High(arC);
for i := 0 to arL do
begin
ColorToRGB(arC[i], R, G, B);
if (R >= 117) and (R <= 139) and (G >= 112) and (G <= 134) and (B >= 107) and (B <= 129) then
begin
Result := arC[i];
Writeln('Edgeville Road Colour = ' + IntToStr(arC[i]));
Break;
end;
end;
ColorToleranceSpeed(tmpCTS);
if (i = arL + 1) then
Writeln('AutoColor failed in finding the color.');
end;
function WalkToYews(Number: Integer): boolean;
var
C: integer;
begin
if (not (LoggedIn)) then
Exit;
Result := False;
case Number of
0:
begin
Writeln('Using walking Method #1.');
BankDTM := DTMFromString('78DA633CC5CCC0E0CAC800024C0C10F0E70F1' + '38339900689FE07D1A7816A6C71AB0101C6334035A6F8D500007D4A0' + 'AC3');
if FindDTMRotated(BankDTM, x, y, MMX1, MMY1, MMX2, MMY2, - Pi, Pi, 0.4, WalkAngle) then
begin
Mouse(x, y + 60, 5, 5, true);
FFlag(1);
if FindSymbolDirection(x, y, 'tree', 'bottom') then
begin
Mouse(x, y - 9, 2, 2, true);
FFlag(1);
FreeDTM(BankDTM);
Result := True;
exit;
end;
end
else
FreeDTM(BankDTM);
Information('Walk Method 1 failed');
Inc(c);
if C > 4 then
begin
Result := false;
Information('Walking Failed!');
Logout;
end;
if not WalkToYews(1) then
begin
Result := false;
Information('Walking Failed!');
Logout;
end;
end;
1:
begin
Writeln('Using walking Method #2.');
if FindSymbolDirection(x, y, 'tree', 'bottom') then
begin
Mouse(x, y + 12, 3, 6, true);
FFlag(0);
Result := True;
exit;
end;
Information('Walk Method #2 failed.');
Inc(C);
if C > 4 then
begin
Result := false;
Information('Walking Failed!');
Logout;
end;
if not WalkToYews(0) then
begin
Result := false;
Information('Walking Failed!');
Logout;
end;
end;
end;
end;
procedure WalkToBank;
var
xx, yy: integer;
begin
if (not (LoggedIn)) then
Exit;
Setrun(true);
if FindSymbolDirection(x, y, 'tree', 'top') then
begin
mouse(x, y + 9, 3, 3, true);
FFlag(2);
end;
BankDTM := DTMFromString('78DA633CC5CCC0E0CAC800024C0C10F0E70F1' + '38339900689FE07D1A7816A6C71AB0101C6334035A6F8D500007D4A0' + 'AC3');
if FindDTMRotated(BankDTM, x, y, MMX1, MMY1, MMX2, MMY2, - Pi, Pi, 0.4, WalkAngle) then
begin
Mouse(x - 7, y - 3, 5, 5, true);
IsMoving(150);
FreeDTM(BankDTM);
exit;
end
else
FreeDTM(BankDTM);
Information('Failed to walk to bank.');
Logout;
end;
function CountBitmap(BM: Integer): boolean;
var
i, x, y: Integer;
TB: Tbox;
begin
GameTab(4);
for i := 1 to 28 do
begin
TB := InvBox(i);
if ExistsItem(i) then
if FindBitmapToleranceIn(srl_GetBitmap(BM), x, y, TB.x1, TB.y1, TB.x2, TB.y2, 10) then
Inc(Chopped);
Result := true;
end;
end;
procedure BankStuff;
var
XbZ: integer;
begin
repeat
OpenBankFast('eb');
Findrandoms;
Inc(XbZ);
until ((BankScreen) or (PinScreen) or (XbZ > 3));
if (XbZ > 3) then
begin
Logout;
Information('Failed to Open Bank');
Exit;
end;
if (PinScreen) then
begin
InPin(IntToStr(Players[CurrentPlayer].Integers[1]));
Wait(500 + Random(250));
end;
if (Bankscreen) then
begin
srl_LoadBitmaps([60]);
CountBitmap(60);
Deposit(2, 28, true);
srl_FreeBitmaps;
CloseBank;
inc(Banked);
BeatRecordTiming(LapTime);
ProgressReport;
end;
end;
function FindAxeEx: boolean;
var
Ix, Iy: Integer;
I, InvAxe, WieldAxe: Byte;
Typee: string;
begin
if not LoggedIn then
exit;
srl_LoadBitmaps([47, 48, 49, 50, 51, 52, 53, 54]);
I := 0;
repeat
case GetCurrentTab of
5:
begin
for WieldAxe := 0 to 7 do
if FindBitmapToleranceIn(srl_GetBitmap(54 - WieldAxe), Ix, Iy, 566, 285, 606, 327, 10) then
Break;
if I = 0 then
if not GameTab(4) then
exit;
Inc(I);
end;
4:
begin
for InvAxe := 0 to 7 do
if FindBitmapToleranceIn(srl_GetBitmap(54 - InvAxe), Ix, Iy, MIX1, MIY1, MIX2, MIY2, 10) then
Break;
if I = 0 then
if not GameTab(5) then
exit;
Inc(I);
end;
else if not GameTab(5) then
exit;
end;
until I = 2;
if (InvAxe = 8) and (WieldAxe = 8) then
begin
Writeln('No axe was found.');
srl_FreeBitmaps;
Result := False;
Exit;
end;
FoundAxe := Min(WieldAxe, InvAxe);
case FoundAxe of
0: typee := 'dragon';
1: typee := 'rune';
2: typee := 'addy';
3: typee := 'mith';
4: typee := 'black';
5: typee := 'steel';
6: typee := 'iron';
7: typee := 'bronze';
end;
WriteLn('Using ' + Capitalize(typee) + ' axe.');
Players[CurrentPlayer].Strings[0] := Capitalize(typee);
Result := true;
srl_FreeBitmaps;
end;
procedure SetupOne;
begin
SetupSRL;
SmartSetupEx(108, false, true, false);
SetTargetDC(SmartGetDC);
ActivateClient;
wait(1000);
DeclarePlayers;
if (not (loggedIn)) then
LoginPlayer;
MakeCompass('N');
end;
procedure SetupTwo;
begin
MarkTime(LapTime);
SetAngle(true);
SetRun(true);
FindRandoms;
end;
procedure SetupAxeNStuff;
var
AxeH: integer;
begin
if not FindAxeEx then
begin
BankDTM := DTMFromString('78DA633CC5CCC0E0CAC800024C0C10F0E70F1' + '38339900689FE07D1A7816A6C71AB0101C6334035A6F8D500007D4A0' + 'AC3');
if FindDTMRotated(BankDTM, x, y, MMX1, MMY1, MMX2, MMY2, - Pi, Pi, 0.4, WalkAngle) then
begin
Mouse(x - 3, y, 1, 1, true);
FFlag(0);
OpenBankFast('eb');
AxeH := DTMFromString('78DA63B463626078CA8002FAB20519FE03694' + '620FE0F048CD640351F18D000231209A42D816A5E115003B2EB36' + '0135CE4035D709A8F102AAB941408D0F50CD1D026ABC816A1E105' + '0E304547317BF1A000F77106A');
if FindDTM(AxeH, x, y, MSX1, MSY1, MSX2, MSY2) then
begin
Mouse(x, y, 1, 1, true);
CloseBank;
FreeDTM(AxeH);
Exit;
end;
end
else
Information('Cant find an axe');
Logout;
FreeDTM(AxeH);
end;
end;
begin
Setupone;
repeat
SetupAxeNStuff;
repeat
SetupTwo;
WalkToYews(random(2));
CutYew;
WalkToBank;
BankStuff;
until (Banked >= (Players[CurrentPlayer].Integers[0])) or (not (LoggedInFailsafe));
if not (LoggedIn) then
begin
Writeln('Choosing Random Next Player');
RandomNextPlayer(false);
Banked := 0;
end;
if (Banked >= (Players[CurrentPlayer].Integers[0])) then
begin
writeln('Loads done, Chaning player');
Players[CurrentPlayer].Loc := 'Bank. Loads done.';
ProgressReport;
Logout;
RandomNextPlayer(true);
Banked := 0;
end;
until (AllPlayersInactive);
ProgressReport;
Writeln('All players are unactive');
Writeln('Thanks for using BH - Edgeville Yew Cutter');
end.