Jump to content

Woody

Members
  • Posts

    715
  • Joined

  • Last visited

  • Feedback

    100%

Posts posted by Woody

  1. mmkk i will try that. as for break. wouldn't it break out of just the loop that it's in? 

    so in hunter it won't move to a new location before it places the trap, and in wait it would only drop while there is nothing to do in hunter?

    though i'm sure that's wrong as it's not running... lol

     

    and i'll just have to get used to  { in line ha, you're right it's definitely cleaner that way.

    yes, it will break out of the loop. But you are using it wrong, you shouldn't break after every action.

     

    Just break and the end of your case.

    • Like 1
  2. Man, cancer sucks... I don't really know you butI really, really hope you'll beat it, as I hope for all those who have cancer.

     

    You should go live your life to absolute maximum and enjoy doing what you like to do.

     

    <3

  3. posting again because I am having much the same error, where the code will populate in the local lis but not execute. So i'm assuming it's a faulty logic thing? But I can't see where or how, though it is pretty late and i'm Suuuuuper tired. Again, any and all criticism, comments, and help on either the error, or my methods is welcomed and appreciated!

     

    import org.osbot.rs07.api.model.Entity;
    import org.osbot.rs07.script.Script;
    import org.osbot.rs07.script.ScriptManifest;
    import org.osbot.rs07.api.ui.Skill;
    import org.osbot.rs07.api.map.Position;
    import org.osbot.rs07.api.model.GroundItem;
    //import org.osbot.rs07.api.EntityAPI;
    //import org.osbot.rs07.api.ui.Message;
    //import org.osbot.rs07.api.ui.Message.MessageType;
    import org.osbot.rs07.api.map.Area;
    
    import java.awt.*;
    import java.util.concurrent.TimeUnit;
     
    @ScriptManifest(
    		author = "Abhorrent", 
    		info = "Hunter", 
    		name = "Upgraded Hunter", 
    		version = 1.1,
    		logo = "")
    
    public class main extends Script {
    	
    	String status = "Nothing";
    	long startTime = System.currentTimeMillis();
    	long timeElapsed = 0;
    	int trapsUp = 1;
    	Position [] spots = {
    			new Position(2540,2882,0),
    			new Position(2538,2882,0),
    			new Position(2539,2884,0),
    			new Position(2537,2884,0),
    			new Position(2536,2882,0),
    	};
    	Position myP = myPlayer().getPosition();
    	Position spot = new Position(0,0,0);
    	Area[] traps = {
    			new Area(2540, 2882, 2540, 2882),
    			new Area(2538, 2882, 2538, 2882),
    			new Area(2539, 2884, 2539, 2884),
    			new Area(2537, 2884, 2537, 2884),
    			new Area(2536, 2882, 2536, 2882),
    	};
    	int huntlvl = skills.getStatic(Skill.HUNTER);
    	int numTraps = huntlvl/20 + 1;
        @Override
        public void onStart() {
            log("=======================");
            log("= Starting Hunter Bot =");
            log("=======================");
            getBot().addMessageListener(this);
        }
        
        private enum State {
        	HUNTING, WAITING;
    	};
        	
    	private State getState() {
    
    		Entity trapDown = objects.closest(9344);
    		Entity trapBird = objects.closest(9348);
    		
    		if (trapsUp < numTraps || trapDown != null || trapBird != null)
    		{
    			status = "Hunting";
    			return State.HUNTING;
    		}
    		else
    		{
    			status = "Waiting";
    			return State.WAITING;
    		}
    	}
    	
    	/*
    	public void onMessage(Message message) {
    		if (message.getType() == MessageType.GAME) {
    			try {
    				if (message.getMessage().contains("You can't")) {
    					if(spot == spots[1]){
    						spot = spots[2];
    					}
    					if (spot == spots[2]){
    						spot = spots[1];
    					}
    					
    				} else {
    					// Do nothing
    				}
    			} catch (Exception e) {
    				e.printStackTrace();
    			}
    		}
    	}
    	*/
    	
    	@Override
        public int onLoop() throws InterruptedException {
    		switch (getState()) {
    		case HUNTING: 
    			myP = myPlayer().getPosition();
    			Entity trapSet = objects.closest(9345);
    			Entity trapDown = objects.closest(9344);
    			Entity trapBird = objects.closest(9348);
    			
    			int x = 1;
    			trapsUp = 0;
    			for (x = 1; x < 5; x++)
    			{
    				if (traps[x].contains(trapSet) || traps[x].contains(trapDown) || traps[x].contains(trapBird))
    				{
    					trapsUp++;
    				}
    			}
    			
    			int y = 1;
    			
    			for (y=1;y<numTraps;y++)
    			{
    				if (trapsUp < numTraps && !myPlayer().isAnimating())
    				{
    					if (myP.equals(spots[y]))
    					{
    						inventory.interact("Lay","Bird Snare");
    						sleep(random(4500,5250));
    						break;
    					}
    					if (!myP.equals(spots[y]))
    					{
    						spots[y].interact(bot,"Walk here");
    						sleep(random(435,550));
    						break;
    					}
    				}
    				if (trapDown != null && trapDown.isVisible() && !myPlayer().isAnimating())
    				{
    					trapDown.interact("Dismantle");
    					sleep(random(500,800));
    					break;
    				}
    				if (trapBird != null && trapBird.isVisible() && !myPlayer().isAnimating())
    				{
    					trapBird.interact("Check");
    					sleep(random(600,890));
    					break;
    				}
    				else
    				{
    				}	
    			}
    			
    		case WAITING:
    			GroundItem trap = groundItems.closest(10006);
    			if (trap != null)
    			{
    				trap.interact("Take");
    				break;
    			}
    			if (inventory.contains("Bones"))
    			{
    				inventory.interact("Drop","Bones");
    				break;
    			}
    			if (inventory.contains("Raw bird meat"))
    			{
    				inventory.interact("Drop","Raw bird meat");
    				break;
    			}
    			sleep(random(675,1100));
    			break;
    		}
    		return random(700,800);
    	}
    	
        @Override
        public void onExit() {
            log("YoloSwagAFk");
        }
     
        @Override
        public void onPaint(Graphics2D g) {
    		long currentTime = System.currentTimeMillis();
    		timeElapsed = currentTime - startTime;
    		long hours = TimeUnit.MILLISECONDS.toHours(timeElapsed);
    		timeElapsed -= TimeUnit.HOURS.toMillis(hours);
    		long minutes = TimeUnit.MILLISECONDS.toMinutes(timeElapsed);
    		timeElapsed -= TimeUnit.MINUTES.toMillis(minutes);
    		long seconds = TimeUnit.MILLISECONDS.toSeconds(timeElapsed);
        	g.drawString("Status: " + status, 200, 314);
        	g.drawString("Run Time: " + hours + ":" + minutes + ":" + seconds, 200, 300);
        	g.drawString("Hunter Lvl: " + skills.getStatic(Skill.HUNTER), 200, 342);
        	g.drawString("Number of traps you can set: " + numTraps, 200, 286);
        	g.drawString("Traps set up : " + trapsUp, 200, 272);
        	g.drawString("My position : " + myP, 200, 328);
        	g.drawString("The spot is: " + spot, 200, 356);
        }
     
    }
    

     

     

    Falling asleep as I type, thanks in advance for any help and advice

    Tbh, your code is really ugly to read; why do you have your "{" on a separate line?

     

    You shouldn't break after every action, it looks like you don't understand what break means in java. And yea, your logic still fails. Try a different approach on how to check for traps. Remember that someone else might set up a trap nearby you, and your script will think it's your characters trap.

     

    Find an empty position -> set up trap -> if trap is up -> save this position in a list as positions with trap -> loop through your list with positions and see if any position has an object on it, matching trap down.

     

    This was just an example. It's up to you how you want to do it.

  4. The other guy could be right. Try deleting C:\Users\YourName\OSBot folder entirely and any other OSBot related file folders, and then download the latest jar and run it.

     

    Don't do this.

     

    It looks like there are some issues with the GUI. If it's not your script, just contact the script writer.

    • Like 1
  5. Remember, getHealth will only return to a value if your health bar is visible, if the character is fighting.

     

    You can use widgets to get the character's HP; find the correct parent and child id for HP widget and translate the string to an int.

    • Like 1
×
×
  • Create New...