Class NPCPackets
- java.lang.Object
-
- com.kraken.api.core.packet.entity.NPCPackets
-
public class NPCPackets extends java.lang.ObjectA static utility class for sending packets related to Non-Player Character (NPC) interactions to the game server.This class handles various forms of NPC interaction, including standard action clicks (e.g., Talk-to, Attack) and "use-with" actions (e.g., using an item on an NPC). It uses a
PacketDefFactoryto determine the correct packet type and aPacketClientto send the raw data.
-
-
Constructor Summary
Constructors Constructor Description NPCPackets()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidqueueNPCAction(int actionFieldNo, int npcIndex, boolean ctrlDown)Queues the low-level packet to perform a generic action click on an NPC.voidqueueNPCAction(net.runelite.api.NPC npc, java.lang.String... actionList)Queues an NPC action by matching a human-readable action string (e.g., "Talk-to", "Attack").voidqueueWidgetOnNPC(int npcIndex, int sourceItemId, int sourceSlot, int sourceWidgetId, boolean ctrlDown)Queues the raw packet for using a widget (typically an item) on an NPC.voidqueueWidgetOnNPC(net.runelite.api.NPC npc, net.runelite.api.widgets.Widget widget)Queues the packet for using a specificWidget(or item it represents) on a targetNPC.
-
-
-
Method Detail
-
queueNPCAction
public void queueNPCAction(int actionFieldNo, int npcIndex, boolean ctrlDown)Queues the low-level packet to perform a generic action click on an NPC.This method sends one of the
OPNPCpackets (e.g.,OPNPC1throughOPNPC10), where the action is determined by theactionFieldNo.- Parameters:
actionFieldNo- The 1-based index of the action to execute (1-10).npcIndex- The server index of the target NPC.ctrlDown- If true, indicates the control key was held down (often used for force-attacking/force-clicking).
-
queueNPCAction
public void queueNPCAction(net.runelite.api.NPC npc, java.lang.String... actionList)Queues an NPC action by matching a human-readable action string (e.g., "Talk-to", "Attack").This is a high-level convenience method that inspects the target NPC's composition for a matching action and automatically determines the correct low-level action number (1-10) to use for the
OPNPCpacket. The search is case-insensitive.- Parameters:
npc- The targetNPCobject to interact with.actionList- A varargs list of action strings to search for. The first match found will be executed.
-
queueWidgetOnNPC
public void queueWidgetOnNPC(int npcIndex, int sourceItemId, int sourceSlot, int sourceWidgetId, boolean ctrlDown)Queues the raw packet for using a widget (typically an item) on an NPC.This method sends the
OPNPCT(Use Widget on NPC) packet, which contains the details of the source item/widget and the target NPC.- Parameters:
npcIndex- The server index of the target NPC.sourceItemId- The ID of the item being used.sourceSlot- The slot index of the item being used (e.g., inventory slot).sourceWidgetId- The ID of the parent widget containing the item (e.g., inventory widget ID).ctrlDown- If true, indicates the control key was held down.
-
queueWidgetOnNPC
public void queueWidgetOnNPC(net.runelite.api.NPC npc, net.runelite.api.widgets.Widget widget)Queues the packet for using a specificWidget(or item it represents) on a targetNPC.This is a convenience method that extracts the necessary item and widget details from the provided
Widgetobject and calls the rawqueueWidgetOnNPCmethod.- Parameters:
npc- The targetNPCobject.widget- The sourceWidgetcontaining the item or action to be used on the NPC.
-
-