SRL Archive - SRL Archives

infight(extra)


nielskool

2009-02-17 16:15:23

i don't know how the in fight mode now works, but sometimes it thinks it is in fight but it actually isn't
so, this script looks if the bar above the head, is +/- equal to its actual health, so when there is an other bar from someone else, he won't see it as yours.

// this script will see if you are really in fight.
program infight;
{.include srl/srl.scar}

Function barfight :Boolean;

var
main: TDTMPointDef;
sub: Array of TDTMPointDef;
bar: TDTM;
x,y,bl,bar2:Integer;
pro,red,green,x1,x2,y1,y2: integer;
begin
green := 65280;
red := 255;
x1 := 225;
x2 := 290;
y1 := 135;
y2 := 177;

pro := ((GetSkillInfo('hitpoints',true)*100)/(GetSkillInfo('hitpoints',false)))*29/100;
bl := red;
if(pro = 29)then
bl:=green;
SetArrayLength(sub, 3);

main.x := 10;
main.y := 10;
main.areasize := 1;
main.areashape := 0;
main.color := green;
main.tolerance := 3;

sub[0].x := 10+pro-1;
sub[0].y := 10;
sub[0].areasize := 1;
sub[0].areashape := 0;
sub[0].color := green;
sub[0].tolerance := 3;

sub[1].x := 10+pro;
sub[1].y := 10;
sub[1].areasize := 1;
sub[1].areashape := 0;
sub[1].color := bl;
sub[1].tolerance := 3;

sub[2].x := 10+29-1;
sub[2].y := 10;
sub[2].areasize := 1;
sub[2].areashape := 0;
sub[2].color := bl;
sub[2].tolerance := 3;

bar.MainPoint := main;
bar.SubPoints := sub;
bar2 := AddDTM(bar);

if(FindDTM(bar2, x, y, x1,y1,x2,y2)) Then
begin
writeln('in fight');
Result:= True;
end else
writeln('not in fight');
Result:= False
end;

begin
repeat
wait(200);
barfight;
until(false);
end.
one function now.

NCDS

2009-02-17 16:19:25

Your standards were all messed up at the bottom, other then that, if it works, then nice job!


// this script will see if you are really in fight.
program infight;
{.include srl/srl.scar}
const
green = 65280;
red = 255;
x1 = 225;
x2 = 278;
y1 = 135;
y2 = 177;
var
x,y,bl:Integer;
pro: integer;



Function tet :Integer;
var
main: TDTMPointDef;
sub: Array of TDTMPointDef;
bar: TDTM;
begin

pro := ((GetSkillInfo('hitpoints',true)*100)/(GetSkillInfo('hitpoints',false)))*29/100;
bl := red;
if(pro = 29)then
bl:=green;
SetArrayLength(sub, 2);

main.x := 10;
main.y := 10;
main.areasize := 1;
main.areashape := 0;
main.color := green;
main.tolerance := 3;

sub[0].x := 10+pro-1;
sub[0].y := 10;
sub[0].areasize := 1;
sub[0].areashape := 0;
sub[0].color := green;
sub[0].tolerance := 3;

sub[1].x := 10+29-1;
sub[1].y := 10;
sub[1].areasize := 1;
sub[1].areashape := 0;
sub[1].color := bl;
sub[1].tolerance := 3;


bar.MainPoint := main;
bar.SubPoints := sub;
Result := AddDTM(bar);
end;

procedure findbar;
begin
if(FindDTM(tet, x, y, x1,y1,x2,y2)) Then
begin
writeln('in fight');
end else
writeln('not in fight');
end;

begin
repeat
writeln('');
wait(200);
findbar;
until(false);
end.

mormonman

2009-02-17 16:32:17

make it one function?

nielskool

2009-02-17 16:38:02

ok, doing it now
//done
if you are with poeple that have the same health% it doen't work.
i jus saw some little thing that must be fixed
now fixing it.
//done
the bug was:
when your healt is low it searches for a lower green level but somoene with more health is also in that green levl, but it now also looks to the red level, if you know what i mean:P

it only needs to be in the stat tab:S how to take the health from the map?

marpis

2009-02-17 18:08:18

This one is made by EvilChicken:
//InCloseCombat by EvilChicken
function InCloseCombat: Boolean;
var
G, R: TPointArray;
begin
FindColorsTolerance(G, 65280, 233, 134, 282, 172, 0);
FindColorsTolerance(R, 255, 233, 134, 282, 172, 0);
Result := High(CombineTPA(G, R)) > 10;
end;

Your function shows that u arnt a noob at all, but if you already don't know about TPAs (TPointArray) i suggest you to read This tutorial. TPAs are all you need if you want to find wheter your in fight or not.
I made one function too to find if your in fight, haha, it was like 40 lines long but had exactly same idea than chickens InCloseCombat :D

EDIT: Btw, if this helps at all, in my Guardkiller i check if orange or yellow color is found from the box which shows your current hp in numbers (the heart next to the map)

Narcle

2009-02-17 19:15:06

Here's one should do same thing:

function InFight2: Boolean;
var
Hp: Integer;
G: TPointArray;
begin
FindColorsTolerance(G, 65280, 233, 134, 282, 172, 0);
Hp := Length(G)/150*100;
Result := InRange(HPPercent, Hp-7, Hp+7);
end;

Da 0wner

2009-02-18 00:38:10

Narcle shortened it surely ;).

nielskool

2009-02-18 02:00:38

hppercent didn't work for me:s
well.. thats alot shorter
//edit
@marpis
i read the tut… kinda easy, but very usefull
hmm, i just don't know where to use it in this script
@narcle
i may be wrong, but with your function it only looks for the green so if it finds anough green it returns true, with mine it also watches the red.
so when there are 2 bars of live under eachother, the one can expand the green of the above, so it thinks to see anoug green.(i think)