Class NpcQuery
- java.lang.Object
-
- com.kraken.api.core.AbstractQuery<NpcEntity,NpcQuery,net.runelite.api.NPC>
-
- com.kraken.api.query.npc.NpcQuery
-
public class NpcQuery extends AbstractQuery<NpcEntity,NpcQuery,net.runelite.api.NPC>
-
-
Field Summary
-
Fields inherited from class com.kraken.api.core.AbstractQuery
ctx
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NpcQueryalive()Filters the query to include only NPCs that are currently alive.NpcQueryat(net.runelite.api.coords.WorldPoint location)Filters and returns anNpcQuerycontaining NPCs located at the specified world point.NpcQueryattackable()Returns Attackable NPC within the scene.NpcQueryidle()Filters for NPCs that are not interacting with anyone (null interaction).NpcQueryinteracting()Filters the query to include only NPCs that are currently interacting with any entity other than the local player.NpcQueryinteractingWith(net.runelite.api.Actor actor)Filters the query to include only NPCs that are currently interacting with the specifiedactor.NpcQueryinteractingWithPlayer()Filters the query to include only NPCs that are currently interacting with the local player.NpcEntitynearest()Retrieves the nearest NPC entity to the local player's current position.NpcQuerynearestTo(net.runelite.api.coords.WorldPoint location)Sorts the current query results by determining the distance of each NPC'sWorldPointto a specifiedWorldPointlocation and arranging them in ascending order of proximity.NpcQueryreachable()Filters the NPCs to include only those that are reachable based on their world location.NpcQuerysortByDistance()Sorts the NPC stream by distance from the local players' current location.protected java.util.function.Supplier<java.util.stream.Stream<NpcEntity>>source()NpcQuerywithAction(java.lang.String action)Filters the query for NPCs that have a specific menu option available.NpcQuerywithin(int distance)Filters the NPCs in the query to include only those within a specified distance from the local player's position.NpcQuerywithinArea(net.runelite.api.coords.WorldPoint min, net.runelite.api.coords.WorldPoint max)Filters the query to include only NPCs that are located within a specified rectangular area.
-
-
-
Constructor Detail
-
NpcQuery
public NpcQuery(Context ctx)
-
-
Method Detail
-
source
protected java.util.function.Supplier<java.util.stream.Stream<NpcEntity>> source()
- Specified by:
sourcein classAbstractQuery<NpcEntity,NpcQuery,net.runelite.api.NPC>
-
at
public NpcQuery at(net.runelite.api.coords.WorldPoint location)
Filters and returns anNpcQuerycontaining NPCs located at the specified world point.This method applies a filter to include only NPCs whose world location matches the given
location.- Parameters:
location- theWorldPointrepresenting the target location to filter NPCs by.- Returns:
- an
NpcQuerycontaining NPCs at the specifiedlocation.
-
attackable
public NpcQuery attackable()
Returns Attackable NPC within the scene. NPC's are considered attackable when: - They are not dead - Their menu options contain an "Attack" optionCombat level is not taken into consideration since there are many NPC's without a combat level that are attackable. i.e. Yama's void flares
- Returns:
- NpcQuery
-
reachable
public NpcQuery reachable()
Filters the NPCs to include only those that are reachable based on their world location.This method applies a filter to the NPC query, ensuring that each NPC's raw data existence is validated and their world location is checked for reachability using the tile service.
- Returns:
- A @NpcQuery containing only the NPCs that are reachable.
-
idle
public NpcQuery idle()
Filters for NPCs that are not interacting with anyone (null interaction). This covers "not interacting with me" AND "not interacting with others".- Returns:
- NpcQuery
-
nearest
public NpcEntity nearest()
Retrieves the nearest NPC entity to the local player's current position.This method determines the NPC closest to the local player by comparing the distances between each NPC's local location and the local player's local location. The comparison is performed by sorting the NPCs based on their proximity, and the first (closest) NPC is selected.
The result is typically used to quickly identify and interact with the most immediate NPC relative to the player's current position, which can assist in various gameplay interactions.
- Returns:
- The
NpcEntitynearest to the local player's current position, as determined based on the shortest distance in the local coordinate system. If no NPCs are available, the return value may benull.
-
nearestTo
public NpcQuery nearestTo(net.runelite.api.coords.WorldPoint location)
Sorts the current query results by determining the distance of each NPC'sWorldPointto a specifiedWorldPointlocation and arranging them in ascending order of proximity.This method calculates the distance between the provided
locationand each NPC's world location. The resulting query will contain NPCs sorted such that those closest to the specified location appear first.- Parameters:
location- TheWorldPointto which NPCs' distances will be calculated. This parameter defines the point of reference for sorting NPCs by proximity.- Returns:
- A
NpcQuerycontaining NPCs sorted by their proximity to the specifiedlocation.
-
sortByDistance
public NpcQuery sortByDistance()
Sorts the NPC stream by distance from the local players' current location.- Returns:
- NpcQuery
-
within
public NpcQuery within(int distance)
Filters the NPCs in the query to include only those within a specified distance from the local player's position.This method calculates the distance between each NPC's world location and the local player's current world location, including only those NPCs with a distance less than or equal to the specified value.
- Parameters:
distance- The maximum distance (in tiles) from the local player within which NPCs should be included. This value must be greater than or equal to 0.- Returns:
- A filtered
NpcQuerycontaining only the NPCs within the specified distance from the local player.
-
withAction
public NpcQuery withAction(java.lang.String action)
Filters the query for NPCs that have a specific menu option available.This method checks the list of actions associated with each NPC's composition. If the specified
optionmatches any of the available actions (case-insensitive), the NPC will be included in the resulting query.- Parameters:
action- The menu option to check for, e.g., @Attack, @Talk-to, @Use, etc... The input is case-insensitive.- Returns:
- A filtered
NpcQuerycontaining only the NPCs that match the specified menu option.
-
withinArea
public NpcQuery withinArea(net.runelite.api.coords.WorldPoint min, net.runelite.api.coords.WorldPoint max)
Filters the query to include only NPCs that are located within a specified rectangular area. The area is defined by two corner points,min(lower-left) andmax(upper-right), in the world map grid.NPCs are included in the resulting query if their world point lies within the bounds created by the two corner points. The bounds are inclusive of the edges. This allows querying NPCs that exist within a specific area of interest.
- Parameters:
min- TheWorldPointrepresenting the lower-left corner of the area. This defines one bound of the rectangular query range.max- TheWorldPointrepresenting the upper-right corner of the area. This defines the opposite bound of the rectangular query range.- Returns:
- A filtered
NpcQuerycontaining only the NPCs located within the specified area.
-
interactingWithPlayer
public NpcQuery interactingWithPlayer()
Filters the query to include only NPCs that are currently interacting with the local player.An NPC is considered to be interacting with the local player if the NPC's
interactingtarget is non-nulland matches the client’s local player.- This method allows narrowing down the query to find NPCs that are actively engaged with the local player, whether by combat, dialogue, or other forms of interaction.
- Returns:
- A filtered
NpcQuerycontaining only the NPCs that are interacting with the local player.
-
interacting
public NpcQuery interacting()
Filters the query to include only NPCs that are currently interacting with any entity other than the local player.An NPC is considered to be interacting if its
interactingtarget is non-nulland does not match the local player. This includes NPCs that are engaged with other players, NPCs, or other entities in any form of interaction (e.g., combat, dialogue, etc.).- This method helps identify NPCs that are actively engaged in an interaction within the game world, excluding those interacting directly with the local player.
- Returns:
- A filtered
NpcQuerycontaining only the NPCs that are interacting with entities other than the local player.
-
interactingWith
public NpcQuery interactingWith(net.runelite.api.Actor actor)
Filters the query to include only NPCs that are currently interacting with the specifiedactor.An NPC is considered to be interacting with the given actor if the NPC's
interactingtarget is non-nulland matches the providedactor.- This method is useful for identifying NPCs actively engaging with a specific actor, such as another player, NPC, or inanimate entity.
- Parameters:
actor- TheActorthat the NPCs being searched for should be interacting with. Passingnullas the parameter is not allowed.- Returns:
- A filtered
NpcQuerycontaining only the NPCs that are interacting with the specified actor.
-
alive
public NpcQuery alive()
Filters the query to include only NPCs that are currently alive.An NPC is considered to be alive if its internal state indicates it is not dead. This method applies a filter to exclude NPCs marked as dead from the result set.
- NPCs included in the resulting query are capable of interaction or action within the game environment.
- This filter helps narrow the query to focus only on viable, active NPCs.
- Returns:
- A filtered
NpcQuerycontaining only the NPCs that are alive.
-
-