Results 1 to 13 of 13

Thread: A couple fixes and improvements..

  1. #1
    Join Date
    Jul 2007
    Location
    Norway.
    Posts
    1,938
    Mentioned
    3 Post(s)
    Quoted
    0 Post(s)

    Default A couple fixes and improvements..

    HAI. Please comment.

    1:
    SCAR Code:
    function FindDead: Boolean;
    begin
      if not LoggedIn then exit;
      Result := FindTextTPA(0, 0, MCX1, MCY1, MCX2, MCY2, 'dear', SmallChars, Nothing);
      if not Result then exit;
      Inc(Deaths);
      SaveToChatLog;
      if Reincarnate then exit;
      if ScreenShots then
        TakeScreen('Found Dead');
      if not LogOut then
        repeat
          Wait(1000 + Random(1000));
        until not LoggedIn;
      Players[CurrentPlayer].Rand := 'Died';
      Players[CurrentPlayer].Active := False;
    end;

    Shortened.

    2: FindLamp skill coords can be shortened using simple maths.

    3:
    SCAR Code:
    function InBlack: Boolean;
    var
      I: Byte;
    begin
      if not LoggedIn then exit;
      for I := 1 to 4 do
      begin
        case I of
          1: Result := ((GetColor(650, 155) = 65536) and (GetColor(650, 145) = 65536)
            and (GetColor(650, 135) = 65536) and (GetColor(650, 125) = 65536));
          2: Result := ((GetColor(650, 15) = 65536) and (GetColor(650, 25) = 65536)
            and (GetColor(650, 35) = 65536) and (GetColor(650, 45) = 65536));
          3: Result := ((GetColor(580, 82) = 65536) and (GetColor(590, 82) = 65536)
            and (GetColor(600, 82) = 65536) and (GetColor(610, 82) = 65536));
          4: Result := ((GetColor(714, 82) = 65536) and (GetColor(704, 82) = 65536)
            and (GetColor(694, 82) = 65536) and (GetColor(684, 82) = 65536));
        end;
        if Result then exit;
      end;
    end;

    Shortened by lots.


    4:
    SCAR Code:
    function NoGameTab: Boolean;
    var                        
      I: Byte;
    begin
      Result := False;
      if not LoggedIn then exit;
      for I := 1 to 14 do
        if not TabExists(I) then
        begin
          Result := True;
          Exit;
        end;
    end;

    I really don't understand the current NoGameTab in Rev#20. No randomness in waiting, and why wait a second if it finds a missing GameTab?

    5:
    SCAR Code:
    function IntArrayMatch(Ar1, Ar2: TIntegerArray): Boolean;
    var
      I, L: Integer;
    begin
      Result := False;
      L := High(Ar1);
      if L <> High(Ar2) then exit;
      for I := 0 to L do
        if not InIntArray(Ar2, Ar1[I]) then exit;
      Result := True;
    end;

    Minor fixes.

    6: I think DwarfItem should be added to Dwarf Handler.

    7:
    SCAR Code:
    function FindNonInventoryRandoms: Boolean;
    var
      I: Byte;
    begin
      if not LoggedIn then exit;
      for I := 1 to 5 do
      begin
        case I of
          1: Result := SolveNonTalkingRandoms; // Why not "Result := .." ?
          2: Respond;
          3: Result := FindTalk;
          4: Result := FindDead;
          5: Result := RC;
        end;
        if Result then exit;
      end;
    end;

    Minor fixes again.

    8:
    SCAR Code:
    function FindNormalRandoms: Boolean;
    var
      I: Byte; // 0..255 and -2147483648..2147483648.
    begin
      Result := False;
      if not LoggedIn then exit;
      for I := 1 to 8 do
      begin
        case I of
          1: Result := SolveNonTalkingRandoms; // Again, why not "Result := .." ?
          2: Respond;
          3: Result := FindTalk;
          4: Result := FindDead;
          5: Result := FindLamp(LampSkill);
          6: Result := (FindBox) and (SolveBox);
          7: Result := RC;
          8: Result := FindMod;
        end;
        if Result then exit;
      end;
    end;

    Again, just small fixes..

    9
    was a fail.


    10: What's the use of GambleNewBox?

    11:
    SCAR Code:
    {*******************************************************************************
    Description: Results: 0 if nothing found, 1 for first and 2 for second screen.
    Coords are taken from current TradeScreen and TradeScreen2 functions.
    *******************************************************************************}

    function TradeScreen: Byte;
    begin
      Result := 0;
      if GetColor(90, 61) = 2070783 then
        Result := 1
      else
        if GetColor(142, 55) = 0 then
          Result := 2;
    end;

    Combined the two TradeScreen functions.

    12:
    SCAR Code:
    function CheckArea(Area: string): Boolean;
    begin
      Result := False;
      case LowerCase(Area) of
        'inv', 'inventory': Result := (BankScreen or ShopScreen or TradeScreen or GameTab(4));
        'shop': Result := ShopScreen;
        'bank': Result := BankScreen; // What if user doesn't want to fix bank..?
        'trade', 'your trade': Result := TradeScreen;
      else
        srl_Warn('CheckArea', Area + ' is an invalid option', warn_AllVersions);
      end;
      if not Result then
        WriteLn('PROBLEM: ' + Area + ' interface not open'); // I'm not sure if thats
    end; // even needed.

    Shortened.

    13:
    SCAR Code:
    procedure RandomRClick; // Why evade simplicity?
    var
      M: Byte;
    begin
      if not LoggedIn then exit;
      M := MouseSpeed;
      MouseSpeed := 7 + Random(4);
      ActivateClient;
      MouseBox(MSX1, MSY1, MIX2, MIY2, 2);
      MouseSpeed := M;
    end;

    Replaced with one single MouseBox.

    14:
    SCAR Code:
    procedure FixBank;
    var
      X, Y, T: Integer;
    begin
      if (BankScreen) and (GetColor(486, 103) = 1975337) then
      begin
        MMouse(486, 105, 3, 3);
        GetMousePos(X, Y);
        HoldMouse(X, Y, True); // Random(1) allways returns 0..
        T := GetSystemTime;
        repeat
          Wait(30 + Random(50));
          if GetSystemTime - T > 10000 then break;
        until GetColor(486, 103) <> 1975337;
        Wait(300 + Random(300));
        ReleaseMouse(X, Y, True);
      end;
    end;

    UUh. Shortened and removed the Random(1)'s.

    15:
    SCAR Code:
    function Flag: Boolean; // Small change..
    var
      timeout, x, y: Integer;
    begin
      if not LoggedIn then exit;
      Result := FindColor(X, Y, 255, MMX1, MMY1, MMX2, MMY2);
      if Result then
        repeat
          Wait(100);
          Inc(Timeout);
        until (not FindColor(x, y, 255, MMX1, MMY1, MMX2, MMY2)) or (Timeout > 300);
    end;

    Shortened.

    16:
    SCAR Code:
    procedure MouseFlag(CX, CY, RandX, RandY, Dist: Integer); // <- Uses FFlag(Dist)
    var
      I: Byte;
    begin
      if not LoggedIn then exit;
      Mouse(CX, CY, RandX, RandY, True);
      repeat
        Wait(50 + Random(50));
        Inc(i);
      until (FlagPresent) or (I < 15);
      FFlag(Dist);
      Wait(500 + Random(350));
    end;

    I think I shortened it? And more importantly, replaced Flag with FFlag and added dist parameter.

    17:
    SCAR Code:
    Procedure ChatsOff;
    var
      I: Byte; // INTEGER NAZI PEOPLE!!!11
    begin
      if not LoggedIn then exit;
      for I := 1 to 5 do
        SetChat('off', I);
    end;

    Very small change.

    18: GetCurrentTab and TabExists can be shortened with simple maths.

    19: Please remove my name from the "Retaliate" function credits.

    20: SkillToCoords should also be shortened using maths.

    21:
    SCAR Code:
    {*******************************************************************************
    Replaces MouseItem and MMouseItem. 8D
    *******************************************************************************}

    procedure MouseItem(I, ClickType: Byte);
    var
      TB: TBox;
    begin
      if not LoggedIn then exit;
      if not GetCurrentTab = 4 then
      begin
        if not GameTab(4) then exit;
        Wait(500 + Random(350));
      end;
      GetInvItemBounds(I, TB);
      MouseBox(TB.X1 + 4, TB.Y1 + 4, TB.X2 - 4, TB.Y2 - 4, ClickType);
    end;

    Small function to replace both MouseItem and MMouseItem.

    SCAR Code:
    {*******************************************************************************
    Small fix + "uptated" for use with new MouseItem, if it will be used.
    *******************************************************************************}

    procedure DragItem(Inv1, Inv2: Byte);
    var
      X, Y: Integer;
    begin
      if not LoggedIn then exit;
      MouseItem(Inv1, 3);
      GetMousePos(X, Y);
      HoldMouse(X, Y, True);
      Wait(150 + Random(150));
      MouseItem(Inv2, 3);
      GetMousePos(X, Y);
      ReleaseMouse(X, Y, True);
      Wait(350 + Random(350));
    end;

    "Updated" for the new MouseItem, if you people decide to use it..

    SCAR Code:
    {*******************************************************************************
    If the items are unloaded, they'll appear a little later than the gametab switch..
    *******************************************************************************}

    function ExistsItem(I: Byte): Boolean;
    var
      X, Y: Integer;
      TB: TBox;
    begin
      Result := False;
      if not LoggedIn then exit;
      if not GetCurrentTab = 4 then
      begin
        if not GameTab(4) then exit;
        Wait(500 + Random(350));
      end;
      TB := InvBox(i);
      Result := FindColor(x, y, 65536, TB.x1 + 5, TB.y1 + 5, TB.x2 - 5, TB.y2 - 5);
    end;

    I noticed a lot of use of Integers where Bytes could be used. An integer has a value of -2147483648..2147483648, while a Byte has a value of 0..255. Saves soem memory and looks prettier. IMO. And also, SmallInt could be used in some places, but I'm currently experiencing some trouble with that, so I decided not to use that var type, in case the problam was global.

    Anyway, see proc description.

    SCAR Code:
    {*******************************************************************************
    Same as above + more small fixes.
    *******************************************************************************}

    function InvCount: Byte;
    var
      I: Byte;
    begin
      Result := 0;
      if not LoggedIn then exit;
      if not GetCurrentTab = 4 then
      begin
        if not GameTab(4) then exit;
        Wait(500 + Random(350));
      end;
      for I := 1 to 28 do
        if ExistsItem(I) then Inc(Result);
    end;

    @Description();

    SCAR Code:
    function InvFull: Boolean; // ^^^
    begin
      Result := False;
      if not LoggedIn then exit;
      if not GetCurrentTab = 4 then
      begin
        if not GameTab(4) then exit;
        Wait(500 + Random(350));
      end;
      Result := InvCount = 28;
    end;

    @DescriptionOfProcAbove();

    SCAR Code:
    function DropItem(i: Byte): Boolean;
    begin
      Result := False;
      if (not LoggedIn) or (not ExistsItem(i)) then exit;// Existsitem switches gametabs..
      MouseItem(I, 2);  // New MouseItem..
      Wait(170 + Random(150));
      Result := ChooseOption('rop');
      Wait(RandomRange(50, 200));
    end;


    All I had time for, please leave comments for me to read when I get back.

    Thanks.

  2. #2
    Join Date
    Dec 2006
    Location
    Sweden
    Posts
    10,812
    Mentioned
    3 Post(s)
    Quoted
    16 Post(s)

    Default

    Sex-eh.

    Make sure though before scanning for the text in FindDead "if not loggedIn then Exit;". And only other thing is standards in one or two spots.

    Looks nice


    Send SMS messages using Simba
    Please do not send me a PM asking for help; I will not be able to help you! Post in a relevant thread or make your own! And always remember to search first!

  3. #3
    Join Date
    Mar 2006
    Posts
    3,051
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    So if someone says 'oh dear', everyone logs out? Lol.


  4. #4
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    Tara, Tara, Tara

    Result := FindTextTPA(0, 0, MCX1, MCY1, MCX2, MCY2, 'dear', SmallChars, Nothing);

    It's black text

  5. #5
    Join Date
    Jul 2007
    Location
    Norway.
    Posts
    1,938
    Mentioned
    3 Post(s)
    Quoted
    0 Post(s)

    Default

    Ok, any comments regarding the actual functions? Or do I have to split them up and comment every single of them?

    Edit: Done, now please comment the functions and procedures.


    Edit2: No one has anything to comment? :'(

  6. #6
    Join Date
    Mar 2006
    Posts
    3,051
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    I don't understand the text tpa stuff too well, but I had a guy stuck with a lamp random, trying to bank it like an idiot.

    We could probably do the same thing with the error text RS spits out.

    "A magical force prevents you from banking this item."

    I think that's the same text it gives you for strange boxes as well. Might be a good failsafe function to have in SRL so people can use it in their banking procedures.


  7. #7
    Join Date
    Jul 2007
    Location
    Norway.
    Posts
    1,938
    Mentioned
    3 Post(s)
    Quoted
    0 Post(s)

    Default

    Quote Originally Posted by tarajunky View Post
    I don't understand the text TPA stuff too well, but I had a guy stuck with a lamp random, trying to bank it like an idiot.

    We could probably do the same thing with the error text RS spits out.

    "A magical force prevents you from banking this item."

    I think that's the same text it gives you for strange boxes as well. Might be a good failsafe function to have in SRL so people can use it in their banking procedures.
    I do agree, but on the other side, SRL should be capable of deactivating players whop have failed a box or a lamp random. For example, if SRL doesn't recognize a new box or lamp, the player times out (since it isn't certain that the coordinates for the new "close" button matches the old one, if you understand) and gets set to inactive. This should make that failsafe unneeded.

    And also, I think that what I mentioned, would be much easier to get done than the depositing failsafe. Firstly, you need to see if there already is a black chat message saying that you cannot deposit something, and even if it is, and the script is aware of that, that message can disappear (or move) while script is depositing, and the script might mistake a old message for being a new, or perhaps ignore the new message, ect..

    With other words, my opinion is that although your idea is a good one, all we need is the simple thing I mentioned to be put in Antirandoms.scar.

    Once again, I must say that it is only MY opinion, and it may be horrifically wrong.


    And going a slight bit off topic, thanks for reminding me to send you a PM

  8. #8
    Join Date
    Mar 2006
    Posts
    3,051
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    SRL seems to have a problem detecting the lamp in the last inventory position. As far as I know, nobody has figured out why that is. Until that bug is squashed, we really should have a text based backup.


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

    Default

    I've added several of these to SRL. Thanks EC.

  10. #10
    Join Date
    Jul 2007
    Location
    Norway.
    Posts
    1,938
    Mentioned
    3 Post(s)
    Quoted
    0 Post(s)

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

    Default

    Now, can a byte be used with an integer as well? So the functions you had returning bytes, what if scripts use it as an integer? Won't that cause massive outdating of scripts? Kinda like fixing the Mouse procedure.
    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

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

    Default

    Quote Originally Posted by EvilChicken! View Post


    Which ones?
    Main ones were:
    • Tradescreen returns an int.
    • MouseFlag has FFlag.
    • MouseItems combined


    There were some others one too but I can't remember them.

    Quote Originally Posted by Nava2 View Post
    Now, can a byte be used with an integer as well? So the functions you had returning bytes, what if scripts use it as an integer? Won't that cause massive outdating of scripts? Kinda like fixing the Mouse procedure.
    I don't think it causes any compatibility issues as from what I can see Integers can be interchanged with Bytes provided the values fall within the range of a Byte. I didn't change Integers to Byte when commiting though cos I'd rather not risk it.

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

    Default

    I will test it out, give me a second or 300.



    SCAR Code:
    program New;
    var
    z : byte;

    function RandomByte: byte;

    begin
      Result := Random(2000);
    end;


    begin
      for z := 0 to 40 do
        Writeln(IntToStr(RandomByte));
    end.

    You won't see anything over 255, meaning, they can be interchanged quite nicely.
    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

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. First Sig, Rate, suggestions for improvements and such
    By sweetleaf in forum Graphics and Multimedia
    Replies: 5
    Last Post: 12-31-2007, 10:59 PM
  2. My first script, power miner, please post improvements
    By nght spud in forum First Scripts
    Replies: 15
    Last Post: 11-07-2007, 12:50 AM
  3. Flax pixker improvements?
    By tomd741 in forum RS3 Outdated / Broken Scripts
    Replies: 4
    Last Post: 09-16-2007, 02:03 PM
  4. wow bot improvements
    By willie199120 in forum OSR Help
    Replies: 14
    Last Post: 04-29-2007, 12:31 PM

Posting Permissions

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