Results 1 to 10 of 10

Thread: Needed help with dtm random selection clicking

  1. #1
    Join Date
    Apr 2017
    Posts
    4
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Question Needed help with dtm random selection clicking

    Using SRL-5
    This script is for RSPS.

    I need help with the way simba found a dtm and click on them. I need simba to randomly pick and click an Essence in the inventory when the dtm was found there; and not always click the one that appear first x,y of where all the dtms are.

    Any help would be much appreciated.

    [/SIMBA]
    Simba Code:
    function DropSalamanders: Boolean;
    var
      i: Integer;
      SalPnts: TPointArray;
      SalaSlots: TIntegerArray;
    begin
         SalaDTM := DTMFromString('mQwAAAHicY2ZgYAhmYmCIBmIfIP4I5H8A4m9AHOjlxRDi68vgZGvLgAwYkTAQAAAZbAZt');
      if FindDTMs(SalaDTM, SalPnts,566,159,752,419) then
      begin
         for i := 0 to High(SalPnts) do
         SalaSlots := SalaSlots+pntToItem(SalPnts[i]);
         ClearSameIntegers(SalaSlots);
         for i := 0 to High(SalaSlots) do
        begin
          InvMouse((SalaSlots[i]), Mouse_Left);
          //do something else
            Result := True;
        end;
      end;
    end;
    Last edited by Bright; 04-29-2017 at 12:42 AM.

  2. #2
    Join Date
    Dec 2011
    Posts
    193
    Mentioned
    5 Post(s)
    Quoted
    51 Post(s)

    Default

    Use FindDTMs, you can simply just select randomly from the returned points. If you wanna go one further, loop through the points and grab the inventory slot it's in and store in int array. Now clear same integers in the array. Now you have an int array with each inventory slot containing the DTM. Pull a random element and mouse to it.

    OSRS Color Scripts: Borland_Salamanders | Borland_Iron_Ores
    Utilities & Snippets: [Color] OSBuddy Item Looting

  3. #3
    Join Date
    Apr 2017
    Posts
    4
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by Borland View Post
    Use FindDTMs, you can simply just select randomly from the returned points.
    I understand, that's why i want to use countdtm to count and invemouse to select one randomly. but the two problems i encounter here are that i don't know how to edit invmouse and the inventory via the inventory.simba file.

    Quote Originally Posted by Borland View Post
    If you wanna go one further, loop through the points and grab the inventory slot it's in and store in int array. Now clear same integers in the array. Now you have an int array with each inventory slot containing the DTM. Pull a random element and mouse to it.
    How do i loop through dtms like that without making many more functions of that same dtm? Also I have no clue on how to make simba recognize that there are 28 slots in rsps. Only know how to make inttobox(x1,y1,x2,y2);

  4. #4
    Join Date
    Dec 2011
    Posts
    193
    Mentioned
    5 Post(s)
    Quoted
    51 Post(s)

    Default

    Quote Originally Posted by Bright View Post
    I understand, that's why i want to use countdtm to count and invemouse to select one randomly. but the two problems i encounter here are that i don't know how to edit invmouse and the inventory via the inventory.simba file.
    Forget countDTM, make the function I laid out above in your script. Read the FindDTMs description by double clicking it in Simba's functionlist. It will tell you that matched points will be stored in the TPA you pass to it as the second parameter. Now you just loop through this TPA like you would any other.

    If you want a working example of this I do it in my Salamander script in my sig. Find the DropSalamanders function. You'll only need the top bit down to where ClearSameIntegers function is used. At that point the variable "SalaSlots" now contains every slot where a salamander was found. The code below loops through and drops each one.


    Also I have no clue on how to make simba recognize that there are 28 slots in rsps. Only know how to make inttobox(x1,y1,x2,y2);
    You're using an old include so people wont be too familiar with it anymore. You'll need to do a lot of the leg work yourself and track down where everything is defined. For example taking a quick look back at SRL5 I see the inventory bounds are defined in the function GetInvent right at the top of inventory.simba. Look for any hard coded numbers, work out what they were representing at the time, change them to what they need to be to work with your RSPS of choice. For example you can see it says "Slot * 42" so we can assume a slot was 42 pixels wide, check if that matches up with the PS inventory, if not edit it to be correct. Repeat for everything else.

    OSRS Color Scripts: Borland_Salamanders | Borland_Iron_Ores
    Utilities & Snippets: [Color] OSBuddy Item Looting

  5. #5
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Use a tbox array to represent each inventory slot, loop through each box & if the dtm is found in the box add them slot # to to a tintegerarray. Then generate a random number from the length of the array to give you a random slot number.

    https://github.com/officerBarbrady/A...nventory.simba

    Is an example of how to use Janilabo's explode box function to make generating the tboxarray faster

  6. #6
    Join Date
    Jan 2012
    Location
    Sydney, Australia
    Posts
    877
    Mentioned
    12 Post(s)
    Quoted
    368 Post(s)

    Default

    Not sure if this is of use, but shows how I get a random slot from a TIntegerArray.

    Simba Code:
    program new;
    {$i AeroLib/AeroLib.Simba}
    var
      OurItem: TItem;
      pnt: tpoint;

    function RandInvSlot(RSlots: TIntegerArray): integer;
    var
      i, a: integer;
      FS: Timer;
    begin
      FS.start;
      While (Result = 0) do
      begin
        if length(RSlots) < 1 then
          Exit(-1);
        a := RandomRange(low(RSlots), high(RSlots));
        for i := low(RSlots) to high(RSlots) do
          if (i = a) then
          begin
            Result := i;
            break;
          end;
        if (FS.TimeElapsed > 1000) then
          Exit(-1);
      end;
    end;

    begin
      initAL;
      OurItem.DTM := DTMFromString('mKgEAAHic42NgYJAEYmkgFgViUyA2AmJ9INYFYlUgVgJieSDmB2J2KAYBFiDWgfJZoZgNiJmBmAnK54Cqg+kByf2fIc+w8+BhMI0M0PkwMRgGAREMFYQBI5kYFQAAx4wOqA==');
      if OurItem.findIn(Area_Inv, pnt) then
        if InteractSlot(RandInvSlot(OurItem.GetSlots), MOUSE_LEFT) then
          WriteLn('Success');
    end.

    This is using Aerolib so won't work with SRL5 but shows you how it is done.

    Basically create a function that will search your TIntegerArray (slots that contain the DTM) and will pick a random number between the high slot number and the low slot number until it picks one that matches the integerArray (ie slot 1 or slot 5 etc).

  7. #7
    Join Date
    Apr 2017
    Posts
    4
    Mentioned
    0 Post(s)
    Quoted
    2 Post(s)

    Default

    At Borland
    What is the pntToItem:
    Unknown identifier 'pntToItem
    Simba Code:
    SalaSlots := SalaSlots+pntToItem(SalPnts[i]);
    Simba Code:
    function DropSalamanders: Boolean;
    var
      i: Integer;
      SalPnts: TPointArray;
      SalaSlots: TIntegerArray;
    begin
         SalaDTM := DTMFromString('mQwAAAHicY2ZgYAhmYmCIBmIfIP4I5H8A4m9AHOjlxRDi68vgZGvLgAwYkTAQAAAZbAZt');
      if FindDTMs(SalaDTM, SalPnts,566,159,752,419) then
      begin
         for i := 0 to High(SalPnts) do
         SalaSlots := SalaSlots+pntToItem(SalPnts[i]);
         ClearSameIntegers(SalaSlots);
         for i := 0 to High(SalaSlots) do
        begin
          InvMouse((SalaSlots[i]), Mouse_Left);
          //do something else
            Result := True;
        end;
      end;
    end;
    At Dan the man, is it possible for me to use both the aerolib and srl5 includes in my script and use that function with minimal edits? If so, then can you give me the aerolib plugin (AND_TPA32), im missing that plugin after downloaded aerolib
    Last edited by Bright; 04-10-2017 at 05:30 PM.

  8. #8
    Join Date
    Jan 2012
    Location
    Sydney, Australia
    Posts
    877
    Mentioned
    12 Post(s)
    Quoted
    368 Post(s)

    Default

    Quote Originally Posted by Bright View Post
    At Borland
    What is the pntToItem:
    Unknown identifier 'pntToItem
    Simba Code:
    SalaSlots := SalaSlots+pntToItem(SalPnts[i]);
    Simba Code:
    function DropSalamanders: Boolean;
    var
      i: Integer;
      SalPnts: TPointArray;
      SalaSlots: TIntegerArray;
    begin
         SalaDTM := DTMFromString('mQwAAAHicY2ZgYAhmYmCIBmIfIP4I5H8A4m9AHOjlxRDi68vgZGvLgAwYkTAQAAAZbAZt');
      if FindDTMs(SalaDTM, SalPnts,566,159,752,419) then
      begin
         for i := 0 to High(SalPnts) do
         SalaSlots := SalaSlots+pntToItem(SalPnts[i]);
         ClearSameIntegers(SalaSlots);
         for i := 0 to High(SalaSlots) do
        begin
          InvMouse((SalaSlots[i]), Mouse_Left);
          //do something else
            Result := True;
        end;
      end;
    end;
    At Dan the man, is it possible for me to use both the aerolib and srl5 includes in my script and use that function with minimal edits? If so, then can you give me the aerolib plugin (AND_TPA32), im missing that plugin after downloaded aerolib
    Would be in effective to run both of them TBH. I am not familiar enough with RSPS servers to really offer advice.

    Also the example I posted is incorrect, it will provide the Integer Array number as the slot number, as opposed to the actual slot. Amended below.

    Simba Code:
    program new;
    {$i AeroLib/AeroLib.Simba}
    var
      OurItem: TItem;
      pnt: tpoint;

    function RandInvSlot(RSlots: TIntegerArray): integer;
    var
      i, a: integer;
      FS: Timer;
    begin
      FS.start;
      While (Result < 1) do
      begin
        if length(RSlots) < 1 then
          Exit(0);
        a := RandomRange(low(RSlots), high(RSlots));
        for i := low(RSlots) to high(RSlots) do
        begin
          if (i = a) then
          begin
            if itemInSlot(RSlots[i]) then
              Result := RSlots[i];
            break;
          end;
        end;
        if (FS.TimeElapsed > 1000) then
          Exit(0);
      end;
    end;

    begin
      initAL;
      OurItem.DTM := DTMFromString('mKgEAAHic42NgYJAEYmkgFgViUyA2AmJ9INYFYlUgVgJieSDmB2J2KAYBFiDWgfJZoZgNiJmBmAnK54Cqg+kByf2fIc+w8+BhMI0M0PkwMRgGAREMFYQBI5kYFQAAx4wOqA==');
      if OurItem.findIn(Area_Inv, pnt) then
        if InteractSlot(RandInvSlot(OurItem.GetSlots), MOUSE_LEFT) then
          writeln('We clicked a random inventory slot that contains our item!');
    end.

  9. #9
    Join Date
    Sep 2010
    Posts
    5,762
    Mentioned
    136 Post(s)
    Quoted
    2739 Post(s)

    Default

    Quote Originally Posted by Dan the man View Post
    Not sure if this is of use, but shows how I get a random slot from a TIntegerArray.

    Simba Code:
    program new;
    {$i AeroLib/AeroLib.Simba}
    var
      OurItem: TItem;
      pnt: tpoint;

    function RandInvSlot(RSlots: TIntegerArray): integer;
    var
      i, a: integer;
      FS: Timer;
    begin
      FS.start;
      While (Result = 0) do
      begin
        if length(RSlots) < 1 then
          Exit(-1);
        a := RandomRange(low(RSlots), high(RSlots));
        for i := low(RSlots) to high(RSlots) do
          if (i = a) then
          begin
            Result := i;
            break;
          end;
        if (FS.TimeElapsed > 1000) then
          Exit(-1);
      end;
    end;

    begin
      initAL;
      OurItem.DTM := DTMFromString('mKgEAAHic42NgYJAEYmkgFgViUyA2AmJ9INYFYlUgVgJieSDmB2J2KAYBFiDWgfJZoZgNiJmBmAnK54Cqg+kByf2fIc+w8+BhMI0M0PkwMRgGAREMFYQBI5kYFQAAx4wOqA==');
      if OurItem.findIn(Area_Inv, pnt) then
        if InteractSlot(RandInvSlot(OurItem.GetSlots), MOUSE_LEFT) then
          WriteLn('Success');
    end.

    This is using Aerolib so won't work with SRL5 but shows you how it is done.

    Basically create a function that will search your TIntegerArray (slots that contain the DTM) and will pick a random number between the high slot number and the low slot number until it picks one that matches the integerArray (ie slot 1 or slot 5 etc).

    Why is that function so long lol


    Simba Code:
    function RandInvSlot(RSlots: TIntegerArray): integer;
    begin
      result := randomRange(low(RSlots), high(RSlots));
    end;

    Just make slots represent all the slot locations you want to choose from

  10. #10
    Join Date
    Jan 2012
    Location
    Sydney, Australia
    Posts
    877
    Mentioned
    12 Post(s)
    Quoted
    368 Post(s)

    Default

    Quote Originally Posted by rj View Post
    Why is that function so long lol


    Simba Code:
    function RandInvSlot(RSlots: TIntegerArray): integer;
    begin
      result := randomRange(low(RSlots), high(RSlots));
    end;

    Just make slots represent all the slot locations you want to choose from
    Was realllllly tired when I wrote this lol.

    From my understanding, Randomrange will pick a number between the 2 declared integers, even if they aren't in the array, which means it could potentially select a number that doesn't have the DTM.

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
  •