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
  • Detecting if another player is in combat with a specific monster


    kamilo

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

    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

    Archived

    This topic is now archived and is closed to further replies.

    ×
    ×
    • 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.