SRL Archive - SRL Suggestions

Fighting.scar - IsFighting


putonajonny

2011-12-03 17:59:02

Aims to do the same thing as the infight function but works by checking the hp of the closest HP bar and then checking your HP, if this is with the Tolerance then it returns true, if not it returns false:


{*******************************************************************************
function IsFighting(Tolerance : Integer);
By: putonajonny
Description: Returns True if you are in a fight, works by checking HP of nearby HP bars and comparing
that to your HP, should have less false positives than InFight.
*******************************************************************************}
function IsFighting(Tolerance : Integer) : Boolean;
var
Hits : TIntegerArray;
HP : Integer;
begin
Result := False
Hits := GetHitsIn(253, 99, 0, 0, 764, 502);

if GetArrayLength(Hits) = 0 then
Exit;

HP := HPPercent
Result := ((HP-Tolerance) < Hits[0]) and ((HP+Tolerance) > Hits[0]);

if (GetArrayLength(Hits) > 1) and (not Result) then
Result := ((HP-Tolerance) < Hits[1]) and ((HP+Tolerance) > Hits[1]);
end;

marpis

2011-12-03 18:46:52

Cleaned it up a bit for you. Let's keep all the bolded words completely lower case, it looks better.

The idea sound pretty good actually. :)
Although, I think you should test it a lot and determine a single tolerance that will work, removing the ugly parameter. The tolerance should probably be a certain percent of the maximum hp, but this of course requires us to check stats tab, unless you write a function that will estimate it from the minimap icon.

On the side note, GetHits hasn't been updated since the lifepoints update.

function IsFighting(Tolerance : Integer) : Boolean; 
var
Hits : TIntegerArray;
HP : Integer;
begin
Result := False
Hits := GetHits(253, 99, 0, 0, 764, 502); // Where did these coords come from?

if GetArrayLength(Hits) = 0 then
Exit;

HP := HPPercent
Result := ((HP-Tolerance) < Hits[0]) and ((HP+Tolerance) > Hits[0]);
end;

Damage 1nc

2011-12-03 19:17:18

From: marpis
Cleaned it up a bit for you. Let's keep all the bolded words completely lower case, it looks better.

The idea sound pretty good actually. :)
Although, I think you should test it a lot and determine a single tolerance that will work, removing the ugly parameter. The tolerance should probably be a certain percent of the maximum hp, but this of course requires us to check stats tab, unless you write a function that will estimate it from the minimap icon.

On the side note, GetHits hasn't been updated since the lifepoints update.

function IsFighting(Tolerance : Integer) : Boolean; 
var
Hits : TIntegerArray;
HP : Integer;
begin
Result := False
Hits := GetHits(253, 99, 0, 0, 764, 502); // Where did these coords come from?

if GetArrayLength(Hits) = 0 then
Exit;

HP := HPPercent
Result := ((HP-Tolerance) < Hits[0]) and ((HP+Tolerance) > Hits[0]);
end;


I believe the Co-ords look like the ones for the small Runescape screen. I believe i use them in my basic autominer.

kingarabian

2011-12-03 19:22:02

Well well well Jonny! I'll be damned, but I am glad your getting to this level. Keep it up! Looks good and useful.

NCDS

2011-12-04 00:00:12

I think you should check the closest two hp bars on the ms. That should help ensure you find your character.

I like the concept though! :)

putonajonny

2011-12-04 11:00:03

From: marpis
Cleaned it up a bit for you. Let's keep all the bolded words completely lower case, it looks better.

The idea sound pretty good actually. :)
Although, I think you should test it a lot and determine a single tolerance that will work, removing the ugly parameter. The tolerance should probably be a certain percent of the maximum hp, but this of course requires us to check stats tab, unless you write a function that will estimate it from the minimap icon.

On the side note, GetHits hasn't been updated since the lifepoints update.



Added the stuff you suggested thank you very much, looks like I need to work on a replacement for GetHitsIn, I'll get testing but I think about 10 would be a good tolerance.

From: NCDS
I think you should check the closest two hp bars on the ms. That should help ensure you find your character.

I like the concept though! :)


I think I have added that, could you check the code?

From: kingarabian
Well well well Jonny! I'll be damned, but I am glad your getting to this level. Keep it up! Looks good and useful.


Thanks for your support, especially for helping me when I started out

Sir R. M8gic1an

2011-12-04 11:18:48

Honestly, I think that a proper inFight needs to receive x,y coordinates of the NPC it is fighting, and checking their HP rather than yours.

~RM

grats

2011-12-04 11:35:51

Nice! It's a start to a better one, I'd use it over the infight probably would be faster

From: Sir R. M8gic1an
Honestly, I think that a proper inFight needs to receive x,y coordinates of the NPC it is fighting, and checking their HP rather than yours.

~RM


yea I would like that, definitely would speed it up a lot

NCDS

2011-12-04 12:45:12

From: putonajonny

I think I have added that, could you check the code?



function IsFighting(Tolerance : Integer) : Boolean;
var
Hits : TIntegerArray;
HP, i : Integer;
begin
Result := False
Hits := GetHitsIn(253, 99, 0, 0, 764, 502);

if GetArrayLength(Hits) = 0 then
Exit;

HP := HPPercent
for i := 0 to High(Hits) do
Result := ((HP-Tolerance) < Hits[i]) and ((HP+Tolerance) > Hits[i]);
end;
;)

putonajonny

2011-12-04 13:34:05

From: NCDS

function IsFighting(Tolerance : Integer) : Boolean;
var
Hits : TIntegerArray;
HP, i : Integer;
begin
Result := False
Hits := GetHitsIn(253, 99, 0, 0, 764, 502);

if GetArrayLength(Hits) = 0 then
Exit;

HP := HPPercent
for i := 0 to High(Hits) do
Result := ((HP-Tolerance) < Hits[i]) and ((HP+Tolerance) > Hits[i]);
end;
;)


I'd worry that if there were lots of hitpoint bars on screen that the chances are one would match, I might change it to
for i := 0 to 3 do

Sir R. M8gic1an

2011-12-04 13:49:24

From: putonajonny
I'd worry that if there were lots of hitpoint bars on screen that the chances are one would match, I might change it to
for i := 0 to 3 do


How about you just check in an area close to your player?

MSCX, MSCY with a 50px box around it?

Honestly, this is not too far from what SRL currently has… but it is a slight improvement :p

~RM