Question How to set Area for bot to choose random coordinate to go to

Discussion in 'Developer Support' started by youramazingames, Oct 27, 2015.

  1. youramazingames

    Oct 24, 2015
    Likes Received:
    Ok so i have my bot set up pretty well its quite basic just a vial filling one while i get use to how to make them!
    However it goes to the same spot every time which is not very good and can easily be picked up as a bot!
    So to get around this i would like to set an Rectangular area and it choose a random coordinate which is set as a variable which i can just add to my current code! I see there is Area.Rectangle and getRandomCoordinate but i have no idea on how to use them.

    Thanks in advance!
    --- Double Post Merged, Oct 27, 2015, Original Post Date: Oct 26, 2015 ---
    Right OK i worked out how to do this with the help of the people in the dev chat, and im going to put this here to help anybody else with the same question!

    Firstly, to set a Area that is a rectangle:
    Code (Text):
    1. final Area area = new Area.Rectangular(new Coordinate(2948, 3381, 0), new Coordinate(2951, 3383, 0));
    Now to find a random coordinate in that area:
    Code (Text):
    1. final Coordinate destination = area.getRandomCoordinate();
    The variable "area" have to be the same exactly as each other, so if you have it as say, "bank" they both have to be "bank " this is where i fell apart and needed help with, THANKS DEV CHAT!!!

    Lastly create a path there:
    Code (Text):
    1. final RegionPath path = RegionPath.buildTo(destination);
    2.             if (path != null)
    3.                 path.step(true);
    Hope this helped anybody that needed it :D

Share This Page