Package com.kraken.api.query.npc
Class NpcEntity
- java.lang.Object
-
- com.kraken.api.core.AbstractEntity<net.runelite.api.NPC>
-
- com.kraken.api.query.npc.NpcEntity
-
- All Implemented Interfaces:
Interactable<net.runelite.api.NPC>
public class NpcEntity extends AbstractEntity<net.runelite.api.NPC>
-
-
Field Summary
-
Fields inherited from class com.kraken.api.core.AbstractEntity
ctx, raw
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanattack()Attacks an NPC.intgetDistanceFromPlayer()Calculates the distance between the NPC and the local player within the game world.net.runelite.api.HeadIcongetHeadIcon()Retrieves the head icon associated with the NPC, if it exists.doublegetHealthPercentage()Gets the health percentage of the NPC.intgetId()The item ID for the wrapped game entityjava.lang.StringgetName()The game entities name.booleaninteract(java.lang.String action)Interacts with the entity using the given action verb.booleanisInArea(GameArea area)Checks if the NPC's current location is within the game area.booleanuseWidget(net.runelite.api.widgets.Widget widget)Uses a specified widget on the NPC (i.e.-
Methods inherited from class com.kraken.api.core.AbstractEntity
equals, hashCode, isNull, raw
-
-
-
-
Constructor Detail
-
NpcEntity
public NpcEntity(Context ctx, net.runelite.api.NPC raw)
-
-
Method Detail
-
getName
public java.lang.String getName()
Description copied from interface:InteractableThe game entities name.- Returns:
- The name of the game entity i.e. NPC name for NPC's, item name for ContainerItem's, and GameObject name for various game objects.
-
getId
public int getId()
Description copied from interface:InteractableThe item ID for the wrapped game entity- Returns:
- int Item id
-
getHealthPercentage
public double getHealthPercentage()
Gets the health percentage of the NPC.- Returns:
- Health percentage (0-100), or -1 if unknown
-
getHeadIcon
public net.runelite.api.HeadIcon getHeadIcon()
Retrieves the head icon associated with the NPC, if it exists.A head icon represents an overhead visual indicator, such as combat prayers or effects like Hunllef's prayers or Nex's deflect melee. This is determined from the NPC's overhead sprite IDs.
- If no head icons are defined for the NPC, this will return
null. - If a valid head icon is found, it will be returned as a
HeadIconenum.
- Returns:
- The
HeadIconfor the NPC, ornullif no valid head icon exists.
- If no head icons are defined for the NPC, this will return
-
getDistanceFromPlayer
public int getDistanceFromPlayer()
Calculates the distance between the NPC and the local player within the game world.The method retrieves the NPC's local location and the local player's location from the game client, then computes the distance between the two positions. If the distance cannot be calculated (e.g., due to a timeout on the client thread),
Integer.MAX_VALUEis returned as a fallback.- The computation is performed on the game's client thread to ensure thread safety unless the result is unavailable.
- Returns:
- The distance between the NPC's location and the local player's location in the game world,
or
Integer.MAX_VALUEif the distance cannot be determined.
-
isInArea
public boolean isInArea(GameArea area)
Checks if the NPC's current location is within the game area.- Parameters:
area- TheGameAreato check.- Returns:
- True if the NPC location is within the game area and false otherwise.
-
interact
public boolean interact(java.lang.String action)
Description copied from interface:InteractableInteracts with the entity using the given action verb.- Parameters:
action- The menu action to trigger (e.g., "Attack", "Talk-to", "Take")- Returns:
- true if the interaction packet was successfully queued/sent
-
attack
public boolean attack()
Attacks an NPC. This is a shallow wrapper around the interact() method.- Returns:
- True if the attack interaction was successful and false otherwise
-
useWidget
public boolean useWidget(net.runelite.api.widgets.Widget widget)
Uses a specified widget on the NPC (i.e. Casting Crumble Undead Spell on the Vorkaths Spawn)- Parameters:
widget- The widget to use on the NPC- Returns:
- True if the interaction was successful and false otherwise
-
-