SRL Archive - SRL Archives

Fighting.scar Addition / Fix


Frement

2010-02-07 13:00:04

Ok so i noticed InFight did not work all the times and gave false results when i was not fighting.

Heres a function i made:
function InFight: Boolean;
var GTPA, RTPA: TPointArray;
begin
FindColorsTolerance( GTPA, 49499, MSCX - 20, MSCY - 30, MSCX + 20, MSCY - 10, 20 );
FindColorsTolerance( RTPA, 590010, MSCX - 20, MSCY - 30, MSCX + 20, MSCY - 10, 20 );
Result := ( ( GetArrayLength( GTPA ) + GetArrayLength( RTPA ) ) >= 20 );
end;

jimmy_mac

2010-02-07 21:43:08

yeh looks good. but the dimensions are too far out.
maybe this:
function InFight: Boolean;
var GTPA, RTPA: TPointArray;
begin
FindColorsTolerance(GTPA, 49499, MSCX-5, MSCY-40, MSCX+5, MSCY-5, 25);
FindColorsTolerance(RTPA, 590010, MSCX-5, MSCY-40, MSCX+5, MSCY-5, 25);
Result := ((GetArrayLength(GTPA) + GetArrayLength(RTPA)) >= 20);
end;

Frement

2010-02-08 01:15:18

From: jimmy_mac
yeh looks good. but the dimensions are too far out.
maybe this:
function InFight: Boolean;
var GTPA, RTPA: TPointArray;
begin
FindColorsTolerance(GTPA, 49499, MSCX-5, MSCY-40, MSCX+5, MSCY-5, 25);
FindColorsTolerance(RTPA, 590010, MSCX-5, MSCY-40, MSCX+5, MSCY-5, 25);
Result := ((GetArrayLength(GTPA) + GetArrayLength(RTPA)) >= 20);
end;


The dimensions are good, If the mob your are fighting is north from you and someone else is hitting it too, your hits to it might go over the hp bar. Then it wouldnt find that many colors and it would fail on it.

Heres an image indicating my search area and yours:

jimmy_mac

2010-02-08 01:36:42

ok. those were just rough estimates. which seemed to work. but your original code detects others fighting nearby you which results in a false positive. maybe use dtms. unless you can make it more accurate.

Frement

2010-02-08 01:40:16

I tested it several times and i did not notice that kind of effect, and i cant even see how it could.

EDIT: Made the box 40x20 and it seems to work nicely now. Still not detecting fights near me.
function InFight: Boolean;
var GTPA, RTPA: TPointArray;
begin
FindColorsTolerance( GTPA, 49499, MSCX - 20, MSCY - 30, MSCX + 20, MSCY - 10, 20 );
FindColorsTolerance( RTPA, 590010, MSCX - 20, MSCY - 30, MSCX + 20, MSCY - 10, 20 );
Result := ( ( GetArrayLength( GTPA ) + GetArrayLength( RTPA ) ) >= 20 );
end;

jimmy_mac

2010-02-08 01:54:42

Just tested yours then your y-range is out, it needs to be greater than 30 pixels, i think 46 pixels from the center is the greatest i have found. still checking tho.
for example with your code, this is a false positive:

Frement

2010-02-08 01:56:31

True, and my mistake was not to check those angles, i only checked on N, E, S, W.

EDIT: This is what i got so far and it seems to work:
function InFight: Boolean;
var GTPA, RTPA: TPointArray;
begin
FindColorsTolerance( GTPA, 49499, MSCX - 15, MSCY - 40, MSCX + 15, MSCY, 20 );
FindColorsTolerance( RTPA, 590010, MSCX - 15, MSCY - 40, MSCX + 15, MSCY, 20 );
Result := ( ( GetArrayLength( GTPA ) + GetArrayLength( RTPA ) ) >= 20 );
end;
EDIT2: Maybe use PixelShift also? If it finds the hp bar it would check pixels that change in MSCX+5, MSCY+5,MSCX-5, MSCY-5?

jimmy_mac

2010-02-08 02:11:32

dont the bars stay in the same spot no matter which direction your facing?

Frement

2010-02-08 02:14:28

Nope, you can try rotating the angle when near a fight.

Sir R. M8gic1an

2010-02-08 04:59:54

I had a look at my cow fighter just now, for which I developed a different InFight. This was before the HP bar update, buth concept can still be used.

Get a TPA of the green part ofthe HP bar 100 pc around you. (x- 100, x + 100, y - 100, y + 100)

TPAToATPA
And the sort the TPAs fro mthe distance to you. Then it's jsut a questin of finding the rght distance.

The main advantage of this is that it only checks the green part. The HP bar after dead still hangs there for a while, returning a false positive when the NPC is already dead.

~RM

NCDS

2010-03-11 20:48:34

From: Rasta Magician
I had a look at my cow fighter just now, for which I developed a different InFight. This was before the HP bar update, buth concept can still be used.

Get a TPA of the green part ofthe HP bar 100 pc around you. (x- 100, x + 100, y - 100, y + 100)

TPAToATPA
And the sort the TPAs fro mthe distance to you. Then it's jsut a questin of finding the rght distance.

The main advantage of this is that it only checks the green part. The HP bar after dead still hangs there for a while, returning a false positive when the NPC is already dead.

~RM


Something like this..?

function N_InFight: Boolean;
var
Arr: array of TPoint;
begin
FindColorsSpiralTolerance(MSCx, MSCy, Arr, 51837, MSCx - 100, MSCy - 75, MSCx + 100, MSCy + 75, 8);
if Length(Arr) = 0 then
Exit;
RemoveDistTPointArray(MSCx, MSCy, 70, Arr, True);
Result := (Length(Arr) > 1);
end;
It has worked everytime for me so far. The color should be set to a constant in SRL though, IMO at least.

Mr. Doctor

2010-03-11 20:54:23

From: NCDS
Something like this..?

function N_InFight: Boolean;
var
Arr: array of TPoint;
begin
FindColorsSpiralTolerance(MSCx, MSCy, Arr, 51837, MSCx - 100, MSCy - 75, MSCx + 100, MSCy + 75, 8);
if Length(Arr) = 0 then
Exit;
RemoveDistTPointArray(MSCx, MSCy, 70, Arr, True);
Result := (Length(Arr) > 1);
end;
It has worked everytime for me so far. The color should be set to a constant in SRL though, IMO at least.


Tested it, worked from start to end perfectly. I also posted a thread about this but it fell to the bottom and this one was made. :l