Simba Code:
{*******************************************************************************
function GetXP(Skill: Variant): Integer;
By: Legoace
Credit to: Nielsie95 for the original
Description: Returns current xp value for a skill
*******************************************************************************}
function GetXP(Skill: Variant): Integer;
begin
result := GetXPEx(Skill, 'current', True);
end;
{*******************************************************************************
function GetXPEx(Skill: Variant; Which: String, MaintainTab: Boolean): Integer;
By: Legoace
Credit to: Nielsie95 for the original
Description: Returns xp value for a skill depending on Which.
Options for Which are ['current', 'next', 'remaining']
If MaintainTab is true, returns to current tab after execution.
Returns -3 if super-fails
-2 if skill is mem and this is F2P account
-1 if text-reading sucked
*******************************************************************************}
function GetXPNew(Skill: Variant; Which: String): Integer;
var
TPA1, TPA2: TPointArray;
ATPA, ATPAt: T2DPointArray;
P: TPoint;
B: TBox;
YOffset, I, T: Integer;
S: String;
begin
Result := -3;
T := GetCurrentTab;
if(not(GameTab(tab_Stats)))then exit;
P := SkillToCoords(Skill);
if(P.x < 1)then exit;
MMouse(P.x, P.y + 5, 12, 4);
Wait(100 + Random(50));
FindColorsTolerance(TPA2, 921102, MIX1, MIY1, MIX2, MIY2, 1); // black behind the orange text
FindColorsTolerance(TPA1, 4305653, MIX1, MIY1, MIX2, MIY2, 1); // Orange text color of XP boxes
//15133931 is another useful color: the white bound of the hover box
TPA1 := CombineTPA(TPA1, TPA2);
B := GetTPABounds(TPA1);
if((B.Y2 - B.Y1) > 20)then // F2P boxes for Mem skills won't be large enough
begin
case Which of
'current': YOffset := 17;
'next': YOffset := 31;
'remaining': YOffset := 45;
end;
B := IntToBox(B.X1, B.Y1 + YOffset, B.X2, B.Y1 + YOffset + 13); // get just the line that current xp is on
FindColorsTolerance(TPA1, 4305653, B.X1, B.Y1, B.X2, B.Y2, 2); // TPA of that line's text
ATPA := SplitTPAEx(TPA1, 15, 2);
SortATPAFromFirstPointY(ATPA, Point(B.X2-B.X1+2/2,0));
if(length(ATPA) > 0)then
begin
for I := 0 to High(ATPA) do
begin
TPA1 := ATPA[I];
ATPAt := SplitTPAEx(TPA1, 1, 10); // Split one into characters
SortATPAFromFirstPointX(ATPAt, Point(0, 0));
S := S + GetTextATPA(ATPAt, 4, 'SmallChars');
end;
Result := StrToIntDef(GetNumbers(S), -1);
end;
end else result := -2;
if(T)then GameTab(T);
end;