SRL Archive - SRL Suggestions

Fighting.Scar InFight;


NCDS

2010-03-12 00:14:44

Me and IceFire got together on the IRC and put this together, as requested by Mr. Doctor(Junkj).

Basically what it does is; it searches for both the red and green parts of the HPbar and makes sure it's yours with a distance check.

I tested it a few times and it worked awesome. If you have a problem with it though be sure to let me know.


{*******************************************************************************
Function InFight: Boolean;
By: NCDS & IceFire908
Description: Result's true if HP bar is found above characters head.
*******************************************************************************}
function InFight: Boolean;
var
CPointArr: array [0..1] of TPointArray;
TColorInfo: TVariantArray;
MDAr: T2DPointArray;
I, CTS: Integer;
HPbar: TPoint;
begin { Green | Red }
TColorInfo := [0.81, 0.00, 52608, 3, 0.19, 0.45, 465114, 4];
cts := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
for I := 0 to 1 do
begin
SetColorSpeed2Modifiers(TColorInfo[I * 4], TColorInfo[(I * 4) + 1]);
FindColorsSpiralTolerance(MSCx, MSCy, CPointArr[I], TColorInfo[(I * 4) + 2],
MSCx - 100, MSCy - 75, MSCx + 100, MSCy + 75, TColorInfo[(I * 4) + 3]);
if (I = 0) then
if (Length(CPointArr[0]) < 4) then
Break;
end;
SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(cts);
if (I = 0) then
Exit;
CPointArr[0] := CombineTPA(CPointArr[0], CPointArr[1]);
MDAr := TPAToATPAEx(CPointArr[0], 55, 7);
if Length(MDAr) < 1 then
Exit;
SortATPAFromFirstPoint(MDAr, Point(MSCx, MSCy));
if Length(MDAr[0]) < 30 then
Exit;
HPbar := MiddleTPA(MDAr[0]);
Result := (Distance(HPbar.x, HPbar.y, MSCx, MSCy) <= 70);
end;

Wanted

2010-03-12 00:21:40

Only thing I'm worried about is false positives… like in weird locations. Would be good to get feedback from various locations from various people.

NCDS

2010-03-12 00:25:23

That would have happened with the other one just as much, if at all. It searches for the same colors in the same area, just this one work's. ;)

Coh3n

2010-03-12 00:32:34

Nice. Couldn't one of marpis's animating functions be used for this?

NCDS

2010-03-12 00:35:46

From: Coh3n
Nice. Couldn't one of marpis's animating functions be used for this?


I thought about that before we got into writing this, but I personally haven't used Animation.scar really so I just stuck to what I'm "good" at. :p

Coh3n

2010-03-12 00:36:54

From: NCDS
I thought about that before we got into writing this, but I personally haven't used Animation.scar really so I just stuck to what I'm "good" at. :p

Well that's probably not such a bad idea. :p

YoHoJo

2010-03-12 01:59:12

I don't think it would be easy to not get false positives, so many angles/views/compass stuff. Its just up to the scripter to be on HighestAngle to reduce possibilities of false positives, great job you two.

marpis

2010-03-12 02:15:54

When you rotate the compass the position of your hpbar greatly changes.
You should take that into account and decrease the max distance. (currently 70)

a := Round(rs_GetCompassAngleDegrees);
while (a < 0) do IncEx(a, 360);
case a of
0..15: BarP := Point(xxx, yyy);
16..30: BarP := Point(xxx, yyy);
etc
end;

NCDS

2010-03-12 06:33:19

From: marpis
When you rotate the compass the position of your hpbar greatly changes.
You should take that into account and decrease the max distance. (currently 70)

a := Round(rs_GetCompassAngleDegrees);
while (a < 0) do IncEx(a, 360);
case a of
0..15: BarP := Point(xxx, yyy);
16..30: BarP := Point(xxx, yyy);
etc
end;


I have to go to work here in a minute, but when I get back I'll look into that. Thanks for pointing that out!

Mr. Doctor

2010-03-12 16:52:20

I will test this in different locations and report here. Testing…

E: I was at Port Sarim where my script is, and it only worked when the compass was North and West, but not South and East. But in Lumbridge Forest, it never worked when my compass was North. It did detect about two false positives(Maybe because of the trees?) I am willing to test more. Any suggestions where?