SRL Archive - SRL Archives

Fighting.scar (InFight & IsFightAt)


Naike

2009-05-27 21:23:23

Was outdated after update.

Note: Only did these two, as they are the most importent.


{*****************************************************************************
function InFight: Boolean;
By: WT-Fakawi fixed by N1ke!
Description: Returns as True if in fight.
*****************************************************************************}

function InFight: Boolean;
var
x, y : Integer;
begin
Result := (FindColor(x, y, 10496, 230, 130, 280, 180) or
FindColor(x, y, 198716, 230, 130, 280, 180));
end;

{*****************************************************************************
function IsFightAt(x, y: Integer): Boolean;
By: realrune fixed by N1ke!
Description: results true if it finds a fight near x,y.
*****************************************************************************}

function IsFightAt(x, y: Integer): Boolean;
var
xx, yy: Integer;
begin
Result := FindColor(xx, yy, 10496, x - 20, y - 20, x + 20, y + 20);
end;

Note: This will not break any scripts.

Cazax

2009-05-29 04:37:01

new HP bar functions:
{*******************************************************************************
Function FindAllHPBars(Sx, Sy, x1, y1, x2, y2: Integer): TBoxArray;
By: Cazax
Description: Finds all the HP bars (the TPAs of them) in the box formed by
x1, y1, x2, y2. Recommended to set Sx and Sy to MSCX and MSCY, so Result[0]
is your own Bar or the closest one to you.
*******************************************************************************}
Function FindAllHPBars(Sx, Sy, x1, y1, x2, y2: Integer): TBoxArray;
Var
a, b : TPointArray;
ATPA : T2DPointArray;
H, I : Integer;
Begin
FindColorsSpiralTolerance(Sx, Sy, a, 10496, x1, y1, x2, y2, 0);
FindColorsSpiralTolerance(Sx, Sy, b, 198716, x1, y1, x2, y2, 0);
ATPA := TPAToATPAEx(CombineTPA(a, b), 55, 7);
H := High(ATPA);
SetLength(Result, Length(ATPA));
For I := 0 To H Do
Result[I] := GetTPABounds(ATPA[I]);
End;

{*******************************************************************************
Function GetHits(Sx, Sy, x1, y1, x2, y2: Integer): TIntegerArray;
By: n3ss3s & Cazax
Description: Finds all HP percents of the HP bars in x1, y1, x2, y2.
READ THE DESCRIPTION OF FindAllHPBars!
*******************************************************************************}
Function GetHitsIn(Sx, Sy, x1, y1, x2, y2: Integer): TIntegerArray;

Var
E: Extended;
TB: TBox;
I: Integer;
TBA : TBoxArray;
Begin
TBA := FindAllHPBars(Sx, Sy, x1, y1, x2, y2);
SetArrayLength(Result, GetArrayLength(TBA));
For I := 0 To High(TBA) Do
Begin
E := CountColorTolerance(56488, TBA[I].x1, TBA[I].y1, TBA[I].x2, TBA[I].y2, 43) / 60;
Result[i] := Round(100 * E);
End;
End;

{*******************************************************************************
Function FindMainScreenHits(Bar: Integer): Integer;
By: n3ss3s
Description: Returns the rounded HP percent of the hp bar Bar counting out from
main screen centre, if Bar is 0, it's your own bar or the closest one to you.
If could not find the bar Bar, returns -1 so you can't confuse it to 0 HP%.
*******************************************************************************}
Function FindMainScreenHits(Bar: Integer): Integer;

Var
TIA: TIntegerArray;
Begin
TIA := GetHitsIn(MSCX, MSCY, MSX1, MSY1, MSX2, MSY2);
Try
Result := TIA[bar];
Except
Result := -1;
End;
End;
This will break scripts that uses FindAllHPbars, but it needs to change.
Sorry to hijack your thread.

Nava2

2009-05-29 06:53:07

Good job guys, keep all these threads as one.

Wizzup?

2009-05-29 14:42:06

Cazax, you could possibly use SplitTPA instead? Unless HP bars overlap.

noidea

2009-05-29 14:54:22

From: Wizzup?
Cazax, you could possibly use SplitTPA instead? Unless HP bars overlap.


They overlap.

Harry

2009-06-06 23:53:16

Commit it? :) I am testing now, looks nice.

Naike

2009-06-06 23:55:35

From: Harry
Commit it? :) I am testing now, looks nice.


Bit late, no?

Almost a week since i started this ^^

Harry

2009-06-07 00:00:01

From: N1ke!
Bit late, no?

Almost a week since i started this ^^

I just tested it, works amazing. It isn't in Rev 33 though. :/