WT-Fakawi
2006-04-27 18:03:11
Look what I found :)
Two completely different methods, both brilliantly written, sitting comfortably side-to-side. A dream come true.
Well done!
[php]
{*******************************************************************************
function GetSkillLevel(skill : String) : Integer;
By: RsN
Description: Gets level of specified skill
*******************************************************************************}
function GetSkillLevel(skill : String) : Integer;
var
T : Tpoint;
TmpResult : String;
i : Integer;
begin
GameTab(2);
case lowercase(skill) of
'attack' : T := SkillCoords(1, 1);
'hitpoints' : T := SkillCoords(1, 2);
'mining' : T := SkillCoords(1, 3);
'strength' : T := SkillCoords(2, 1);
'agility' : T := SkillCoords(2, 2);
'smithing' : T := SkillCoords(2, 3);
'defense' : T := SkillCoords(3, 1);
'herblore' : T := SkillCoords(3, 2);
'fishing' : T := SkillCoords(3, 3);
'ranged' : T := SkillCoords(4, 1);
'thieving' : T := SkillCoords(4, 2);
'cooking' : T := SkillCoords(4, 3);
'prayer' : T := SkillCoords(5, 1);
'crafting' : T := SkillCoords(5, 2);
'firemaking' : T := SkillCoords(5, 3);
'magic' : T := SkillCoords(6, 1);
'fletching' : T := SkillCoords(6, 2);
'woodcutting' : T := SkillCoords(6, 3);
'runecrafting' : T := SkillCoords(7, 1);
'slayer' : T := SkillCoords(7, 2);
'farming' : T := SkillCoords(7, 3);
end;
tmpResult := GetTextAtEx(T.x + 12, T.y + 12, 100, StatChars, False, True, 0, 5, -1, 2, True, tr_Digits);
if (Trim(tmpResult) = '') then
for i := 1 to 5 do
begin
tmpResult := GetTextAtEx(T.x + i + 12, T.y + 12, 100, StatChars, False, True, 0, 5, -1, 2, True, tr_Digits);
if (Trim(tmpResult) <> '') then
Exit;
end;
if (not (Trim(tmpResult) = '')) then
Result := StrToInt(Trim(GetTextAtEx(T.x + 12, T.y + 12, 100, StatChars, False, True, 0, 5, -1, 2, True, tr_Digits)));
end;
[/php]
[php]
{*******************************************************************************
Function GetStat(stat : string):integer;
By: Mutant Squirrle
Description: Gets Specified stat
*******************************************************************************}
Function GetStat(stat : string):integer;
var x1, y1, x2, y2, i, x, y: Integer;
s:array[0..9] of integer;
begin
S[0] := CreateBitmapMaskFromText('0',StatChars)
S[1] := CreateBitmapMaskFromText('1',StatChars)
S[2] := CreateBitmapMaskFromText('2',StatChars)
S[3] := CreateBitmapMaskFromText('3',StatChars)
S[4] := CreateBitmapMaskFromText('4',StatChars)
S[5] := CreateBitmapMaskFromText('5',StatChars)
S[6] := CreateBitmapMaskFromText('6',StatChars)
S[7] := CreateBitmapMaskFromText('7',StatChars)
S[8] := CreateBitmapMaskFromText('8',StatChars)
S[9] := CreateBitmapMaskFromText('9',StatChars)
GameTab(2);
case stat of
'hits' : begin x1:=648; y1:=210; end;
'attack' : begin x1:=583; y1:=210; end;
'mining' : begin x1:=712; y1:=210; end;
'strength' : begin x1:=583; y1:=241; end;
'agility' : begin x1:=648; y1:=241; end;
'smithing' : begin x1:=712; y1:=241; end;
'defence' : begin x1:=583; y1:=272; end;
'herblore' : begin x1:=648; y1:=272; end;
'fishing' : begin x1:=712; y1:=272; end;
'ranged' : begin x1:=586; y1:=303; end;
'thieving' : begin x1:=648; y1:=303; end;
'cooking' : begin x1:=712; y1:=303; end;
'prayer' : begin x1:=586; y1:=334; end;
'crafting' : begin x1:=651; y1:=335; end;
'firemaking' : begin x1:=712; y1:=334; end;
'magic' : begin x1:=586; y1:=365; end;
'fletching' : begin x1:=651; y1:=365; end;
'woodcutting' : begin x1:=712; y1:=365; end;
'runecraft' : begin x1:=586; y1:=396; end;
'slayer' : begin x1:=651; y1:=396; end;
'farming' : begin x1:=717; y1:=398; end;
end;
x2:=x1 + 9
y2:=y1 + 9
for i:=1 to 9 do
if(FindBitmapMaskTolerance(s, x, y, x1, y1, x2, y2, 10, 240))then
Result:=i * 10
x1:=x1 + 6
x2:=x1 + 9
for i:=0 to 9 do
if(FindBitmapMaskTolerance(s, x, y, x1, y1, x2, y2, 10, 240))then
Result:=Result + i
end;
[/php]
Two completely different methods, both brilliantly written, sitting comfortably side-to-side. A dream come true.
Well done!
[php]
{*******************************************************************************
function GetSkillLevel(skill : String) : Integer;
By: RsN
Description: Gets level of specified skill
*******************************************************************************}
function GetSkillLevel(skill : String) : Integer;
var
T : Tpoint;
TmpResult : String;
i : Integer;
begin
GameTab(2);
case lowercase(skill) of
'attack' : T := SkillCoords(1, 1);
'hitpoints' : T := SkillCoords(1, 2);
'mining' : T := SkillCoords(1, 3);
'strength' : T := SkillCoords(2, 1);
'agility' : T := SkillCoords(2, 2);
'smithing' : T := SkillCoords(2, 3);
'defense' : T := SkillCoords(3, 1);
'herblore' : T := SkillCoords(3, 2);
'fishing' : T := SkillCoords(3, 3);
'ranged' : T := SkillCoords(4, 1);
'thieving' : T := SkillCoords(4, 2);
'cooking' : T := SkillCoords(4, 3);
'prayer' : T := SkillCoords(5, 1);
'crafting' : T := SkillCoords(5, 2);
'firemaking' : T := SkillCoords(5, 3);
'magic' : T := SkillCoords(6, 1);
'fletching' : T := SkillCoords(6, 2);
'woodcutting' : T := SkillCoords(6, 3);
'runecrafting' : T := SkillCoords(7, 1);
'slayer' : T := SkillCoords(7, 2);
'farming' : T := SkillCoords(7, 3);
end;
tmpResult := GetTextAtEx(T.x + 12, T.y + 12, 100, StatChars, False, True, 0, 5, -1, 2, True, tr_Digits);
if (Trim(tmpResult) = '') then
for i := 1 to 5 do
begin
tmpResult := GetTextAtEx(T.x + i + 12, T.y + 12, 100, StatChars, False, True, 0, 5, -1, 2, True, tr_Digits);
if (Trim(tmpResult) <> '') then
Exit;
end;
if (not (Trim(tmpResult) = '')) then
Result := StrToInt(Trim(GetTextAtEx(T.x + 12, T.y + 12, 100, StatChars, False, True, 0, 5, -1, 2, True, tr_Digits)));
end;
[/php]
[php]
{*******************************************************************************
Function GetStat(stat : string):integer;
By: Mutant Squirrle
Description: Gets Specified stat
*******************************************************************************}
Function GetStat(stat : string):integer;
var x1, y1, x2, y2, i, x, y: Integer;
s:array[0..9] of integer;
begin
S[0] := CreateBitmapMaskFromText('0',StatChars)
S[1] := CreateBitmapMaskFromText('1',StatChars)
S[2] := CreateBitmapMaskFromText('2',StatChars)
S[3] := CreateBitmapMaskFromText('3',StatChars)
S[4] := CreateBitmapMaskFromText('4',StatChars)
S[5] := CreateBitmapMaskFromText('5',StatChars)
S[6] := CreateBitmapMaskFromText('6',StatChars)
S[7] := CreateBitmapMaskFromText('7',StatChars)
S[8] := CreateBitmapMaskFromText('8',StatChars)
S[9] := CreateBitmapMaskFromText('9',StatChars)
GameTab(2);
case stat of
'hits' : begin x1:=648; y1:=210; end;
'attack' : begin x1:=583; y1:=210; end;
'mining' : begin x1:=712; y1:=210; end;
'strength' : begin x1:=583; y1:=241; end;
'agility' : begin x1:=648; y1:=241; end;
'smithing' : begin x1:=712; y1:=241; end;
'defence' : begin x1:=583; y1:=272; end;
'herblore' : begin x1:=648; y1:=272; end;
'fishing' : begin x1:=712; y1:=272; end;
'ranged' : begin x1:=586; y1:=303; end;
'thieving' : begin x1:=648; y1:=303; end;
'cooking' : begin x1:=712; y1:=303; end;
'prayer' : begin x1:=586; y1:=334; end;
'crafting' : begin x1:=651; y1:=335; end;
'firemaking' : begin x1:=712; y1:=334; end;
'magic' : begin x1:=586; y1:=365; end;
'fletching' : begin x1:=651; y1:=365; end;
'woodcutting' : begin x1:=712; y1:=365; end;
'runecraft' : begin x1:=586; y1:=396; end;
'slayer' : begin x1:=651; y1:=396; end;
'farming' : begin x1:=717; y1:=398; end;
end;
x2:=x1 + 9
y2:=y1 + 9
for i:=1 to 9 do
if(FindBitmapMaskTolerance(s, x, y, x1, y1, x2, y2, 10, 240))then
Result:=i * 10
x1:=x1 + 6
x2:=x1 + 9
for i:=0 to 9 do
if(FindBitmapMaskTolerance(s, x, y, x1, y1, x2, y2, 10, 240))then
Result:=Result + i
end;
[/php]