Open and close gate?

Discussion in 'Projects' started by mrpiccard, Mar 23, 2015.

  1. mrpiccard

    Joined:
    Mar 20, 2015
    Messages:
    3
    Likes Received:
    2
    Hey guys! This is my first forum post so if it's in the wrong section please move it or let me know.

    I'm working on my first bot, and one thing I'm stuck on is gates. How do I check if its open or closed? Or is there a standard way of dealing with walking past open/closed gates?
     
  2. Exia

    Joined:
    Nov 3, 2013
    Messages:
    600
    Likes Received:
    250
    You have a couple of options:
    1) You'll need to grab the tile location. It should be different when the door/gate is opened/closed.
    2) If the location doesn't change, then try the actual model ID, that should be different.
    3) If those can't tell the difference, then try looking at the value of getOrientation() on the gameobject.

    Hope this helps.
     
  3. Arbiter

    Arbiter Mod Automation

    Joined:
    Jul 26, 2013
    Messages:
    2,532
    Likes Received:
    1,046
    To answer your question there is in fact a standard way to deal with doors and other such navigation related items, but it involves adding to the web walking implementation. That is an advanced topic for a beginner, but I know a lot of our great devs would be happy to explain it to you in our Skype dev chat. PM me your Skype if you're interested.
     
  4. mrpiccard

    Joined:
    Mar 20, 2015
    Messages:
    3
    Likes Received:
    2
    thank you! i actually just realized the ID is different
     
  5. Ozzy

    Joined:
    Nov 5, 2014
    Messages:
    504
    Likes Received:
    159
    Another way would be to run a query to find nearby closed gates. (Adjust the query to search within a certain area/distance of you)

    Code (Text):
    1. LocatableEntityQueryResults<GameObject> closedGates = GameObjects.newQuery().names("Gate").actions("Open");
    You can then do something like:

    Code (Text):
    1. if (!closedGates.isEmpty()) {
    2. GameObject gate = closeGates.nearest();
    3. // Code to open a gate
    4. }
    5.  
     
  6. Cloud

    Cloud Just another one...

    Joined:
    Jul 28, 2013
    Messages:
    2,412
    Likes Received:
    795
    I'd recommend finding something else besides the id, the id is unstable and prone to changes by Jagex.
     
  7. mrpiccard

    Joined:
    Mar 20, 2015
    Messages:
    3
    Likes Received:
    2
    ah, alright. ill try some of the other methods suggested then. thanks
     
  8. Factionless

    Joined:
    Feb 6, 2015
    Messages:
    216
    Likes Received:
    55
    You can try using coordinates at each side of the door, and check if it's reachable or not. If it's not reachable. door.interact("Open");
    I personally haven't done it but if I did that's how I'd do it.
     
  9. Cloud

    Cloud Just another one...

    Joined:
    Jul 28, 2013
    Messages:
    2,412
    Likes Received:
    795
    Just remember that reachability is an intense calculation is done frequently.
     
    Factionless likes this.
  10. red

    red

    Joined:
    Nov 17, 2013
    Messages:
    225
    Likes Received:
    100
    Yes but it is hard not to use it at times. Especially when you have absolutely no choice.
     
  11. Cloud

    Cloud Just another one...

    Joined:
    Jul 28, 2013
    Messages:
    2,412
    Likes Received:
    795
    I've yet to encounter a single situation like that, I've always managed to find a solution even when it seemed really impractical.
     

Share This Page

Loading...