SRL Archive - SRL Archives

Object.scar Shorten


MylesMadness

2009-10-25 14:11:12

{*******************************************************************************
function FindObjTPAMulti(var X, Y: integer; Color: TIntegerArray; Tol, CTS, ObjWidth, ObjHeight, minCount :Integer; UpText: TStringArray): Boolean;
By: Wizzup?
Description: This is a modification of FindObjTPA, which uses a TIntegerArray for the Colors.
Date: 29th August 2009
*******************************************************************************}
function FindObjTPAMulti(var X, Y: Integer; Colour: TIntegerArray; Tol, CTS, ObjWidth, ObjHeight, minCount: Integer; UpText: TStringArray): Boolean;
var
i, tCTS: Integer;
myPoint: TPoint;
aPoints: T2DPointArray;
ATPA: T2DPointArray;
TPA: TPointArray;
begin
Result := False;
if not LoggedIn then exit;
tCTS := GetColorToleranceSpeed;
if CTS * 9 mod 3 <> 0 then
CTS := 1;
ColorToleranceSpeed(CTS);
SetLength(ATPA, Length(Colour));
for i := 0 to High(Colour) do
begin
FindColorsSpiralTolerance(x, y, ATPA[i], Colour[i], MSX1, MSY1, MSX2, MSY2, Tol);
end;
TPA := MergeATPA(ATPA);
if Length(TPA) = 0 then
begin
ColorToleranceSpeed(tCTS);
Exit;
end;
ColorToleranceSpeed(1);
aPoints := TPAtoATPAEx(TPA, ObjWidth, ObjHeight);
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);
if WaitUpTextMulti(UpText, 300) then
begin
GetMousePos(X, Y);
Result := True;
ColorToleranceSpeed(tCTS);
Exit;
end;
end;

ColorToleranceSpeed(tCTS);
end;
{*******************************************************************************
function FindObjTPA(var x, y: integer; color, tol, cts, ObjWidth, ObjHeight, minCount :Integer; UpText: tstringarray): Boolean;
By: Wizzup?
Description: Finds object using WizzyPlugin functions.
Starts with a Spiral from x and y.
Put in the color, Tolerance and ColorToleranceSpeed.
If you don't know what colortolerancespeed to choose, put in -1.
ObjWidth and ObjHeight are the parameters TPAToATPAEx uses, thus filtering
the MS's FindColorsSpiralTolerance points in boxes defined by
ObjWidth and ObjHeigth.
minCount is the amount of colors it should at least find in a Object box.
UpText, is ofcourse the text the object should have. In the Multi variant the
UpText is a string array.

*******************************************************************************}

function FindObjTPA(var X, Y: Integer; Color, Tol, CTS, ObjWidth, ObjHeight, minCount: Integer; UpText: TStringArray): Boolean;
begin
Result:=FindObjTPAMulti(X, Y, [Color], Tol, CTS, ObjWidth, ObjHeight, minCount, UpText);
end;

Just a little shorten

Naum

2009-10-25 14:23:53

Good work, I can't believe I hadn't spotted it :(. Rep++

Just while we're at it:

  if CTS * 9 mod 3 <> 0 then
CTS := 1;

to:

CTS := Integer(CTS * 9 mod 3 <> 0);


Furthermore:


  for i := 0 to High(Colour) do
begin
FindColorsSpiralTolerance(x, y, ATPA[i], Colour[i], MSX1, MSY1, MSX2, MSY2, Tol);
end;

to:

  for i := 0 to High(Colour) do
FindColorsSpiralTolerance(x, y, ATPA[i], Colour[i], MSX1, MSY1, MSX2, MSY2, Tol);

Torrent of Flame

2009-10-25 14:38:13

The hell, I wrote FindObjTPAMutli :P

Well. Modded it.

n2 edit: no swears, son.

MylesMadness

2009-10-25 15:26:15

From: Torrent of Flame
The hell, I wrote FindObjTPAMutli :P

Well. Modded it.

n2 edit: no swears, son.
Modded wizzup's code, so basicly, since his code was gone I thought he technically wrote it so he should get credit. The devs can decide who to give credit to.

Torrent of Flame

2009-10-25 15:50:33

From: MylesMadness
Modded wizzup's code, so basicly, since his code was gone I thought he technically wrote it so he should get credit. The devs can decide who to give credit to.


true true. fair gain son.

MylesMadness

2010-01-05 21:21:52

Bump, this still isn't done…

MylesMadness

2010-05-08 11:20:26

Still hasn't been done…

Frement

2010-05-08 11:21:51

Maybe go rape someones private in irc? :D

Sex

2010-05-08 15:51:35

Who cares -_-.

Wizzup?

2010-05-08 18:37:33

From: Naum
Good work, I can't believe I hadn't spotted it :(. Rep++

Just while we're at it:

  if CTS * 9 mod 3 <> 0 then
CTS := 1;

to:

CTS := Integer(CTS * 9 mod 3 <> 0);


Please don't do this. It's not a proper way of coding. It makes several assumption that aren't really viable, and it is less readable too.

Naum

2010-05-08 18:44:19

From: Wizzup?
Please don't do this. It's not a proper way of coding. It makes several assumption that aren't really viable, and it is less readable too.


That was roughly half a dozen months ago. My fixation with distilling code has long since passed.
On another note, would someone please be able to commit this? (since i can't atm):)

Wanted

2010-05-08 19:11:40

I never found object.scar to be useful.

Awkwardsaw

2010-05-08 19:16:55

From: IceFire908
I never found object.scar to be useful.


its useful for the newbs that haven't learned tpas yet :)

Coh3n

2010-05-11 16:11:22

From: IceFire908
I never found object.scar to be useful.

Just because you don't, doesn't mean other people don't. ;)

Sex

2010-05-11 18:13:42

From: Coh3n
Just because you don't, doesn't mean other people don't. ;)

That comma doesn't belong there.

Wizzup?

2010-05-11 20:16:11

From: Naum
That was roughly half a dozen months ago. My fixation with distilling code has long since passed.
On another note, would someone please be able to commit this? (since i can't atm):)


Whoops. Sorry! :)
We'll fix you an account soon, too.

Coh3n

2010-05-11 20:18:45

From: Wizzup?
Whoops. Sorry! :)
We'll fix you an account soon, too.

Please and thank-you. :D

bullzeye95

2010-05-11 20:34:51

  if CTS * 9 mod 3 <> 0 then
CTS := 1;
That has no purpose. If an integer is multiplied by 9, it will always be divisible by 3.

MylesMadness

2010-05-11 21:16:34

From: bullzeye95
  if cts * 9 mod 3 <> 0 then
cts := 1;
that has no purpose. If an integer is multiplied by 9, it will always be divisible by 3.
cts = 0?

bullzeye95

2010-05-11 21:23:23

Even in that case, it still returns 0.

MylesMadness

2010-05-11 21:52:45

So CTS will always be one?

i luffs yeww

2010-05-11 23:34:32

Yes. You catch on quick. :)

marpis

2010-05-16 14:26:20

From: MylesMadness
So CTS will always be one?


No, CTS will always be the one in the parameter.
CTS * 9 mod 3 <> 0
always returns false, so the "then" statement will never be called.

E: Now that I look at the function, I see that
FindColorsSpiralTolerance(x, y, ATPA, Colour, MSX1, MSY1, MSX2, MSY2, Tol);
always starts searching from variables x, y which will most likely be 0, 0. Should be changed to MSCX, MSCY.