Results 1 to 10 of 10

Thread: GameTab.Scar Additions

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

    Default GameTab.Scar Additions

    SkillCoords:
    In SRL/SRL/Core/GameTab.scar


    SCAR Code:
    Function SkillCoords(Row, Column : ShortInt): TPoint;
    Begin
      Result := Point(577 + (53 * (Column-1)), 228 + (32 * (Row-1)));
      If Row = 8 Then Result.y := 419;
    End;
    ^ This is basically a shorter SkillCords, and it does work! ^


    Tab_Music Functions
    All of these In SRL/SRL/Core/GameTab.scar


    SCAR Code:
    Procedure Loop(State : (TurnOn, TurnOff));
    Begin
      GameTab(tab_Music);
       If GetCurrentTab <> tab_Music Then Exit;  
        If (GetColor(643, 226) = 716552) xOr (State = TurnOn) Then
          Mouse(633, 212, 20, 20, True);
    End;



    Function NumberOfUnlockedSongs: Integer;
    Var TmpStr : String;
        x, y : Integer;
    Begin
      GameTab(tab_Music);
       If GetCurrentTab <> tab_Music Then Exit;

      If FindColor(x, y, 39423, 671, 220, 673, 223) Then
        TmpStr := GetTextAtEx(x - 2, y - 2, 0, StatChars, False, False, 0, 1, 39423, 30, False, tr_AllChars);
      If Pos(' ', TmpStr) > 0 Then Delete(TmpStr, Pos(' ', TmpStr), Length(TmpStr));
      Result := StrToIntDef(Trim(TmpStr), -1);
    End;



    Function SelectMusic(Name : String) : Boolean;
    Var I, x, y, xx, yy, Time : Integer;
        Arr : TStringArray;
        CordY : Extended;
        Result2 : Boolean;

    Begin
      Result := (Capitalize(Trim(LowerCase(Name))) = GetMusic);
      If Result Then
      Begin
        WriteLn('We are already playing the song');
        Exit;
      End;
      If NumberOfUnlockedSongs <= 30 Then
      Begin
        WriteLn('Too few songs unlocked');
        Exit
      End;
      GameTab(tab_Music);
      If GetCurrentTab <> tab_Music Then Exit;
     
      Arr := ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
      'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
      If Pos('the ', Trim(LowerCase(Name))) > 0 Then Delete(Name, 1, 4);

      For I := 0 to High(Arr) Do
      If LowerCase(Name) = 'random' Then
      Begin
        I := Random(23);
        Name := Capitalize(Arr[i]);
        Break;
      End Else
      If LowerCase(Trim(Left(Name, 1))) = Arr[i] Then
        Break;

      CordY := ((5.158 * I) + I Mod 3);

      If StartsWith('s', Trim(Name)) Then CordY := CordY - 2.03;
      If GetNumbers(Left(LowerCase(Trim(Name)), 1)) = '7' Then
        CordY := CordY - (CordY - 0.5);
       
      Mouse(719, 287 + Round(CordY), 6, 1, True);
      Wait(200 + Random(200));
      Time := GetSystemTime + 9600;

      MMouse(718, 440, 7, 7);
      GetMousePos(x, y);
      HoldMouse(x, y, True);
      Repeat
        Result := FindTextTpaEx(ClGreen, 0, MIX1, MIY1, MIX2, MIY2, xx, yy, Capitalize(Name), StatChars, Nothing);
        Result2 := FindTextTpaEx(ClRed, 0, MIX1, MIY1, MIX2, MIY2, xx, yy, Capitalize(Name), StatChars, Nothing);
      Until((Result) Or (Result2) Or (GetSystemTime >= Time));
      Wait((Round(CordY)/5) + Random(30));
      ReleaseMouse(x, y, True);
      Wait(100 + Random(200));
     
      If Result Then
        ClickText(Capitalize(Name), StatChars, MIX1, MIY1, MIX2, MIY2, True);
      If Result2 Then
       If Random(5) = 0 Then
         ClickText(Capitalize(Name), StatChars, MIX1, MIY1, MIX2, MIY2, True);

      If Result Then WriteLn('Found The Song (Unlocked)');
       If Result2 Then WriteLn('Found The Song (Locked)');
        If (Not (Result)) And (Not (Result2)) Then WriteLn('Could NOT Find The Song :(');
    End;


    Loop(State : (TurnOn, TurnOff));
    Loop(TurnOff);
    Will turn off the Loop if it is on and will not do anything if it is off.

    Loop(TurnOn);
    Will turn on the Loop if it is off and will not do anything if it is on.


    NumberOfUnlockedSongs : Integer
    Gets the amount of Unlocked Songs out of 604, will return '-1' if failed


    SelectMusic(Music : String);
    If the selected music is playing then it will abort.
    Otherwise, it will select the given music if it is unlocked, otherwise there is a 1/5 chance of it clicking the locked tune.
    It uses some basic math to calculate where the song titles (of that respective suffix) begins. Useful for Anti-Ban .
    Last edited by Naum; 07-24-2009 at 04:13 PM.

  2. #2
    Join Date
    Mar 2007
    Location
    <3
    Posts
    2,683
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Lookin' good, tho I'm still not certain that It would change sound if you get a random...
    However, you forgot to use GameTab(Tab_Music) in the first two music functions.

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

    Default

    Quote Originally Posted by N1ke! View Post
    Lookin' good, tho I'm still not certain that It would change sound if you get a random...
    However, you forgot to use GameTab(Tab_Music) in the first two music functions.
    Thanks, added

  4. #4
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    No to the music changer. Randoms rely on it too much.

    Sorry bud.
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

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

    Default

    Okay, I accept that. Could you give the SkillCoords shorten a once-over please?

  6. #6
    Join Date
    Apr 2007
    Location
    Perth, Australia
    Posts
    3,926
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    You sure your SkillCoords work 100%. Cos when we tested it a couple weeks back, the coords weren't exactly the same, remember?

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

    Default

    Quote Originally Posted by ZephyrsFury View Post
    You sure your SkillCoords work 100%. Cos when we tested it a couple weeks back, the coords weren't exactly the same, remember?
    I remember, but I fixed it, try it with this script:

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

    Var x, y : Integer;
        tp : tpoint;
       
    Function SkillCoords1(Row, Column : ShortInt): TPoint;
    Begin
      Result := Point(577 + (54 * (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.

    Open your skills table and confirm that it matches.

    Edit: I get this as the SCAR output:

    SCAR Code:
    Successfully compiled (2257 ms)
    Line 4: [Hint] (19801:5): Variable 'Y' never used in script
    Line 5: [Hint] (19802:1): Variable 'TP' never used in script
    SRL Compiled in 31 msec
    49
    51
    48
    3
    28
    37
    6
    49
    1
    1
    1
    3
    1
    1
    38
    31
    0
    31
    33
    73
    1
    1
    1
    1
    Successfully executed

    My Stats are this:

    Last edited by Naum; 07-24-2009 at 04:10 PM.

  8. #8
    Join Date
    Dec 2008
    Posts
    2,813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Doesn't work if the skill is 10-19?

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

    Default

    Quote Originally Posted by 99_ aka ian. View Post
    Doesn't work if the skill is 10-19?
    The current one is SRL does not do the '1's either according to my SCAR?

  10. #10
    Join Date
    Dec 2008
    Posts
    2,813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    It does the skills that are 1 or end in a 1, but if it's 10-19, it doesn't get the one, only x in 1x.

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
  •