SRL Archive - OSR Help

Method to detect if fighting.


Frement

2010-02-07 04:07:22

At the moment i use InFight, but it gives false results when there are others fighting near me. Should i use PixelShift?

Any other ideas how to detect if in fight? Thanks in advance :)

TRiLeZ

2010-02-07 04:09:19

Check for hp bar right above your head.

Frement

2010-02-07 04:09:58

From: TRiLeZ
Check for hp bar right above your head.


I have not checked what InFight does but i thought it does that. Well thanks for the idea :)

TRiLeZ

2010-02-07 04:12:08

From: Frement
I have not checked what InFight does but i thought it does that. Well thanks for the idea :)


InFight looks for the hp bar in a big area. What I'm saying to do is look for the hp bar in a really small area. Hmm.. I may make a new InFight function…

Frement

2010-02-07 04:15:39

From: TRiLeZ
InFight looks for the hp bar in a big area. What I'm saying to do is look for the hp bar in a really small area. Hmm.. I may make a new InFight function…


I just checked and my area only differs few pixels.

The box i got just now: (225, 120, 290, 145)
And the box in InFight: (200, 130, 280, 180)

NCDS

2010-02-07 04:18:09

It seems odd that SRL's current InFight wouldn't just search a box above your char's head. Hmmm..


You could try out some Animation.scar functions though ;)

Frement

2010-02-07 04:34:08

From: NCDS
It seems odd that SRL's current InFight wouldn't just search a box above your char's head. Hmmm..


You could try out some Animation.scar functions though ;)


Yes, pixelshift is my next thing to try out. If i dont get out a working function from the HP bar. I cant seem to get my CountColor to work properly, and CountColorTolerance doesnt either. Returns 0 even if i check with the colorpicker that theres that color.

NCDS

2010-02-07 04:37:24

From: Frement
Yes, pixelshift is my next thing to try out. If i dont get out a working function from the HP bar. I cant seem to get my CountColor to work properly, and CountColorTolerance doesnt either. Returns 0 even if i check with the colorpicker that theres that color.


That's odd..assuming you have everything up to date, try restarting everything.

Color counting is usually my "go to" method as well ;)

Frement

2010-02-07 04:41:40

Still wont work properly, here are the colors im using:
9984 //Green outline 1
10496 //Green outline 2
198716 //Red outline 1
All counts combined should result in 90+.

TRiLeZ

2010-02-07 04:56:36


Search for hp bar colors in that box. Don't count colors though.

Frement

2010-02-07 05:59:31

From: TRiLeZ

Search for hp bar colors in that box. Don't count colors though.


Yeah great idea, this is what i came up with:
function F_InFight: Boolean;
var x, y: Integer;
begin
Result := False;
if ( FindColorTolerance( x, y, 49499, 258, 137, 272, 164, 2 ) ) then
Result := True;
end;
Works 100% :)

EDIT: Restarted scar etc and now it stopped working. Whats going on with my color finding functions :D
EDIT2: The search area must be wider because the hits get on the way.

EDIT3: This is the final function, works good (now that my color finding works lol).
function F_InFight: Boolean;
var x, y: Integer;
begin
Result := FindColorTolerance( x, y, 49499, 226, 118, 262, 147, 40 );
end;

NCDS

2010-02-07 10:10:00

By "color counting" findcolor… Is what I meant. Just seemed easier to explain then the feared TPA . Also
you may want to have an amount to compare it to. Currently it will return true if it finds that color at all. Where as if you put result := findcolor() > 30;
that would mean that if it finds the color on more than 30 pixels in your search box it will result true. It's just sort of a failsafe. Play with that a bit.

Frement

2010-02-07 10:25:24

From: NCDS
By "color counting" findcolor… Is what I meant. Just seemed easier to explain then the feared TPA . Also
you may want to have an amount to compare it to. Currently it will return true if it finds that color at all. Where as if you put result := findcolor() > 30;
that would mean that if it finds the color on more than 30 pixels in your search box it will result true. It's just sort of a failsafe. Play with that a bit.


Yeah did that, works flawlessly :)

function F_InFight: Boolean;
var GTPA, RTPA: TPointArray;
begin
FindColorsTolerance( GTPA, 49499, 226, 118, 262, 147, 20 );
FindColorsTolerance( RTPA, 590010, 226, 118, 262, 147, 20 );
Result := ( ( GetArrayLength( GTPA ) + GetArrayLength( RTPA ) ) >= 20 );
end;