NpcAPI
Find NPCs and interact with them.
ClassRLPlugins API
public class NpcAPI extends ActorAPIStart a search with search(), narrow it down with filters, then take the nearest match. Pass that NPC to interact(…) with the menu action you want.
Example
NpcEx banker = NpcAPI.search().withName("Banker").alive().nearest();
if (banker != null) {
NpcAPI.interact(banker, "Bank");
}Members
Static methods
- StringgetDefinitionName(int)
Reads a definition name for server-provided NPC IDs such as the boss healthbar target.
- voidinteract(NpcEx, String...)
Clicks the first of these actions the NPC offers.
- voidinteract(NpcEx, int)
Interact with an npc by int option.
- voidinteract(int, int)
Interact with an npc by its index.
- voidinteract(int, int, int)
Clicks an NPC action by the NPC's index, the action number and a sub-action.
- NpcQuerysearch()
Starts a search over the NPCs around you.
Inherited from ActorAPI
- ActorEx<?>getInCombatWith()
Find the actor currently in combat with the local player.
getDefinitionName(int)static
public static String getDefinitionName(int id)Reads a definition name for server-provided NPC IDs such as the boss healthbar target.
Parameters
id- Id.
interact(NpcEx, String...)static
public static void interact(NpcEx npc, String... actions)Clicks the first of these actions the NPC offers.
Parameters
npc- The NPC. Nothing happens when it is
null. actions- Menu actions to try in order, such as
"Bank"or"Talk-to". Capital letters are ignored.
- If the client moves a real mouse for your plugin, only the first action is used.
interact(NpcEx, int)static
public static void interact(NpcEx npc, int option)Interact with an npc by int option.
Parameters
npc- Npc.
option- Option.
interact(int, int)static
public static void interact(int npcIndex, int option)Interact with an npc by its index.
Parameters
npcIndex- Npc index.
option- Option.
interact(int, int, int)static
public static void interact(int npcIndex, int option, int subop)Clicks an NPC action by the NPC's index, the action number and a sub-action.
Parameters
npcIndex- Npc index.
option- Option.
subop- Subop.
search()static
public static NpcQuery search()Starts a search over the NPCs around you.
Returns
A new NpcQuery that matches every NPC. Add filters, then call AbstractActorQuery.nearest() or AbstractQuery.first().
getInCombatWith()staticfrom ActorAPI
public static ActorEx<?> getInCombatWith()Find the actor currently in combat with the local player.
Returns
The actor, or null if none found.
Also allowed
Every class has these, as in plain Java.
equals, toString