SRL Archive - SRL Archives

Function GetDamageIn(x1, y1, x2, y2: LongInt): Array Of Integer;


Wizzup?

2007-06-15 13:07:07

It searches for damage splashes in x1, y1, x2 ,y2.
Make sure you got chat effects on off, in case someone starts typing in white.

I let the debug in, so you can see what it does.

I'll make one later that returns the position on every damage splash on the screen.

program New;

Function NearbyPointInArray(P: TPoint; Dist:Integer; a: TPointArray): Boolean;

Var
I: Integer;

Begin
For I := 0 To GetArrayLength(a) - 1 Do
If (Abs(P.x - a[i].x) <= Dist) And (Abs(P.y - a[i].y) <= Dist) Then
Begin
Result := True;
Exit;
End;
End;

Function RearrangeAndShortenArray(a: TPointArray): TPointArray;

Var
I: Integer;

Begin
For I := 0 To GetArrayLength(a) - 1 Do
If Not NearbyPointInArray(a[I], 14, Result) Then
Begin
SetArrayLength(Result, GetArrayLength(Result) + 1);
Result[GetArrayLength(Result) - 1] := a[I];
End;
End;

Function GetDamage(x, y: integer): String;

Begin
Result := GetTextAtEx(x, y, 0, StatChars, False, False, 0,
3, 16777215, 2, False, tr_Digits);
End;

Function GetDamageIn(x1, y1, x2, y2: LongInt): Array Of Integer;

Var
Width, Height, ClientBMP, I, TempH: LongInt;
Points, YATPA: TPointArray;

Begin
TempH := GetClientWindowHandle;

DisplayDebugImgWindow(Width, Height);
GetClientDimensions(Width, Height);
ClientBMP := BitmapFromString(Width, Height, '');
CopyClientToBitmap(ClientBMP, 0, 0, Width, Height);
SafeDrawBitmap(ClientBMP, GetDebugCanvas, 0, 0);
DisplayDebugImgWindow(Width, Height);
SetTargetBitmap(ClientBMP);
FindColorsTolerance(YATPA, 16777215, x1, y1, x2, y2, 0);
Points := ReArrangeAndShortenArray(YATPA);
SetArrayLength(Result, GetArrayLength(Points));
For I := 0 To GetArrayLength(Points) - 1 Do
Begin
Points[I].X := Points[I].X - 5;
Points[I].Y := Points[I].Y - 2;
FindColor(Points[I].X, Points[I].Y, 16777215, Points[I].X, Points[I].Y,
Points[I].X + 8, Points[I].Y + 5);
Points[I].X := Points[I].X - 3;
Points[I].Y := Points[I].Y - 1;
Try
Result[I] := StrToInt(Trim(GetDamage(Points[I].X, Points[I].Y)));
Except Result[I] := -1 End;
WriteLn(IntToStr(Result[I]));
FastSetPixel(ClientBMP, Points[I].X, Points[I].Y, 65280);
End;
SafeDrawBitmap(ClientBMP, GetDebugCanvas, 0, 0);
DisplayDebugImgWindow(Width, Height);
FreeBitmap(ClientBMP);
SetClientWindowHandle(TempH);
End;

Var
I1, I2: Integer;
begin
i1 := getsystemtime;
GetDamageIn(MSX1, MSY1, MSX2, MSY2);
i2 := getsystemtime;
writeln('time '+inttostr(i2-i1));
end.

~ Wizzup?

bullzeye95

2007-06-15 13:20:43

I'm in a perfect spot to test. I'll edit my post after I'm done testing ;)

EDIT: It works perfectly, great job! BUT it sometimes writes -1 into the debug box.

nielsie95

2007-06-15 13:25:31

Nice! This could come handy in Fighters; to see if you/mosters are in fight :).

Santa_Clause

2007-06-16 03:21:36

I'll be using this, thanks Wizzup?

Wizzup?

2007-06-16 07:54:29

From: bullzeye95
I'm in a perfect spot to test. I'll edit my post after I'm done testing ;)

EDIT: It works perfectly, great job! BUT it sometimes writes -1 into the debug box.


Thats when it finds the whitecolor on the MS while there is no Number.
I'll make it filter those. :)

n3ss3s

2007-06-20 09:07:48

Gj!! I'll propably use that if I ever make an autofighter.

Wizzup?

2007-06-20 10:47:34

From: n3ss3s
Gj!! I'll propably use that if I ever make an autofighter.


I am making one. ;)

Bobarkinator

2007-06-20 10:53:51

public?

Wizzup?

2007-06-20 11:38:39

From: bobarkinator
public?


Problaby, and I forgot to mention I am making it together with Lorax.

Mjordan

2007-06-20 11:40:23

From: Wizzup?
Problaby, and I forgot to mention I am making it together with Lorax.

Awesome! It's gonna own!

Bobarkinator

2007-06-20 11:43:29

Yay new script from Wizzy and with Lorax!!! I can't wait. Will probably be perfect for training my guys.

Dan Cardin

2007-06-21 13:49:42

i got[BANANA]//i edited the way it was written
2
88, 88
88, 88
15, 88
88, 88
88, -1
88, 88
-1, -1
88, 88
88, 88
88, -1
88, 88
88, 88
88, 88
88, 88
88, 88
88, 88
9, 88
-1, 88
88
88
88
1
88
88
time 25516[/BANANA]i know what -1 is…but no one hit a 15 and whats the 88's? also, is there a way to make sure that its you or your opponent, and not someone else in the screen being attacked?