Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!

Question How to properly filter an NPC who's attacking me

Joined
Jan 23, 2017
Messages
9
I'm having trouble getting the actual NPC who's in combat with my player. My combat handler begins to choose a new target before I've killed the current target. Any help?
 
I've been called a god before.
Joined
Aug 5, 2014
Messages
3,212
Your target:

Player.getTarget

Npc: ....targeting(player)
I'm having trouble getting the actual NPC who's in combat with my player. My combat handler begins to choose a new target before I've killed the current target. Any help?
 
Joined
May 24, 2016
Messages
1,113
I'm having trouble getting the actual NPC who's in combat with my player. My combat handler begins to choose a new target before I've killed the current target. Any help?

RS3? If yes, there are certain abilities that cause the 'target to break'. One of the is Snipe.
 
( ͡° ͜ʖ ͡°)
Joined
Mar 30, 2015
Messages
2,410
Code:
Npcs.newQuery().targeting(Players.getLocal()).results();
should return all that are targeting the player, and yeah like Qos said you can search local players target in case you have multiple wanting to attack you while you're in 1v1 situations.
 
Java Warlord
Joined
Nov 17, 2014
Messages
4,906
Code:
Npcs.newQuery().targeting(Players.getLocal()).results();
should return all that are targeting the player, and yeah like Qos said you can search local players target in case you have multiple wanting to attack you while you're in 1v1 situations.
Nullcheck player, and probably add an action filter for attackable npcs to ignore pets etc.
 
Top