Jump to content

Question about a snippet of code


Psychotechno

Recommended Posts

16 hours ago, Psychotechno said:

I've been thinking about what you said about your design pattern, but I'm unsure how to implement such a thing. How can I make sure only one interaction happens per OnLoop execution?  Only thing I can think of is to store all my compound actions inside some data structure outside onloop and call them one by one in onLoop, only moving on to the next one when the previous one succeeds. Is that what you mean? Again, appreciate the response 😃 Thanks

This is fairly simple to achieve. Your goal is to map the current game state to a single action. Here is some pseudocode:

onLoop {
  if (some condition) {
    do this interaction;
  } else {
    do a different interaction;
  }
  return 200;
}

Naturally this is a very simple case, but no matter what the game state, this will only ever execute a single game interaction per iteration of onLoop.

Hopefully that makes sense!

Apa

Link to comment
Share on other sites

  • 2 months later...
On 11/4/2020 at 4:01 PM, Apaec said:

This is fairly simple to achieve. Your goal is to map the current game state to a single action. Here is some pseudocode:


onLoop {
  if (some condition) {
    do this interaction;
  } else {
    do a different interaction;
  }
  return 200;
}

Naturally this is a very simple case, but no matter what the game state, this will only ever execute a single game interaction per iteration of onLoop.

Hopefully that makes sense!

Apa

Dear Apa,

I'm a bit further along my scripting journey now and managed to implement a working script.  Previously you told me that I should be "Executing a single game interaction per iteration of onLoop".

 

 I indeed see that a lot else-if constructs are used, to ensure that only one if-statement is executed per onLoop. I did not adhere to this principle, and instead of using else-if's i'm simply using some sequential if's to check. It does work, but I'm not sure my script is "In a state to retry" If a function fails; Take for example my bank function;

private void bank() throws InterruptedException {
    if (!FEROXENCLAVE_TELESPOT.contains(myPosition())) {
        getEquipment().interact(EquipmentSlot.RING, "Ferox Enclave");
        Sleep.sleepUntil(() -> FEROXENCLAVE_TELESPOT.contains(myPosition()), random(2500, 3000));
        log("Teleported to Ferox enclave");
    }
    if (!FEROXENCLAVE_POOLS.contains(myPosition())) {
        poolWalker();
    }
    RS2Object refreshmentPool = getObjects().closest("Pool of Refreshment");
    if (refreshmentPool != null) {
        refreshmentPool.interact("Drink");
        Sleep.sleepUntil(() -> myPlayer().isAnimating(), random(2500, 3500));
        log("Succesfully drank refreshments... Sweet");
    }
    if (!FEROXENCLAVE_BANK.contains(myPosition())) {
        bankWalker();
    }
    if (!getBank().isOpen()) {
        boolean isGloryEmpty = gloryChecker();
        boolean isDuelingEmpty = duelingChecker();
        getBank().open();
        log("Bank was opened");
        getBank().depositAll();
        log("Stuff was deposited");
        getBank().withdraw("Salmon", 3);
        log("Salmon was withdrawn");
        if (gloryChecker()) {
            getBank().withdraw("Amulet of glory(4)", 1);
            log("Glory empty, so withdraw a new one");
        }
        if (isDuelingEmpty) {
            getBank().withdraw("Ring of dueling(8)", 1);
            log("ROD empty, so withdraw a new one");
        }
        getBank().close();
        if (isGloryEmpty) {
            getInventory().getItem("Amulet of glory(4)").interact("Wear");
            log("Equipped new amulet of glory");
            getBank().open();
            getBank().deposit("Amulet of glory", 1);
            getBank().close();
        }
        if (isDuelingEmpty) {
            getInventory().getItem("Ring of dueling(8)").interact("Wear");
            log("Equipped new ring of dueling");
        }
    }
    if (!EDGEVILLE_TELESPOT.contains(myPosition())) {
        getEquipment().interact(EquipmentSlot.AMULET, "Edgeville");
    }
}

I am doing some checks to see if the script advances, but only with sequential if statements. Now, say for example the poolWalker function fails. Then probably the script will get stuck further along the line, for example when trying to open the bank. Is this why I see so many if-elseif-elseif constructs in people's scripts? Since, if one if evaluates to true in an if-elseif-elseif, the other "if"s won't be executed, and hence the onLoop progresses to the next action? If that's the case I think I finally get what you mean 😃

Also, finally; do you ideally want to execute exactly *one* action per onloop iteration? For example, in the code above, I open the bank, deposit, withdraw etc all in one go... Is that bad practice too?

 

Thanks in advance

 

 

Link to comment
Share on other sites

5 hours ago, Psychotechno said:

Dear Apa,

I'm a bit further along my scripting journey now and managed to implement a working script.  Previously you told me that I should be "Executing a single game interaction per iteration of onLoop".

[ ... ]

I am doing some checks to see if the script advances, but only with sequential if statements. Now, say for example the poolWalker function fails. Then probably the script will get stuck further along the line, for example when trying to open the bank. Is this why I see so many if-elseif-elseif constructs in people's scripts? Since, if one if evaluates to true in an if-elseif-elseif, the other "if"s won't be executed, and hence the onLoop progresses to the next action? If that's the case I think I finally get what you mean 😃

Also, finally; do you ideally want to execute exactly *one* action per onloop iteration? For example, in the code above, I open the bank, deposit, withdraw etc all in one go... Is that bad practice too?

 

Thanks in advance

Hey Psychotechno,

Quote

Is this why I see so many if-elseif-elseif constructs in people's scripts? Since, if one if evaluates to true in an if-elseif-elseif, the other "if"s won't be executed, and hence the onLoop progresses to the next action?

Yes, exactly!

As I mentioned, the script is interacting with a live game, so every game interaction could fail. Therefore, if your script is entirely deterministic, the script will always be in a position to retry an action until it succeeds (which will cause the 'game state' to change, thereby allowing the script to progress).

The code that you have shared is not quite deterministic; we can prove this by simply looking at your banking statement:

if (!getBank().isOpen()) {
  // ...
  getBank().open();
  log("Bank was opened");
  getBank().depositAll();
  log("Stuff was deposited");
  // ...
}

Let's say that the game is in a state where the bank is not open, thus the above condition evaluates to true and the inner code block executes. First, the script will try to open the bank. This may succeed or fail (high probability of success, but non-zero probability of failure). In either case, the script will next try to deposit everything. This will fail and the script will crash if the bank failed to open initially - uh oh! If the bank opens successfully, then the depositAll may or may not succeed (again, high probability of success). So therefore, for our one input state, we have three potential output states: (1) The bank is not open; (2) The bank is open but your inventory is not empty; and (3) The bank is open and your inventory is empty. In this example, the fact that a single input game state maps to more than two potential output states means that the script is prone to failure. So - how do we prevent this? It's actually very simple:

if (!getBank().isOpen()) {
  getBank().open();
} else {
  getBank().depositAll();
}

If this was the sole contents of your onLoop, then a single game state maps to exactly two output game states: A success state and a failure state. If a failure state is reached, the game state should remain unchanged, thus the script will re-try the interaction automatically.

Naturally, this is only a simple example, but you can extend this paradigm to your use case. This kind of determinism is what separates low quality scripts, such as those typically written by beginners or found in the local scripts section, from the reliable, high quality scripts found on the SDN (for the most part 😜).

I hope that made sense, please let me know if anything is still unclear - always happy to help!

-Apa

  • Heart 1
Link to comment
Share on other sites

7 minutes ago, Apaec said:

Hey Psychotechno,

Yes, exactly!

As I mentioned, the script is interacting with a live game, so every game interaction could fail. Therefore, if your script is entirely deterministic, the script will always be in a position to retry an action until it succeeds (which will cause the 'game state' to change, thereby allowing the script to progress).

The code that you have shared is not quite deterministic; we can prove this by simply looking at your banking statement:


if (!getBank().isOpen()) {
  // ...
  getBank().open();
  log("Bank was opened");
  getBank().depositAll();
  log("Stuff was deposited");
  // ...
}

Let's say that the game is in a state where the bank is not open, thus the above condition evaluates to true and the inner code block executes. First, the script will try to open the bank. This may succeed or fail (high probability of success, but non-zero probability of failure). In either case, the script will next try to deposit everything. This will fail and the script will crash if the bank failed to open initially - uh oh! If the bank opens successfully, then the depositAll may or may not succeed (again, high probability of success). So therefore, for our one input state, we have three potential output states: (1) The bank is not open; (2) The bank is open but your inventory is not empty; and (3) The bank is open and your inventory is empty. In this example, the fact that a single input game state maps to more than two potential output states means that the script is prone to failure. So - how do we prevent this? It's actually very simple:


if (!getBank().isOpen()) {
  getBank().open();
} else {
  getBank().depositAll();
}

If this was the sole contents of your onLoop, then a single game state maps to exactly two output game states: A success state and a failure state. If a failure state is reached, the game state should remain unchanged, thus the script will re-try the interaction automatically.

Naturally, this is only a simple example, but you can extend this paradigm to your use case. This kind of determinism is what separates low quality scripts, such as those typically written by beginners or found in the local scripts section, from the reliable, high quality scripts found on the SDN (for the most part 😜).

I hope that made sense, please let me know if anything is still unclear - always happy to help!

-Apa

Hey boss - Thanks again for the elaborate response. Really do appreciate it!! Completely get it now.  I'm going to rewrite the entire script so I execute exactly one game action per onLoop. Shouldn't be too hard now I get the design paradigm =). One question remains: what about walking paths? For example this function;

private void poolWalker() {
    log("Starting poolWalker");
    WalkingEvent ferox_1 = new WalkingEvent(new Position(3148, 3629, 0));
    ferox_1.setMinDistanceThreshold(2);
    execute(ferox_1);
    Sleep.sleepUntil(() -> myPlayer().isMoving(), random(2500, 3500));
    WalkingEvent ferox_2 = new WalkingEvent(new Position(3138, 3629, 0));
    ferox_2.setMinDistanceThreshold(2);
    execute(ferox_2);
    Sleep.sleepUntil(() -> myPlayer().isMoving(), random(2500, 3500));
    WalkingEvent ferox_3 = new WalkingEvent(new Position(3134, 3636, 0));
    ferox_3.setMinDistanceThreshold(2);
    execute(ferox_3);
    Sleep.sleepUntil(() -> myPlayer().isMoving(), random(2500, 3500));
    log("Finished poolWalker");
}

How does one check if previous movement was successful?? I could make Areas of each position and see if the player position contains the "previous" area coordinates (So for example; before executing the ferox_3 WalkingEvent check if playerPosition is somewhere in area of ferox_2 coords). But that seems a bit cumbersome... 

Link to comment
Share on other sites

3 hours ago, Psychotechno said:

Hey boss - Thanks again for the elaborate response. Really do appreciate it!! Completely get it now.  I'm going to rewrite the entire script so I execute exactly one game action per onLoop. Shouldn't be too hard now I get the design paradigm =). One question remains: what about walking paths? For example this function;


private void poolWalker() {
    log("Starting poolWalker");
    WalkingEvent ferox_1 = new WalkingEvent(new Position(3148, 3629, 0));
    ferox_1.setMinDistanceThreshold(2);
    execute(ferox_1);
    Sleep.sleepUntil(() -> myPlayer().isMoving(), random(2500, 3500));
    WalkingEvent ferox_2 = new WalkingEvent(new Position(3138, 3629, 0));
    ferox_2.setMinDistanceThreshold(2);
    execute(ferox_2);
    Sleep.sleepUntil(() -> myPlayer().isMoving(), random(2500, 3500));
    WalkingEvent ferox_3 = new WalkingEvent(new Position(3134, 3636, 0));
    ferox_3.setMinDistanceThreshold(2);
    execute(ferox_3);
    Sleep.sleepUntil(() -> myPlayer().isMoving(), random(2500, 3500));
    log("Finished poolWalker");
}

How does one check if previous movement was successful?? I could make Areas of each position and see if the player position contains the "previous" area coordinates (So for example; before executing the ferox_3 WalkingEvent check if playerPosition is somewhere in area of ferox_2 coords). But that seems a bit cumbersome... 

Hey,

The nicest way of doing this is pre-recording a list of positions, and feeding that into `getWalking().walkPath()`.

Here are the relevant docs: https://osbot.org/api/org/osbot/rs07/api/Walking.html#walkPath-java.util.List-

Good luck!

(Btw, feel free to PM me your code when you're done - i'd be more than happy to comb through it and give you some feedback :))

-Apa

  • Heart 1
Link to comment
Share on other sites

12 hours ago, Apaec said:

Hey,

The nicest way of doing this is pre-recording a list of positions, and feeding that into `getWalking().walkPath()`.

Here are the relevant docs: https://osbot.org/api/org/osbot/rs07/api/Walking.html#walkPath-java.util.List-

Good luck!

(Btw, feel free to PM me your code when you're done - i'd be more than happy to comb through it and give you some feedback :))

-Apa

I thought about using walkPath's, But ended up using WalkingEvents because there I can set the 

setMinDistanceThreshold(1);

for some added randomization. If I were to use walkPaths; the both would walk the same path time after time which I believe is very bot-like. Trying to randomize the script as much as possible. Will PM you once done!! 

EDIT1: This is a better try, but I'm still not sure if it's perfect; 

    @Override
    public int onLoop() throws InterruptedException {
        dungeonWalker();
        log("One iteration of onLoop finished");
        return random(350, 550);
    }

    private void dungeonWalker() {
        //Player is not near teleport spot and not on it's way to dungeon, so Webwalk to telespot
        if(!TELESPOT.contains(myPosition()) && !NEAR_DUNGEON.contains(myPosition())){
            getWalking().webWalk(TELESPOT);
            Sleep.sleepUntil(() -> myPlayer().isMoving(), random(2500, 3500));
            log("Webwalker finished");
        //Player is not near dungeon and at telespot (Because of previous if) so Walk near dungeon.
        }else if(!NEAR_DUNGEON.contains(myPosition())){
            //Can executing a walkPath be seen as a "Single game interaction?"
            //If not, how do i build "in between" checks as the walkPath is a single function call?
            List<Position> telespot_neardungeon = new ArrayList<>();
            telespot_neardungeon.add(new Position(3086, 3488, 0));
            telespot_neardungeon.add(new Position(3093, 3479, 0));
            telespot_neardungeon.add(new Position(3094, 3470, 0));
            getWalking().walkPath(telespot_neardungeon);
            Sleep.sleepUntil(() -> myPlayer().isMoving(), random(2500, 3500));
            log("Near Dungeon");
        //Player should be near dungeon because of previous block
        }else if(!DUNGEON.contains(myPosition())){
            //Same holds for walkPath. Say WalkPath fails and onLoop executes again. In that case the previous if block
            //else if(!NEAR_DUNGEON.contains(myPosition())) will execute because my player is not near the dungeon anymore but further along the road,
            //And script will get stuck.
            getWalking().webWalk(DUNGEON);
            Sleep.sleepUntil(() -> myPlayer().isMoving(), random(2500, 3500));
            log("In desired area");
            stop(true);
        }
    }

 

Edited by Psychotechno
Link to comment
Share on other sites

1 hour ago, Psychotechno said:

EDIT2: I believe this is getting better; I'm even handling the case when the webWalk fails. If the walkPath fails in the middle, it will simply do it over and since it's only a short walk that's fine. 

EDIT3: Still not perfect because when the Webwalk in the third code block fails (Player is already on its way to dungeon), the onLoop will execute again and then the first if-clause will execute again (Because player is not @ telespot and not at spot near dungeon)... So it walks back all the way to the telespot, to retry again. Which is fine because the script will not break. But it's not that efficient. 


    @Override
    public int onLoop() throws InterruptedException {
        dungeonWalker();
        log("One iteration of onLoop finished");
        return random(350, 550);
    }

    private void dungeonWalker() {
        //Player is not near teleport spot and not on it's way to dungeon, so webwalk to telespot.
        if(!TELESPOT.contains(myPosition()) && !NEAR_DUNGEON.contains(myPosition())){
            getWalking().webWalk(TELESPOT);
            Sleep.sleepUntil(() -> myPlayer().isMoving(), random(2500, 3500));
            log("Webwalker finished, at telespot");
        //Player is not near dungeon and at telespot (Because of previous if) so Walk near dungeon.
        }else if(TELESPOT.contains(myPosition()) && !NEAR_DUNGEON.contains(myPosition())){
            //Can executing a walkPath be seen as a "Single game interaction?"
            //If not, how do i build "in between" checks as the walkPath is a single function call?
            List<Position> telespot_neardungeon = new ArrayList<>();
            telespot_neardungeon.add(new Position(3086, 3488, 0));
            telespot_neardungeon.add(new Position(3093, 3479, 0));
            telespot_neardungeon.add(new Position(3094, 3470, 0));
            getWalking().walkPath(telespot_neardungeon);
            Sleep.sleepUntil(() -> myPlayer().isMoving(), random(2500, 3500));
            log("Near Dungeon");
        //Player is near dungeon but not yet in desired area, so webWalk the rest of the route
        }else if(NEAR_DUNGEON.contains(myPosition()) && !DUNGEON.contains(myPosition())){
            getWalking().webWalk(DUNGEON);
            Sleep.sleepUntil(() -> myPlayer().isMoving(), random(2500, 3500));
            log("In Desired area");         
        }else{
            //If webWalk in previous if block gets stuck, simply WebWalk to desired spot
            getWalking().webWalk(DUNGEON);
            Sleep.sleepUntil(() -> myPlayer().isMoving(), random(2500, 3500));
            log("In Desired area");
        }
    }

 

 

Edited by Psychotechno
SPELLING
Link to comment
Share on other sites

EDIT 4: Got it! Does take a lot of checks though, since I am basically walking in three blocks I need to check a lot of conditions, for the bot to know in which "Section" it currently is. Could maybe simplify somehow but at the moment I don't see how haha. Only posted walker function since onloop did not change. I think readers can skip edit 1, 2 and 3 and refer to this block, as this is the final version... Sorry for the SPAM haha kept getting new ideas just after my edits 🤣

private void dungeonWalker() {
    //Player is not near teleport spotm not on it's way to dungeon, and not already in dungeon so walk to telespot. 
    if(!TELESPOT.contains(myPosition()) && !NEAR_DUNGEON.contains(myPosition()) && myPlayer().getY() < 9700){
        getWalking().webWalk(TELESPOT);
        Sleep.sleepUntil(() -> myPlayer().isMoving(), random(2500, 3500));
        log("Webwalker finished");
    //Player is not near dungeon and at telespot (Because of previous if) so Walk near dungeon.
    }else if(TELESPOT.contains(myPosition()) && !NEAR_DUNGEON.contains(myPosition())){
        List<Position> telespot_neardungeon = new ArrayList<>();
        telespot_neardungeon.add(new Position(3086, 3488, 0));
        telespot_neardungeon.add(new Position(3093, 3479, 0));
        telespot_neardungeon.add(new Position(3094, 3470, 0));
        getWalking().walkPath(telespot_neardungeon);
        Sleep.sleepUntil(() -> myPlayer().isMoving(), random(2500, 3500));
        log("Near Dungeon");
    //Player is near dungeon but not yet in desired area, so webWalk the rest of the route
    }else if(NEAR_DUNGEON.contains(myPosition()) && !DUNGEON.contains(myPosition())){
        getWalking().webWalk(DUNGEON);
        Sleep.sleepUntil(() -> myPlayer().isMoving(), random(2500, 3500));
        log("In desired Area");
    }
    //Player is in dungeon but not yet in desired area (Maybe cuz webwalk broke in previous onLoop), so webWalk the rest of the route 
    else if (myPosition().getY() > 9700){
        //Player is in dungeon, so continue webwalk.
        getWalking().webWalk(DUNGEON);
        Sleep.sleepUntil(() -> myPlayer().isMoving(), random(2500, 3500));
        log("In desired Area");
    }
}

 

Edited by Psychotechno
Link to comment
Share on other sites

2 hours ago, Psychotechno said:

EDIT 4: Got it! Does take a lot of checks though, since I am basically walking in three blocks I need to check a lot of conditions, for the bot to know in which "Section" it currently is. Could maybe simplify somehow but at the moment I don't see how haha. Only posted walker function since onloop did not change. I think readers can skip edit 1, 2 and 3 and refer to this block, as this is the final version... Sorry for the SPAM haha kept getting new ideas just after my edits 🤣


private void dungeonWalker() {
    //Player is not near teleport spotm not on it's way to dungeon, and not already in dungeon so walk to telespot. 
    if(!TELESPOT.contains(myPosition()) && !NEAR_DUNGEON.contains(myPosition()) && myPlayer().getY() < 9700){
        getWalking().webWalk(TELESPOT);
        Sleep.sleepUntil(() -> myPlayer().isMoving(), random(2500, 3500));
        log("Webwalker finished");
    //Player is not near dungeon and at telespot (Because of previous if) so Walk near dungeon.
    }else if(TELESPOT.contains(myPosition()) && !NEAR_DUNGEON.contains(myPosition())){
        List<Position> telespot_neardungeon = new ArrayList<>();
        telespot_neardungeon.add(new Position(3086, 3488, 0));
        telespot_neardungeon.add(new Position(3093, 3479, 0));
        telespot_neardungeon.add(new Position(3094, 3470, 0));
        getWalking().walkPath(telespot_neardungeon);
        Sleep.sleepUntil(() -> myPlayer().isMoving(), random(2500, 3500));
        log("Near Dungeon");
    //Player is near dungeon but not yet in desired area, so webWalk the rest of the route
    }else if(NEAR_DUNGEON.contains(myPosition()) && !DUNGEON.contains(myPosition())){
        getWalking().webWalk(DUNGEON);
        Sleep.sleepUntil(() -> myPlayer().isMoving(), random(2500, 3500));
        log("In desired Area");
    }
    //Player is in dungeon but not yet in desired area (Maybe cuz webwalk broke in previous onLoop), so webWalk the rest of the route 
    else if (myPosition().getY() > 9700){
        //Player is in dungeon, so continue webwalk.
        getWalking().webWalk(DUNGEON);
        Sleep.sleepUntil(() -> myPlayer().isMoving(), random(2500, 3500));
        log("In desired Area");
    }
}

 

Hey,

This is looking nice! I'm not exactly sure if your conditions cover every case, because I don't know the context of the script. However this is something that you should have a feeling of and something I am sure you can test.

A few things to note:

  1. All walking events could fail at any point throughout the walk (though this is unlikely). You therefore have to support this, so make sure this is the case. A good way to test this is to start the script at various stages in the journey and see if the script successfully completes the journey (relying on the webwalker as little as possible).
  2. getWalking().webWalk() and getWalking().walkPath are both blocking operations; there is no need for a conditional sleep after them.
  3. What happens if none of the conditions are met?
  4. Checking a Y coordinate like that is a little strange; I would keep things to area checks to make your code more readable!
  5. You should pull constants (such as the path) outside of the function. You can also instantiate the ArrayList from an array of positions.
  6. Try and stuck to java naming conventions where possible (though this doesn't matter so much, just a nit really).
  7. I wouldn't worry about walkPath not being random enough, lots of factors will combine to mean this isn't a problem (e.g. camera angle, network latency fluctuations, clickbox randomisation, etc)

Nice one :)

-Apa

 

  • Heart 1
Link to comment
Share on other sites

On 1/16/2021 at 7:21 PM, Apaec said:

Hey,

This is looking nice! I'm not exactly sure if your conditions cover every case, because I don't know the context of the script. However this is something that you should have a feeling of and something I am sure you can test.

A few things to note:

  1. All walking events could fail at any point throughout the walk (though this is unlikely). You therefore have to support this, so make sure this is the case. A good way to test this is to start the script at various stages in the journey and see if the script successfully completes the journey (relying on the webwalker as little as possible).
  2. getWalking().webWalk() and getWalking().walkPath are both blocking operations; there is no need for a conditional sleep after them.
  3. What happens if none of the conditions are met?
  4. Checking a Y coordinate like that is a little strange; I would keep things to area checks to make your code more readable!
  5. You should pull constants (such as the path) outside of the function. You can also instantiate the ArrayList from an array of positions.
  6. Try and stuck to java naming conventions where possible (though this doesn't matter so much, just a nit really).
  7. I wouldn't worry about walkPath not being random enough, lots of factors will combine to mean this isn't a problem (e.g. camera angle, network latency fluctuations, clickbox randomisation, etc)

Nice one :)

-Apa

 

Hey Apa!

To address point 3 (I think I've met all the conditions but you never know), I added an else-clause that webwalks the entire way to the destination dungeon. This is a backup after all else fails; so I think it will never be executed but you never know. 

To address point 5; do you mean that I should initialize the walkpath as a field somewhere (Like i did with for example the variables NEAR_DUNGEON and TELESPOT?) With the comment about instantiating the arraylist, do you mean instantiating it in a oneliner? So simply add the positions to the new ArrayList constructor? 

Point 6: Any example where I did not do this? 

Thanks again for all the feedback 😃 Script is really improving because of it. 

~Pscyho

Link to comment
Share on other sites

29 minutes ago, Psychotechno said:

Hey Apa!

To address point 3 (I think I've met all the conditions but you never know), I added an else-clause that webwalks the entire way to the destination dungeon. This is a backup after all else fails; so I think it will never be executed but you never know. 

To address point 5; do you mean that I should initialize the walkpath as a field somewhere (Like i did with for example the variables NEAR_DUNGEON and TELESPOT?) With the comment about instantiating the arraylist, do you mean instantiating it in a oneliner? So simply add the positions to the new ArrayList constructor? 

Point 6: Any example where I did not do this? 

Thanks again for all the feedback 😃 Script is really improving because of it. 

~Pscyho

Hey :) Cheers for taking the feedback on board.

Nice one on point 3. As I mentioned before, a nice way to test that you don't have any holes in the journey (and hence places the script could get stuck) is to start the script at various points in-game and seeing if the script can get into the normal flow.

As for point 5, yep - that's more or less what I mean. Right now, you are creating your dungeons path each time you enter the method, which is unnecessary as this path is constant. Instead, you could do something like this:

List<Position> TELESPOT_TO_DUNGEON = Arrays.asList(new Position(3086, 3488, 0), new Position(3093, 3479, 0), new Position(3094, 3470, 0));

Also, you can add more positions to your path (I like to add every other tile to my paths and I have a script to record such data). As the walkPath method will select the next suitable position from your path (typically, I believe, the furthest point in the path reachable on the minimap), you don't have to worry about the script walking in small increments.

As for point 6, local variables e.g. your `telespot_neardungeon` should be camelCase, i.e. `telespotNearDungeon`. That's the only inconsistency with the java conventions that I can see :)

GL!

-Apa

  • Heart 1
Link to comment
Share on other sites

  • Gunman locked this topic
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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