Jump to content

lingoling

Members
  • Posts

    102
  • Joined

  • Last visited

  • Feedback

    0%

Posts posted by lingoling

  1. I have this code, but it doesn't seem to work. The other methods on here only work randomly. IDK >>

    RS2Object rock = closestObject(GEM_ID);
    
    	        if(rock.exists() && !myPlayer().isAnimating()) {
    	        	if (rock != null) {
    	        		if (rock.interact("Mine"))
    	        			curRock = rock;
    	        			sleep(random(1000, 1500));
    	        	}
    	        }		
    	        if(!curRock.exists()) {
    	            if(myPlayer().isAnimating()) {
    	            	traversePath(avoid, true);
    					sleep(random(1500, 2500));
    	            }
    	        }			
    			
    
  2.  

    I don't think that's going to stop your player from keeping on mining while your rock changed in smoking rock.

     

    Maybe you should try something with states: (I'm just writing this now and I never wrote a mining script so it could be wrong)

    private Enum State { MINING,WAITING}
    private State state = State.MINING;
    private RS2Object currentRock = null;
    private int rockId = <ROCK_ID>;// replace with your rock id
    switch (state){
     case WAITING:
       if(currentRock.getId() == rockId){// currentRock still is normal rock (I don't know what to check for, could be id or modelHeight or something)
       // sleep or antiban or w/e
       }else{
        currentRock = null;
       state = State.MINING;
       }
    break;
    case MINING:
       currentRock = closestObject(rockId);
       if(currentRock!=null){
         currentRock.interact("Mine");
       }
    break;
    }
    

     

    Is there a way that I can define an RS2Object as the object (the rock) in front of me?

     

    I think that I can make this work this way :

    case MINE:
    			RS2Object rock = closestObject(GEM_ID);
    			int GemHeight = rock.getModel().getHeight();
    			RS2Object facing = getFacingObject();
    			int currentHeight = facing.getModel().getHeight();
    			if (rock != null) {
    				if ( GemHeight == currentHeight ) { 
    					if (!myPlayer().isAnimating()) {
    									if (rock.interact("Mine"))
    										sleep(random(1000, 1500));
    										
    								
    					}
    				} else {
    					traversePath(avoid, true);
    					sleep(random(1500, 2500));
    				}
    			}
    		break;
    

    But I have to define

     

    RS2Object facing = getFacingObject();

     

    as obviously getFacingObject isn't real. Is there a method I can actually use that would do that? If not, I'll try your state switching idea.

     

     

    Even if there isn't a prebuilt function for it, is there a way I could manually determine it?

  3. Here's what I'm currently trying. I'll post back the results:

    RS2Object rock = closestObject(GEM_ID);
    			if (rock != null) {
    				currrentRockID = rock.getId();
    				if (!myPlayer().isAnimating()) {
    						if (Arrays.binarySearch(GEM_ID, currrentRockID) != -1) {
    								if (rock.interact("Mine"))
    									sleep(random(1000, 1500));
    									
    						} else {
    							traversePath(avoid, true);
    							sleep(random(1500, 2500));
    						}
    				}
    			}
    
  4. 2 ways i can think of:

    Parse Model Height (non smoking has the aprox y triangles of 90) so if model.height > normal height

    Parse current ID, log the ID's on start in an array and then if the current interacting Id != logged ID's

     

    How do you tell the current ID of the rock? I read that getFacingId() doesn't work for objects.

  5. Set up a global integer called tCount or something and instantiate it to 0.

    When you have your player interact with the rock use this code.

    tCount = rock.getModel().getTriangleCount();
    

    Then display that value in your paint and run your bot. Once he mines the different modeled rocks the paint will show you your tcount.

     

    Take any default tCounts and toss them in an array and use the code from the original post

     

    I figured it out earlier and ran my script for 10 hours. Then my pickaxe broke. I ran it again for 30 minutes and it broke again.  It seems that the code doesn't work? The idea seems logical but in practice my pickaxes are still getting broken :/

  6. No problem :)

    I'm not too sure, did you change the areas at all, and double check your path.

    I didn't change any of the areas, and I've experienced this problem using the positions you provided and custom ones. I've been told that it's a problem with the API though. It runs for hours on end and randomly starts going off the path. I've also experienced this in other scripts too.
  7. I'm trying to make my script walk from the mine back to the bank and it's acting weird. I have this for the positions:

    private Position[] path = {
    		     new Position(3289, 3371, 0),
    		     new Position(3290, 3374, 0),
    		     new Position(3294, 3386, 0),
    		     new Position(3290, 3391, 0),
    		     new Position(3291, 3401, 0),
    		     new Position(3289, 3406, 0),
    		     new Position(3286, 3418, 0),
    		     new Position(3276, 3426, 0),
    		     new Position(3264, 3429, 0),
    		     new Position(3254, 3421, 0)
    	};
    

    I manually put them in so I don't know why it's acting odd. Once it gets to the 3rd position it clicks back  towards the mine then starts walking South. Any idea what's causing this?

     

    Here is my whole script for reference.

    
    import java.awt.Graphics;
    
    
    import org.osbot.script.Script;
    import org.osbot.script.ScriptManifest;
    import org.osbot.script.mouse.MinimapTileDestination;
    import org.osbot.script.rs2.map.Position;
    import org.osbot.script.rs2.model.RS2Object;
    import org.osbot.script.rs2.utility.Area;
    @ScriptManifest(author ="Lingoling", info="Mines Tin in Varrock east. Start in bank or at mine.", name = "BasicMiner", version = 0)
    
    public class BasicMiner extends Script {
    	
    	private static final int[] TIN_ID = {11636,11634, 11635};
    	
    	
    	private enum State {
    		MINE, WALK_TO_BANK, BANK, WALK_TO_MINE};
    	
    	private State getState() {
    		if (client.getInventory().isFull() && MINE_AREA.contains(myPlayer()))
    			return State.WALK_TO_BANK;
    		if (!client.getInventory().isFull() && BANK_AREA.contains(myPlayer()))
    			return State.WALK_TO_MINE;
    		if (client.getInventory().isFull() && BANK_AREA.contains(myPlayer()))
    			return State.BANK;
    		return State.MINE;
    	}
    	private Position[] path = {
    		     new Position(3289, 3371, 0),
    		     new Position(3290, 3374, 0),
    		     new Position(3294, 3386, 0),
    		     new Position(3290, 3391, 0),
    		     new Position(3291, 3401, 0),
    		     new Position(3289, 3406, 0),
    		     new Position(3286, 3418, 0),
    		     new Position(3276, 3426, 0),
    		     new Position(3264, 3429, 0),
    		     new Position(3254, 3421, 0)
    	};
    	private static final Area MINE_AREA = new Area(3277, 3358, 3293, 3371);
        private static final Area BANK_AREA = new Area(3250, 3419, 3257, 3423);
        
        private void traversePath(Position[] path, boolean reversed) throws InterruptedException {
        	if (!reversed) {
        		for (int i = 1; i < path.length; i++)
        			if (!walkTile(path[i]))
        				i--;
        	} else {
        		for (int i = path.length-2; i > 0; i--)
        			if (!walkTile(path[i]))
        				i++;
        	}
        } 
        private boolean walkTile(Position p) throws InterruptedException {
        	client.moveMouse(new MinimapTileDestination(bot, p), false);
        	sleep(random(150, 250));
        	client.pressMouse();
        	int failsafe = 0;
        	while (failsafe < 10 && myPlayer().getPosition().distance(p) > 2) {
        		sleep(200);
        		failsafe++;
        		if (myPlayer().isMoving())
        			failsafe = 0;
        	}
        	if (failsafe == 10)
        		return false;
        	return true;
        }
    	@Override
    	public void onStart() {
    		log("I like women but they don't like me, and it's hard, yes siree");
    	}
    	@Override
    	public int onLoop() throws InterruptedException {
    		switch (getState()) {
    		case MINE:
    			if (!myPlayer().isAnimating()) {
    				RS2Object vein = closestObject(TIN_ID);
    				if (vein != null) {
    					if (vein.interact("Mine"))
    						sleep(random(1000, 1500));
    				}
    			}
    		break;
    		case WALK_TO_BANK:
    			traversePath(path, false);
    			sleep(random(1500, 2500));
    		break;
    		case WALK_TO_MINE:
    			traversePath(path, true);
    			sleep(random(1500, 2500));
    		break;
    		case BANK:
    			RS2Object bank = closestObjectForName("Bank booth");
    			if (bank != null) {
    				if (bank.interact("Bank")) {
    					while (!client.getBank().isOpen())
    						sleep(250);
    					client.getBank().depositAll();
    				}
    			}
    		break;
    		}
    		return random(200, 300);
    	}
    	@Override
    	public void onExit() {
    		log("Thanks ********a.");
    		
    	}
    	@Override
    	public void onPaint(Graphics g) {
    		
    
    	}
    }
    
    
×
×
  • Create New...