SRL Archive - OSR Help

Error: Exception: Access violation at line 157


Haxz

2013-05-29 12:16:05

Here's the image.

It opens up simba.simba and shows the error. Simba will be in state of "Not responding" after I got that error. This only happens when it started to walk. I used Flight's walking functions which has the forcenorth function in it. And here's the full script.


procedure SetupLogin;
begin
ClearDebug;
DeclarePlayers;
SetupSRL;
writeln(ToStr(SmartGetRefresh));
LoginPlayer;

repeat
wait(500);
until LoggedIn;

{$IFDEF SMART}
SMART_ClearCanvas;
{$ENDIF}
SRL_CombatRandoms := false;
SetAngle(0);
Food := 'Trout';

MonCTS := 2;
MonCol := [1213602];
MonTol := [12];
MonHue := [0.02];
MonSat := [0.17];
MonWidth := 15;
MonLength := 30;
MonName := 'ket Gua';

SPS_Setup(RUNESCAPE_SURFACE, ['11_7']);

case Food of
'Trout':
FoodDTM := DTMFromString('m1gAAAHic42JgYMhhYmBIA+ISIM4C4lIgrgLiQqh4PBAnAzEPIwODABCzADEzEP9jgNDcQCwCxVxA3F9ayLC4tZEhKzwEqIIRJ2YFkjCMD+A2ARUjAAAzqgoU');
end;

end;


Procedure SetupDTM;
begin
TeleTabDTM := DTMFromString('mFQEAAHic42VgYHBkYmCwBGIfIHYCYmcgNoViKyD2BGJ/IA6AYi8gfgzU9wSKbwPxKwaI2Bsg/gTF74H4BRDfAeLrQDxp6zYGGeV7KJiBgREv5geS6JgQwG8idowCAKtAFhc=');
end;

Procedure FreeDatDTM;
begin
FreeDTM(FoodDTM);
FreeDTM(TeleTabDTM);
end;


Function FindMonster(CTS: Integer; Color, Tolerance: array of Integer; Hue, Sat: array of Extended; Width, Height: Integer; Option: String) : Boolean;
var
i: Integer;
TPA : TPointArray;
ATPA : T2DPointArray;
MP : TPoint;
tmpCTS : Integer;
begin
tmpCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(CTS);
FindNonInventoryRandoms;

for i:=0 to High(Color) do
begin
if Result then
Break;
SetToleranceSpeed2Modifiers(Hue[i],Sat[i]);
FindColorsTolerance(TPA,Color[i],MSX1,MSY1,MSX2,MSY2,Tolerance[i]);
SortTPAFrom(TPA, Point(MSCX, MSCY));
TPAtoATPAExWrap(TPA, Width, Height, ATPA);
//SortATPASize(ATPA, true);

for i := 0 to High(ATPA) do
begin
SMART_DrawDots(ATPA[0]);
MP := MiddleTPA(ATPA[0]);
Mouse(MP.x, MP.y, 3, 3, mouse_Right);
if WaitOption(MonName, 500) then
begin
Result := True;
Break;
end;
end;
end;
ColorToleranceSpeed(tmpCTS);
SetColorSpeed2Modifiers(0.2, 0.2);

end;


Function InvertPath(Points: TPointArray): TPointArray;
Var
i, j: integer;
begin
SetLength(Result, Length(Points));
j := 0;
for i := High(Points) downto 0 do
begin
Result[j] := Points[i];
Inc(j);
end;
end;

Function IsMoving_F: Boolean;
begin
Result := PixelShift(IntToBox(MMCX-30, MMCY-30, MMCX+30, MMCY+30), 200) > 200;
end;

{*******************************************************************************
Function GenerateWallDTM(WallType, WallLength: Integer): Integer;
By: Flight
Description: Creates a DTM of a perfectly straight wall.
-WallType : 1 for vertical, 2 for horizontal
-WallLength: Length of the DTM to be generated
*******************************************************************************}
function GenerateWallDTM(WallType, WallLength: Integer): Integer;
var
i: Integer;
TempTDTM: TDTM;
mPnt: TDTMPointDef;
sPnts: array of TDTMPointDef;
begin
SetArrayLength(sPnts, (WallLength-1));
mPnt.x := 0;
mPnt.y := 0;
mPnt.AreaSize := 0;
mPnt.AreaShape := 0;
mPnt.Color := 16119287;
mPnt.Tolerance := 40;

for i:=0 to High(sPnts) do
begin
case WallType of
1:
begin
sPnts[i].x := 0;
sPnts[i].y := i+1;
end;
2:
begin
sPnts[i].x := i+1;
sPnts[i].y := 0;
end;
end;
sPnts[i].AreaSize := 0;
sPnts[i].AreaShape := 0;
sPnts[i].Color := 16119287;
sPnts[i].Tolerance := 40;
end;

TempTDTM.MainPoint := mPnt;
TempTDTM.SubPoints := sPnts;
Result := AddDTM(TempTDTM);
end;

{*******************************************************************************
Function GetLongestWallLength(WallType: Integer): Integer;
By: Flight
Description: Determines the longest wall on your MM at any compass angle.
-WallType: 1 for vertical walls, 2 for horizontal walls
*******************************************************************************}
function GetLongestWallLength(WallType: Integer): Integer;
var
B: TBox;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
ColorToleranceSpeed(1);

FindColorsSpiralTolerance(MMCX, MMCY, TPA, 16119287, MMX1, MMY1, MMX2, MMY2, 40);
if (Length(TPA)<1) then
Exit;

RAaSTPA(TPA, 1);
if (WallType = 1) then
SplitTPAExWrap(TPA, 2, 3, ATPA)
else
SplitTPAExWrap(TPA, 3, 2, ATPA);

SortATPASize(ATPA, True);
B := GetTPABounds(ATPA[0]);
if (WallType = 1) then
Result := (B.Y2-B.Y1)
else
Result := (B.X2-B.X1);
end;

{*******************************************************************************
Function ForceMapNorth: Boolean;
By: Flight
Description: Using auto-generated wall DTMs, this function will attempt to
rotate the compass to near-perfect north. Should it fail it will revert
back to default north.
*******************************************************************************}
Function ForceMapNorth: Boolean;
var
Left: Boolean;
StartAngle: Extended;
X,Y,DTM_VertWall,
DTM_HorWall,T,F,L1,L2: Integer;
label
Start,FuncEnd;
begin
Result := False;
L1 := GetLongestWallLength(1);
L2 := GetLongestWallLength(2);
if (L1 > 50) then
L1 := 50;
if (L2 > 50) then
L2 := 50;

DTM_VertWall := GenerateWallDTM(1, Round(L1*0.85)); //Create a DTM 85% of the length of the longest vertical wall
DTM_HorWall := GenerateWallDTM(2, Round(L2*0.85)); //Create a DTM 85% of the length of the longest horizontal wall

if (FindDTM(DTM_VertWall, X, Y, MMx1, MMy1, MMx2, MMy2) or
FindDTM(DTM_HorWall, X, Y, MMx1, MMy1, MMx2, MMy2)) then
begin
Result := True;
GoTo FuncEnd;
end;

StartAngle := (rs_GetCompassAngleDegrees);
Left := (Round((360 - StartAngle)) mod 360 <= Round((StartAngle + 360)) mod 360);

Start:
if (F > 0) then
MakeCompass('N');

MarkTime(T);
Repeat
TypeByte((Ord(not Left) * 2) + 37); //No holding down, actually press the arrow key
if (FindDTM(DTM_VertWall, X, Y, MMx1, MMy1, MMx2, MMy2) or
FindDTM(DTM_HorWall, X, Y, MMx1, MMy1, MMx2, MMy2)) then
break;
Until(TimeFromMark(T) >= 1000)

FuncEnd:
if ((not FindDTM(DTM_VertWall, X, Y, MMx1, MMy1, MMx2, MMy2)) and
(not FindDTM(DTM_HorWall, X, Y, MMx1, MMy1, MMx2, MMy2))) then
begin
Inc(F);
StartAngle := (rs_GetCompassAngleDegrees);
Left := (Round((360 - StartAngle)) mod 360 <= Round((StartAngle + 360)) mod 360);
if (F < 2) then
GoTo Start;
end else if ((X > 1) and (Y > 1)) then
Result := True;

if not Result then
MakeCompass('N');
FreeDTM(DTM_VertWall);
FreeDTM(DTM_HorWall);
end;


function WalkPath_F(Path: TPointArray): boolean;
var
I, H, T, D, Fails: integer;
P, MM, MMF: TPoint;
begin
ColorToleranceSpeed(1);
H := High(Path);
T := GetSystemTime + 11000 + Random(2000);
Fails := 0;

ForceMapNorth;
RunEnergy(70);
while (not Result) and (GetSystemTime < T) and (Fails < 5) do
begin
FindNormalRandoms;
if (not LoggedIn()) then
Exit;

P := SPS_GetMyPos();

for I := H downto 0 do
begin
MM := RotatePoint(Point(MMCX + Path[I].X - P.X, MMCY + Path[I].Y - P.Y), 0-(Radians((Round(rs_GetCompassAngleDegrees + DF) mod 360))), MMCX, MMCY);

if MM = MMF then
Inc(Fails);

D := Distance(MM.X, MM.Y, MMCX, MMCY);

if (D < 10) then
break
else
if (D < 70) then
begin
Mouse(MM.X, MM.Y, 0, 0, mouse_left);
WaitFunc(@IsMoving_F, 10, 2500);
MMF := MM;
FFlag(30);

T := getSystemTime + 11000 + Random(2000);
Break;
end;
end;
if (I = H) then
While IsMoving_F do
Wait(1);
Result := (I = H);
end;
end;


procedure WalkToGuards;
var
myPath:TPointArray;
begin
FindNormalRandoms;
writeln('Walking to Guards');
myPath := [Point(4573, 2935), Point(4567, 2943), Point(4560, 2959), Point(4543, 2961), Point(4524, 2964)];
WalkPath_F(myPath);
end;

procedure WalkToBank;
var
myPath:TPointArray;
begin
FindNormalRandoms;
writeln('Walking to Bank');
myPath := [Point(4573, 2935), Point(4567, 2943), Point(4560, 2959), Point(4543, 2961), Point(4524, 2964)];
InvertTPA(myPath);
WalkPath_F(myPath);
end;


Function BankerBank2: Boolean;
var
MP: TPoint;
I, L, t: Integer;
ATPA: T2DPointArray;
TPA: TPointArray;
begin
FindNormalRandoms;
MarkTime(t);
if BankScreen then
begin
Result := True;
Exit;
end;
repeat
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.10, 0.77);
FindColorsTolerance(TPA, 4664118, MSX1, MSY1, MSX2,MSY2, 8);
If (Length(TPA) < 1) then Exit;

SortTPAFrom(TPA, Point(MSCX, MSCY));


TPAtoATPAExWrap(TPA, 13, 13, ATPA);
L := Length(ATPA);
If (L < 1) then Exit;
//SortATPASize(ATPA, true);

For I := 0 To High(ATPA) Do
begin
SMART_DrawDotsEx(true, ATPA[i], clNavy);
MP := MiddleTPA(ATPA[i]);
Mouse(MP.x, MP.y, 1, 1, mouse_Right);
if WaitOption('nk Bank', 500) then
begin
writeln('Opening bank');
repeat
if WaitFunc(@BankScreen, 10, 5000) then
Break;
BankerBank2;
until (BankScreen) or (PinScreen);
Result := (BankScreen) or (PinScreen);
Break;
end;
end;
if Result then Break;
until TimeFromMark(t) > 60000;
ColorToleranceSpeed(1);
SetColorSpeed2Modifiers(0.2, 0.2);
end;


procedure Proggy;
var
Sec: Integer;
begin
Sec := GetTimeRunning/1000;
Writeln('+++++++++++++++++++++++++++++++++++++++++++++++++++++++');
Writeln(' Haxz Flax Spinner ');
Writeln('+++++++++++++++++++++++++++++++++++++++++++++++++++++++');
Writeln('Trips Done : ' + IntToStr(Trips));
Writeln('Trips / Hour : ' + IntToStr(Round(3600 * Trips / Sec)));
Writeln('Total Essence Used : ' + IntToStr(Banked));
Writeln('Essence/ Hour : ' + IntToStr(Round(3600 * Banked / Sec)));
Writeln('Time Ran : ' + TimeRunning);
Writeln('-------------------------------------------------------');
end;


begin
SetupLogin;
SetupDTM;
AddOnTerminate('FreeDatDTM');

WalkToGuards;
if InvFull then
begin
FTab(tab_Inv);
FindDTM(FoodDTM, x, y, MIX1, MIY1, MIX2, MIY2);
Mouse(x, y, 5, 5, mouse_Left);
end;
repeat
if not FindMonster(MonCTS, MonCol, MonTol, MonHue, MonSat, MonWidth, MonLength, MonName) then
begin
writeln('Cant find monster, rotating compass');
MakeCompass('random');
end;

if HPPercent(false) < 50 then
begin
FindNonInventoryRandoms;
writeln('Low on hp, eating');
GameTab(tab_Inv);
if FindDTM(FoodDTM, x, y, MIX1, MIY1, MIX2, MIY2) then
begin
Mouse(x, y, 3, 3, mouse_Left);
ftab(tab_Stats);
//wait(RandomRange(1000, 1500));
end else
begin
writeln('Out of food');
wait(RandomRange(3000, 5000));
WalkToBank;
BankerBank2;
if WaitFunc(@BankScreen, 50, 10000) then
begin
writeln('Found bank screen');
for i := 1 to 28 do
begin
if ExistsItem(i) then
begin
InvMouse(i, mouse_Right);
if WaitOption('All', 1000) then
wait(1000);
end;
end;
MouseBankSlot(1, mouse_Right);
WaitOption('All', 500);
end;
WalkToGuards;
FTab(tab_Inv);
FindDTM(FoodDTM, x, y, MIX1, MIY1, MIX2, MIY2);
Mouse(x, y, 5, 5, mouse_Left);
end;
end;
until false;
end.

Please don't mind the name of functions and some other things. I've made the script from my combat script, combat script is made from my flax spinner script.

Sjoe

2013-05-29 12:20:13

Is your map open on the path generator or smthing else? close it down first.

Haxz

2013-05-29 12:22:06

From: Sjoe
Is your map open on the path generator or smthing else? close it down first.


Nope. Not possible to start the script if custom map was opened. I opened world map and loaded only a part of the map, so it won't get that error.

Any other possibilities?

Sjoe

2013-05-29 12:25:46

From: Haxz
Nope. Not possible to start the script if custom map was opened. I opened world map and loaded only a part of the map, so it won't get that error.

Any other possibilities?


maybe InvertTPA causing it? try flight's InvertPath

Haxz

2013-05-29 12:26:46

From: Sjoe
maybe InvertTPA causing it? try flight's InverPath


Never thought of that, maybe that's why Flight made his own invertpath. I'll try it out and see what happens. Thanks!