Jump to content

liverare

Scripter II
  • Posts

    1296
  • Joined

  • Last visited

  • Days Won

    3
  • Feedback

    0%

Posts posted by liverare

  1. Have you checked out

    bot.getMouseEventHandler().generateBotMouseEvent

    ? If not, try that before using Robot - I've included you in a PM where somebody else asked how I got around OSBot's slow keyboard/mouse problem.

    Also, you shouldn't need to use JNativeHook library as you can add listeners to the client itself

    gl dude, my script blows so I hope you do a ton better :)

     

  2. Something like...

    
    Position tile = null;
    RS2Object box = null;
    Item boxItem = null;
    
    if (tile != null) {
    
    	box = getBox(tile);
    	
    	if (box.hasActions("Check")) {
    		// loot
    	}
    	
    } else {
    
    	boxItem = inventory.getItem("Box trap");
    
    	if (boxItem != null && boxItem.interact("Lay")) {
    	
    		tile = myPosition();
    	}
    
    }
    
    // other stuff.....
    
    public RS2Object getBox(Position tile) {
    	return objects.getAll().stream().filter(obj -> obj != null
    		&& obj.exists()
    		&& obj.getName().equals("Box trap")
    		&& obj.getX() == tile.getX()
    		&& obj.getY() == tile.getY())
    		.findFirst().orElse(null);
    }

     

    • Like 1
  3. Looking good!

    In your AttackCow code, you're finding a suitable cow on the activate method and on the execute method. Perhaps create a cow variable up top and reuse the same cow? Also, you could filter out any cows that are being attacked by other players:

    private boolean isCow(NPC npc) {
    	return npc.getName().equals("Cow")
    		&& npc.getAnimation() != Cow.DYING.getAnimation()
    		&& (ctx.myPlayer().equals(npc.getInteracting()) || npc.getInteracting() == null); // So either we're the dude the cow's focused on OR the cow's not focused on anybody right now
    }
    
    NPC cow = ctx.getNpcs().singleFilter(ctx.getNpcs().getAll(), (Filter<NPC>) this::isCow);

    Also, you could make your Task a little easier to use by having it extend MethodProvider and then exchanging the context. You can find it under the MethodProvider section here:

     

    • Like 1
  4. On 5/8/2019 at 4:12 AM, MJtheNurse said:

    does this script still work? i dont see much support 😞

     

    On 5/20/2019 at 4:21 PM, jacobas said:

    i just bought this script and it doesn't work. can i get a refund?

     

     

    The 'fast keyboard' feature is broken...again. It's an experimental feature that breaks whenever the devs decide it's time to break it.

    Please restart the script and turn off the fast keyboard feature before submitting the GUI. The bot will revert to using OSBot's default keyboard mechanics. I tested this and it works.

    I will look into fixing the fast keyboard feature when I have some time.

  5. 11 hours ago, Tom said:

    In case you wanted an actual answer to this, it won't affect multiple bot windows as they run on their own JVM

    I recall one of the changes from OSBot v1 to v2 was that bots could no longer read/write to the same static variables, so that's likely it.

    • Like 2
    1. Figure out what you want. When the script starts, take note of what your stats are and create a list of items you can use and prioritise them by usefulness.
    2. Figure out what you need. You might not get what you want, but you'll get what you need. A dragon axe is better than an rune one, but if you don't have a dragon axe or if your woodcutting level isn't 61, then that rune axe is your best friend.

     

    Once your bot knows what it's got, what it's not got, and where it's at, you can plan for the bot to progress. Depending on the complexity, you may need to look into using a data-structure. It'll be a lot less code than having 20+ IF's for each axe, pick axe, etc.

    • Like 1
    • Heart 1
  6. The rules are a bit ridiculous for scriptwriters, but I believe it's to protect the customers and OSBot's brand. Making it so only the higher ranked scriptwriters get to make & sell the hardest and most complicated scripts not only makes it more likely the customer is getting a higher quality service, but also prevents the market from being over-saturated with potentially worse ones. However, that doesn't mean you can't release your scripts publicly or sell them privately.

  7. A combination of:

    On 5/27/2019 at 11:52 PM, Neanel said:

    Get the position of the monster you are interacting with & loot items only on that position, this won't always be correct but it's a start.

    For a fail safe use the onMessage method to check if the loot isn't yours I guess.

     

    And a looting API that remembers which items it couldn't pick up so as to avoid them completely.

  8. 3 hours ago, Imthabawse said:

    Got this working. Thanks a lot. Will still be looking into animation timers as I've had this problem in scripts where your animation bounces from -1 to animating within seconds.

    You don't need to watch for animations:

    // Some basic mathematics...
    
    long barsInInventory = inventory.getAmount("Bronze bar");
    long barsPerPlatebody = 5;
    long platebodiesWeCanMake = (barsInInventory / barsPerPlatebody);
    
    // let's figure out how long we need to sleep
    long timeToMakeEachPlatebody = 1500; // 1.5 seconds (might be more or less don't know)
    long timeToMakePlatebodies = (platebodiesWeCanMake * timeToMakeEachPlatebody);
    long timeToMakePlatebodiesWithRandomOffset = (timeToMakePlatebodies + random(500, 1500)); // + 0.5 to 1.5 seconds
    
    if (anvil.interact("Smith")) {
    	
    	new ConditionalSleep(timeToMakePlatebodiesWithRandomOffset) {
    		
    		@Override
    		public boolean condition() {
    			
    			// if any of the following happen, then we need to wake up!
    			
    			return getDialogues().isPendingContinuation() // level up message
    			 || inventory.getAmount("Bronze bar") == 0 // we're out of bronze bars
    			 || (inventory.getAmount("Bronze bar") / barsPerPlatebody) == 0; // we don't have enough bars to make another platebody
    		}
    		
    	}.sleep();
    	
    }

     

    • Heart 1
  9. Try avoid re-checking the same logic cases and instead structure your code to run the fewest number of checks as possible:

    private void smithPlateBodys() throws InterruptedException {
    	
    	if(smithArea.contains(myPosition())) {
    		
    		RS2Object anvil = getObjects().closest("Anvil");
    		RS2Widget smithMenu = getWidgets().getWidgetContainingText("What would you like to make?");
    		RS2Widget plateBody = getWidgets().get(312,15,2);
    		
    		if (getDialogues().isPendingContinuation()) {
    			
    			log("Handling dialogue...");
    			
    			if (getDialogues().clickContinue()) {
    				sleep(random(500,700));
    			}
    			
    		} else if (smithMenu != null && plateBody != null) {
    			
    			log("Smithing Platebody's...");
    			new ConditionalSleep(10000) {
    				@Override
    				public boolean condition() {
    					return !readyToSmith() || getInventory().getAmount("Iron platebody") == 5;
    				}
    			}.sleep();
    			
    		} else if (anvil != null && !myPlayer().isAnimating()) {
    			
    			log("Interacting with Anvil...");
    			if (anvil.interact("Smith")) {
    				
    				new ConditionalSleep(5000) {
    					@Override
    					public boolean condition() {
    						return getWidgets().getWidgetContainingText("What would you like to make?") != null;
    					}
    				}.sleep();
    			}
    		}
    		
    	} else {
    		
    		log("Walking to Anvil...");
    		if (getWalking().webWalk(smithArea)) {
    			sleep(random(500,700));
    		}
    	}
    }

     

    • Like 1
  10. It's not enough just to copy/paste code, you actually need to read it and try to understand what it's doing.

    Here:

     

    
    	// ...
    	
    	textField.addActionListener(e -> {
    	
    		String text = ((JTextField) e.getSource()).getText()
    		
    		int number = -1;
    		
    		try {
    		
    			number = Integer.parseInt(text);
    			
    			someStaticNumber = number; // let's pretend someStaticNumber is a static int
    			
    		} catch (NumberFormatException e) {
    		
    			// err you typed something in, but it wasn't a number!
    		}
    	});
    	
    	
    	// ...

    When you hit [enter] after typing in a number, that'll kick-start an "action event" which will go on to kick-start a bunch of routines that deal with that event.

  11. 5 hours ago, DoubleD said:

     

    @liverare Any updates?

    Slow progress man. I hit writer's block trying to reconstruct the fundamentals of this script to improve its efficiency and make it easier to maintain.

    Also am lazy af. I have done some work to it, but I've got like 5 other projects on the go. :)

    • Like 1
  12. I had trouble recovering an old account of mine that I had forgotten the password for, and it was so old it didn't have an email associated with it.

    In my recovery notes, I talked about when I created the account, when I first brought membership, some of the achievements I'd accomplished, and what items I had on the account. If you've ever paid for membership via mobile/telephone, then dig up your old numbers and mention those too. I'm sure Jagex has records on that.

    I don't quite remember what else I talked about, but I did eventually end up gaining access again after the 2nd or 3rd try.

×
×
  • Create New...