Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Question How to interact with the bank or with an NPC as soon as possible?

Joined
Mar 29, 2015
Messages
8
Hey guys,

I am currently working on my very first RuneMate bot and I keep running into problems when trying to make the bot interact with the bank before my player actually reached it.
If the bank is near my player but not visible, I want the bot to turn the camera to the bank and then interact with it. However, the bot never turns the camera under any circumstances. It always just walks to the bank and interacts with it as soon as it can see it. Even weirder, when it finally opens the bank it also seems to act very weird and missclicks like 10-20 times before it finally manages to deposit an item from my inventory. I am currently using a BranchTask with the following validate-Statement to check if the player reached the bank:
public boolean validate()
{
Player player = Players.getLocal();
LocatableEntity bank = Banks.getLoaded().nearest();

if (bank != null && !bank.isVisible())
{
Camera.turnTo(bank);
}

return (player != null && Tools.GetBankArea().contains(player))
|| (bank != null && bank.isVisible());
}


I have also tried something similar with an NPC (the kebab trader in Al Kharid) and in that case it seems to get bugged and randomly walk around inside the shop while never interacting with the NPC at all (or sometimes after a very very long time it finally manages to talk to the NPC). For this I use the following validate-Statement:
public boolean validate()
{
Area kebabShopArea = Tools.GetKebabShopArea();
Player player = Players.getLocal();
Actor karim = Npcs.newQuery().names("Karim").within(kebabShopArea).reachable().results().first();

if (karim != null && !karim.isVisible())
{
Camera.turnTo(karim);
}

return (player != null && kebabShopArea.contains(player))
|| (karim != null && karim.isVisible());
}


When I replace these two functions with a basic area check I do not have any of these issues.
Am I doing something wrong? How am I supposed to implement something like this?
My idea behind this was that it looks extremely bot-like to first walk to a certain area, wait and then interact with the NPC so I wanted to improve that.
 
#1 Fabric Cleaner
Joined
Mar 18, 2017
Messages
393
Hey guys,

I am currently working on my very first RuneMate bot and I keep running into problems when trying to make the bot interact with the bank before my player actually reached it.
If the bank is near my player but not visible, I want the bot to turn the camera to the bank and then interact with it. However, the bot never turns the camera under any circumstances. It always just walks to the bank and interacts with it as soon as it can see it. Even weirder, when it finally opens the bank it also seems to act very weird and missclicks like 10-20 times before it finally manages to deposit an item from my inventory. I am currently using a BranchTask with the following validate-Statement to check if the player reached the bank:
public boolean validate()
{
Player player = Players.getLocal();
LocatableEntity bank = Banks.getLoaded().nearest();

if (bank != null && !bank.isVisible())
{
Camera.turnTo(bank);
}

return (player != null && Tools.GetBankArea().contains(player))
|| (bank != null && bank.isVisible());
}


I have also tried something similar with an NPC (the kebab trader in Al Kharid) and in that case it seems to get bugged and randomly walk around inside the shop while never interacting with the NPC at all (or sometimes after a very very long time it finally manages to talk to the NPC). For this I use the following validate-Statement:
public boolean validate()
{
Area kebabShopArea = Tools.GetKebabShopArea();
Player player = Players.getLocal();
Actor karim = Npcs.newQuery().names("Karim").within(kebabShopArea).reachable().results().first();

if (karim != null && !karim.isVisible())
{
Camera.turnTo(karim);
}

return (player != null && kebabShopArea.contains(player))
|| (karim != null && karim.isVisible());
}


When I replace these two functions with a basic area check I do not have any of these issues.
Am I doing something wrong? How am I supposed to implement something like this?
My idea behind this was that it looks extremely bot-like to first walk to a certain area, wait and then interact with the NPC so I wanted to improve that.
Handle the camera turning in the leaftask. If the player is in an area near the bank, turn the camera, if not, walk to that area/bank.
 
Joined
Mar 29, 2015
Messages
8
Handle the camera turning in the leaftask. If the player is in an area near the bank, turn the camera, if not, walk to that area/bank.
Thanks for your response! What would be the best way to check if the player is near the bank? I wanted to use reachable() in the NPC/Bank query so that it would always return false until the webpath walking to the bank/npc would have opened any doors that might block the way to the bank.
With an area check like you suggested I could not do this. As I originally said, I want to prevent using a rectangle area in front of the bank booth to check if my player arrived at the bank because it looks very bot-like. I simply want the bot to interact with the bank as soon as possible.
 
Last edited:
#1 Fabric Cleaner
Joined
Mar 18, 2017
Messages
393
Thanks for your response! What would be the best way to check if the player is near the bank? I wanted to use reachable() in the NPC/Bank query so that it would always return false until the webpath walking to the bank/npc would have opened any doors that might block the way to the bank.
With an area check like you suggested I could not do this. As I originally said, I want to prevent using a rectangle area in front of the bank booth to check if my player arrived at the bank because it looks very bot-like. I simply want the bot to interact with the bank as soon as possible.
You should try it out and see what works best for you, yea I think reachable() would work to see if the door is open or closed. Just mess around with different implementations until you find one that works the best.
 
Joined
Mar 29, 2015
Messages
8
You should try it out and see what works best for you, yea I think reachable() would work to see if the door is open or closed. Just mess around with different implementations until you find one that works the best.
Thank you for the response again! I have one more question:
I just tried to use Banks.getLoaded().nearest() and then call isVisible() if the returned bank is not null to check if the bank is visible.
With this code I noticed that for some reason when I am very very close to seeing the bank sometimes isVisible() would return true even when I cannot yet see the bank (for example when I am like 1 tile away from being able to see the bank booth). This caused my bot to get stuck in some situations because it would think that the bank is visible and then be unable to interact with it because it actually is not visible. Is this a bug or is there any more accurate visibility check that I can use to make sure that the bot won't get stuck?
 
Joined
Aug 11, 2018
Messages
4
Okay, I'm not a Bot Author, but I have written quite a few for myself. No expert. I guess I can suggest a few things.

1. You can try using a GameObject query for Counter/Chest, or an Npc query for Bankers.
2. Just turn the camera to the LocatableEntity if it is != null. Skip Visibility check. It's pretty normal, people turn cameras to interactables, not many click on the very edges of the screen.
3. OR - nest the isVisible() check inside the, Null check, because sometimes isVisible() throws a null - I don't know why.

{
Player player = Players.getLocal();

if(player!=null) {

Actor karim = Npcs.newQuery().names("Karim").within(kebabShopArea).reachable().results().first();

if(karim != null) {

if(karim.isVisible()) {
Karim.interact("Talk", "Karim");
} else {
Camera.turnTo(Karim);
}
.
.
.
.


4. If your clicks are missing, use a right click - left click approach. Or use interact("action","target") method.

5. On the actual topic of this post : I sometimes use a concentric Areas approach. Like, a radius of 10-15 tiles to query GameObject and interact with it, followed by a smaller area of 3-5 tiles where I build a path to...

For Example, if I need a Banker, the BresenhamPath clicks a random Coordinate in an Area of 3 tiles around the banker - but I query the object, and turn the camera, from 10 tiles away. So while my player is moving toward the Banker, my bot can interact with the Banker before my player actually reaches the specified Area. If not, my player will still reach the Banker, then stop and interact.

That is, as soon as visible/ as soon as possible.

Again, I'm not an expert.
 
Joined
Mar 29, 2015
Messages
8
Okay, I'm not a Bot Author, but I have written quite a few for myself. No expert. I guess I can suggest a few things.

1. You can try using a GameObject query for Counter/Chest, or an Npc query for Bankers.
2. Just turn the camera to the LocatableEntity if it is != null. Skip Visibility check. It's pretty normal, people turn cameras to interactables, not many click on the very edges of the screen.
3. OR - nest the isVisible() check inside the, Null check, because sometimes isVisible() throws a null - I don't know why.

{
Player player = Players.getLocal();

if(player!=null) {

Actor karim = Npcs.newQuery().names("Karim").within(kebabShopArea).reachable().results().first();

if(karim != null) {

if(karim.isVisible()) {
Karim.interact("Talk", "Karim");
} else {
Camera.turnTo(Karim);
}
.
.
.
.


4. If your clicks are missing, use a right click - left click approach. Or use interact("action","target") method.

5. On the actual topic of this post : I sometimes use a concentric Areas approach. Like, a radius of 10-15 tiles to query GameObject and interact with it, followed by a smaller area of 3-5 tiles where I build a path to...

For Example, if I need a Banker, the BresenhamPath clicks a random Coordinate in an Area of 3 tiles around the banker - but I query the object, and turn the camera, from 10 tiles away. So while my player is moving toward the Banker, my bot can interact with the Banker before my player actually reaches the specified Area. If not, my player will still reach the Banker, then stop and interact.

That is, as soon as visible/ as soon as possible.

Again, I'm not an expert.
Thanks for your response! It has been quite a while and I already improved my bot but I am actually doing it pretty similar to what you suggested.
My bot currently does the following checks to decide if it should try interacting with the bank:
public boolean validate()
{
Player player = Players.getLocal();

if (player != null)
{
if ([Bank area].contains(player))
{
return true;
}
else
{
LocatableEntity bank = Banks.newQuery().results().nearest();

if (bank != null)
{
if (!bank.isVisible())
{
if (player.distanceTo(bank) < [Camera turn distance])
{
Camera.concurrentlyTurnTo(bank);
}
}
else
{
Coordinate bankPosition = bank.getPosition();

if (bankPosition != null && player.distanceTo(bankPosition) <= 15
&& bankPosition.isReachable())
{
return true;
}
}
}
}
}

return false;
}


I'm pretty sure this can still be optimized but so far it works just fine.
 
Top