i luffs yeww
2010-07-03 04:35:21
Not really important, but a few things about the test scripts aren't working for me.
bitmapfloodfill doesn't show anything. I'm not sure if it's supposed to, but it just compiles and executes.
BmpTest doesn't find the bitmap.
colour conversions has r, g, b set to bytes. They should be integers.
ColourTest2 uses bmppath = 'C:\Carina_1_by_Eeitam.png'; as the bitmap; that's not something everyone has. I used ScriptPath + '/smart.bmp' instead. I can't seem to fix the error.. I don't know what causes it.
Error: Exception: Target bitmap was destroyed! at line 30
debugimageform had unfreed bitmaps (not that it matters in Simba).
Deformedtest had an unfreed bitmap and unused variable.
dtmtest still had pdtm. I don't recall the changed type.
dtmtest2 also had pdtm.
FileTests gave exception errors for ReWriteFile and OpenFile. May be Windows 7, may be the script. Not sure.
loadsystemfont had an unfreed bitmap.
MaskTest had unused variables and an unfreed bitmap.
Neopets_old had unused variables.
plugintest had {.LoadDLL libsmart}, while it should be {$LoadLib libsmart}.
Several bitmap operations had eight unfreed bitmaps, but I'm too lazy to fix it.
SimpleBMPLoader had unfreed bitmaps.
stringtest had an unused variable.
bitmapfloodfill doesn't show anything. I'm not sure if it's supposed to, but it just compiles and executes.
BmpTest doesn't find the bitmap.
colour conversions has r, g, b set to bytes. They should be integers.
ColourTest2 uses bmppath = 'C:\Carina_1_by_Eeitam.png'; as the bitmap; that's not something everyone has. I used ScriptPath + '/smart.bmp' instead. I can't seem to fix the error.. I don't know what causes it.
program new;
var
p1, p2: TPointArray;
w, h: integer;
i, col: integer;
bmp: integer;
begin
SetColorToleranceSpeed(2);
bmp := LoadBitmap(ScriptPath + '/smart.bmp');
SetTargetBitmap(bmp);
GetClientDimensions(W, H);
writeln(inttostr(w) + ' : ' + inttostr(h));
for i := 0 to 100 do
begin
col := Random(clWhite);
writeln(inttostr(col));
FindColorsTolerance(p1, col, 0, 0, W - 1, H - 1, 40);
FindColorsToleranceOptimised(p2, col, 0, 0, W - 1, H - 1, 40);
writeln(inttostr(length(p1)) + ' : ' + inttostr(length(p2)));
if(length(p1) <> length(p2)) then
writeln('wat!');
setlength(p1,0);
setlength(p2,0);
end;
FreeBitmap(bmp);
end.
Error: Exception: Target bitmap was destroyed! at line 30
debugimageform had unfreed bitmaps (not that it matters in Simba).
program new;
var
Bmp,x,y : integer;
DebugBmp : integer;
begin
Bmp := createbItmap(100,100);
CopyClientToBitmap(Bmp,0,0,99,99);
for x := 0 to 49 do
begin;
for y := 0 to 49 do
begin;
fastsetpixel(bmp,x,y,random(clwhite));
fastsetpixel(bmp,y,x,random(clwhite));
end;
x := x + 5;
end;
DisplayDebugImgWindow(100,100);
DrawBitmapDebugImg(bmp);
DebugBMP := GetDebugBitmap;
SaveBitmap(DebugBmp,ScriptPath + 'debugimage.bmp');
FreeBitmap(bmp);
FreeBitmap(DebugBMP);
end.
Deformedtest had an unfreed bitmap and unused variable.
program New;
//Scar manual -> you have to pick x1,y1,x2,y2 yourself. (It's at the first bitmapa
var
Deformed ,x,y: integer;
ThaTime : integer;
acc : extended;
begin
Deformed := BitmapFromString(25, 24, 'beNrN1UEKwCAMBMDtb/oO' +
'r/0//U1pISCiYUnCIpU9eRgihgTg525HD6pnRKZIkKAWEYJmjXI1F' +
'VV2IhQavpzX02M3XHOdEZmSoohj5bmUW3CWMi3rkDf+k1q1AiX/QS' +
'21aqRFuRNssP2TQTv6suDmNVFcXi/8Qvf1');
//Doing this same code in scar will result in invalid results, since
//fast replacedolor didn't work alright, atleast for me.
FastReplaceColor(Deformed,clblack,clwhite);
FastReplaceColor(deformed,82647,clblack);
ThaTime := GetSystemTime;
FindDeformedBitmapToleranceIn(Deformed, x, y, 119, 538, 213, 613, 70, 10, True, acc);
Writeln(inttostr(GetSystemTime - ThaTime));
Writeln(floattostr(acc));
FreeBitmap(Deformed);
end.
dtmtest still had pdtm. I don't recall the changed type.
dtmtest2 also had pdtm.
FileTests gave exception errors for ReWriteFile and OpenFile. May be Windows 7, may be the script. Not sure.
loadsystemfont had an unfreed bitmap.
program new;
var
Font : TFont;
bmp : integer;
begin
Font := TFont.Create;
Font.Name := 'Courier New';
Font.Size := 10;
Font.Style := [];
LoadSystemFont(Font,'test');
DisplayDebugImgWindow(0,0);
DisplayDebugImgWindow(150,50);
bmp := BitmapFromText('BMP[0] has not been freed','test');
DrawBitmapDebugImg(bmp);
Font.free;
FreeBitmap(bmp);
end.
MaskTest had unused variables and an unfreed bitmap.
program new;
//http://nl.wikipedia.org/wiki/Lily_Allen
//This finds a mask of the text 'Op 24 september',
//so target wikipedia halfway down. Might not work because of
//different font's/sizes in your browser.
var
Bmp : integer;
Mask : TMask;
x,y : integer;
w,h : integer;
begin
Bmp := BitmapFromString(107, 19, 'beNrtVkEOgCAM8/+fxoOJUYG' +
'uWwZKbE9KtmYrHbBtgiAIgpCOckFiopdtZr/j2HhynBjYjmntJxaW' +
'6BwJWC8eH6QU15gz0Zx9vFgX0Iwhs0CASRUW8CFmioB1JFisA5qRI' +
'KvJQNKa5mEcyAhoauI6N8ymAlkxWpdtwgL2bhPXCJc7+E7JLNJsgG' +
'qQgL1jhHwX4VJdBsNZMbN5D//m/ob5XzwDp40wfg/jW9g024hbuPd' +
'ritabVqaAj7zYVyxg9fol4M8FFG7YAfIG00k=');
Mask := CreateMaskFromBitmap(Bmp);
GetClientDimensions(w,h);
// if FindBitmapMaskTolerance(Bmp,x,y,0, 0,w-1, h-1,1,5) then
if FindMaskTolerance(Mask,x,y,0, 0,w-1, h-1,1,5) then
MoveMouse(x,y);
FreeBitmap(Bmp);
end.
Neopets_old had unused variables.
program BankProblems;
// [url]http://www.neopets.com/games/play.phtml?game_id=371[/url]
Const
KeyDownUpSpeed = 1; // The Higher the "KeyDownUpSpeed", the slower the script is.
Type
Door = record
X: Integer;
Y: Integer;
DoorChar: Byte;
IsOpen: Boolean;
IsMonster: Boolean;
WhatMonster: String;
End;
Var
Doors: Array [0..5] Of Door;
Procedure DeclareStuff;
Var
I: Integer;
Begin
For I := 0 To 5 Do
Begin
Doors[I].X := 45 + I * 96;
Doors[I].Y := 210;
End;
Doors[0].DoorChar := 83;
Doors[1].DoorChar := 68;
Doors[2].DoorChar := 70;
Doors[3].DoorChar := 74;
Doors[4].DoorChar := 75;
Doors[5].DoorChar := 76;
End;
Function IsBadGuy(DN: Integer): Boolean;
Var
TempColor: Array [0..11] Of Integer;
I, x, y: Integer;
H, S, L: Extended;
Begin
TempColor[0] := GetColor(Doors[DN].X, Doors[DN].Y);
TempColor[1] := GetColor(Doors[DN].X, Doors[DN].Y-1);
TempColor[2] := GetColor(Doors[DN].X-1, Doors[DN].Y);
TempColor[3] := GetColor(Doors[DN].X, Doors[DN].Y+1);
TempColor[4] := GetColor(Doors[DN].X+1, Doors[DN].Y);
TempColor[5] := GetColor(Doors[DN].X, Doors[DN].Y-2);
TempColor[5] := GetColor(Doors[DN].X-2, Doors[DN].Y);
TempColor[6] := GetColor(Doors[DN].X+1, Doors[DN].Y+2);
TempColor[7] := GetColor(Doors[DN].X+2, Doors[DN].Y);
TempColor[8] := GetColor(Doors[DN].X, Doors[DN].Y-3);
TempColor[9] := GetColor(Doors[DN].X-3, Doors[DN].Y);
TempColor[10] := GetColor(Doors[DN].X+1, Doors[DN].Y+3);
TempColor[11] := GetColor(Doors[DN].X+3, Doors[DN].Y);
For I := 0 To 11 Do
Begin
If SimilarColors(TempColor[I], 3055, 30) Then // Red Devil
Begin
Result := True;
Doors[DN].WhatMonster := 'Devil';
Exit;
End;
End;
For I := 0 To 11 Do
Begin
If SimilarColors(TempColor[I], 12841714, 40) Then // Squirrle
Begin
ColorToHSL(TempColor[I], H, S, L);
If (L > 60) And (L < 95) Then
If (H > 5 ) And (H < 30) Then
If FindColorTolerance(x, y, 4092580, Doors[DN].X, Doors[DN].Y-1,
Doors[DN].X + 20, Doors[DN].Y + 1, 40)
Then
Begin
Result := True;
Doors[DN].WhatMonster := 'Squirrle';
Exit;
End;
End;
End;
For I := 0 To 11 Do
Begin
If SimilarColors(TempColor[I], 28756, 30) Then // Green Monster
Begin
Result := True;
Doors[DN].WhatMonster := 'Green Monster';
Exit;
End;
End;
For I := 0 To 11 Do
Begin
If SimilarColors(TempColor[I], 794793, 30) Then // Mysterious Man
Begin
Result := True;
Doors[DN].WhatMonster := 'Mysterious Man';
Exit;
End;
End;
End;
Procedure HandleMonsters;
Var
I: Integer;
Begin
For I := 0 To 5 Do
Begin
If IsBadGuy(I) Then
Begin
KeyDown(Doors[I].DoorChar);
Wait(10 * KeyDownUpSpeed);
KeyUp(Doors[I].DoorChar);
End;
End;
End;
Procedure AddToGold;
Begin
If GetColor(388, 25) = 0 Then
Begin
Wait(100);
KeyDown(32);
Wait(10 * KeyDownUpSpeed);
KeyUp(32);
End;
End;
begin
//ClearDebug;
DeclareStuff;
Repeat
AddToGold;
HandleMonsters;
Wait(10);
Until False;
end.
plugintest had {.LoadDLL libsmart}, while it should be {$LoadLib libsmart}.
Several bitmap operations had eight unfreed bitmaps, but I'm too lazy to fix it.
SimpleBMPLoader had unfreed bitmaps.
stringtest had an unused variable.
program new;
type
LetsDoThis = record
str : string;
x,y : integer;
end;
LetsDoThis2 = record
str : string;
pt : TPoint;
end;
Yeah = array of LetsDoThis2;
ArrThis = array of yeah;
var
x : LetsDoThis;
y : arrthis;
i,ii : integer;
begin
x.str := 'Testmebitch';
x.x := 500;
x.y := -900;
Writeln(x);
SetLength(y,2);
for i := 0 to high(y) do
begin;
setlength(y[i],2);
for ii := 0 to high(y[i]) do
begin;
y[i][ii].pt := Point(i*5,-random(9000));
y[i][ii].str := format('[%d][%d]=%s',[i,ii,tostr(y[i][ii].pt)]);
end;
end;
Writeln(y);
Writeln(TPointArray([Point(5,5),Point(20,1337),point(1,2)]));
end.