Results 1 to 15 of 15

Thread: RightClickCombiner by Nasus

  1. #1
    Join Date
    May 2012
    Location
    Runeterra
    Posts
    36
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default RightClickCombiner by Nasus

    I was inspired to write this by my complete inability to find an existing script that would take any two items and combine them without restrictions--specifically, the restriction of a left-click eat or consume option. This should be equally useful for cooking and moneymaking.

    I owe some credit to Gucci for his Battlestaff Maker; I based my banking methods directly on his, though they are not direct copies (the withdrawl comes close, though). This has antiban (a standard procedure, variable wait times, and variable mouse speed), anti-randoms (completely useless for now, since it works at Soul Wars bank), and a basic (but usually reliable) failsafe.

    I am aware that if the first inventory space has fourteen items left, and the third inventory space has at least that many, the failsafe will not function. I do not yet have the knowledge to check if inventory has actually changed, but that's what would be required.

    Testing appreciated. I don't have much in the way of a proggy designed, so just let me know whether it worked, and please run for at least eleven inventories to test the mouse speed antiban.

    Simba Code:
    program RightClickCombiner;
    // Script written by Nasus
    // Credit to Gucci for basing my banking off his Battlestaff Maker

    // Requirements: Stand in front of Soul Wars bank with empty inventory
    // Intended items must be in first two slots of active bank tab

    {$DEFINE SMART}
    {$i srl/srl.simba}

    var
      loadsCombined, loadsAtSpeed, buttonColor, secondaryColor: Integer;
      suppliesRemain: Boolean;

    procedure DeclarePlayers;
      begin
        HowManyPlayers := 1;
        NumberOfPlayers(HowManyPlayers);
        CurrentPlayer := 0;
        Players[0].Name := ''; // Username
        Players[0].Pass := ''; // Password
        Players[0].Nick := ''; // 3-4 lowercase letters from username; used for random event detection
        Players[0].BoxRewards := ['Xp', 'mote', 'ostume', 'oins', 'aphire', 'ssence'];
        Players[0].Active := True; // Set to true if you want to use Player 0
        Players[0].Pin := ''; // Leave blank if the player doesn't have a bank pin
      end;

    procedure Antiban;
      begin
        case Random(60) of // Random(60) generates a random integer from 0 to 59
          10: RandomRClick;
          20: HoverSkill('Cooking', False);
          30: PickUpMouse;
          40: RandomMovement;
          50: BoredHuman;
          59: ExamineInv;
        end;
      end;

    procedure AntiRandoms; // We operate at Soul Wars, so no need for anti-randoms
      begin                // But let's include it anyway!  Future use, maybe
        FindNormalRandoms;
        LampSkill := 'slayer';
      end;

    procedure CombineItems;
      begin
         //Writeln('Processing items now');
         InvMouse(14, mouse_right); // Right-clicks first item, avoids consumption!
         Wait(100 + Random(10));
         ChooseOption('Use');
         InvMouse(15, mouse_left);

         // Only click to confirm operation when button has popped up!
         buttonColor := GetColor(260, 430);
         WaitColorGone(buttonColor, 260, 430, 4, 1000);
         Wait(40 + Random(40)); // Slight human-like delay before continuing
         Mouse(260, 430, 0, 0, True);
         ClickMouse2(True);

         // Tell this procedure to stop once all items are combined
         secondaryColor := GetColor(702, 446);
         if (not WaitColorGone(secondaryColor, 702, 446, 4, 20000)) then
           Writeln('The script has advanced based on time, not color change.');
         Wait(40 + Random(160)); // Slight human-like delay before continuing
      end;

    procedure GetItems; // Withdraws items from first two bank spaces
    begin
      //Writeln('Withdrawing items now);
      Wait(200 + Random(100));

      if (BankScreen) or (PinScreen) then // Confirms that we are in the bank

      begin
        if (PinScreen) then // Enter the PIN if required
          repeat
            InPin(Players[0].Pin);
          until (BankScreen);

        if (BankScreen) then
          begin
            DepositAll;
            if (GetBankItemAmount(0, 0) <= 14) or (GetBankItemAmount(1, 0) <= 14) then
            begin
              suppliesRemain := False;
              exit;
            end;
            Withdraw(0, 0, 14);
            Withdraw(1, 0, 14);
            Wait(200 + Random(100));
            CloseBank;
          end;
        end;
    end;

    procedure DepositItems; // Banks items
    begin
      begin
        //Writeln('Depositing inventory now');
        OpenBankChest(SRL_BANK_SW);

          if (BankScreen) then
            begin
              DepositAll;
              Wait(200 + Random(100));
            end;
      end;
    end;

    procedure MainLoop;
    begin
      Repeat
        GetItems; // Requires bank to be open, hence opening before loop
        if (suppliesRemain) then // Don't want to try to mix items if we're out!
        begin
          CombineItems;
          Antirandoms; // If we get randomed, it will be during prior step
          Antiban; // Randomness in waiting timers will also contribute

          LevelUp; // Just in case...

          DepositItems;

          Inc(loadsCombined);
          Inc(loadsAtSpeed);
          Writeln('Processed ' + IntToStr(loadsCombined) + ' loads.');

          if (loadsAtSpeed = 10) then // Custom antiban by varying mouse speed
            begin
              MouseSpeed := 17 + Random(6);
              loadsAtSpeed := 0;
            end;
        end else
          exit;
      Until(AllPlayersInactive);
    end;

    begin
      Smart_Server := 60;
      Smart_Members := False;
      Smart_Signed := True;
      Smart_SuperDetail := False;

      ClearDebug;
      SetupSRL;
      DeclarePlayers;
      LoginPlayer;

      MouseSpeed := 20; // Initialize variables
      loadsCombined := 0;
      loadsAtSpeed := 0;
      buttonColor := 0;
      secondaryColor := 0;
      suppliesRemain := True;

      SetAngle(SRL_ANGLE_HIGH); // Set correct camera angle
      OpenBankChest(SRL_BANK_SW); // Opens the bank
      DepositItems; // Allows items to be present in starting inventory

      MainLoop;
    end.
    Last edited by Nasus; 07-05-2012 at 12:16 PM.

  2. #2
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Your MouseSpeed of 40 is a bit too high, the default srl speed is only 15, u probably shouldn't go anywhere above 25.

    You could use color functions like CountColor, WaitColorGone etc to detect when to go to next action instead of using Waits, which may not be accurate and will be problematic if the user is experiencing a bit of lag.

    I dont understand what failsafe you are talking about? From what i see there is currently no failsafe to detect when supplies run out? You could probably use some inventory functions (InvCount etc) to detect if u've withdrawn sufficient supplies.

    Overall a good first script though, nice standards

  3. #3
    Join Date
    May 2012
    Location
    Runeterra
    Posts
    36
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    In order:

    1) The MouseSpeed of 40 was the same used by Gucci's Battlestaff Maker, which I found worked perfectly in that script. Since that was the first place I saw the function used, I tried a value of 40 first, and it works well for me.

    2) Use of Wait functions was twofold: One, they allow me to add some randomness, which serves antiban purposes. Two, it was easier. In the event of a severe lag spike, the script will simply deposit the items, withdraw a fresh set, and try again, so there should be no risk of breaking entirely.

    3) Check the MainLoop procedure. The InvFull() check ensures that we are dealing with a full inventory. It's possible that the last 14 spaces of the inventory have the WRONG item present, and the failsafe will not detect this; this results when the first item withdrawn only had 14 left in the bank, and the newly-second-space item (the former third inventory space) has at least fourteen to withdraw.

  4. #4
    Join Date
    Jan 2012
    Posts
    2,568
    Mentioned
    35 Post(s)
    Quoted
    356 Post(s)

    Default

    Quote Originally Posted by Nasus View Post
    In order:

    1) The MouseSpeed of 40 was the same used by Gucci's Battlestaff Maker, which I found worked perfectly in that script. Since that was the first place I saw the function used, I tried a value of 40 first, and it works well for me.

    2) Use of Wait functions was twofold: One, they allow me to add some randomness, which serves antiban purposes. Two, it was easier. In the event of a severe lag spike, the script will simply deposit the items, withdraw a fresh set, and try again, so there should be no risk of breaking entirely.

    3) Check the MainLoop procedure. The InvFull() check ensures that we are dealing with a full inventory. It's possible that the last 14 spaces of the inventory have the WRONG item present, and the failsafe will not detect this; this results when the first item withdrawn only had 14 left in the bank, and the newly-second-space item (the former third inventory space) has at least fourteen to withdraw.
    1. Its just not too human-like to move ur mouse at that speed, its okay if u are comfortable with that speed though.

    2. You can still have randomness if u use color functions, like adding a random wait after u found the color. Just thought that 18 sec may only be applicable to a limited no. of activities?

    Maybe use ExistsItem(28), most combining will result in the 2nd ingredients getting used up. Or u can use GetColor to detect the color of the ingredient first, then use WaitColorGone to detect change in color of last slot. (unless the raw material and finished product have the same color)

    3. Oh i see what u mean now. U can use GetBankItemAmount during banking to check remaining supplies, so u can make it break if there is <=14 left.

  5. #5
    Join Date
    May 2012
    Location
    Runeterra
    Posts
    36
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    "Most items you can combine don't leave anything behind" and "most aren't the same color as the finished product" would each put restrictions on what you can make using this script. I specifically used the most generic methods possible so that there would be NO restrictions on what you can make: mix potions, prepare cooking anything from wine to making potatoes, this should even work fine for stringing, though I haven't tried it yet.

    The eighteen second wait is for the inventory to be completed. It worked well for both crafting battlestaffs and preparing potatoes, so I think it should be generally accurate.

    GetBankItemAmount seems to be what I need to make my failsafe foolproof. If/when anybody else detects a bug I need to fix, I'll include that into the new version as well.

  6. #6
    Join Date
    Feb 2007
    Location
    Colorado, USA
    Posts
    3,716
    Mentioned
    51 Post(s)
    Quoted
    624 Post(s)

    Default

    I have a 5600dpi mouse and 40 craps on my speed by like 5 times.. I think you should rethink the speed, even though you disagree
    The only true authority stems from knowledge, not from position.

    You can contact me via matrix protocol: @grats:grats.win or you can email me at the same domain, any user/email address.

  7. #7
    Join Date
    May 2012
    Location
    Runeterra
    Posts
    36
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Well, I've updated the script with a few changes.

    1) Thanks to Riwu providing me with GetBankItemAmount, the script now stops itself if either of the first two bank slots have 14 or fewer items (exactly 14 will cause an error the next iteration, and better to stop one inventory too soon than not at all).

    2) I changed the mouse speed from 40 to 20, as mentioned, tremendously speeding up the mouse. The variation is from 17 to 23 instead of 37 to 43. The comments about changing the speed seem to have it backwards, though; 40 is much, much slower on my screen than 20. Or is the complaint that 40 is so slow that it doesn't look human-like?

    3) Added Writeln commands to banking, depositing, and combining methods, commented out, to simplify troubleshooting.


    Next goal is going to be replacing the eighteen second pause for inventory mixing with something that monitors the inventory and 'knows' when it was completed. Can't key it off inventory items because adding potato toppings, among other possible uses, leaves a full inventory behind. Having looked them up, GetColor and WaitColorGone on the 28th inventory slot should work regardless what is being processed; a container will have lost its contents, and in most cases it'll just be empty entirely.

  8. #8
    Join Date
    Jan 2012
    Location
    Calgary, AB, Canada
    Posts
    1,819
    Mentioned
    5 Post(s)
    Quoted
    120 Post(s)

    Default

    Nicely made first script the mouse speed isn't all that bad since there isn't a lot of movement involved
    Current Project: Retired

  9. #9
    Join Date
    May 2012
    Location
    Runeterra
    Posts
    36
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Given that I started out by practically copying your script, and then turned it into my own, that actually means a lot to me. =D

  10. #10
    Join Date
    May 2012
    Posts
    9
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Testing this script for making uncooked curry. For some reason ithout any errors the script randomly stops. The loads can vary from 1-20.

  11. #11
    Join Date
    May 2012
    Location
    Runeterra
    Posts
    36
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Hmm, thanks for the heads up, I'll try to find out what bug I introduced between the first version and the updated version. I could just need to change the timers; I'd noticed issues when I didn't have the SMART slider all the way up.

  12. #12
    Join Date
    May 2012
    Location
    Runeterra
    Posts
    36
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I *think* I have the error pinned down to checking the inventory when, due to lag, the withdrawl hasn't actually happened yet. If so, then removing that check (and relying entirely on checking the two bank spots to ensure 15+ items remain in each) would solve it without causing the script to crash. The removed line is redundant now anyway, and was left in as a "just in case."

    Testing now, trying to intentionally lag the system to see if that does it. Will edit in results.

    Edit: With the placement of an extra testing line, I've confirmed the problem. Will include its removal in the next update, once I can get the color checking to work.
    Last edited by Nasus; 07-03-2012 at 04:47 AM.

  13. #13
    Join Date
    Nov 2011
    Posts
    76
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    very nice script...

    I will test it soon
    M1STER


  14. #14
    Join Date
    May 2012
    Location
    Runeterra
    Posts
    36
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Alright, I'm a bit stuck on implementing the color checking. Can anybody tell me how to check a location's coordinates? I want to 'look' at the color of the 28th slot item, just above the center of the item; that way if it's a bowl, I'll be looking at the contents rather than the bowl itself.

    I've got everything down except the coords I need. Better to learn how to find myself, so here's me asking how to do it.

  15. #15
    Join Date
    May 2012
    Location
    Runeterra
    Posts
    36
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Alright, fairly major update time! Couple of changes have gone out.

    1) I've removed the problematic, and now outdated, failsafe that checked whether the inventory was full. Lag on withdrawl could cause this one to fail, and since it no longer served any useful purpose, I removed it rather than reworked it.

    2) The script no longer has a Wait timer to determie when to click the popup button to begin creating items; now, it actually looks at the colors to see if the button has appeared yet. If it still hasn't after a full second, it clicks anyway and will eventually just time out of the procedure and loop back around.

    3) The inventory processing is no longer on a Wait timer, either. The script looks at the last inventory slot and, once the color there changes from the item being used up, the script continues on its merry way.

    If it doesn't change after twenty seconds, it continues on regardless under the assumption that it's probably something of the same color being left behind, maybe a bowl. The script also writes into the progress report that the color didn't change, and if you see that message appear with a specific item, please let me know! This is a key part of my debugging and ensuring optimum compatibility with all possible items.

    4) Added some additional documentation. It should be quite easy for other new scripters to follow along with my script--possibly so much that experienced guys will feel it's overly-documented!



    Comments, suggestions, complaints? I'd like to get this as close to a perfect general-use "combine two items" script as its possible to get, so all feedback greatly appreciated.

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
  •