Results 1 to 22 of 22

Thread: Simple pick-up-item addition to scripts (eg a fighting script)

  1. #1
    Join Date
    Nov 2015
    Posts
    43
    Mentioned
    1 Post(s)
    Quoted
    21 Post(s)

    Default Simple pick-up-item addition to scripts (eg a fighting script)

    Hello, I have just begun learning simba. I was killing a monster using HoodzFighter and noticed there were items I'd like to pick up. So I wrote this, and called it in the main loop.

    Code:
    Procedure PickUpItem;
    
    var x, y: integer;
    begin
    
      if FindObj(x, y, 'nameOfItem', 11974335, 20) then
    
      begin
    
          Mouse(x, y, 2, 2, false);
          ChooseOption('NameOfItem');
          Wait(1000+random(1500));
    
      end;
    end;

    What do you guys think of my very first little addition? Any recommendations? Better methods to use etc? How would I go about implimenting the pickUpItem so it only happens randomly per loop?
    something like:

    Code:
    x = random(10);
    if x > 3 then pickupitem;
    Another question I have is when I added this to the script, I had to include:
    {$i AeroLib/AeroLib.Simba}
    {$i srl-osr/srl.simba}

    both of these in the same script, and it seemed to error out? I assume I cannot use both in one script?
    Last edited by Tog; 11-19-2015 at 01:41 AM.

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

    Default

    First of all welcome and congrats on learning Simba. I am also learning it, and so far its been a lot of fun

    I can't offer feedback on the FindObj snippet but I can offer feedback on the random line.
    I think you can consolidate the following:

    Simba Code:
    if (Random(10) > 3 then pickupitem;

    Looks good though, does it function ok?

    Also your username "TOG" - No affiliation with The Older Gamers is there?

  3. #3
    Join Date
    Nov 2015
    Posts
    43
    Mentioned
    1 Post(s)
    Quoted
    21 Post(s)

    Default

    Quote Originally Posted by Dan the man View Post
    First of all welcome and congrats on learning Simba. I am also learning it, and so far its been a lot of fun

    I can't offer feedback on the FindObj snippet but I can offer feedback on the random line.
    I think you can consolidate the following:

    Simba Code:
    if (Random(10) > 3 then pickupitem;

    Looks good though, does it function ok?

    Also your username "TOG" - No affiliation with The Older Gamers is there?
    No relation, sorry. Although I do remember that name from somewhere? Is he a member on these forums?

    What are the other methods of finding a dropped item on the ground?


    Thanks for the help so far

  4. #4
    Join Date
    Dec 2013
    Location
    Sweden
    Posts
    269
    Mentioned
    17 Post(s)
    Quoted
    161 Post(s)

    Default

    Quote Originally Posted by Tog View Post
    No relation, sorry. Although I do remember that name from somewhere? Is he a member on these forums?

    What are the other methods of finding a dropped item on the ground?


    Thanks for the help so far
    To start off, Aerolib and SRL-OSR are two different includes for the same game. They are somewhat similar but still very different. Aerolib uses Lape, is faster and more up to date. SRL-OSR is old, slow, and there is really no reason to use it anymore. I suggest you stick to Aerolib. Aerolib doesn't utilize FindObj, which you are using, but there are several other, more powerful and reliable ways to do what you want to do. What item are you trying to pick up? An easy way would be like this, using TColEx (tutorial here). In your case something like this should work:

    Simba Code:
    program itemgrabber;
    {$I Aerolib/Aerolib.simba}
    procedure PickUpStuff();
    var                    //declare stuff
      color_Item : TColEx;
      pnt : TPoint;
    begin
      color_Item.create(11974335, 20);  //let's store the color of the item to begin with
      if color_Item.findIn(Area_MS, pnt) then //if color is found in mainscreen area then its location will be stored in our "pnt"
      begin
        HumanMMouse(pnt, random(5), random(5)); //move mouse to found "pnt", with added randomness
        if IsUpTextMulti(['Up', 'text', 'here']) then
        begin
          FastClick(Mouse_right);
          ChooseOptionMulti(['Text', 'here']);
        end;
      end;
    end;

    begin
    InitAl;
    PickUpStuff();
    end.

    This is just a bare-bone script, you could try making it more flawless by for example adding hue and sat modifiers, storing the found color in multiple TPoints (using color_Item.findAllIn(...)), and so on. Have a look at the tutorial I linked above.

    About the random line: I'd try using cases like this:
    Simba Code:
    Case random(10) of
      0..6: PickUpStuff();
      7..9: AntiBan;
    end;

    It should pick up 7 out of 10 times, and the rest it will do an antiban, which I think is better than doing nothing.

  5. #5
    Join Date
    Nov 2015
    Posts
    43
    Mentioned
    1 Post(s)
    Quoted
    21 Post(s)

    Default

    Quote Originally Posted by kristi View Post
    To start off, Aerolib and SRL-OSR are two different includes for the same game. They are somewhat similar but still very different. Aerolib uses Lape, is faster and more up to date. SRL-OSR is old, slow, and there is really no reason to use it anymore. I suggest you stick to Aerolib. Aerolib doesn't utilize FindObj, which you are using, but there are several other, more powerful and reliable ways to do what you want to do. What item are you trying to pick up? An easy way would be like this, using TColEx (tutorial here). In your case something like this should work:

    Simba Code:
    program itemgrabber;
    {$I Aerolib/Aerolib.simba}
    procedure PickUpStuff();
    var                    //declare stuff
      color_Item : TColEx;
      pnt : TPoint;
    begin
      color_Item.create(11974335, 20);  //let's store the color of the item to begin with
      if color_Item.findIn(Area_MS, pnt) then //if color is found in mainscreen area then its location will be stored in our "pnt"
      begin
        HumanMMouse(pnt, random(5), random(5)); //move mouse to found "pnt", with added randomness
        if IsUpTextMulti(['Up', 'text', 'here']) then
        begin
          FastClick(Mouse_right);
          ChooseOptionMulti(['Text', 'here']);
        end;
      end;
    end;

    begin
    InitAl;
    PickUpStuff();
    end.

    This is just a bare-bone script, you could try making it more flawless by for example adding hue and sat modifiers, storing the found color in multiple TPoints (using color_Item.findAllIn(...)), and so on. Have a look at the tutorial I linked above.

    About the random line: I'd try using cases like this:
    Simba Code:
    Case random(10) of
      0..6: PickUpStuff();
      7..9: AntiBan;
    end;

    It should pick up 7 out of 10 times, and the rest it will do an antiban, which I think is better than doing nothing.

    I can't thank you enough Kristi! The code with the comments has helped me learn so much! Thank you
    I had no idea before now that OSR was outdated and dodgy, too! So thats always good to know, I would have wasted some time on learning an outdated scripting language.

    EDIT: I forgot to answer your question: What item are you trying to pick up? - I was picking up bones and feathers. Ill have a play with what you've written now! see how it goes!
    Last edited by Tog; 11-20-2015 at 11:53 PM.

  6. #6
    Join Date
    Dec 2013
    Location
    Sweden
    Posts
    269
    Mentioned
    17 Post(s)
    Quoted
    161 Post(s)

    Default

    Quote Originally Posted by Tog View Post
    I can't thank you enough Kristi! The code with the comments has helped me learn so much! Thank you
    I had no idea before now that OSR was outdated and dodgy, too! So thats always good to know, I would have wasted some time on learning an outdated scripting language.

    EDIT: I forgot to answer your question: What item are you trying to pick up? - I was picking up bones and feathers. Ill have a play with what you've written now! see how it goes!
    I'm glad it helped! Yeah and unfortunately there are a lot of tutorials left based on SRL-OSR. Not saying that they are completely outdated, it's pretty much the same syntax and such, though for a beginner it can be confusing to differentiate between what's outdated and what's not. I've gotten somewhat bored of my agility script lately, so let me know if you need any help.

  7. #7
    Join Date
    Nov 2015
    Posts
    43
    Mentioned
    1 Post(s)
    Quoted
    21 Post(s)

    Default

    Quote Originally Posted by kristi View Post
    I'm glad it helped! Yeah and unfortunately there are a lot of tutorials left based on SRL-OSR. Not saying that they are completely outdated, it's pretty much the same syntax and such, though for a beginner it can be confusing to differentiate between what's outdated and what's not. I've gotten somewhat bored of my agility script lately, so let me know if you need any help.
    Code:
    program itemgrabber;
    {$I Aerolib/Aerolib.simba}
    {$DEFINE SMART}
    
    
    //original pickUpStuff Code origianlly by kristi
    procedure PickUpStuff();
    var                    //declare stuff
      color_Item : TColEx;
      pnt : TPoint;
    begin
      color_Item.create(16777215, 50);  //let's store the color of the item to begin with
      if color_Item.findIn(Area_MS, pnt) then //if color is found in mainscreen area then its location will be stored in our "pnt"
      begin
        HumanMMouse(pnt, random(5), random(5)); //move mouse to found "pnt", with added randomness
        if IsUpTextMulti(['Bone', 'Feather']) then
        begin
          FastClick(Mouse_right);
          ChooseOptionMulti(['Bone', 'Feather']);
        end;
      end;
    end;
    
    
    
    procedure AntiBan;  // ANTIBAN taken from FoolPottatoMashAL foolmonstermashalpha
    ...//deleted as waste of space
    
    
    procedure BuryBones
    
    var
      item_Bone : TItem;
      bonesBuried : Integer;
    
    begin
      item_Bone.Name := 'Bone';
      item_Bone.DTM := DTMFromString('mggAAAHicY2NgYMhhYmDIB+IyIM4G4iQgzgRiXUYGBhUg1gZiE0YIXw2IF0yZAtTFiAVjB9hUIlQDABjeBXY=');
    
      repeat
      if item_Bone.inInventory() then
        writeln('Found bone! attempting to bury!');
        item_Bone.interact(MOUSE_LEFT);
        wait(800+random(300));
        inc(BonesBuried);
      until(item_Bone.inInventory() = False);
      writeln('Buried ~', bonesBuried, ' bones so far!');
    
      freeDTM(item_Bone.DTM);
    
    end
    
    
    
    
    begin
    InitAl;
    ClearDebug;
    
    repeat
      PickUpStuff();
      if (Random(10) >= 8) then BuryBones;
      wait(300+random(500));
      if (random(100) >=95) then AntiBan;
    until(false);
    end.
    Thanks for the code! Its working I added a bit more and it buries too! But unfortunately I cannot actually get it to work that great haha, whatever colour I choose seems to always end up finding other colours on that map, eg white flowers of the 'walk here' text in the top left corner! Is there any way around this?

    I have a few more important questions:
    1: How do I get the SMART client to spawn in my code and how do I get it to run through smart? I have loaded up the smart client and focused it but it seems to still want to use my mouse.

    2. How do I go about using global variables? (This is not vital for the sript to run) The reason I ask is as you can see I have tried to calculate and count the total amount of bones buried, but after it has exited the procedure BuryBones the variable "bonesBuried" resets back to 1? Ive tried placing bonesBuried : Integer; around a few different places but it doesn't seem to change anything.

    Thank you very much for taking the time to help
    Last edited by Tog; 11-21-2015 at 01:06 AM.

  8. #8
    Join Date
    Dec 2013
    Location
    Sweden
    Posts
    269
    Mentioned
    17 Post(s)
    Quoted
    161 Post(s)

    Default

    Great work, you're really getting the basics now! To load smart I'm guessing the problem lies within you calling "{DEFINE SMART}" AFTER including Aerolib, try the other way around.

    Remember what I said earlier about this being a bare-bones script (no pun intended)? The thing that our current color-finding function utilizes CTS1 (ColorToleranceSpeed1) which is very simple: it only look for a color with a certain tolerance. This results in a few problems as there are probably a lot of other items which share the same color. Now is the time to switch to CTS2 which is more accurate and uses hue and sat modifiers to determine the correct color. Don't worry, it's not as advanced as it sounds.

    We're gonna use the following function to create a CTS2-color:
    color_Item.create(color, tolerance, hue, sat);

    All of these values can easily be retrieved by using a nifty tool called ACA, see tutorial here. When you've got all of the values (color, tolerance, hue, and sat) we can begin.

    We previously used color_Item.findIn(Area_MS, pnt) to retrieve a point (the first) where the color is found. Let's step it up and look for ALL of them:

    color_Item.findAllIn(Area_MS, TPA);

    So what this does is that it searches for all of the point on the mainscreen which have the colors we're looking for, and stores them in an array consisting of TPoints.

    What we have so far is:
    Simba Code:
    var                    
      color_Item : TColEx;
      TPA : TPointArray;
    begin
      color_Item.create(color, tolerance, hue, sat);  //replace color, tolerance, hue and sat with respective values (from ACA)
      if color_Item.findAllIn(Area_MS, TPA) then
         //do stuff
    end;

    Our current TPA looks like this:
    http://i.imgur.com/nAuseJl.png
    The red dots are the TPoints found.

    Now, to make it easier to find what we're looking for, we're gonna make another array, out of TPA:s! These are called ATPA:s. There are several ways to do this, I'm gonna use TPAtoATPAEx (read more about these here). What this is gonna do is turn these TPA:s into small boxes, with a specified width and height, like this:
    http://i.imgur.com/15L57I2.png

    Our code so far:
    Simba Code:
    var
      color_Item : TColEx;
      TPA : TPointArray;
    begin
      color_Item.create(color, tolerance, hue, sat);  //replace color, tolerance, hue and sat with respective values (from ACA)
      if color_Item.findAllIn(Area_MS, TPA) then
         TPAtoATPAEx(TPA, 5, 5); //split these into 5x5 boxes, change these parameters as you like
    end;

    Now we might wanna sort these ATPA:s a little. It's pretty logical to assume that the place where you're most likely to find a bone is where the ATPA:s are the biggest (biggest = more TPA:s = more matching colors). So let:s sort them from biggest to smallest:
    SortATPASize(ATPA, true);

    Now what we're gonna do is create a for...to do loop:

    Simba Code:
    for i := 0 to high(ATPA) do
    begin
      ...
    end;

    What this loop will do is that it search through every single ATPA, starting at zero. But we want it to actually click something too!

    Simba Code:
    for i := 0 to high(ATPA) do
    begin
      pnt := MiddleTPA(ATPA[i]);  //set our pnt to the middle of the ATPA
      HumanMMouse(pnt, random(5), random(5)); //move the mouse to our point
      if isUpTextMulti(['Ta', 'ke B', 'ones']) then //if the uptext is what we want it to be
      begin
        FastClick(Mouse_right);
        ChooseOption(['text', 'here']);
        break; //("break" out of the for..to..do loop, we found our point)
      end;  
    end;

    So to summarize, here's our new, and improved pickup-procedure!
    Simba Code:
    {$DEFINE SMART}
    {$I AeroLib/AeroLib.simba}

    Procedure GetMyStuff()
    var
      color_Item : TColEx;
      TPA : TPointArray;
      ATPA : T2DPointArray;
      pnt : TPoint;
      i : Integer;
    begin
      color_Item.create(color, tolerance, hue, sat);  //replace color, tolerance, hue and sat with respective values (from ACA)
      if color_Item.findAllIn(Area_MS, TPA) then
         TPAtoATPAEx(TPA, 5, 5); //split these into 5x5 boxes, change these parameters as you like
         SortATPASize(ATPA, true); //sort big first, these are the ones who we will search first
         for i := 0 to high(ATPA) do
         begin
          pnt := MiddleTPA(ATPA[i]);  //set our pnt to the middle of the ATPA
          HumanMMouse(pnt, random(5), random(5)); //move the mouse to our point
          if isUpTextMulti(['Ta', 'ke B', 'ones']) then //if the uptext is what we want it to be
          begin
            FastClick(Mouse_right);
            ChooseOptionMulti(['text', 'here']);
            break; //("break" out of the for..to..do loop, we found our point)
          end;
        end;
    end;

    begin
    InitAL;
    GetMyStuff();
    end.

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

    Default

    Quote Originally Posted by kristi View Post
    Great work, you're really getting the basics now! To load smart I'm guessing the problem lies within you calling "{DEFINE SMART}" AFTER including Aerolib, try the other way around.

    Remember what I said earlier about this being a bare-bones script (no pun intended)? The thing that our current color-finding function utilizes CTS1 (ColorToleranceSpeed1) which is very simple: it only look for a color with a certain tolerance. This results in a few problems as there are probably a lot of other items which share the same color. Now is the time to switch to CTS2 which is more accurate and uses hue and sat modifiers to determine the correct color. Don't worry, it's not as advanced as it sounds.

    We're gonna use the following function to create a CTS2-color:
    color_Item.create(color, tolerance, hue, sat);

    All of these values can easily be retrieved by using a nifty tool called ACA, see tutorial here. When you've got all of the values (color, tolerance, hue, and sat) we can begin.

    We previously used color_Item.findIn(Area_MS, pnt) to retrieve a point (the first) where the color is found. Let's step it up and look for ALL of them:

    color_Item.findAllIn(Area_MS, TPA);

    So what this does is that it searches for all of the point on the mainscreen which have the colors we're looking for, and stores them in an array consisting of TPoints.

    What we have so far is:
    Simba Code:
    var                    
      color_Item : TColEx;
      TPA : TPointArray;
    begin
      color_Item.create(color, tolerance, hue, sat);  //replace color, tolerance, hue and sat with respective values (from ACA)
      if color_Item.findAllIn(Area_MS, TPA) then
         //do stuff
    end;

    Our current TPA looks like this:
    http://i.imgur.com/nAuseJl.png
    The red dots are the TPoints found.

    Now, to make it easier to find what we're looking for, we're gonna make another array, out of TPA:s! These are called ATPA:s. There are several ways to do this, I'm gonna use TPAtoATPAEx (read more about these here). What this is gonna do is turn these TPA:s into small boxes, with a specified width and height, like this:
    http://i.imgur.com/15L57I2.png

    Our code so far:
    Simba Code:
    var
      color_Item : TColEx;
      TPA : TPointArray;
    begin
      color_Item.create(color, tolerance, hue, sat);  //replace color, tolerance, hue and sat with respective values (from ACA)
      if color_Item.findAllIn(Area_MS, TPA) then
         TPAtoATPAEx(TPA, 5, 5); //split these into 5x5 boxes, change these parameters as you like
    end;

    Now we might wanna sort these ATPA:s a little. It's pretty logical to assume that the place where you're most likely to find a bone is where the ATPA:s are the biggest (biggest = more TPA:s = more matching colors). So let:s sort them from biggest to smallest:
    SortATPASize(ATPA, true);

    Now what we're gonna do is create a for...to do loop:

    Simba Code:
    for i := 0 to high(ATPA) do
    begin
      ...
    end;

    What this loop will do is that it search through every single ATPA, starting at zero. But we want it to actually click something too!

    Simba Code:
    for i := 0 to high(ATPA) do
    begin
      pnt := MiddleTPA(ATPA[i]);  //set our pnt to the middle of the ATPA
      HumanMMouse(pnt, random(5), random(5)); //move the mouse to our point
      if isUpTextMulti(['Ta', 'ke B', 'ones']) then //if the uptext is what we want it to be
      begin
        FastClick(Mouse_right);
        ChooseOption(['text', 'here']);
        break; //("break" out of the for..to..do loop, we found our point)
      end;  
    end;

    So to summarize, here's our new, and improved pickup-procedure!
    Simba Code:
    {$DEFINE SMART}
    {$I AeroLib/AeroLib.simba}

    Procedure GetMyStuff()
    var
      color_Item : TColEx;
      TPA : TPointArray;
      ATPA : T2DPointArray;
      pnt : TPoint;
      i : Integer;
    begin
      color_Item.create(color, tolerance, hue, sat);  //replace color, tolerance, hue and sat with respective values (from ACA)
      if color_Item.findAllIn(Area_MS, TPA) then
         TPAtoATPAEx(TPA, 5, 5); //split these into 5x5 boxes, change these parameters as you like
         SortATPASize(ATPA, true); //sort big first, these are the ones who we will search first
         for i := 0 to high(ATPA) do
         begin
          pnt := MiddleTPA(ATPA[i]);  //set our pnt to the middle of the ATPA
          HumanMMouse(pnt, random(5), random(5)); //move the mouse to our point
          if isUpTextMulti(['Ta', 'ke B', 'ones']) then //if the uptext is what we want it to be
          begin
            FastClick(Mouse_right);
            ChooseOptionMulti(['text', 'here']);
            break; //("break" out of the for..to..do loop, we found our point)
          end;
        end;
    end;

    begin
    InitAL;
    GetMyStuff();
    end.
    Clearest explanation I've seen so far

    How would it go about finding objects that drop, but aren't visible on the screen (ie under a herb)?

  10. #10
    Join Date
    Dec 2013
    Location
    Sweden
    Posts
    269
    Mentioned
    17 Post(s)
    Quoted
    161 Post(s)

    Default

    @Dan the man, thank you! Unless you're using reflection, we can only look for the things we have in front of us on the screen. To do that we'll have to make the script right click on each stack and search them for the items we're looking for

  11. #11
    Join Date
    Nov 2015
    Posts
    43
    Mentioned
    1 Post(s)
    Quoted
    21 Post(s)

    Default

    Quote Originally Posted by kristi View Post
    Simba Code:
    for i := 0 to high(ATPA) do
         begin
          writeln('picking up all found items!', random(10));
          pnt := MiddleTPA(ATPA[i]);  //set our pnt to the middle of the ATPA
    Thanks for the great in depth explanation, I have had a go at running the code and trying to work out what everything does, Ill keep trying to make it work, but I have tried to run the code above ^ with a few debug writeln messages thrown in but, it seems the program never enters the loop. It just wont print the 'picking up all found items!'. Maybe I've just stuffed up the colours. Ill have another go!

    EDIT: I'm just looking in this thread https://villavu.com/forum/showthread.php?t=49067 trying to work out whats gone wrong but everything looks fine to me

    EDIT2: I've printed off the TPA in a writeln and its printing off all of the locations, which is good, but if I try to print ATPA it comes up as [] <- an empty array?

    Thanks for the help!
    Last edited by Tog; 11-22-2015 at 12:30 AM.

  12. #12
    Join Date
    Dec 2013
    Location
    Sweden
    Posts
    269
    Mentioned
    17 Post(s)
    Quoted
    161 Post(s)

    Default

    Quote Originally Posted by Tog View Post
    Thanks for the great in depth explanation, I have had a go at running the code and trying to work out what everything does, Ill keep trying to make it work, but I have tried to run the code above ^ with a few debug writeln messages thrown in but, it seems the program never enters the loop. It just wont print the 'picking up all found items!'. Maybe I've just stuffed up the colours. Ill have another go!

    EDIT: I'm just looking in this thread https://villavu.com/forum/showthread.php?t=49067 trying to work out whats gone wrong but everything looks fine to me

    EDIT2: I've printed off the TPA in a writeln and its printing off all of the locations, which is good, but if I try to print ATPA it comes up as [] <- an empty array?

    Thanks for the help!
    My bad! Was too tired to notice. First of all this:
    TPAtoATPAEx(TPA, 5, 5);

    Should be:
    ATPA := TPAtoATPAEx(TPA, 5, 5); (we need to set what our ATPA is gonna be)

    Also, you could change TPAtoATPAEx(TPA, 5, 5); to ClusterTPAtoATPAEx(TPA, 5, 5); which will do the same thing but is much faster. Check the Wizzyplugin thread for more info. Also I forgot a "begin...end" after the "if findAllIn" function. This is what it should look like:
    Simba Code:
    {$DEFINE SMART}
    {$I AeroLib/AeroLib.simba}

    Procedure GetMyStuff()
    var
      color_Item : TColEx;
      TPA : TPointArray;
      ATPA : T2DPointArray;
      pnt : TPoint;
      i : Integer;
    begin
      color_Item.create(13158865, 20, 0.10, 0.20);  //replace color, tolerance, hue and sat with respective values (from ACA)
      if color_Item.findAllIn(Area_MS, TPA) then
      begin //should be a begin here
         ATPA := ClusterTPAEx(TPA, 10, 10); //split these into 5x5 boxes, change these parameters as you like
         SortATPASize(ATPA, true); //sort big first, these are the ones who we will search first
         DebugATPABounds(ATPA);

         for i := 0 to high(ATPA) do
         begin
          pnt := MiddleTPA(ATPA[i]);  //set our pnt to the middle of the ATPA
          HumanMMouse(pnt, random(5), random(5)); //move the mouse to our point
          if isUpTextMulti(['Ta', 'ke B', 'ones']) then //if the uptext is what we want it to be
          begin
            FastClick(Mouse_right);
            Wait(RandomRange(200, 400));
            ChooseOptionMulti(['Ta', 'ke B', 'one']);
            break; //("break" out of the for..to..do loop, we found our point)
          end;
        end;
      end
      else
        Writeln('No bones found!'); //if color was not found on Area_MS
    end;

    begin
    InitAL;
    GetMyStuff();
    end.

  13. #13
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    Quote Originally Posted by kristi View Post
    My bad! Was too tired to notice. First of all this:
    TPAtoATPAEx(TPA, 5, 5);

    Should be:
    ATPA := TPAtoATPAEx(TPA, 5, 5); (we need to set what our ATPA is gonna be)

    Also, you could change TPAtoATPAEx(TPA, 5, 5); to ClusterTPAtoATPAEx(TPA, 5, 5); which will do the same thing but is much faster.
    ClusterTPAtoATPAEx ?

    Since you are most likely refering to ClusterTPAEx / ClusterTPA it's not the same, not even similar, nor related.
    !No priv. messages please

  14. #14
    Join Date
    Dec 2013
    Location
    Sweden
    Posts
    269
    Mentioned
    17 Post(s)
    Quoted
    161 Post(s)

    Default

    Quote Originally Posted by slacky View Post
    ClusterTPAtoATPAEx ?

    Since you are most likely refering to ClusterTPAEx / ClusterTPA it's not the same, not even similar, nor related.
    Sorry a typo, if you looked at the code you can see that I actually ment ClusterTPAEx. You mean it is not the same as TPAtoATPAEx? I didn't say that, I just said that they'll do the same thing (for our purpose) but faster (According to this).

  15. #15
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    Quote Originally Posted by kristi View Post
    Sorry a typo, if you looked at the code you can see that I actually ment ClusterTPAEx. You mean it is not the same as TPAtoATPAEx? I didn't say that, I just said that they'll do the same thing (for our purpose) but faster (According to this).
    They will by no means do the same thing, nor yield the same result. The documentation on both TPAToATPA, and SplitTPA/ClusterTPA is an oversimplification.
    ClusterTPA(Ex) is a density-based spatial clustering function, while TPAToATPA pretty much splits the TPA in to equally sized groups (the size being the given width and height) - how it does this is a bit special tho.
    !No priv. messages please

  16. #16
    Join Date
    Dec 2013
    Location
    Sweden
    Posts
    269
    Mentioned
    17 Post(s)
    Quoted
    161 Post(s)

    Default

    Quote Originally Posted by slacky View Post
    They will by no means do the same thing, nor yield the same result. The documentation on both TPAToATPA, and SplitTPA/ClusterTPA is an oversimplification.
    ClusterTPA(Ex) is a density-based spatial clustering function, while TPAToATPA pretty much splits the TPA in to equally sized groups (the size being the given width and height) - how it does this is a bit special tho.
    I understand they are not the same thing. My reasoning is this- whether you use SplitTPAEx or ClusterTPAEx, the bone will still be found. But ClusterTPAEx is allegedly faster, so why not use it instead? I'd love to learn more about it if you got any links, I found this via google:

    Quote Originally Posted by slacky View Post
    ClusterTPA offers the same functionality as SplitTPA, and ClusterTPAEx offers the same functionality as SplitTPAEx. Order of the ATPA, and the points inside each TPA may not be the same. ClusterTPA is optimized for large data-sets / arrays. It's able to cluster huge amounts of points in much much less time. For small arrays/TPA SplitTPA(Ex) is just as good.

  17. #17
    Join Date
    Feb 2012
    Location
    Norway
    Posts
    995
    Mentioned
    145 Post(s)
    Quoted
    596 Post(s)

    Default

    Quote Originally Posted by kristi View Post
    I understand they are not the same thing. My reasoning is this- whether you use SplitTPAEx or ClusterTPAEx, the bone will still be found. But ClusterTPAEx is allegedly faster, so why not use it instead? I'd love to learn more about it if you got any links, I found this via google:
    The input TPA is the one named "original" in the image.
    The image shows the ways each method will split up the given TPA. ClusterTPA/SplitTPA is superior in just about all such uses we see @ this forum because of the way it clusters.


    Even tho I find comparing ClusterTPA to TPAToATPA foolish, purely looking at the speed, claiming that ClusterTPA is faster than TPAToATPA doesn't have to be true, it has a lot of overhead, and speed depends on several things.
    But as I said it's foolish to compare them as they do completely different things.
    Last edited by slacky; 11-22-2015 at 02:30 AM.
    !No priv. messages please

  18. #18
    Join Date
    Nov 2015
    Posts
    43
    Mentioned
    1 Post(s)
    Quoted
    21 Post(s)

    Default

    Quote Originally Posted by kristi View Post
    My bad! Was too tired to notice. First of all this:
    TPAtoATPAEx(TPA, 5, 5);

    Should be:
    ATPA := TPAtoATPAEx(TPA, 5, 5); (we need to set what our ATPA is gonna be)

    Also, you could change TPAtoATPAEx(TPA, 5, 5); to ClusterTPAtoATPAEx(TPA, 5, 5); which will do the same thing but is much faster. Check the Wizzyplugin thread for more info. Also I forgot a "begin...end" after the "if findAllIn" function. This is what it should look like:
    Simba Code:
    {$DEFINE SMART}
    {$I AeroLib/AeroLib.simba}

    Procedure GetMyStuff()
    var
      color_Item : TColEx;
      TPA : TPointArray;
      ATPA : T2DPointArray;
      pnt : TPoint;
      i : Integer;
    begin
      color_Item.create(13158865, 20, 0.10, 0.20);  //replace color, tolerance, hue and sat with respective values (from ACA)
      if color_Item.findAllIn(Area_MS, TPA) then
      begin //should be a begin here
         ATPA := ClusterTPAEx(TPA, 10, 10); //split these into 5x5 boxes, change these parameters as you like
         SortATPASize(ATPA, true); //sort big first, these are the ones who we will search first
         DebugATPABounds(ATPA);

         for i := 0 to high(ATPA) do
         begin
          pnt := MiddleTPA(ATPA[i]);  //set our pnt to the middle of the ATPA
          HumanMMouse(pnt, random(5), random(5)); //move the mouse to our point
          if isUpTextMulti(['Ta', 'ke B', 'ones']) then //if the uptext is what we want it to be
          begin
            FastClick(Mouse_right);
            Wait(RandomRange(200, 400));
            ChooseOptionMulti(['Ta', 'ke B', 'one']);
            break; //("break" out of the for..to..do loop, we found our point)
          end;
        end;
      end
      else
        Writeln('No bones found!'); //if color was not found on Area_MS
    end;

    begin
    InitAL;
    GetMyStuff();
    end.
    Wow this works amazing! My little bot can now pick up as many feathers and bones as he likes and bury them all away. Hopefully I can stick this in a chicken killing script I hope to make one day!

    I really do appreciate all the time and effort you've given to help me. I've actually enjoyed watching the improvements in the script go from basic, quite stupid to damn smart! haha. Wow, this is really cool. I can see so many possibilities with this TPA method using all the points to make better decisions when picking up items and such.

    Could you possibly recommend what I should learn next to click on NPC's? also- with the debug window, is there a way to hide this?/disable? or is it needed to work out where the items are?

  19. #19
    Join Date
    Dec 2013
    Location
    Sweden
    Posts
    269
    Mentioned
    17 Post(s)
    Quoted
    161 Post(s)

    Default

    Quote Originally Posted by slacky View Post
    The input TPA is the one named "original" in the image.
    The image shows the ways each method will split up the given TPA. ClusterTPA/SplitTPA is superior in just about all such uses we see @ this forum because of the way it clusters.


    Even tho I find comparing ClusterTPA to TPAToATPA foolish, purely looking at the speed, claiming that ClusterTPA is faster than TPAToATPA doesn't have to be true, it has a lot of overhead, and speed depends on several things.
    But as I said it's foolish to compare them as they do completely different things.
    Alright, thanks for the explanation! I shall not commit the sin of saying they are the same thing again.

    Quote Originally Posted by Tog View Post
    Wow this works amazing! My little bot can now pick up as many feathers and bones as he likes and bury them all away. Hopefully I can stick this in a chicken killing script I hope to make one day!

    I really do appreciate all the time and effort you've given to help me. I've actually enjoyed watching the improvements in the script go from basic, quite stupid to damn smart! haha. Wow, this is really cool. I can see so many possibilities with this TPA method using all the points to make better decisions when picking up items and such.

    Could you possibly recommend what I should learn next to click on NPC's? also- with the debug window, is there a way to hide this?/disable? or is it needed to work out where the items are?
    If you look at the script, you can see the line "DebugATPABounds", just comment it out and your done. You can use it however you like for debug purposes. Tbh I have no idea what to do next. I'm assuming you got a new account so why not do a some sort of skilling bot maybe? Have a look at Slackys RSWalker, it's very useful for scripts which involve a lot of walking. Other than that, feel free to PM if you need any help.

  20. #20
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    One could utilize TMSObjects for ground item-finding as well. These can be extremely precise including objects (or in this case, ground items) that have 2 colors near each other, have a specific height/width, and specific count of the main color of the item. Some of you may remember an earlier version of AeroLib having a TGroundItem branch devoted to recognizing ground items, but in the end I decided to merge the features of that branch with TMSObjects for simplicity.

    Here's a couple examples of TMSObjects I used for locating ground items:
    Simba Code:
    gi_Arrows.create('Arrows', [''], [createCol(670304,3,0.09,0.94)], 30, 30, 20, 15);
    gi_Feather.create('Feather', createCol(10592941,7,0.20,0.17), createCol(4608,1,0.00,0.00), 20, 5, 10, 7);

    And here's a arrow-picking function I use in my minotaur/zombie killer in the Security Stronghold.
    Simba Code:
    function checkForArrows(): Boolean;
    var
      i    : Integer;
      pnts : TPointArray;
    begin
      if not isLoggedIn() then Exit;

      while isplayerWalking() do
        waitEx(50);
      if not gi_Arrows.findAll(10, MSCP, pnts) then
        Exit;

      for i:=0 to high(pnts) do
      begin
        missMouse(pnts[i], 0, 0);
        fastClick(MOUSE_RIGHT);

        if chooseOptionMulti(['ke Bronze a','ke Ir','ke Ste']) then
        begin
          if waitFunc(@isPlayerWalking, 70, 2000) then
          begin
            FFlag(0);
            while isPlayerWalking() do
              waitEx(70);
          end;
          result := true;
        end;
      end;
    end;

    Of course you'll need to be familiar with TMSObjects to know how to create them. You can find everything to do with TMSObjects in AeroLib>entities>object>Object.simba. There's also a detailed tutorial on that subject, which I strongly recommend reading over.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


  21. #21
    Join Date
    Nov 2015
    Posts
    43
    Mentioned
    1 Post(s)
    Quoted
    21 Post(s)

    Default

    Quote Originally Posted by Flight View Post

    Of course you'll need to be familiar with TMSObjects to know how to create them. You can find everything to do with TMSObjects in AeroLib>entities>object>Object.simba. There's also a detailed tutorial on that subject, which I strongly recommend reading over.

    I shall do! Oooh, TMSObjects is also good for finding NPC's and interacting! Seems like AeroLib has everything I need! Just a quick question though, I have noticed that a lot of scripts use both AeroLib as well as Reflection - What do most people use Reflection for rather than Aerolib?

    Thanks for the help!

  22. #22
    Join Date
    Aug 2007
    Location
    Colorado
    Posts
    7,421
    Mentioned
    268 Post(s)
    Quoted
    1442 Post(s)

    Default

    Quote Originally Posted by Tog View Post
    I shall do! Oooh, TMSObjects is also good for finding NPC's and interacting! Seems like AeroLib has everything I need! Just a quick question though, I have noticed that a lot of scripts use both AeroLib as well as Reflection - What do most people use Reflection for rather than Aerolib?

    Thanks for the help!
    If I were to use Reflection it would be for a 100% accurate combat detection or specific animation ID; everything else can be done via AeroLib. Infact both of these can be as well with the right amount of detail included. However I believe the reason most people use both is because Reflection makes writing scripts extremely easy and without much critical thinking.

    Current projects:
    [ AeroGuardians (GotR minigame), Motherlode Miner, Blast furnace ]

    "I won't fall in your gravity. Open your eyes,
    you're the Earth and I'm the sky..."


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
  •