Results 1 to 20 of 20

Thread: Updated SkillCoords and SkillToCoords

  1. #1
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default Updated SkillCoords and SkillToCoords

    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.

    SCAR Code:
    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;
    Last edited by Wanted; 04-13-2010 at 09:41 PM.

  2. #2
    Join Date
    May 2006
    Location
    Amsterdam
    Posts
    3,620
    Mentioned
    5 Post(s)
    Quoted
    0 Post(s)

    Default

    I already committed something =)
    Verrekte Koekwous

  3. #3
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by mastaraymond View Post
    I already committed something =)
    Bah, probably should have checked.

    E: Just tested yours. You may want to have it add a little more to each row as the coords are at the very top of each skill. Also, adding the srl_Warn for the non-skill areas may not be a bad idea.
    Last edited by Coh3n; 04-12-2010 at 07:32 PM.

  4. #4
    Join Date
    May 2006
    Location
    Amsterdam
    Posts
    3,620
    Mentioned
    5 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Coh3n View Post
    Bah, probably should have checked.

    E: Just tested yours. You may want to have it add a little more to each row as the coords are at the very top of each skill. Also, adding the srl_Warn for the non-skill areas may not be a bad idea.
    I looked up where the 'old' starting point was, and it was a little bit left from the attack-level (the upper one)..

    E: Try now
    Last edited by mastaraymond; 04-12-2010 at 07:43 PM.
    Verrekte Koekwous

  5. #5
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by mastaraymond View Post
    I looked up where the 'old' starting point was, and it was a little bit left from the attack-level (the upper one)..

    E: Try now
    Still the same. It's at the top for every skill. It's not really a big deal because it still works, I was just pointing it out.


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

    Default

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

    Var X, Y, I : Integer;
        TPA : TPointArray;
        ATPA : T2DPointArray;
        TP : TPoint;
        TB : TBox;

    Function SkillCoords2(Row, Column : ShortInt): TPoint;
    Begin
      Result := Point(570 + (60 * (Column - 1)) + Column * 2,
                211 + (27 * (Row - 1)) + Round(Row Div 2 * 1.5));
    End;

    function SkillToCoords2(Skill: Variant) : TPoint;
    var
      SkillArr: TStringArray;
      CX, CY, 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', 'construction', 'dungeoneering', 'hitpoints',
      'agility', 'herblore', 'thieving', 'crafting', 'fletching', 'slayer',
      'hunting', '', 'mining', 'smithing', 'fishing', 'cooking',
      'firemaking', 'woodcutting', 'farming', '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;
      If skNo = 18 Then Inc(SkNo);  //empty space
     
      if (InRange(skNo + 1, 1, 27)) then
      begin
        CX := skNo div 9 + 1;
        CY := skNo mod 9 + 1;
        Disguise(SkillArr[SkNo]);
      end;
     
      Result := SkillCoords2(CY, CX);

      GameTab(tab_Stats);
    end;

    function GetSkillInfo2(Skill: Variant; Amount : Boolean): Integer;
    var
      TP: TPoint;
      Box : TBox;
      TPA : TPointArray;
      Cts : Integer;

    begin
      Result := -1;
      GameTab(tab_Stats);
      TP := SkillToCoords2(Skill);
      if (not(Amount)) then
        TP := Point(TP.x + 7, TP.y + 15);
      CTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(0);
      if not FindColors(TPA, 65535, TP.x - 5, TP.y - 4, TP.x + 29, TP.y + 14) then
        exit;
      DebugTPA(TPA, '');
      Box := GetTPABounds(TPA);
      Result := StrToIntDef(GetNumbers(GetTextAtEx(Box.x1 - 2, Box.y1 - 1, 140,
        StatChars, False, True, 0, 3, 65535, 3, True, tr_Digits)), -1);
      ColorToleranceSpeed(CTS);
    end;

    function GetSkillLevel2(Skill: Variant): Integer;
    begin
      Result := GetSkillInfo2(Skill, False);
    end;


    Begin
      SetupSRL;
      SRLPlayerForm(False, [], [], [], []);
      For I := 1 To 25 Do
      Begin
    {    TP := SkillToCoords2(I);
        MMouse(TP.x, TP.y, 0, 0); }

        WriteLn(GetSkillLevel2(I));
        wait(1200);
      End;
    End.

    This one works in scar, but only cannot get 4 skills due to the ocr failing.
    In simba it works 100% perfect.

    (I've attached it with the test script and stuff, I'd advise you to use it with strings, not integers)

  7. #7
    Join Date
    May 2007
    Location
    Ohio
    Posts
    2,296
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Naum View Post
    SCAR Code:
    program New;
    {.Include SRL/SRL.Scar}
    {.Include SRL/SRL/Misc/Debug.Scar}
    {.Include SRL/SRL/Misc/Users.Scar}

    Var X, Y, I : Integer;
        TPA : TPointArray;
        ATPA : T2DPointArray;
        TP : TPoint;
        TB : TBox;

    Function SkillCoords2(Row, Column : ShortInt): TPoint;
    Begin
      Result := Point(570 + (60 * (Column - 1)) + Column * 2,
                211 + (27 * (Row - 1)) + Round(Row Div 2 * 1.5));
    End;

    function SkillToCoords2(Skill: Variant) : TPoint;
    var
      SkillArr: TStringArray;
      CX, CY, 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', 'construction', 'dungeoneering', 'hitpoints',
      'agility', 'herblore', 'thieving', 'crafting', 'fletching', 'slayer',
      'hunting', '', 'mining', 'smithing', 'fishing', 'cooking',
      'firemaking', 'woodcutting', 'farming', '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;
      If skNo = 18 Then Inc(SkNo);  //empty space
     
      if (InRange(skNo + 1, 1, 27)) then
      begin
        CX := skNo div 9 + 1;
        CY := skNo mod 9 + 1;
        Disguise(SkillArr[SkNo]);
      end;
     
      Result := SkillCoords2(CY, CX);

      GameTab(tab_Stats);
    end;

    function GetSkillInfo2(Skill: Variant; Amount : Boolean): Integer;
    var
      TP: TPoint;
      Box : TBox;
      TPA : TPointArray;
      Cts : Integer;

    begin
      Result := -1;
      GameTab(tab_Stats);
      TP := SkillToCoords2(Skill);
      if (not(Amount)) then
        TP := Point(TP.x + 7, TP.y + 15);
      CTS := GetColorToleranceSpeed;
      ColorToleranceSpeed(0);
      if not FindColors(TPA, 65535, TP.x - 5, TP.y - 4, TP.x + 29, TP.y + 14) then
        exit;
      DebugTPA(TPA, '');
      Box := GetTPABounds(TPA);
      Result := StrToIntDef(GetNumbers(GetTextAtEx(Box.x1 - 2, Box.y1 - 1, 140,
        StatChars, False, True, 0, 3, 65535, 3, True, tr_Digits)), -1);
      ColorToleranceSpeed(CTS);
    end;

    function GetSkillLevel2(Skill: Variant): Integer;
    begin
      Result := GetSkillInfo2(Skill, False);
    end;


    Begin
      SetupSRL;
      SRLPlayerForm(False, [], [], [], []);
      For I := 1 To 25 Do
      Begin
    {    TP := SkillToCoords2(I);
        MMouse(TP.x, TP.y, 0, 0); }

        WriteLn(GetSkillLevel2(I));
        wait(1200);
      End;
    End.

    This one works in scar, but only cannot get 4 skills due to the ocr failing.
    In simba it works 100% perfect.

    (I've attached it with the test script and stuff, I'd advise you to use it with strings, not integers)
    Code:
    SRL Compiled in 16 msec
    -1
    3
    26
    64
    24
    8
    28
    1
    1
    5
    6
    1
    37
    7
    26
    1
    23
    -1
    -1
    -1
    17
    99
    44
    30
    1
    Successfully executed

  8. #8
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    There's also some unused variables in your version, Ray.

  9. #9
    Join Date
    May 2006
    Location
    Amsterdam
    Posts
    3,620
    Mentioned
    5 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Coh3n View Post
    There's also some unused variables in your version, Ray.
    . I'm willing to accept fixes to make it work for Scar, but please let it use the current system, as dirty hax are dirty and not readable . Also have to fix Pinball for Simba 2morrow (note to self)
    Verrekte Koekwous

  10. #10
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by mastaraymond View Post
    . I'm willing to accept fixes to make it work for Scar, but please let it use the current system, as dirty hax are dirty and not readable . Also have to fix Pinball for Simba 2morrow (note to self)
    Dirty hax?

    Oh, and if someone were to have 4 or 5 randomness when moving/clicking the mouse, it could result in hovering/clicking the wrong skill...

  11. #11
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    This still needs to be 100% fixed, I am working on it.

    Any progress anyone makes or suggestions to this thread would be appreciated.

  12. #12
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by IceFire908 View Post
    This still needs to be 100% fixed, I am working on it.

    Any progress anyone makes or suggestions to this thread would be appreciated.
    Seems to work for me, Naum and Raymond?



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  13. #13
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by Wizzup? View Post
    Seems to work for me, Naum and Raymond?
    What Raymond committed works, yes, but the coords aren't near the middle of the skill box (they're almost at the very top edge). It's not really a big deal, but depending on the randomness of the point, it is possible to return an invalid point. I was discussing this with IceFire last night; if you use my SkillCoords, and the SkillToCoords ray committed, it works perfect in both SCAR and Simba. That being said, IceFire was still working on it after I left, so he may have noticed something I didn't.

    Also, I'm pretty sure GetSkillInfo doesn't work (and I think Naum posted a Simba fix above, but doesn't work 100% in SCAR).

  14. #14
    Join Date
    May 2006
    Location
    Amsterdam
    Posts
    3,620
    Mentioned
    5 Post(s)
    Quoted
    0 Post(s)

    Default

    It returns the exact same point as the old one returned, just relative to the new box.. The old 'SkillCoords' returned the upper-level-coordinate. That's why I changed kept this behavior to not break any backwards compatibility..

    Also running this script in scar works fine:
    SCAR Code:
    program New;
    {.include srl/srl.scar}
    begin
      setupsrl;
      Writeln(getxp(skill_woodcutting));
    end.

    So I fail to see your point Coh3n . Use less randomness in skill hovering ^^
    Verrekte Koekwous

  15. #15
    Join Date
    Apr 2008
    Location
    Marquette, MI
    Posts
    15,252
    Mentioned
    138 Post(s)
    Quoted
    680 Post(s)

    Default

    Quote Originally Posted by mastaraymond View Post
    It returns the exact same point as the old one returned, just relative to the new box.. The old 'SkillCoords' returned the upper-level-coordinate. That's why I changed kept this behavior to not break any backwards compatibility..

    Also running this script in scar works fine:
    SCAR Code:
    program New;
    {.include srl/srl.scar}
    begin
      setupsrl;
      Writeln(getxp(skill_woodcutting));
    end.

    So I fail to see your point Coh3n . Use less randomness in skill hovering ^^
    I should have said that it worked, but it could be made better in my opinion.

    I didn't realize that the old one also returned coords near the edge. I thought when I used HoverSkill, it would hover in the middle, but maybe the coords are edited in that procedure. I don't know, I've never looked at it. I just thought it would make more sense to have it return coords in the middle of the box.

    And it would appear that GetSkillInfo is working, my bad.

  16. #16
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    All skills, hovering, getxp, getlevel seem to work pretty well in SCAR 3.23 Beta Latest Rev / Open Dev SRL Latest Rev.

    Also fixed the worldswitcher.

    Edit: Noticed that this version doesn't like bytes ect... for input. I'm pretty sure the old one worked with bytes so I went ahead and added that ability.

  17. #17
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Why on earth would you use a Byte for this... To save memory...? I can assure those three bytes aren't going to make ANY noticeable difference... You're only making this more complex by using Variants.
    Honestly...? Why not just use Integers...

    If it's for backwards compatibility... Who ever got that idea... (I hope it wasn't me... )

    EDIT: Also, why doesn't a byte just work automatically? Casting a byte to an integer should never be a problem...
    Last edited by Wizzup?; 04-13-2010 at 10:30 PM.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  18. #18
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Wizzup? View Post
    Why on earth would you use a Byte for this... To save memory...? I can assure those three bytes aren't going to make ANY noticeable difference... You're only making this more complex by using Variants.
    Honestly...? Why not just use Integers...

    If it's for backwards compatibility... Who ever got that idea... (I hope it wasn't me... )
    Lol a few of the scripts I were using were using Bytes, and I just tested them out to see the debug spammed by 25 lines of "*****WARNING"

    It's for backwards compatibility. The variants have been apart of this since the beginning.

  19. #19
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    Quote Originally Posted by IceFire908 View Post
    Lol a few of the scripts I were using were using Bytes, and I just tested them out to see the debug spammed by 25 lines of "*****WARNING"

    It's for backwards compatibility. The variants have been apart of this since the beginning.
    Well, IMO they should just update their scripts. Keeping endless backwards compatibility not a good idea.



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  20. #20
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Wizzup? View Post
    Also, why doesn't a byte just work automatically? Casting a byte to an integer should never be a problem...
    I dunno why it doesn't work either , all I had to do was add or (This)) then.. not a big change

    SCAR Code:
    var
      B: Byte;

    begin
      WriteLn(BoolToStr(VarType(B) = VarInteger));
      WriteLn(BoolToStr(VarType(B) = VarByte));
    end.

    Quote Originally Posted by Wizzup? View Post
    Well, IMO they should just update their scripts.
    Thought it was easier to update the SVN then two or three (known) scripts =P

    Quote Originally Posted by Wizzup? View Post
    Keeping endless backwards compatibility not a good idea.
    SRL5
    Last edited by Wanted; 04-13-2010 at 10:44 PM.

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
  •