Results 1 to 6 of 6

Thread: SkillCoords

  1. #1
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default SkillCoords

    The current function could be shortened.

    SCAR Code:
    Function SkillCoords(Row, Column : ShortInt): TPoint;
    Begin
      Result := Point(577 + (55 * (Column-1)), 228 + (32 * (Row-1)));
      If Row = 8 Then Result.y := 419;
    End;

    That's my one, and to test it:

    SCAR Code:
    program New;
    {.Include SRL/SRL.Scar}

    Var x, y : Integer;
        tp : tpoint;
       
    Function SkillCoords(Row, Column : ShortInt): TPoint;
    Begin
      Result := Point(577 + (55 * (Column-1)), 228 + (32 * (Row-1)));
      If Row = 8 Then Result.y := 419;
    End;

    function SkillToCoords1(ScrollDownIfNeeded : Boolean; skill: Variant): TPoint;
    var
      Scroll: Boolean;
      CX, CY, Col, skNo: Integer;
      ScrollP : TPoint;
      SkillS: string;
      SkillArr: TStringArray;
    begin
      if (not(LoggedIn)) then Exit;

      if (VarType(Skill) = 11) then
        SkillS := IntToStr(Skill)
      else
        SkillS := Lowercase(Skill);

      case Lowercase(SkillS) of
        'hp': SkillS := 'hitpoints';
        'ranged': SkillS := 'range';
        'hunter': SkillS := 'hunting';
      end;

      SkillArr := ['attack', 'strength', 'defence', 'range', 'prayer', 'magic', 'runecrafting',
                   'hitpoints', 'agility', 'herblore', 'thieving', 'crafting', 'fletching',
                   'slayer', 'mining', 'smithing', 'fishing', 'cooking', 'firemaking',
                   'woodcutting', 'farming', 'construction', 'hunting', 'summoning'];
      if (GetNumbers(SkillS) = SkillS) and (InRange(StrToIntDef(GetNumbers(SkillS), -1), 1, Length(SkillArr))) then
        skNo := StrToInt(SkillS) - 1
      else
      if (not(InStrArrEx(SkillS, SkillArr, skNo))) then
      begin
        srl_Warn('SkillToCoords', 'Invalid Skill Name/Number: ''' + Skill + '''', warn_AllVersions);
        Exit;
      end;

      if (InRange(skNo + 1, 1, 21)) then
      begin
        CX := skNo div 7 + 1;
        CY := skNo mod 7 + 1;
      end else
      begin
        CX := skNo mod 3 + 1;
        CY := skNo div 3 + 1;
      end;

      Result := skillcoords1(CY, CX);

      Scroll := (ScrollDownIfNeeded) and (InRange(skNo + 1, 21, 24));
      ScrollP := Point(724, 240 + 194 * Integer(Scroll));
      Col := 1316634 - 658704 * Integer(Scroll);
      //GameTab(2);

      if (GetColor(ScrollP.X, ScrollP.Y) <> Col) then
      begin
        MMouse(ScrollP.X, ScrollP.Y + 10 * (2 * Integer(Scroll) - 1), 5, 5);
        GetMousePos(CX, CY);
        HoldMouse(CX, CY, True);
        while (GetColor(ScrollP.X, ScrollP.Y) <> Col) and (GetColor(724, 239) = 657930) do
          Wait(500 + Random(500));
        ReleaseMouse(CX, CY, True);
      end;
    end;

    {*******************************************************************************
    function GetSkillInfo(skill: Variant; Amount : Boolean): Integer;
    By: Raymond
    Description: Gets the amount / level of a skill.
    E.G.
    0/15
    Amount = True will return 0.
    Amount = False will return 15 (The actual level).
    *******************************************************************************}


    function GetSkillInfo1(skill: Variant; Amount : Boolean): Integer;
    var
      TP: TPoint;
      Box : TBox;
      TPA : TPointArray;
      Cts : Integer;
    begin
      GameTab(2);
      TP := SkillToCoords1(True,skill);
      CTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(0);
      if not Amount then
        TP := Point(TP.x + 7,TP.y + 13);
      FindColorsTolerance(TPA,65535,TP.x - 2,TP.y - 2, TP.x + 15,TP.y + 15,0);
      Box := GetTPABounds(TPA);
      Result := StrToIntDef(GetNumbers(GetTextAtEx(Box.x1-2, Box.y1 -1, 100,
        StatChars, False, True, 0, 5,65535, 2, True, tr_Digits)),0);
      ColorToleranceSpeed(CTS);
    end;

    {*******************************************************************************
    Function GetSkillLevel(skill: Variant): Integer;
    By: Raymond
    Description: Gets the max level for a particular skill.
    *******************************************************************************}


    Function GetSkillLevel1(skill: Variant): Integer;
    Begin
      Result := GetSkillInfo1(skill, False);
    End;

    begin
      SetupSRL;
      For x := 1 to 24 Do
        Writeln(GetSkillLevel1(x));
    end.
    Last edited by Naum; 07-14-2009 at 11:55 PM.

  2. #2
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    Not easy to add new skills but I like it!
    Good job

  3. #3
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by Zyt3x View Post
    Not easy to add new skills but I like it!
    Good job
    Thanks, it's much shorter and it works!!

  4. #4
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    New skills are added very rarely Zyt3x .

  5. #5
    Join Date
    Jan 2007
    Posts
    8,876
    Mentioned
    123 Post(s)
    Quoted
    327 Post(s)

    Default

    Quote Originally Posted by Da 0wner View Post
    New skills are added very rarely Zyt3x .
    Still; They do add new skills + what if they changed the coords and stuff like that? then it would be harder to edit Nauman's verision than the current one...

    NaumanAkhlaQ: Which one is faster?
    EDIT: Found a bug: "Result := skillcoords1(CY, CX);"

  6. #6
    Join Date
    Mar 2007
    Posts
    4,810
    Mentioned
    3 Post(s)
    Quoted
    3 Post(s)

    Default

    Quote Originally Posted by Zyt3x View Post
    Still; They do add new skills + what if they changed the coords and stuff like that? then it would be harder to edit Nauman's verision than the current one...

    NaumanAkhlaQ: Which one is faster?
    EDIT: Found a bug: "Result := skillcoords1(CY, CX);"
    Nah, its weird that way, we would expect it do Col then Row, in fact it does the opposite, hence that

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •