Jump 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.

fighting algorithm

Featured Replies

Ok, so I've tried out 100000 things to make my fighting scripts as good as possible but it still keeps dissapointing me.

Currently I'm using this one, its an example that should kill chickens at the new chicken area in lumbridge:

http://pastebin.com/xGX3bTfD

And PLEASE, for those who have little to none expierence with fighting scripts, dont post obvious stuff like do this..., or you should better do that..., cuz the chance is big I've alrdy tried it lol. Or just dont post at all in that case. 

 

Just a call out for help to those who have expierence with this kind of stuff.

Edited by dokato

Well firstly, you don't need to iterate the npc's in the region to get the best one you can just use filters for that and return the npc best suited based on the conditions you provide. 

 

1) Get the instance of the NPC

2) Check if your player is interacting with it

3) If not attack if yes, sleep

 

I would give you the code for it but then I don't think you would learn from it unless you familiarize yourself with the api by digging through it.

  • Author

@Botre

it will sometimes click on another chicken while he's alrdy in combat with a chicken, and sometimes while he's fighting a chicken, it will reclick on the chicken, while it is alrdy fighting it.

And after it has killed the chicken, it will keep clicking on it till it completely dissapears (the animation of one dying and dissapearing).


Well firstly, you don't need to iterate the npc's in the region to get the best one you can just use filters for that and return the npc best suited based on the conditions you provide. 

 

1) Get the instance of the NPC

2) Check if your player is interacting with it

3) If not attack if yes, sleep

 

I would give you the code for it but then I don't think you would learn from it unless you familiarize yourself with the api by digging through it.

 

"1) Get the instance of the NPC"

if i do that, and the chicken is alrdy under attack by someone else, it will do nothing and wait till it's dead, while it should be looking for another one to kill, that can be located a bit further than the one in the instance. So basically it is wasting time while he could be attacking another one.

 

Or do you mean something else, or did i misunderstand u?

Edited by dokato

@Botre

it will sometimes click on another chicken while he's alrdy in combat with a chicken, and sometimes while he's fighting a chicken, it will reclick on the chicken, while it is alrdy fighting it.

And after it has killed the chicken, it will keep clicking on it till it completely dissapears (the animation of one dying and dissapearing).

 

"1) Get the instance of the NPC"

if i do that, and the chicken is alrdy under attack by someone else, it will do nothing and wait till it's dead, while it should be looking for another one to kill, that can be located a bit further than the one in the instance. So basically it is wasting time while he could be attacking another one.

 

Or do you mean something else, or did i misunderstand u?

i meant use filters;

NPC chicken = getNpcs().closest(new Filter<NPC>({
    @Override
    public boolean match(NPC npc){
       return npc.getName().equalsIgnoreCase("chicken") && !npc.isUnderAttack() && getMap().canReach(npc) && npc.getHealth() > 0;
    }
});

Don't copy and paste cos I wrote that with no code assist so the filter could be wrong. This in essence will return the closest chicken that you can attack, is reachable, has health > 0, not currently being attacked. Of course you can tweak the boolean as you wish but that's all you need really.

 

Much more efficient/cleaner/easy to read & understand happy.png

Edited by Divinity

i meant use filters;

NPC chicken = getNpcs().closest(new Filter<NPC>({
    @Override
    public boolean match(NPC npc){
       return npc.getName().equalsIgnoreCase("chicken") && !npc.isUnderAttack() && getMap().canReach(npc) && npc.getHealth() > 0;
    }
});

Don't copy and paste cos I wrote that with no code assist so the filter could be wrong. This in essence will return the closest chicken that you can attack, is reachable, has health > 0, not currently being attacked. Of course you can tweak the boolean as you wish but that's all you need really.

 

Much more efficient/cleaner/easy to read & understand happy.png

 

Alek is going to kill you for not using a stream + lambda :x

  • Author

i meant use filters;

NPC chicken = getNpcs().closest(new Filter<NPC>({
    @Override
    public boolean match(NPC npc){
       return npc.getName().equalsIgnoreCase("chicken") && !npc.isUnderAttack() && getMap().canReach(npc) && npc.getHealth() > 0;
    }
});

Don't copy and paste cos I wrote that with no code assist so the filter could be wrong. This in essence will return the closest chicken that you can attack, is reachable, has health > 0, not currently being attacked. Of course you can tweak the boolean as you wish but that's all you need really.

 

Much more efficient/cleaner/easy to read & understand happy.png

Wauwohmy.png ohmy.png ohmy.png , didnt know that, thank you man!!!

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

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.