Results 1 to 18 of 18

Thread: 4 small things.

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

    Default 4 small things.

    1) FindXP, 'prayer' augument could be shortened from this:

    SCAR Code:
    'prayer': case sType of   // PRAYER
            'normal bones'     : Result:= 4.5;     // NORMAL BURYING BONES
            'burnt bones'      : Result:= 4.5;
            'wolf bones'       : Result:= 4.5;
            'monkey bones'     : Result:= 5;
            'bat bones'        : Result:= 5.3;
            'big bones'        : Result:= 15;
            'jogre bones'      : Result:= 15;
            'shaikahan bones'  : Result:= 25;
            'baby dragon bones': Result:= 30;
            'wyvern bones'     : Result:= 50;
            'dragon bones'     : Result:= 72;
            'dagannoth bones'  : Result:= 125;
            'zogre bones'      : Result:= 22.5;
            'fayrg bones'      : Result:= 84;
            'raurg bones'      : Result:= 96;
            'ourg bones'       : Result:= 140;

            'g normal bones'     : Result:= 4.5 * 3.5;     // GILDED + BURNERS
            'g burnt bones'      : Result:= 4.5 * 3.5;
            'g wolf bones'       : Result:= 4.5 * 3.5;
            'g monkey bones'     : Result:= 5 * 3.5;
            'g bat bones'        : Result:= 5.3 * 3.5;
            'g big bones'        : Result:= 15 * 3.5;
            'g jogre bones'      : Result:= 15 * 3.5;
            'g shaikahan bones'  : Result:= 25 * 3.5;
            'g baby dragon bones': Result:= 30 * 3.5;
            'g wyvern bones'     : Result:= 50 * 3.5;
            'g dragon bones'     : Result:= 72 * 3.5;
            'g dagannoth bones'  : Result:= 125 * 3.5;
            'g zogre bones'      : Result:= 22.5 * 3.5;
            'g fayrg bones'      : Result:= 84 * 3.5;
            'g raurg bones'      : Result:= 96 * 3.5;
            'g ourg bones'       : Result:= 140 * 3.5;

            'e normal bones'     : Result:= 4.5 * 4;     // ECTOFUNTUS
            'e burnt bones'      : Result:= 4.5 * 4;
            'e wolf bones'       : Result:= 4.5 * 4;
            'e monkey bones'     : Result:= 5 * 4;
            'e bat bones'        : Result:= 5.3 * 4;
            'e big bones'        : Result:= 15 * 4;
            'e jogre bones'      : Result:= 15 * 4;
            'e shaikahan bones'  : Result:= 25 * 4;
            'e baby dragon bones': Result:= 30 * 4;
            'e wyvern bones'     : Result:= 50 * 4;
            'e dragon bones'     : Result:= 72 * 4;
            'e dagannoth bones'  : Result:= 125 * 4;
            'e zogre bones'      : Result:= 22.5 * 4;
            'e fayrg bones'      : Result:= 84 * 4;
            'e raurg bones'      : Result:= 96 * 4;
            'e ourg bones'       : Result:= 140 * 4;
        end;

    to this:

    SCAR Code:
    'prayer': Begin
                  Case sType[1] Of
                    'g' : T := 3.5;
                    'e' : T := 4.0;
                  End;
                  If T = 3.5 Then P := 'g ';
                  If T = 4.0 Then P := 'e ';
                  If T = 0.0 Then P := '';

            Case sType of   // PRAYER
                P+'normal bones', P+'burnt bones', P+'wolf bones'      : Result:= 4.5 * (1.0 * T);
                P+'monkey bones'     : Result:= 5 * (1.0 * T);
                P+'bat bones'        : Result:= 5.3 * (1.0 * T);
                P+'jogre bones', P+'big bones'      : Result:= 15 * (1.0 * T); //those give same amount of XP too.
                P+'shaikahan bones'  : Result:= 25 * (1.0 * T);
                P+'baby dragon bones': Result:= 30 * (1.0 * T);
                P+'wyvern bones'     : Result:= 50 * (1.0 * T);
                P+'dragon bones'     : Result:= 72 * (1.0 * T);
                P+'dagannoth bones'  : Result:= 125 * (1.0 * T);
                P+'zogre bones'      : Result:= 22.5 * (1.0 * T);
                P+'fayrg bones'      : Result:= 84 * (1.0 * T);
                P+'raurg bones'      : Result:= 96 * (1.0 * T);
                P+'ourg bones'       : Result:= 140 * (1.0 * T);
            End;
        End;

    If this is done then 2 new variables, 'P' being a string and 'T' being an Extended would need to be added .



    2) SetAngle could be shortened and a variable could be removed:

    SCAR Code:
    procedure SetAngle(Highest : Boolean);
    var
      Key: Byte;
    begin;
      if (not LoggedIn) then exit;
      if (Highest) then
        Key := 38
      else Key := 40;
      KeyDown(Key);
      Sleep(1000 + Random(100) + Random(200));
      KeyUp(Key);
      Wait(500 + Random(100));
    end;

    to:

    SCAR Code:
    procedure SetAngle(Highest : Boolean);
    begin
      if (not LoggedIn) then exit;
      KeyDown((Integer(Not Highest)*2)+38);
      Sleep(1000 + Random(300));
      KeyUp((Integer(Not Highest)*2)+38);
      Wait(500 + Random(100));
    end;



    3) A new SetupAutoCast:

    SCAR Code:
    function SetUpAutoCast(AutoSpell: string; Defensive: Boolean): Boolean;
    var
      X, Y: Integer;

    begin
      Result := False;
      if not GameTab(tab_Combat) then exit;

      if (Defensive) then
        Mouse(655, 253, 50, 25, True)
      else Mouse(665, 320, 50, 25, True);

      Wait(2000 + Random(1500));
      case LowerCase(AutoSpell) of
        'wind strike', '1':  Result := FindColor(X, Y, 16579836, 577, 236, 588, 246);
        'water strike','2':  Result := FindColor(X, Y, 16563743, 617, 236, 628, 246);
        'earth strike','3':  Result := FindColor(X, Y, 3003805, 657, 236, 668, 246);
        'fire strike', '4':  Result := FindColor(X, Y, 835570, 696, 236, 707, 246);

        'wind bolt',   '5':  Result := FindColor(X, Y, 16579836, 577, 295, 590, 309);
        'water bolt',  '6':  Result := FindColor(X, Y, 16563743, 617, 295, 630, 309);
        'earth bolt',  '7':  Result := FindColor(X, Y, 3003805, 656, 295, 669, 309);
        'fire bolt',   '8':  Result := FindColor(X, Y, 835570, 697, 295, 710, 309);

        'wind blast',  '9':  Result := FindColor(X, Y, 16579836, 573, 356, 587, 371);
        'water blast','10': Result := FindColor(X, Y, 16563743, 614, 356, 628, 371);
        'earth blast','11': Result := FindColor(X, Y, 3003805, 654, 356, 668, 371);
        'fire blast', '12': Result := FindColor(X, Y, 835570, 694, 357, 708, 372);

        'wind wave',  '13':  Result := FindColor(X, Y, 16579836, 574, 414, 591, 435);
        'water wave', '14':  Result := FindColor(X, Y, 16563743, 614, 414, 631, 435);
        'earth wave', '15':  Result := FindColor(X, Y, 3003805, 655, 414, 672, 435);
        'fire wave',  '16':  Result := FindColor(X, Y, 835570, 694, 414, 711, 435);
      else
        begin
          srl_Warn('SetUpAutoCast', '"' + AutoSpell + '" is not a valid autocasting spell.', warn_Warning);
          Mouse(687, 584, 4, 4, True); // Exits the autocasting spells setup 'popup'.
          Exit;
        end;
      end;
      if (Result) then
      begin
        Mouse(X, Y, 2, 2, True);
        Wait(1750 + Random(1500));
      end;
    end;

    to:

    SCAR Code:
    Procedure SetupAutoCast(Spell: String; Defensive: Boolean);
    Var SpellNames : Array [0..1] Of TStringArray;
        TSA : TStringArray;
        i, xb, yb, x, y : Integer;
        SpellInt : TIntegerArray;
    Begin
      If Not GameTab(Tab_Combat) Then Exit;
      SpellNames[0] := ['wind', 'water', 'earth', 'fire'];
      SpellNames[1] := ['strike', 'bolt', 'blast', 'wave'];
      Mouse(655, ((Integer(not(Defensive)) * 60) + 253), 50, 25, True);
      TSA := srl_Explode(Spell, ' ');
      SetLength(SpellInt, 2);
      For I := 0 To 1 Do
      If Not(InStrArrEx(TSA[i], SpellNames[i], SpellInt[i])) Then
      Begin
        srl_Warn('SetupAutoCast', 'Invalid spell name', warn_AllVersions);
        Exit;
      End;
      xb := 585 + (39 * SpellInt[0]);
      yb := 245 + (60 * SpellInt[1]);
      Wait(500 + Random(500));
      If Not FindColor(x, y, 2, xb - 10, yb - 10, xb + 10, yb + 10) then
        Mouse(xb, yb, 3, 3, True)
      Else
        Mouse(687, 448, 9, 4, True); //If it's invalid then exit menu
    End;

    Fixed a DIB error

    Fixed Out Of Range Error
    Fixed Co-ordinates
    Removed the need for colors, found out that the outline stayed the same.
    Added a Mouse() to exit the popup
    Needed To Set The Length
    Fixed how it would select 'Defensive', the co-ords were off by too much.
    Credits go to Richard.
    Big hand to Markus for letting me test it on his account



    4) FindAxe's 'FoundAxe' output could be array'ised'.


    Thanks for looking over, please post suggestions, or further shortenings
    Last edited by Naum; 09-07-2009 at 11:51 PM.

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

    Default

    Nice!
    Good work, although the new SetupAutoCast has a lot of variables :P

    By the way; that's 3 things, not 4

  3. #3
    Join Date
    May 2007
    Location
    England
    Posts
    4,141
    Mentioned
    11 Post(s)
    Quoted
    266 Post(s)

    Default

    Quote Originally Posted by Zyt3x View Post
    By the way; that's 3 things, not 4
    Quote Originally Posted by NaumanAkhlaQ View Post
    1) FindXP, 'prayer' augument could be shortened from this

    2) SetAngle could be shortened and a variable could be removed:

    3) A new SetupAutoCast:

    4) FindAxe's 'FoundAxe' output could be array'ised'.


    Couldn't this
    SCAR Code:
    Case sType of   // PRAYER
                P+'normal bones'     : Result:= 4.5 + (1.0 * T);     // NORMAL BURYING BONES
                P+'burnt bones'      : Result:= 4.5 + (1.0 * T);
                P+'wolf bones'       : Result:= 4.5 + (1.0 * T);
                P+'monkey bones'     : Result:= 5 + (1.0 * T);
                P+'bat bones'        : Result:= 5.3 + (1.0 * T);
                P+'big bones'        : Result:= 15 + (1.0 * T);
                P+'jogre bones'      : Result:= 15 + (1.0 * T);
                P+'shaikahan bones'  : Result:= 25 + (1.0 * T);
                P+'baby dragon bones': Result:= 30 + (1.0 * T);
                P+'wyvern bones'     : Result:= 50 + (1.0 * T);
                P+'dragon bones'     : Result:= 72 + (1.0 * T);
                P+'dagannoth bones'  : Result:= 125 + (1.0 * T);
                P+'zogre bones'      : Result:= 22.5 + (1.0 * T);
                P+'fayrg bones'      : Result:= 84 + (1.0 * T);
                P+'raurg bones'      : Result:= 96 + (1.0 * T);
                P+'ourg bones'       : Result:= 140 + (1.0 * T);

    Be shortened to this?

    SCAR Code:
    Case sType of   // PRAYER
                P+'normal bones'     : Result:= 4.5 + T;     // NORMAL BURYING BONES
                P+'burnt bones'      : Result:= 4.5 + T;
                P+'wolf bones'       : Result:= 4.5 + T;
                P+'monkey bones'     : Result:= 5 + T;
                P+'bat bones'        : Result:= 5.3 + T;
                P+'big bones'        : Result:= 15 + T;
                P+'jogre bones'      : Result:= 15 + T;
                P+'shaikahan bones'  : Result:= 25 + T;
                P+'baby dragon bones': Result:= 30 + T;
                P+'wyvern bones'     : Result:= 50 + T;
                P+'dragon bones'     : Result:= 72 + T;
                P+'dagannoth bones'  : Result:= 125 + T;
                P+'zogre bones'      : Result:= 22.5 + T;
                P+'fayrg bones'      : Result:= 84 + T;
                P+'raurg bones'      : Result:= 96 + T;
                P+'ourg bones'       : Result:= 140 + T;

    Richard.
    <3

    Quote Originally Posted by Eminem
    I don't care if you're black, white, straight, bisexual, gay, lesbian, short, tall, fat, skinny, rich or poor. If you're nice to me, I'll be nice to you. Simple as that.

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

    Default

    - BUMP, I know at least one Dev who would have liked to see the SetupAutoCast one.

    EDIT: R1ch, I made an operator error there , fixed.
    Last edited by Naum; 09-07-2009 at 01:22 AM.

  5. #5
    Join Date
    Feb 2007
    Posts
    3,616
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Couldn't this:
    SCAR Code:
    'prayer': Begin
                  Case sType[1] Of
                    'g' : T := 3.5;
                    'e' : T := 4.0;
                  End;
                  If T = 3.5 Then P := 'g ';
                  If T = 4.0 Then P := 'e ';
                  If T = 0.0 Then P := '';

            Case sType of   // PRAYER
                P+'normal bones'     : Result:= 4.5 * (1.0 * T);     // NORMAL BURYING BONES
                P+'burnt bones'      : Result:= 4.5 * (1.0 * T);
                P+'wolf bones'       : Result:= 4.5 * (1.0 * T);
                P+'monkey bones'     : Result:= 5 * (1.0 * T);
                P+'bat bones'        : Result:= 5.3 * (1.0 * T);
                P+'big bones'        : Result:= 15 * (1.0 * T);
                P+'jogre bones'      : Result:= 15 * (1.0 * T);
                P+'shaikahan bones'  : Result:= 25 * (1.0 * T);
                P+'baby dragon bones': Result:= 30 * (1.0 * T);
                P+'wyvern bones'     : Result:= 50 * (1.0 * T);
                P+'dragon bones'     : Result:= 72 * (1.0 * T);
                P+'dagannoth bones'  : Result:= 125 * (1.0 * T);
                P+'zogre bones'      : Result:= 22.5 * (1.0 * T);
                P+'fayrg bones'      : Result:= 84 * (1.0 * T);
                P+'raurg bones'      : Result:= 96 * (1.0 * T);
                P+'ourg bones'       : Result:= 140 * (1.0 * T);
            End;
        End;

    Be
    SCAR Code:
    'prayer': Begin
                  Case sType[1] Of
                    'g' : T := 3.5;
                    'e' : T := 4.0;
                  End;
                  If T = 3.5 Then P := 'g ';
                  If T = 4.0 Then P := 'e ';
                  If T = 0.0 Then P := '';

            Case sType of   // PRAYER
                P+'normal bones', P+'burnt bones', P+'wolf bones'      : Result:= 4.5 * (1.0 * T);
                P+'monkey bones'     : Result:= 5 * (1.0 * T);
                P+'bat bones'        : Result:= 5.3 * (1.0 * T);
                P+'big bones'        : Result:= 15 * (1.0 * T);
                P+'jogre bones'      : Result:= 15 * (1.0 * T);
                P+'shaikahan bones'  : Result:= 25 * (1.0 * T);
                P+'baby dragon bones': Result:= 30 * (1.0 * T);
                P+'wyvern bones'     : Result:= 50 * (1.0 * T);
                P+'dragon bones'     : Result:= 72 * (1.0 * T);
                P+'dagannoth bones'  : Result:= 125 * (1.0 * T);
                P+'zogre bones'      : Result:= 22.5 * (1.0 * T);
                P+'fayrg bones'      : Result:= 84 * (1.0 * T);
                P+'raurg bones'      : Result:= 96 * (1.0 * T);
                P+'ourg bones'       : Result:= 140 * (1.0 * T);
            End;
        End;

  6. #6
    Join Date
    May 2008
    Posts
    308
    Mentioned
    1 Post(s)
    Quoted
    14 Post(s)

    Default

    It sure could.

    Edit: You could do the same with all of them?
    SCAR Code:
    'prayer': Begin
                  Case sType[1] Of
                    'g' : T := 3.5;
                    'e' : T := 4.0;
                  End;
                  If T = 3.5 Then P := 'g ';
                  If T = 4.0 Then P := 'e ';
                  If T = 0.0 Then P := '';

            Case sType of   // PRAYER
                P+'normal bones', P+'burnt bones', P+'wolf bones'      : Result:= 4.5 * (1.0 * T);
                P+'monkey bones'     : Result:= 5 * (1.0 * T);
                P+'bat bones'        : Result:= 5.3 * (1.0 * T);
                P+'jogre bones', P+'big bones'      : Result:= 15 * (1.0 * T); //those give same amount of XP too.
                P+'shaikahan bones'  : Result:= 25 * (1.0 * T);
                P+'baby dragon bones': Result:= 30 * (1.0 * T);
                P+'wyvern bones'     : Result:= 50 * (1.0 * T);
                P+'dragon bones'     : Result:= 72 * (1.0 * T);
                P+'dagannoth bones'  : Result:= 125 * (1.0 * T);
                P+'zogre bones'      : Result:= 22.5 * (1.0 * T);
                P+'fayrg bones'      : Result:= 84 * (1.0 * T);
                P+'raurg bones'      : Result:= 96 * (1.0 * T);
                P+'ourg bones'       : Result:= 140 * (1.0 * T);
            End;
        End;
    Last edited by slackeru; 09-07-2009 at 03:07 AM. Reason: Ctrl + C, Ctrl + V is handy.

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

    Default

    Added to first post, thanks

  8. #8
    Join Date
    Mar 2008
    Location
    New Jersey
    Posts
    1,673
    Mentioned
    1 Post(s)
    Quoted
    9 Post(s)

    Default

    NaumanAkhlaQ:= Genious;

    Definitely jealous of your abilities and knowledge, wish I was as good as you

    Nice fixes, and I like your use of (not Highest) * 2, VERY creative, I don't see people do stuff like that, use the booleans returned result of 1 or 0, and it saved memory good job. What can't you do? I bet I see a new dev coming soon

    Rep++ for you, I bet you're getting close to 6 now haha, you'll make us have to add a 6th one.

  9. #9
    Join Date
    Jul 2008
    Location
    England
    Posts
    763
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    One thing though, does SetupAutoCast(...) work with the new rs?
    lol

  10. #10
    Join Date
    Aug 2009
    Location
    Nova Scotia, Canada
    Posts
    604
    Mentioned
    0 Post(s)
    Quoted
    56 Post(s)

    Default

    At the risk of being flamed right out of this thread, making code a tiny bit more efficient at the expensive of making it cryptic is not always a good thing.

    I used to have to do maintenance on fortran code written by engineers that was so cryptic/confusing that half the time they couldn't even understand it. Drove me nuts.

    Personally I say spend the couple extra cpu cycles if it means readable code. Cpu power is cheap these days.

  11. #11
    Join Date
    Jun 2006
    Posts
    1,492
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Bixby Sayz View Post
    At the risk of being flamed right out of this thread, making code a tiny bit more efficient at the expensive of making it cryptic is not always a good thing.

    I used to have to do maintenance on fortran code written by engineers that was so cryptic/confusing that half the time they couldn't even understand it. Drove me nuts.

    Personally I say spend the couple extra cpu cycles if it means readable code. Cpu power is cheap these days.
    Agreed.

    Shortening with things like (Not Highest)*2 is good, but most SRL functions are made so it is readable and easily edited when changed.

  12. #12
    Join Date
    Mar 2008
    Location
    New Jersey
    Posts
    1,673
    Mentioned
    1 Post(s)
    Quoted
    9 Post(s)

    Default

    (not highest) * 2 is very readable and easily edited. I don't think this is a hard concept for any dev to not be able to understand or edit.

  13. #13
    Join Date
    Jun 2006
    Posts
    1,492
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by Baked0420 View Post
    (not highest) * 2 is very readable and easily edited. I don't think this is a hard concept for any dev to not be able to understand or edit.
    Yeah, I said that was great =)

    But things like the edited SetupAutoCast, that's hard to read and edit.

  14. #14
    Join Date
    Sep 2006
    Posts
    5,219
    Mentioned
    4 Post(s)
    Quoted
    1 Post(s)

    Default

    Interesting timing, there's a discussion in dev section atm about commenting in SRL more.

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

    Default

    Quote Originally Posted by Bixby Sayz View Post
    At the risk of being flamed right out of this thread, making code a tiny bit more efficient at the expensive of making it cryptic is not always a good thing.

    I used to have to do maintenance on fortran code written by engineers that was so cryptic/confusing that half the time they couldn't even understand it. Drove me nuts.

    Personally I say spend the couple extra cpu cycles if it means readable code. Cpu power is cheap these days.
    Bixby Sayz: I absolutely agree with you. The main reason I fixed it up (note: I did not make it) becuase EC! wanted to see it, as stated in the last SUAC Thread.


    Quote Originally Posted by Infantry001 View Post
    Yeah, I said that was great =)

    But things like the edited SetupAutoCast, that's hard to read and edit.
    Same as above


    @Baked, Hey thanks . I did the Integer(no Highest)*2 mainly because there was no discussion about efficiency (as there is a wait afterward).

  16. #16
    Join Date
    Apr 2009
    Posts
    10
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Where would I find a tutorial on how to understand any of this? Pm please...thanks.

  17. #17
    Join Date
    Sep 2007
    Location
    British Columbia, Canada
    Posts
    4,047
    Mentioned
    1 Post(s)
    Quoted
    2 Post(s)

    Default

    The answer to your question is here, and the real answer is here.
    Oh Hai Dar

  18. #18
    Join Date
    May 2007
    Location
    England
    Posts
    4,141
    Mentioned
    11 Post(s)
    Quoted
    266 Post(s)

    Default

    Haha. Was about the report Snowleader for spamming after reading his other posts, but he's suspended now. Spooky...
    <3

    Quote Originally Posted by Eminem
    I don't care if you're black, white, straight, bisexual, gay, lesbian, short, tall, fat, skinny, rich or poor. If you're nice to me, I'll be nice to you. Simple as 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
  •