Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
  • Detecting if another player is in combat with a specific monster


    kamilo
     Share

    Recommended Posts

    Lets say for example i was in rev caves, is there a way to detect which player is attacking which revenant?

     

    seems complex but i feel like anythings dooable 

    if anyone has experience with this please lmk

    Link to comment
    Share on other sites

    Player player = getPlayers().closest(p->p!=null && p.getName().equalsIgnoreCase("playerName"));
    if(player != null) {
    	if(player.isInCombat()) {
    		Character npcInteractingWithPlayer = player.getInteractingCharacter();
    		//then you can do whatever you want with the character.. like.. getName.. etc..
    	}
    }

    ^ that's how you can get the characters interacting with the player

    you can also call .all(); and loop through them getting all the npcs all the players in the room are interacting with like so:

    List<Player> players = getPlayers().all();
    for(Player player : players) {
      if(player.isInCombat()) {
        Character character = player.getInteractingCharacter();
        //..etc
      }
    }

    you can also compare the InteractingCharacter that you get from the code above with your character.. etc..

    Edited by Defiled
    Link to comment
    Share on other sites

    12 hours ago, Defiled said:
    Player player = getPlayers().closest(p->p!=null && p.getName().equalsIgnoreCase("playerName"));
    if(player != null) {
    	if(player.isInCombat()) {
    		Character npcInteractingWithPlayer = player.getInteractingCharacter();
    		//then you can do whatever you want with the character.. like.. getName.. etc..
    	}
    }

    ^ that's how you can get the characters interacting with the player

    you can also call .all(); and loop through them getting all the npcs all the players in the room are interacting with like so:

    List<Player> players = getPlayers().all();
    for(Player player : players) {
      if(player.isInCombat()) {
        Character character = player.getInteractingCharacter();
        //..etc
      }
    }

    you can also compare the InteractingCharacter that you get from the code above with your character.. etc..

    tysm

    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
     Share

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.