Jump to content

Interact with object and then move on (PROBLEM)


Ornamental

Recommended Posts

So as the title says, i do have a problem when i pick a berry from a cadava bush and then it doesn't move on to the next state.

 

case getCadava:
script.walking.webWalk(new Position(3277, 3373, 0));
script.objects.closest("Cadava bush").interact("Pick-from");
script.walking.webWalk(new Position(3192, 3406, 0));
break;

 

I have tried several ways to fix this and even with the walking after the interact it still doesn't walk, it just stands still :(

 

 

Link to comment
Share on other sites

package org.quests;

import org.locations.Areas;
import org.osbot.rs07.api.map.Position;
import org.osbot.rs07.script.Script;

public class RomeoAndJuliet extends IQuest {

enum State{startQuest, findJuliet, deliverMessage, fatherLawrence, getCadava, gotCadava, makePotion}

State getState(){
if(script.getConfigs().get(144) <= 10){
return State.startQuest;
}else if(script.getConfigs().get(144) == 20){
return State.findJuliet;
}else if(script.getConfigs().get(144) == 30){
return State.deliverMessage;
}else if(script.getConfigs().get(144) == 30){
return State.fatherLawrence;
}else if(script.getConfigs().get(144) == 40){
return State.getCadava;
}else if(script.getConfigs().get(144) == 40){
return State.gotCadava;
}else if(script.getConfigs().get(144) == 50){
return State.makePotion;
}
return null;
}

@Override
public int onLoop() throws InterruptedException {
switch(getState()){
case startQuest:
dialogue.talkNpcInArea("Romeo", Areas.VARRY_CENTER, new String[]{"Yes, i have seen her actually!",
"Yes, ok, i'll let her know.",
"Ok, thanks"});
break;
case findJuliet:
dialogue.talkNpcInArea("Juliet", Areas.JULIET_BALCONY, "");
break;
case deliverMessage:
dialogue.talkNpcInArea("Romeo", Areas.VARRY_CENTER, "Ok, thanks.");
break;
case fatherLawrence:
dialogue.talkNpcInArea("Father Lawrence", Areas.VARRY_CHURCH, "Ok, thanks.");
break;
case getCadava:
script.walking.webWalk(new Position(3277, 3373, 0));
script.objects.closest("Cadava bush").interact("Pick-from");
script.walking.webWalk(new Position(3192, 3406, 0));
break;
case gotCadava:
script.walking.webWalk(new Position(3192, 3406, 0));
break;
}
return 0;
}
}

Link to comment
Share on other sites

}else if(script.getConfigs().get(144) == 40){
return State.getCadava;
}else if(script.getConfigs().get(144) == 40){
return State.gotCadava;

isnt this the same if statement so it'll always return the state getCadava instead of gotCadava as it comes first

 

It doesn't change the config thats why its the same 

Link to comment
Share on other sites

Well its very poor logic considering the script will loop thise  3 commands every single cycle:

script.walking.webWalk(new Position(3277, 3373, 0));
script.objects.closest("Cadava bush").interact("Pick-from");
script.walking.webWalk(new Position(3192, 3406, 0));

so it walks to bush, fails to interact maybe

walk back to somewhere even when it doesn't even interacted.

 

Add some conditions to improve your script logic ^^

 

Khaleesi

Link to comment
Share on other sites

It doesn't change the config thats why its the same 

And there is your problem, man, think about the boolean logic, you want it to say got and need to get at the same time, ofc it will do the first one. You need to have something like getInventory().contains("berries") && configstuff. -_-

Link to comment
Share on other sites

Well its very poor logic considering the script will loop thise  3 commands every single cycle:

script.walking.webWalk(new Position(3277, 3373, 0));
script.objects.closest("Cadava bush").interact("Pick-from");
script.walking.webWalk(new Position(3192, 3406, 0));

so it walks to bush, fails to interact maybe

walk back to somewhere even when it doesn't even interacted.

 

Add some conditions to improve your script logic ^^

 

Khaleesi

It does interact actually i've tested it several times, but after it picked the berry, the bot just stands still.

And there is your problem, man, think about the boolean logic, you want it to say got and need to get at the same time, ofc it will do the first one. You need to have something like getInventory().contains("berries") && configstuff. sleep.png

What do you mean by this ? :o

Link to comment
Share on other sites

It does interact actually i've tested it several times, but after it picked the berry, the bot just stands still.

What do you mean by this ? ohmy.png

 

This doesn't change the fact its not a reliable method.

It will work it 75% of the cases but will fail in the other 25%.

 

Thus this is not stable at all, just by chcking if you actually have a berry or not or check in what area you are it would work 100% of the time.

 

Check the log when it stands still, you probably walking to position thats obstructed.

 

he meant that your script logic has flaws and you need extra conditions to check what to execute, not simply execute 3 things in one cycle ^^

Link to comment
Share on other sites

It does interact actually i've tested it several times, but after it picked the berry, the bot just stands still.

What do you mean by this ? ohmy.png

 

In  ur states ur cycling through 1 by 1 right and as soon as one if statement returns true it will return that state, if it's the same if statement you will just always return the State.GetCadava

}else if(script.getConfigs().get(144) == 40 && !inventory.contains("Cadava berry")){
return State.getCadava;
}else if(script.getConfigs().get(144) == 40){
return State.gotCadava;

with this it will only return the State.getCadava when the player doesnt have any Cadava berries on them, e.g before they have picked them

Link to comment
Share on other sites

This doesn't change the fact its not a reliable method.

It will work it 75% of the cases but will fail in the other 25%.

 

Thus this is not stable at all, just by chcking if you actually have a berry or not or check in what area you are it would work 100% of the time.

 

Check the log when it stands still, you probably walking to position thats obstructed.

 

he meant that your script logic has flaws and you need extra conditions to check what to execute, not simply execute 3 things in one cycle ^^

So how am i going to fix this then ? I don't really get it :o

Link to comment
Share on other sites

}else if(script.getConfigs().get(144) == 40){
return State.getCadava;
}else if(script.getConfigs().get(144) == 40){
return State.gotCadava;

isnt this the same if statement so it'll always return the state getCadava instead of gotCadava as it comes first

 

 

This.

 

Although your getCadava method itself is bad practise, like Khaleesi said, that is Not the reason why your code is failing.

 

If the config is 40, it will ALWAYS return State.getCadava.

 

as soon as you type return getCadava it can not go down to any other return statement like return gotCadava

 

Vilius already told you the solution.

}else if(script.getConfigs().get(144) == 40){
return State.getCadava;
}else if(script.getConfigs().get(144) == 40){
return State.gotCadava;

Vilius solution, which you seemed to ignore:

}else if(script.getConfigs().get(144) == 40 && inventory does not have berries yet!){
return State.getCadava;
}else if(script.getConfigs().get(144) == 40 && inventory does have the berry){
return State.gotCadava;
Edited by MegaManAlpha
Link to comment
Share on other sites

In  ur states ur cycling through 1 by 1 right and as soon as one if statement returns true it will return that state, if it's the same if statement you will just always return the State.GetCadava

}else if(script.getConfigs().get(144) == 40 && !inventory.contains("Cadava berry")){
return State.getCadava;
}else if(script.getConfigs().get(144) == 40){
return State.gotCadava;

with this it will only return the State.getCadava when the player doesnt have any Cadava berries on them, e.g before they have picked them

Thanks for the quick snippet, i'll test this out later and i'll let you know if it worked :D

 

This.

 

Although your getCadava method itself is bad practise, like Khaleesi said, that is Not the reason why your code is failing.

 

If the config is 40, it will ALWAYS return State.getCadava.

 

as soon as you type return getCadava it can not go down to any other return statement like return gotCadava

 

Vilius already told you the solution.

}else if(script.getConfigs().get(144) == 40){
return State.getCadava;
}else if(script.getConfigs().get(144) == 40){
return State.gotCadava;

Vilius solution, which you seemed to ignore:

}else if(script.getConfigs().get(144) == 40 && inventory does not have berries yet!){
return State.getCadava;
}else if(script.getConfigs().get(144) == 40 && inventory does have the berry){
return State.gotCadava;

I didn't ignore... I was replying to Khaleesi when he posted that ...

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...