SCAR Code:
{*******************************************************************************
Function GetMMLevels(LevelType : String;var ColorSign : String): integer;
By: Raymond / Wizzup / Sabzi
Last Edit: 29 June 2010
Description: Returns the level shown next to the minimap.
Colorsign returns the color of the text (Green,Yellow,Orange,Red).
Returns -1 if failed.
*******************************************************************************}
function GetMMLevels(LevelType: string; var ColorSign: string): Integer;
var
Colors : TIntegerArray;
Signs: TStringArray;
P: TPointArray;
TP: TPoint;
I,cl: Integer;
B: TBox;
{$ifdef Scar}
x,y : integer;
{$endif}
W,H, T: integer;
SearchBox : TBox;
Run: Boolean;
begin;
Result := -1;
ColorSign := '';
case LowerCase(Leveltype) of
'health', 'hp', 'hitpoints', 'constitution': TP := Point(715,27);
'prayer', 'pray' : TP := Point(730,66);
'summon', 'summoning' : TP := Point(715,140);
'run','energy' :
begin
TP := Point(730,105);
Run := True;
end;
else
begin;
srl_Warn('GetMMLevels', 'Invalid LevelType: ''' + LevelType + '', warn_AllVersions);
Exit;
end;
end;
Colors := [65280, 65535, 2070783, 255];
Signs := ['Green', 'Yellow', 'Orange', 'Red'];
GetClientDimensions(w,h); //We donnot want to search out of the clients area!
SearchBox := IntToBox(TP.X, TP.Y, Min(w-1,TP.X + 30), min(h-1,TP.Y + 15));
for I := 0 to 3 do
begin
if Run then
begin
MarkTime(T);
cl := GetColor(749, 118);
repeat
if not IsResting then Break;
{$ifdef Simba}
if CountColorTolerance(cl, 730, 105, 760, 120, 20) = 215 then Break;
{$else}
if not FindColorComp(x, y, clYellow, ccBlue, 730, 107, 742, 108, 130) then Break;
{$endif}
until (TimeFromMark(T) >= 5000);
end; //Do not search outside the client
With SearchBox do
FindColorsTolerance(P, Colors[i], x1, y1, x2, y2, 30);
if Length(P) < 1 then
Continue;
B := GetTPABounds(P);//GetTextAtEx works better for Simba for Run
Result := StrToIntDef(GetNumbers(GetTextAtEx(B.X1 - 1 , B.Y1 - 1, 30, statChars,
False, False, 0, 0, Colors[i], 20, False, tr_Digits)), -1);
if (Result > 0) then
begin
ColorSign := Signs[i];
Exit;
end;
end;
end;