Coh3n
2010-04-12 15:21:44
I've tested both, and they work, but I may have missed something, so testing is appreciated. You'll need to update your skill constants.
const
Skill_Attack = 1;
Skill_Strength = 2;
Skill_Defense = 3;
Skill_Range = 4;
Skill_Prayer = 5;
Skill_Mage = 6;
Skill_RuneCrafting = 7;
Skill_HP = 8;
Skill_Agility = 9;
Skill_Dungeoneering = 10;
Skill_Herblore = 11;
Skill_Thieving = 12;
Skill_Crafting = 13;
Skill_Fletching = 14;
Skill_Slayer = 15;
Skill_Mining = 16;
Skill_Smithing = 17;
Skill_Fishing = 18;
Skill_Cooking = 19;
Skill_FireMaking = 20;
Skill_WoodCutting = 21;
Skill_Farming = 22;
Skill_Construction = 23;
Skill_Hunter = 24;
Skill_Summoning = 25;
{*******************************************************************************
function SkillCoords(Row, Column: Integer): TPoint;
By: Naum & Coh3n
Description: Returns Coords of Skill's Row and Column (Used for GetSkill functions)
*******************************************************************************}
function SkillCoords(Row, Column : ShortInt): TPoint;
begin
if (((Column = 2) or (Column = 3)) and (Row = 9)) then
begin
srl_Warn('SkillCoords', 'Invalid skill choice ', warn_AllVersions);
Exit;
end;
Result := Point(577 + (60 * (Column - 1)), 223 + (28 * (Row - 1)));
end;
{*******************************************************************************
function SkillToCoords(ScrollDownIfNeeded: Boolean; Skill: Variant): TPoint;
By: Masquerader, Cheesehunk, Raymond, Wizzup?, ZephyrsFury, Timer & Coh3n
Description: Turns skill string into tpoint.
If Scroll returns true then you must scroll down.
*******************************************************************************}
function SkillToCoordsEx(Skill: Variant): TPoint;
var
SkillArr: TStringArray;
CX, CY, Col, skNo: Integer;
SkillS: string;
begin
if (not LoggedIn) then exit;
if (VarType(Skill) = varInteger) then
SkillS := IntToStr(Skill)
else
SkillS := Lowercase(Skill);
case Lowercase(SkillS) of
'hp', 'constitution': SkillS := 'hitpoints';
'ranged': SkillS := 'range';
'hunter': SkillS := 'hunting';
end;
SkillArr := ['attack', 'strength', 'defence', 'range', 'prayer', 'magic',
'runecrafting', 'hitpoints', 'agility', 'dungeoneering', 'herblore', 'thieving', 'crafting',
'fletching', 'slayer', 'mining', 'smithing', 'fishing', 'cooking',
'firemaking', 'woodcutting', 'farming', 'construction', 'hunting', 'summoning'];
if (GetNumbers(SkillS) = SkillS) and (InRange(StrToIntDef(GetNumbers(SkillS), 0), 1, Length(SkillArr))) then
skNo := StrToInt(SkillS) - 1
else
if (not InStrArrEx(SkillS, SkillArr, skNo)) then
begin
srl_Warn('SkillToCoords', 'Invalid Skill Name/Number: ''' + string(Skill) + '''', warn_AllVersions);
Exit;
end;
Writeln(IntToStr(skNo));
if (InRange(skNo + 1, 1, 25)) then
begin
CX := skNo div 9 + 1;
CY := skNo mod 9 + 1;
end;
Result := SkillCoords(CY, CX);
end;