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.

[HELP] how to detect "Attack Mode" and how to intract with entinty

Featured Replies

Hey there , im new on runescape os and im making my own script .

 

i am having issu with 2 things , i need to check if my player is in "attack mode" then wait until he is finish .
second problem is i can intract with entitys , i want my player to collect bones but nothing happens ,
ill paste my code and plz tell me what i did wrong..

if(getInventory().isFull())
         getInventory().interact("Bury", "Bones");
     else{
         Entity bones = getObjects().closest("Bones");
         NPC chiken = getNpcs().closest("Chicken");
         NPC cow = getNpcs().closest("Cow");
         NPC cowcalf = getNpcs().closest("Cow Calf");
         
         if (chiken != null) //attack chicken
             if (!myPlayer().isAnimating())
                 chiken.interact("Attack");
         if (cow != null) //attack cow
             if (!myPlayer().isAnimating())
                 cow.interact("Attack");
         if (cowcalf != null) //attack cow calf
             if (!myPlayer().isAnimating())
                 cowcalf.interact("Attack");
         if (bones != null) //take Bones
             if (!myPlayer().isAnimating())
             bones.interact("Take");
}

 

Hey there , im new on runescape os and im making my own script .

 

i am having issu with 2 things , i need to check if my player is in "attack mode" then wait until he is finish .

second problem is i can intract with entitys , i want my player to collect bones but nothing happens ,

ill paste my code and plz tell me what i did wrong..

if(getInventory().isFull())
         getInventory().interact("Bury", "Bones");
     else{
         Entity bones = getObjects().closest("Bones");
         NPC chiken = getNpcs().closest("Chicken");
         NPC cow = getNpcs().closest("Cow");
         NPC cowcalf = getNpcs().closest("Cow Calf");
         
         if (chiken != null) //attack chicken
             if (!myPlayer().isAnimating())
                 chiken.interact("Attack");
         if (cow != null) //attack cow
             if (!myPlayer().isAnimating())
                 cow.interact("Attack");
         if (cowcalf != null) //attack cow calf
             if (!myPlayer().isAnimating())
                 cowcalf.interact("Attack");
         if (bones != null) //take Bones
             if (!myPlayer().isAnimating())
             bones.interact("Take");
}

 

 

Items on the ground are GroundItems not RS2Objects. So to get the bones you need to do:

GroundItem bones = getGroundItems().closest("Bones");

To check if your player is attacking something you can do:

if(myPlayer().getInteracting() != null)

Or this may work too:

getCombat().isFighting()

Also FYI you don't need a separate variable for each target NPC. You can get the closest out of all of them with one statement:

NPC enemy = S.getNpcs().closest("Chicken", "Cow", "Cow calf");

But you may also want to check that those npcs are not under attack themselves, and that they are not dead. Perhaps something like:

NPC enemy = getNpcs().closest(new NameFilter<>("Chicken", "Cow", "Cow calf"), npc -> !npc.isUnderAttack() && npc.getHealthPercent() > 0);

Edited by Explv

  • Author

 

Items on the ground are GroundItems not Objects. So to get the bones you need to do:

GroundItem bones = getGroundItems().closest("Bones");

To check if your player is attacking something you can do:

if(myPlayer().getInteracting() != null)

Or this may work too:

getCombat().isFighting()

Also FYI you don't need a separate variable for each target NPC. You can get the closest out of all of them with one statement:

NPC enemy = S.getNpcs().closest("Chicken", "Cow", "Cow calf");

But you may also want to check that those npcs are not under attack themselves, and that they are not dead. Perhaps something like:

NPC enemy = getNpcs().closest(new NameFilter<>("Chicken", "Cow", "Cow calf"), npc -> !npc.isUnderAttack() && npc.getHealthPercent() > 0);

thanx man .. :)  im on the right way now 

 

Items on the ground are GroundItems not Objects. So to get the bones you need to do:

GroundItem bones = getGroundItems().closest("Bones");

To check if your player is attacking something you can do:

if(myPlayer().getInteracting() != null)

Or this may work too:

getCombat().isFighting()

Also FYI you don't need a separate variable for each target NPC. You can get the closest out of all of them with one statement:

NPC enemy = S.getNpcs().closest("Chicken", "Cow", "Cow calf");

But you may also want to check that those npcs are not under attack themselves, and that they are not dead. Perhaps something like:

NPC enemy = getNpcs().closest(new NameFilter<>("Chicken", "Cow", "Cow calf"), npc -> !npc.isUnderAttack() && npc.getHealthPercent() > 0);

Explv is a boss, always see him helping people with scripting and putting out some quality scripts

 

Items on the ground are GroundItems not Objects. So to get the bones you need to do:

GroundItem bones = getGroundItems().closest("Bones");

 

Scripter Drama Issue #717

 

Technically speaking, GroundItem is an object :troll:

Scripter Drama Issue #717

 

Technically speaking, GroundItem is an object Troll.png

 

I meant RS2Objects*  emote3.png

 

Don't make me hurt you Troll.png

Edited by Explv

RS2Objects*  emote3.png

 

Don't make me hurt you Troll.png

 

nop just object :troll:

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.