legoace
2011-12-04 01:36:43
I've written a new GetXP function. I used both the current GetXP function and GetChooseOptions as my guides.
Why it should be committed: this one actually works!
Why it should be committed: this one actually works!
function GetXPNew(Skill: Variant): Integer;
var
TPA1, TPA2: TPointArray;
ATPA, ATPAt: T2DPointArray;
P: TPoint;
B: TBox;
begin
Result := -1;
if (not TabExists(tab_Stats)) then exit;
GameTab(tab_Stats);
if (GetCurrentTab <> tab_Stats) then exit;
P := SkillToCoords(Skill);
if (P.x < 1) then exit;
MMouse(P.x, P.y + 5, 12, 4);
if (not WaitFindColors(TPA1, 4305653, MIX1, MIY1, MIX2, MIY2, 1, 4000)) then exit; // Orange text color of XP boxes
FindColorsTolerance(TPA2, 921102, MIX1, MIY1, MIX2, MIY2, 1); // black behind the orange text
//15133931 is another useful color: the white bound of the hover box
TPA1 := CombineTPA(TPA1, TPA2);
B := GetTPABounds(TPA1);
B := IntToBox(B.X1, B.Y1 + 17, B.X2, B.Y1 + 17 + 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));
TPA1 := ATPA[0];
ATPAt := SplitTPAEx(TPA1, 1, 10); // Split one into characters
SortATPAFromFirstPointX(ATPAt, Point(0, 0));
Result := StrToIntDef(GetNumbers(GetTextATPA(ATPAt, 4, 'SmallChars')), -1);
end;