Package com.valhalla.sdk.api.methods
Class Npcs
java.lang.Object
com.valhalla.sdk.api.methods.Npcs
Queries immutable NPC snapshots and dispatches native NPC menu actions.
NPC indices are live scene references and can be reused by the client after a despawn. Re-query before acting on long-held snapshots. Nearest searches use same-plane Chebyshev distance rather than collision reachability. A successful interaction confirms native dispatch, not completion of dialogue or combat.
-
Method Summary
Modifier and TypeMethodDescriptionall()Returns all decoded NPCs.Selects every NPC accepted by a filter.Selects NPCs matching any non-null definition identifier.Selects NPCs matching any exact name, ignoring case.closest()Finds the nearest same-plane NPC.Alias fornearest(Filter).Finds the filtered NPC nearest to an arbitrary tile.Finds the nearest same-plane NPC matching any identifier.Finds the nearest same-plane NPC matching any exact name, ignoring case.static intCounts NPCs accepted by a filter.static booleanTests whether a filtered NPC exists.static booleanTests whether any candidate identifier exists.static booleanTests whether any candidate name exists.static Npc[]getArray()Copies all NPC snapshots into an array.getAtIndex(int index) Alias forgetByIndex(int).getById(int id) Selects every NPC with a definition identifier.getByIndex(int index) Finds the NPC currently occupying a scene index.Selects every NPC with an exact name, ignoring case.static booleaninteract(int index, int action) Dispatches a raw action to a current NPC scene index.static booleanDispatches a raw action to an NPC snapshot.static booleanDispatches a typed menu action to an NPC snapshot.static booleanDispatches to the nearest same-plane NPC accepted by a filter.static booleanDispatches to the nearest same-plane NPC with an exact name.static booleaninteractNearestId(int id, NpcAction action) Dispatches to the nearest same-plane NPC with an identifier.nearest()Finds the nearest same-plane NPC.Finds the filtered same-plane NPC nearest to the local player.static booleanreferenceExists(int index) Tests whether an NPC currently occupies a scene index.
-
Method Details
-
all
Returns all decoded NPCs.- Returns:
- all NPCs from the latest native scene snapshot
-
all
Selects every NPC accepted by a filter.- Parameters:
filter- NPC predicate- Returns:
- matching snapshots in native enumeration order
-
all
Selects NPCs matching any non-null definition identifier.- Parameters:
ids- candidate NPC identifiers- Returns:
- matching snapshots, or an empty list for no candidates
-
all
Selects NPCs matching any exact name, ignoring case.- Parameters:
names- candidate names- Returns:
- matching snapshots, or an empty list for no candidates
-
getByIndex
Finds the NPC currently occupying a scene index.- Parameters:
index- live scene index- Returns:
- current matching snapshot, or empty
-
getAtIndex
Alias forgetByIndex(int).- Parameters:
index- live scene index- Returns:
- current matching snapshot, or empty
-
referenceExists
public static boolean referenceExists(int index) Tests whether an NPC currently occupies a scene index.- Parameters:
index- live scene index- Returns:
truewhen the latest snapshot contains that index
-
getArray
Copies all NPC snapshots into an array.- Returns:
- all NPC snapshots as a newly allocated array
-
getById
Selects every NPC with a definition identifier.- Parameters:
id- NPC definition identifier- Returns:
- matching snapshots
-
getByName
Selects every NPC with an exact name, ignoring case.- Parameters:
name- exact NPC name- Returns:
- matching snapshots, or an empty list for
null
-
nearest
Finds the nearest same-plane NPC.- Returns:
- nearest same-plane NPC by Chebyshev distance, or empty
-
closest
Finds the nearest same-plane NPC.- Returns:
- nearest same-plane NPC; alias for
nearest()
-
closest
Alias fornearest(Filter).- Parameters:
filter- NPC predicate- Returns:
- nearest matching same-plane NPC, or empty
-
closest
Finds the filtered NPC nearest to an arbitrary tile.- Parameters:
filter- NPC predicatetoTile- comparison tile and required plane- Returns:
- nearest matching NPC on that plane, or empty
-
closest
Finds the nearest same-plane NPC matching any identifier.- Parameters:
ids- candidate NPC identifiers- Returns:
- nearest match, or empty
-
closest
Finds the nearest same-plane NPC matching any exact name, ignoring case.- Parameters:
names- candidate names- Returns:
- nearest match, or empty
-
nearest
Finds the filtered same-plane NPC nearest to the local player.- Parameters:
filter- NPC predicate- Returns:
- nearest matching NPC by Chebyshev distance, or empty
-
interact
public static boolean interact(int index, int action) Dispatches a raw action to a current NPC scene index.- Parameters:
index- live NPC scene indexaction- native NPC action opcode- Returns:
truewhen the client was ready and accepted dispatch
-
interact
Dispatches a raw action to an NPC snapshot.- Parameters:
npc- current NPC snapshotaction- native NPC action opcode- Returns:
truewhen dispatch was accepted
-
interact
Dispatches a typed menu action to an NPC snapshot.- Parameters:
npc- current NPC snapshotaction- ordered NPC menu action- Returns:
truewhen accepted; gameplay completion is not implied
-
interactNearestId
Dispatches to the nearest same-plane NPC with an identifier.- Parameters:
id- NPC definition identifieraction- ordered NPC menu action- Returns:
truewhen a match existed and dispatch was accepted
-
interact
Dispatches to the nearest same-plane NPC with an exact name.- Parameters:
name- exact case-insensitive NPC nameaction- ordered NPC menu action- Returns:
truewhen a match existed and dispatch was accepted
-
interact
Dispatches to the nearest same-plane NPC accepted by a filter.- Parameters:
filter- NPC predicateaction- ordered NPC menu action- Returns:
truewhen a match existed and dispatch was accepted
-
count
Counts NPCs accepted by a filter.- Parameters:
filter- NPC predicate- Returns:
- number of matching snapshots
-
exists
Tests whether a filtered NPC exists.- Parameters:
filter- NPC predicate- Returns:
- whether a same-plane matching NPC exists
-
exists
Tests whether any candidate identifier exists.- Parameters:
ids- candidate identifiers- Returns:
- whether a same-plane matching NPC exists
-
exists
Tests whether any candidate name exists.- Parameters:
names- candidate exact names- Returns:
- whether a same-plane matching NPC exists
-