Skip to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Help with my Chicken Killer

Featured Replies

I'm going off Saiyan's chicken killer, trying to customize it so it will actually run and look legit. Well, I've tried to customize it and I am not having much luck learning. So I thought I would post a topic and request some help. Remember, I'm fairly new to java and am trying not to give up. I think i'm looking how to use a Filter so it attacks the right npc.. not sure if this is the same thing as a filter or not.
Also, here is a link to Saiyan's chicken killer he posted a half year ago. http://osbot.org/forum/topic/89682-open-source-chicken-killer-can-copy-and-paste-and-improve5-min-script/

Do I need to create my own methods to start using them in if statements so for ex. I can call a method to have a conditional Sleep?

Idk how to use a filter, i think i need that to be successful.

This is what I found for a filter, i think this is the most relevant to my script but idk!!
 

Any help is appreciated!
And yes I have looked at the API, its intimidating at a glance

NPC chicken = getNpcs().closest("Chicken"); 
NPC chicken = getNpcs().closest(filters)
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;
import org.osbot.rs07.utility.ConditionalSleep;
import org.osbot.rs07.api.filter.NameFilter;
import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.GroundItem;
import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.api.model.Player;

import java.awt.*;

@ScriptManifest(author = "Kitten Krazy", info = "Adam's Chicken Killer", name = "Chicken Killer", version = 0, logo = "")
public class main extends Script {

	final Area CHICKEN_AREA = new Area(3226, 3001, 3236, 3295);

	@Override
	public void onStart() {
		log("Kitten Krazy's chicken killer");
	}

	private enum State {
		KILL, SLEEP;
	}

	private State getState() {

		NPC chicken = getNpcs().closest("Chicken");
			if(chicken != null){
				
					return State.KILL;
		}
		return State.SLEEP;

		}
	

	@Override
	public int onLoop() throws InterruptedException {
		switch (getState()) {
		case KILL:
			
		
			NPC chicken = getNpcs().closest("Chicken");
			if(!getCombat().isFighting()){ 
				if(!myPlayer().isUnderAttack()){
					if(chicken != null){
						chicken.interact("Attack");
					}
				}
			}
			
			
			
				if(chicken.interact("Attack")){
				new ConditionalSleep(3000, 500){
					public boolean condition() throws InterruptedException{
						return myPlayer().isInteracting(chicken);
					}
				}.sleep();
			}
				if(myPlayer().isInteracting(chicken)){
					new ConditionalSleep(3000, 500){
						public boolean condition() throws InterruptedException{
							return myPlayer().isInteracting(chicken);
						}
					}.sleep();
				}
					
			}
			
				
			

				
			
			
			
		return 0;
	}

	@Override
	public void onExit() {
		log("Thanks for running my chicken killer!");
	}

	@Override
	public void onPaint(Graphics2D g) {

	}

}

        NPC chicken = getNpcs().closest(new Filter<NPC>() {
            @Override
            public boolean match(NPC npc) {
                return npc != null && npc.exists() && 
                        npc.getName().equals("Chicken") && npc.isAttackable();
            }
        });
//ConditionalSleep example
            if (chicken != null){
                if (chicken.interact("Attack")){
                    new ConditionalSleep(5000) { // 5000ms timeout
                       @Override
                       public boolean condition() throws InterruptedException {
                          return myPlayer().isInteracting(chicken);
                       }
                    }.sleep();
                }
            }

Hope it helps

Edited by Christopher

  • Author

Why exactly does Filter stay having red lines under it? I copyed that exact code and it still gives red lines. Did I not import something

I appreciate your response

Edited by Kitten Krazy

Why exactly does Filter stay having red lines under it? I copyed that exact code and it still gives red lines. Did I not import something

I appreciate your response

 

Yes you need to import

 

import org.osbot.rs07.api.filter.Filter;


Rsz02uO.gif

You could also use lambda

NPC blah = getNpcs().closest(npc -> npc.getName().equals("Cat") && //other conditions);

then interact

View this thread for some helpful information.

 

ZTp3Y57.png

Edited by Christopher

  • Author

Thank you so much,
Why doesn't Eclipse pop up and tell me I need to import the filter? All it does is show me the methods I can use with .closest

It has been fine for ground items and all the other stuff I had. Do you use intelliJ? I tried using it but it doesn't recognize something.. Eclipse should work anyways. Any idea? Thank you again!

I use intellij so idk about eclipse. I'm off to bed now. Good luck

Thank you so much,

Why doesn't Eclipse pop up and tell me I need to import the filter? All it does is show me the methods I can use with .closest

It has been fine for ground items and all the other stuff I had. Do you use intelliJ? I tried using it but it doesn't recognize something.. Eclipse should work anyways. Any idea? Thank you again!

  • Author

Thank you!
Switched to IntelliJ

Helped me dearly

Edited by Kitten Krazy

Thank you so much,

Why doesn't Eclipse pop up and tell me I need to import the filter? All it does is show me the methods I can use with .closest

It has been fine for ground items and all the other stuff I had. Do you use intelliJ? I tried using it but it doesn't recognize something.. Eclipse should work anyways. Any idea? Thank you again!

Eclipse does tell to import if you hover over the red text. Ctrl+shift+o is a useful shortcut to sort out all imports, super useful.

Another useful shortcut in eclipse is ctrl+shift+f which formats your code to make it more readable.

As for the code, I'd split it up into logical steps:

 

if (not in combat)
    NPC chicken = findChicken();
    attack(chicken);
else
    Sleep or do anything you would do in combat

As for a findChicken method, something like this.

private NPC findNPC(NPC... exceptions) {
		@SuppressWarnings("unchecked")
		NPC chicken = getNpcs().closest(new Filter<NPC>() {
			@Override
			public boolean match(NPC npc) {
				return npc.getName().equals("Chicken") 
					&& !npc.isUnderAttack() && (npc.getHealthPercent() > 0)
			}
		});
		return chicken;
	}

And for attack, maybe

	private void attack(NPC chicken) throws InterruptedException {
		if (chicken != null) {
			if (map.canReach(chicken)) {
				if (chicken.isVisible()) {
					chicken.interact("Attack");
				} else {
					s.camera.toEntity(chicken);
				}
			} 
		}
	}

I think it's just a good habit overall to split your steps into methods, leads to cleaner code and makes it so you can reuse it often.

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.