Samuel91 6 Share Posted October 17, 2018 As title says is there anyway to check if a tree/rock is already being used by another player and avoid it? Link to comment Share on other sites More sharing options...
Empyrean GB 7 Share Posted October 17, 2018 For a tree you can check or the tree has the "Chop down" option: GameObject tree = caller.getGameObjects().closest(object -> object != null && object.hasAction("Chop down")); Combine that with the name of the tree you want to chop and you should be fine Rocks, I don't know yet Link to comment Share on other sites More sharing options...
Samuel91 6 Author Share Posted October 17, 2018 I think you've misunderstood. I'm not trying to avoid resources that are already depleted I'm trying to to avoid resources that are still there but have another player trying to harvest them. Link to comment Share on other sites More sharing options...
Samuel91 6 Author Share Posted October 17, 2018 52 minutes ago, Empyrean GB said: Rocks, I don't know yet As an aside you can filter for depleted rocks by using this snippet of code from dQw4w9WgXcQ. GameObject rock = getGameObjects().closest(gameObject -> gameObject != null && gameObject.getName().equals("Rocks") && gameObject.getModelColors()[0] == ROCK_COLOR); It uses the rocks color to tell whether or not it is depleted. Link to comment Share on other sites More sharing options...
Empyrean GB 7 Share Posted October 17, 2018 O sorry my bad, I only did woodcutting so far and from lvl 15 onwards it doesn't matter if multiple player interact with the same tree so misunderstood the issue. Never worked with this. You could check if there's a player standing next to the game object facing it and is in the mining animation... A player has a tile he is on, getFacingDirection and getAnimation. But that sounds more like a work around if anything with a lot of looping or a really complex labda. Other then that I wouldn't know sorry Link to comment Share on other sites More sharing options...
ozeki6 32 Share Posted October 17, 2018 8 hours ago, Samuel91 said: As title says is there anyway to check if a tree/rock is already being used by another player and avoid it? As far as I know, there isn't an easy way of doing this. What I can think of is check if there are player around, check if it's 1 tile away from the tree/rock, check animations to see if he is mining/woodcutting and check if the player is facing the rock/tree. Link to comment Share on other sites More sharing options...
pokemonhuang 1 Share Posted October 17, 2018 so from the tutorial of goblin killing , game filter was introduced. base on that idea. you expand on it. you can check if there are players around by using getPlayers.all() and compare there location. its a good idea. i have the same idea and implemented. heres my checker for rocks. the problem is. for rocks its only up down left right. but i used get area. so its not perfect yet. good list is the list of rocks i want to mine. public Boolean checkIfTileAroundHasPlayer(GameObject go){ Tile temp=new Tile(go.getX(),go.getY()); for(Player i:getPlayers().all()){ if( temp.getArea(1).contains(i)&&!i.getName().equals(getLocalPlayer().getName())){ return true; } } return false; } public Filter<GameObject> rockFilter = new Filter<GameObject>() { @Override public boolean match(GameObject gameObject) { if(checkIfTileAroundHasPlayer(gameObject)){ return false; } if (goodList.contains(gameObject.getID())) { return true; } return false; } }; Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.