Ornamental Posted March 28, 2016 Share Posted March 28, 2016 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 Quote Link to comment Share on other sites More sharing options...
iJodix Posted March 28, 2016 Share Posted March 28, 2016 The code you gave us doesn't really help, you better off show us your whole class. 1 Quote Link to comment Share on other sites More sharing options...
Ornamental Posted March 28, 2016 Author Share Posted March 28, 2016 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;}@Overridepublic 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;}} Quote Link to comment Share on other sites More sharing options...
IHB Posted March 28, 2016 Share Posted March 28, 2016 }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 1 Quote Link to comment Share on other sites More sharing options...
Psvxe Posted March 28, 2016 Share Posted March 28, 2016 Send me a pm with your Skype. I'll help you out.. Made the quest already. 1 Quote Link to comment Share on other sites More sharing options...
Ornamental Posted March 28, 2016 Author Share Posted March 28, 2016 }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 Quote Link to comment Share on other sites More sharing options...
Khaleesi Posted March 28, 2016 Share Posted March 28, 2016 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 Quote Link to comment Share on other sites More sharing options...
Vilius Posted March 28, 2016 Share Posted March 28, 2016 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. -_- Quote Link to comment Share on other sites More sharing options...
Ornamental Posted March 28, 2016 Author Share Posted March 28, 2016 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. What do you mean by this ? Quote Link to comment Share on other sites More sharing options...
Khaleesi Posted March 28, 2016 Share Posted March 28, 2016 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 ? 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 ^^ Quote Link to comment Share on other sites More sharing options...
IHB Posted March 28, 2016 Share Posted March 28, 2016 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 ? 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 Quote Link to comment Share on other sites More sharing options...
Ornamental Posted March 28, 2016 Author Share Posted March 28, 2016 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 Quote Link to comment Share on other sites More sharing options...
DragonAlpha Posted March 28, 2016 Share Posted March 28, 2016 (edited) }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 March 28, 2016 by MegaManAlpha Quote Link to comment Share on other sites More sharing options...
Ornamental Posted March 28, 2016 Author Share Posted March 28, 2016 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 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 ... Quote Link to comment Share on other sites More sharing options...
DragonAlpha Posted March 28, 2016 Share Posted March 28, 2016 (edited) Thanks for the quick snippet, i'll test this out later and i'll let you know if it worked I didn't ignore... I was replying to Khaleesi when he posted that ... I meant IHB He gave a good quick response to this Edited March 28, 2016 by MegaManAlpha Quote Link to comment Share on other sites More sharing options...