Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • How do I check if player is on the other side of the gate to Al-Kharid?


    Deniii

    Recommended Posts

    Hi, I am currently making a basic cow killer that loots hides and banks them and I have stumbled upon some bugs/things I want to fix.

     

    I am using a state driven script, and currently it gets stuck when walking to bank in Al-Kharid. It pays the toll, then goes like 4 tiles and returns to pay toll again, then continues on. I have no idea how to check if player is already on the other side of the gate, because if the player starts the script somewhere in Al-Kharid it will not be flawless.

        private void WalkToBank(Player localPlayer)
        {
            //if player is in cow area
            if (cowArea.contains(localPlayer))
            {
                log("Player is in cow area.");
                //find gate
                GameObject gate = getGameObjects().closest("Gate");
                //is the gate closed?
                if (gate != null && gate.hasAction("Open"))
                {
                    if (!gate.isOnScreen())
                    {
                        log("Rotating camera to gate");
                        //turn camera to gate
                        getCamera().rotateToEntity(gate);
    
                    }
                    //open gate
                    log("Opening gate.");
                    gate.interact("Open");
                    sleepUntil(() -> !gate.hasAction("Open"), 1000);
                }
                //gate is opened
                else if (gate != null && !gate.hasAction("Open"))
                {
                    log("Walking to toll gate.");
                    //walk to toll gate
                    getWalking().walk(tollGateLeft.getRandomTile());
                }
            }
            else // This right here is what I do not know how to make it check properly. 
            {
                getWalking().walk(tollGateLeft.getRandomTile());
    
                GameObject tollGate = getGameObjects().closest(gameObject -> gameObject != null
                        && gameObject.getName().equals("Gate")
                        && gameObject.hasAction("Pay-toll(10gp)"));
    
                if(tollGate.interact("Pay-toll(10gp)"))
                {
                    sleepUntil(() -> tollGateRight.contains(localPlayer), Calculations.random(1200, 2300));
                    getWalking().walk(BankLocation.AL_KHARID.getArea(20).getRandomTile());
                }
            }
    
        }
    
    

    Obviously this won't work as it will always walk back to "tollGateLeft" even if we are on the Al-Kharid side of the gate...

     

    How do I make the script smart and implement something like this?

     

     

    Link to comment
    Share on other sites

    Could you do something where the script checks if you are in the area past the gate, using the contains method that you used for cowArea? Once player triggers this, you can return a boolean value "inDesert = true" and then walk to bank. To get past the gate on the opposite side, you create an area past the gate, check if the player is contained within it and set the inDesert to false and run to cows. This could be a solution to your problem. 

    Link to comment
    Share on other sites

    Could you do something where the script checks if you are in the area past the gate, using the contains method that you used for cowArea? Once player triggers this, you can return a boolean value "inDesert = true" and then walk to bank. To get past the gate on the opposite side, you create an area past the gate, check if the player is contained within it and set the inDesert to false and run to cows. This could be a solution to your problem. 

    Oh wow... I am actually using this system, but I forgot to implement the "inDesert" bool... thank you very much for helping me!

    Link to comment
    Share on other sites

    you can also check if getLocalPlayer().getX() < amount , same for Y 

    makes the area a bit bigger ^^

    Interesting. That would be even better if the user starts the script somewhere else. If X pos is to the left of the gate - not in desert. If X pos is to the right of the gate - in desert.

     

    EDIT: Works perfectly!

          if (BankLocation.AL_KHARID.getArea(20).contains(getLocalPlayer()) || tollGateRight.contains(getLocalPlayer()) || getLocalPlayer().getX() >= 3268)
            {
                inDesert = true;
            }
            else if (cowArea.contains(getLocalPlayer()) || tollGateLeft.contains(getLocalPlayer()) || getLocalPlayer().getX() < 3268)
            {
                inDesert = false;
            }
    
    Link to comment
    Share on other sites

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.