SRL Archive - SRL Bugs

DTMRotated Error


Gearsnare

2009-04-11 16:08:56

Sometimes when using DTMRotated I get the following error:
[Runtime Error] : Exception: Access violation at address 004B998D in module 'scar.exe'. Read of address 03280030 in line 81 in script C:\Program Files\SCAR 3.15\includes\SRL/SRL/Core/Color.scar

Anyone know if this is a bug or my own mistakes?

Frt

2009-04-11 16:37:28

Is the DTM declared?

Gearsnare

2009-04-11 16:52:37

I'm using a function to declare them since I'm using DDTMs. I had four in my script but only one of them would make this error but now they all are.

Frt

2009-04-11 16:53:12

Post your script please. Otherwise we can't help.

noidea

2009-04-11 17:11:06

Make sure you have the Params right

DTMRotated(DTM, x, y, x1, y1, x2, y2);

ian.

2009-04-11 18:07:55

pretty sure it's cuz of not freeing/freeing when you weren't supposed to.. but it would help if you would show the script ;)

Gearsnare

2009-04-12 08:09:33

From: 99_
pretty sure it's cuz of not freeing/freeing when you weren't supposed to.. but it would help if you would show the script ;)


I just made new DDTMs and freed them and it seems to be working.

Thanks!

Edit: It's back! It's like a rash it keeps coming back even though it was totally gone the night before. -_-

Anyway heres my script:

program AlKharidTanner;
{.include SRL\SRL.scar}

var
x, y: Integer;

function Floor1Color: Integer;
var
i, Red, Green, Blue, GC, TestColor, CX, CY: Integer;
P: TPointArray;
H, S, L: Extended;
begin
GC := 6061218;
FFlag(0);
if (FindSymbol(x, y, 'bank')) then
begin
CX := x;
CY := y;
end else
begin
CX := MMCX;
CY := MMCY;
end;
FindColorsSpiralTolerance(CX, CY, P, GC, MMX1, MMY1, MMX2, MMY2, 30);
for i := 0 to High(P) - 1 do
begin
if rs_OnMinimap(P[i].x,P[i].y) then
begin
TestColor := GetColor(P[i].x, P[i].y);
ColorToRGB(TestColor, Red, Green, Blue);
ColorToHSL(TestColor, H, S, L);
if InRange(Red - Blue, 58, 82) then
if InRange(Red - Green, 22, 54) then
if InRange(Green - Blue, 19, 47) then
if InRange(Round(S - H), 14, 31) then
if InRange(Round(L - H), 32, 52) then
if InRange(Round(L - S), 13, 26) then
if GetColor(P[i].x + 2, P[i].y + 2) = TestColor then
if GetColor(P[i].x + 1, P[i].y + 1) = TestColor then
if GetColor(P[i].x, P[i].y + 2) = TestColor then
if GetColor(P[i].x + 2, P[i].y) = TestColor then
if GetColor(P[i].x, P[i].y + 1) = TestColor then
if GetColor(P[i].x + 1, P[i].y) = TestColor then
if GetColor(P[i].x + 2, P[i].y + 1) = TestColor then
if GetColor(P[i].x + 1, P[i].y + 2) = TestColor then
begin
Result := TestColor;
Writeln('Floor1Color = ' + IntToStr(Result));
Exit;
end;
end;
end;
Writeln('Floor1Color could not be found.');
Result := 0;
end;

function Floor2Color: Integer;
var
i, Red, Green, Blue, GC, TestColor: Integer;
P: TPointArray;
H, S, L: Extended;
begin
GC := 6983098;
FFlag(0);
FindColorsSpiralTolerance(MMCX, MMCY, P, GC, MMX1, MMY1, MMX2, MMY2, 30);
for i := 0 to High(P) - 1 do
begin
if rs_OnMinimap(P[i].x,P[i].y) then
begin
TestColor := GetColor(P[i].x, P[i].y);
ColorToRGB(TestColor, Red, Green, Blue);
ColorToHSL(TestColor, H, S, L);
if InRange(Red - Blue, 70, 90) then
if InRange(Red - Green, 32, 67) then
if InRange(Green - Blue, 17, 53) then
if InRange(Round(S - H), 23, 40) then
if InRange(Round(L - H), 44, 59) then
if InRange(Round(L - S), 13, 25) then
if GetColor(P[i].x + 2, P[i].y + 2) = TestColor then
if GetColor(P[i].x + 1, P[i].y + 1) = TestColor then
if GetColor(P[i].x, P[i].y + 2) = TestColor then
if GetColor(P[i].x + 2, P[i].y) = TestColor then
if GetColor(P[i].x, P[i].y + 1) = TestColor then
if GetColor(P[i].x + 1, P[i].y) = TestColor then
if GetColor(P[i].x + 2, P[i].y + 1) = TestColor then
if GetColor(P[i].x + 1, P[i].y + 2) = TestColor then
begin
Result := TestColor;
Writeln('Floor2Color = ' + IntToStr(Result));
Exit;
end;
end;
end;
Writeln('Floor2Color could not be found.');
Result := 0;
end;

function CactiColor: Integer;
var
i, Red, Green, Blue, GC, TestColor: Integer;
P: TPointArray;
H, S, L: Extended;
begin
GC := 3240012;
FFlag(0);
FindColorsSpiralTolerance(MMCX, MMCY, P, GC, MMX1, MMY1, MMX2, MMY2, 50);
for i := 0 to High(P) - 1 do
begin
if rs_OnMinimap(P[i].x,P[i].y) then
begin
TestColor := GetColor(P[i].x, P[i].y);
ColorToRGB(TestColor, Red, Green, Blue);
ColorToHSL(TestColor, H, S, L);
if InRange(Red - Blue, 3, 35) then
if InRange(Green - Red, 19, 60) then
if InRange(Green - Blue, 38, 78) then
if InRange(Round(S - H), -9, 30) then
if InRange(Round(L - H), -6, 16) then
if InRange(Round(L - S), -32, 16) then
if GetColor(P[i].x + 2, P[i].y + 2) = TestColor then
if GetColor(P[i].x + 1, P[i].y + 1) = TestColor then
if GetColor(P[i].x, P[i].y + 2) = TestColor then
if GetColor(P[i].x + 2, P[i].y) = TestColor then
if GetColor(P[i].x, P[i].y + 1) = TestColor then
if GetColor(P[i].x + 1, P[i].y) = TestColor then
if GetColor(P[i].x + 2, P[i].y + 1) = TestColor then
if GetColor(P[i].x + 1, P[i].y + 2) = TestColor then
begin
Result := TestColor;
Writeln('CactiColor = ' + IntToStr(Result));
Exit;
end;
end;
end;
Writeln('CactiColor could not be found.');
Result := 0;
end;

function TreeBaseColor: Integer;
var
i, Red, Green, Blue, GC, TestColor: Integer;
P: TPointArray;
H, S, L: Extended;
begin
GC := 1130626;
FFlag(0);
FindColorsSpiralTolerance(MMCX, MMCY, P, GC, MMX1, MMY1, MMX2, MMY2, 50);
for i := 0 to High(P) - 1 do
begin
if rs_OnMinimap(P[i].x,P[i].y) then
begin
TestColor := GetColor(P[i].x, P[i].y);
ColorToRGB(TestColor, Red, Green, Blue);
ColorToHSL(TestColor, H, S, L);
if InRange(Red - Blue, 100, 138) then
if InRange(Red - Green, 57, 89) then
if InRange(Green - Blue, 27, 66) then
if InRange(Round(S - H), 51, 98) then
if InRange(Round(S - L), 23, 82) then
if InRange(Round(L - H), 12, 32) then
if GetColor(P[i].x, P[i].y + 1) = TestColor then
begin
Result := TestColor;
Writeln('TreeBaseColor = ' + IntToStr(Result));
Exit;
end;
end;
end;
Writeln('TreeBaseColor could not be found.');
Result := 0;
end;

function Walk1DDTM: Integer;
var
dtmMainPoint: TDTMPointDef;
dtmSubPoints: Array [0..5] of TDTMPointDef;
TempTDTM: TDTM;
begin
dtmMainPoint.x := 76;
dtmMainPoint.y := 25;
dtmMainPoint.AreaSize := 0;
dtmMainPoint.AreaShape := 0;
dtmMainPoint.Color := 6262182;
dtmMainPoint.Tolerance := 255;

dtmSubPoints[0].x := 76;
dtmSubPoints[0].y := 25;
dtmSubPoints[0].AreaSize := 0;
dtmSubPoints[0].AreaShape := 0;
dtmSubPoints[0].Color := 6262182;
dtmSubPoints[0].Tolerance := 255;

dtmSubPoints[1].x := 58;
dtmSubPoints[1].y := 7;
dtmSubPoints[1].AreaSize := 20;
dtmSubPoints[1].AreaShape := 0;
dtmSubPoints[1].Color := Floor2Color;
dtmSubPoints[1].Tolerance := 0;

dtmSubPoints[2].x := 31;
dtmSubPoints[2].y := 9;
dtmSubPoints[2].AreaSize := 4;
dtmSubPoints[2].AreaShape := 1;
dtmSubPoints[2].Color := CactiColor;
dtmSubPoints[2].Tolerance := 0;

dtmSubPoints[3].x := 80;
dtmSubPoints[3].y := 48;
dtmSubPoints[3].AreaSize := 4;
dtmSubPoints[3].AreaShape := 1;
dtmSubPoints[3].Color := CactiColor;
dtmSubPoints[3].Tolerance := 0;

dtmSubPoints[4].x := 49;
dtmSubPoints[4].y := 43;
dtmSubPoints[4].AreaSize := 16;
dtmSubPoints[4].AreaShape := 0;
dtmSubPoints[4].Color := Floor1Color;
dtmSubPoints[4].Tolerance := 0;

dtmSubPoints[5].x := 12;
dtmSubPoints[5].y := 16;
dtmSubPoints[5].AreaSize := 16;
dtmSubPoints[5].AreaShape := 0;
dtmSubPoints[5].Color := 800886;
dtmSubPoints[5].Tolerance := 0;

TempTDTM.MainPoint := dtmMainPoint;
TempTDTM.SubPoints := dtmSubPoints;
Result := AddDTM(TempTDTM);
end;

function Walk2DDTM: Integer;
var
dtmMainPoint: TDTMPointDef;
dtmSubPoints: Array [0..3] of TDTMPointDef;
TempTDTM: TDTM;
begin
dtmMainPoint.x := 66;
dtmMainPoint.y := 16;
dtmMainPoint.AreaSize := 15;
dtmMainPoint.AreaShape := 0;
dtmMainPoint.Color := Floor2Color;
dtmMainPoint.Tolerance := 0;

dtmSubPoints[0].x := 66;
dtmSubPoints[0].y := 16;
dtmSubPoints[0].AreaSize := 15;
dtmSubPoints[0].AreaShape := 0;
dtmSubPoints[0].Color := Floor2Color;
dtmSubPoints[0].Tolerance := 0;

dtmSubPoints[1].x := 25;
dtmSubPoints[1].y := 53;
dtmSubPoints[1].AreaSize := 5;
dtmSubPoints[1].AreaShape := 1;
dtmSubPoints[1].Color := CactiColor;
dtmSubPoints[1].Tolerance := 0;

dtmSubPoints[2].x := 73;
dtmSubPoints[2].y := 103;
dtmSubPoints[2].AreaSize := 5;
dtmSubPoints[2].AreaShape := 1;
dtmSubPoints[2].Color := CactiColor;
dtmSubPoints[2].Tolerance := 0;

dtmSubPoints[3].x := 7;
dtmSubPoints[3].y := 42;
dtmSubPoints[3].AreaSize := 5;
dtmSubPoints[3].AreaShape := 1;
dtmSubPoints[3].Color := 800886;
dtmSubPoints[3].Tolerance := 255;

TempTDTM.MainPoint := dtmMainPoint;
TempTDTM.SubPoints := dtmSubPoints;
Result := AddDTM(TempTDTM);
end;

function Walk3DDTM: Integer;
var
dtmMainPoint: TDTMPointDef;
dtmSubPoints: Array [0..4] of TDTMPointDef;
TempTDTM: TDTM;
begin
dtmMainPoint.x := 45;
dtmMainPoint.y := 116;
dtmMainPoint.AreaSize := 0;
dtmMainPoint.AreaShape := 0;
dtmMainPoint.Color := 6196132;
dtmMainPoint.Tolerance := 255;

dtmSubPoints[0].x := 45;
dtmSubPoints[0].y := 116;
dtmSubPoints[0].AreaSize := 0;
dtmSubPoints[0].AreaShape := 0;
dtmSubPoints[0].Color := 6196132;
dtmSubPoints[0].Tolerance := 255;

dtmSubPoints[1].x := 83;
dtmSubPoints[1].y := 12;
dtmSubPoints[1].AreaSize := 4;
dtmSubPoints[1].AreaShape := 1;
dtmSubPoints[1].Color := CactiColor;
dtmSubPoints[1].Tolerance := 0;

dtmSubPoints[2].x := 67;
dtmSubPoints[2].y := 15;
dtmSubPoints[2].AreaSize := 4;
dtmSubPoints[2].AreaShape := 0;
dtmSubPoints[2].Color := CactiColor;
dtmSubPoints[2].Tolerance := 0;

dtmSubPoints[3].x := 41;
dtmSubPoints[3].y := 15;
dtmSubPoints[3].AreaSize := 4;
dtmSubPoints[3].AreaShape := 1;
dtmSubPoints[3].Color := CactiColor;
dtmSubPoints[3].Tolerance := 0;

dtmSubPoints[4].x := 2;
dtmSubPoints[4].y := 85;
dtmSubPoints[4].AreaSize := 4;
dtmSubPoints[4].AreaShape := 1;
dtmSubPoints[4].Color := CactiColor;
dtmSubPoints[4].Tolerance := 0;

TempTDTM.MainPoint := dtmMainPoint;
TempTDTM.SubPoints := dtmSubPoints;
Result := AddDTM(TempTDTM);
end;

function Walk4DDTM: Integer;
var
dtmMainPoint: TDTMPointDef;
dtmSubPoints: Array [0..4] of TDTMPointDef;
TempTDTM: TDTM;
begin
dtmMainPoint.x := 50;
dtmMainPoint.y := 125;
dtmMainPoint.AreaSize := 16;
dtmMainPoint.AreaShape := 0;
dtmMainPoint.Color := Floor1Color;
dtmMainPoint.Tolerance := 0;

dtmSubPoints[0].x := 50;
dtmSubPoints[0].y := 125;
dtmSubPoints[0].AreaSize := 16;
dtmSubPoints[0].AreaShape := 0;
dtmSubPoints[0].Color := Floor1Color;
dtmSubPoints[0].Tolerance := 0;

dtmSubPoints[1].x := 102;
dtmSubPoints[1].y := 79;
dtmSubPoints[1].AreaSize := 16;
dtmSubPoints[1].AreaShape := 1;
dtmSubPoints[1].Color := Floor1Color;
dtmSubPoints[1].Tolerance := 0;

dtmSubPoints[2].x := 52;
dtmSubPoints[2].y := 62;
dtmSubPoints[2].AreaSize := 16;
dtmSubPoints[2].AreaShape := 0;
dtmSubPoints[2].Color := Floor2Color;
dtmSubPoints[2].Tolerance := 0;

dtmSubPoints[3].x := 77;
dtmSubPoints[3].y := 107;
dtmSubPoints[3].AreaSize := 4;
dtmSubPoints[3].AreaShape := 1;
dtmSubPoints[3].Color := CactiColor;
dtmSubPoints[3].Tolerance := 0;

dtmSubPoints[4].x := 17;
dtmSubPoints[4].y := 64;
dtmSubPoints[4].AreaSize := 4;
dtmSubPoints[4].AreaShape := 1;
dtmSubPoints[4].Color := CactiColor;
dtmSubPoints[4].Tolerance := 0;

TempTDTM.MainPoint := dtmMainPoint;
TempTDTM.SubPoints := dtmSubPoints;
Result := AddDTM(TempTDTM);
end;

procedure WalkToTanner;
begin
DTMRotated(Walk1DDTM, x, y, MMX1, MMY1, MMX2, MMY2);
Mouse(x, y, 4, 4, True);
FFlag(5);
FreeDTM(Walk1DDTM);
DTMRotated(Walk2DDTM, x, y, MMX1, MMY1, MMX2, MMY2);
Mouse(x, y, 4, 4, True);
FFlag(5);
FreeDTM(Walk2DDTM);
end;

procedure WalkToBank;
begin
DTMRotated(Walk3DDTM, x, y, MMX1, MMY1, MMX2, MMY2);
Mouse(x, y, 4, 4, True);
FFlag(5);
FreeDTM(Walk3DDTM);
DTMRotated(Walk4DDTM, x, y, MMX1, MMY1, MMX2, MMY2);
Mouse(x, y, 4, 4, True);
FFlag(5);
FreeDTM(Walk4DDTM);
end;


begin
SetupSRL;
ActivateClient;
WalkToTanner;
WalkToBank;
end.

All the DDTM's worked at the time I made them and all my AutoColor functions correctly output the colors they should.

Please help!

Iroki

2009-04-12 08:34:59

Try to change areaShape to 0 and i think that AreaSize := 16; is too much i think 4 is max. Maybe it can help but i'm not sure.

Gearsnare

2009-04-12 10:39:47

I think it had to do with all the memory it was using, I tried on a different computer and it just froze. Now I've made DDTMs with 4 points and they seem to be working perfectly!

Thanks for your help.

Edit: My script was working perfectly, then 5 minutes later and start getting the error again.

The DDTMs work but then suddenly stop working, I don't understand why.

Iroki

2009-04-12 17:40:36

insted useing:

procedure WalkToTanner;
begin
DTMRotated(Walk1DDTM, x, y, MMX1, MMY1, MMX2, MMY2);
Mouse(x, y, 4, 4, True);
FFlag(5);
FreeDTM(Walk1DDTM);
DTMRotated(Walk2DDTM, x, y, MMX1, MMY1, MMX2, MMY2);
Mouse(x, y, 4, 4, True);
FFlag(5);
FreeDTM(Walk2DDTM);
end;
use:

procedure WalkToTanner;
var
DTM: integer;
begin
DTM := Walk1DDTM;
DTMRotated(DTM, x, y, MMX1, MMY1, MMX2, MMY2);
Mouse(x, y, 4, 4, True);
FFlag(5);
// FreeDTM(DTM);
DTM := Walk2DDTM;
DTMRotated(DTM, x, y, MMX1, MMY1, MMX2, MMY2);
Mouse(x, y, 4, 4, True);
FFlag(5);
FreeDTM(DTM);
end;

It should help.

Kasi

2009-04-12 20:01:17

do u get a file access error?

Gearsnare

2009-04-12 21:10:36

I think it had to do with not being able to find the DDTMs, I have created new ones and they seem to be working.


program TouchWood;

var
Luck: Integer;

begin
Luck := Luck + 50;
end.

Kasi

2009-04-12 21:12:34

i had the same problem i did the same thing u did made new dtms and then i redownloaded includes and the old 1's worked again

Nava2

2009-04-12 22:00:52

Make sure that the DTM reference doesn't = 0. So check the integer to see if it is 0 or a number. :)

Remember, the integer you set a DTM to is just a pointer to the memory where the DTM is stored.

Iroki

2009-04-13 05:29:36


procedure WalkToTanner;
begin
DTMRotated(Walk1DDTM, x, y, MMX1, MMY1, MMX2, MMY2);//creating DTM in memory and serching it
Mouse(x, y, 4, 4, True);
FFlag(5);
FreeDTM(Walk1DDTM);// creating another one DTM in memory and freeing it
...
end;
Maybe i'm wrong??

Gearsnare

2009-04-13 08:06:42

From: Iroki

procedure WalkToTanner;
begin
DTMRotated(Walk1DDTM, x, y, MMX1, MMY1, MMX2, MMY2);//creating DTM in memory and serching it
Mouse(x, y, 4, 4, True);
FFlag(5);
FreeDTM(Walk1DDTM);// creating another one DTM in memory and freeing it
...
end;
Maybe i'm wrong??


Might be but I still had the errors when I set each one individually, if anyone knows if this code actually frees the DDTMs please say.


function LoadDDTM(DDTMNumber: Integer): Integer;
var
dtmMainPoint: TDTMPointDef;
dtmSubPoints: array[0..3] of TDTMPointDef;
TempTDTM: TDTM;
begin
case DDTMNumber of
1:
begin
dtmMainPoint.x := 133;
dtmMainPoint.y := 27;
dtmMainPoint.AreaSize := 0;
dtmMainPoint.AreaShape := 0;
dtmMainPoint.Color := 255;
dtmMainPoint.Tolerance := 255;

dtmSubPoints[0].x := 133;
dtmSubPoints[0].y := 27;
dtmSubPoints[0].AreaSize := 0;
dtmSubPoints[0].AreaShape := 0;
dtmSubPoints[0].Color := 255;
dtmSubPoints[0].Tolerance := 255;

dtmSubPoints[1].x := 79;
dtmSubPoints[1].y := 48;
dtmSubPoints[1].AreaSize := 0;
dtmSubPoints[1].AreaShape := 0;
dtmSubPoints[1].Color := FloorColor;
dtmSubPoints[1].Tolerance := 0;

dtmSubPoints[2].x := 98;
dtmSubPoints[2].y := 91;
dtmSubPoints[2].AreaSize := 0;
dtmSubPoints[2].AreaShape := 0;
dtmSubPoints[2].Color := FloorColor;
dtmSubPoints[2].Tolerance := 0;

dtmSubPoints[3].x := 130;
dtmSubPoints[3].y := 60;
dtmSubPoints[3].AreaSize := 0;
dtmSubPoints[3].AreaShape := 0;
dtmSubPoints[3].Color := CactiColor;
dtmSubPoints[3].Tolerance := 0;
end;
end;
TempTDTM.MainPoint := dtmMainPoint;
TempTDTM.SubPoints := dtmSubPoints;
Result := AddDTM(TempTDTM);
end;

procedure Walking;
DTMRotated(LoadDDTM(1), x, y, MMX1, MMY1, MMX2, MMY2);
Mouse(x, y, 2, 2, True);
FFlag(5);
FreeDTM(LoadDDTM(1));

Frt

2009-04-13 08:09:17

function LoadDDTM(DDTMNumber: Integer): Integer;
var
dtmMainPoint: TDTMPointDef;
dtmSubPoints: array[0..3] of TDTMPointDef;
TempTDTM: TDTM;
begin
case DDTMNumber of
1:
begin
dtmMainPoint.x := 133;
dtmMainPoint.y := 27;
dtmMainPoint.AreaSize := 0;
dtmMainPoint.AreaShape := 0;
dtmMainPoint.Color := 255;
dtmMainPoint.Tolerance := 255;

dtmSubPoints[0].x := 133;
dtmSubPoints[0].y := 27;
dtmSubPoints[0].AreaSize := 0;
dtmSubPoints[0].AreaShape := 0;
dtmSubPoints[0].Color := 255;
dtmSubPoints[0].Tolerance := 255;

dtmSubPoints[1].x := 79;
dtmSubPoints[1].y := 48;
dtmSubPoints[1].AreaSize := 0;
dtmSubPoints[1].AreaShape := 0;
dtmSubPoints[1].Color := FloorColor;
dtmSubPoints[1].Tolerance := 0;

dtmSubPoints[2].x := 98;
dtmSubPoints[2].y := 91;
dtmSubPoints[2].AreaSize := 0;
dtmSubPoints[2].AreaShape := 0;
dtmSubPoints[2].Color := FloorColor;
dtmSubPoints[2].Tolerance := 0;

dtmSubPoints[3].x := 130;
dtmSubPoints[3].y := 60;
dtmSubPoints[3].AreaSize := 0;
dtmSubPoints[3].AreaShape := 0;
dtmSubPoints[3].Color := CactiColor;
dtmSubPoints[3].Tolerance := 0;
end;
end;
TempTDTM.MainPoint := dtmMainPoint;
TempTDTM.SubPoints := dtmSubPoints;
Result := AddDTM(TempTDTM);
end;

procedure Walking;
var
DTM: Integer;
begin
DTM := LoadDDTM(1);
DTMRotated(DTM, x, y, MMX1, MMY1, MMX2, MMY2);
Mouse(x, y, 2, 2, True);
FFlag(5);
FreeDTM(DTM);
end;

You need to put the DDTM in a variable. Otherwise you will load it two times.
This way you loads it into a variable, searches for it and then frees the variable :)

Iroki

2009-04-13 09:33:23

look at 10th post